Bläddra i källkod

[new]调整ios快捷方式

zk 1 år sedan
förälder
incheckning
1ac2e4b96c

BIN
assets/images/bg_ios_shortcut_video_preview.webp


BIN
assets/images/dialog_ios_add_shortcut_guide.webp


BIN
assets/images/icon_ios_add_shortcut_close.webp


BIN
assets/images/icon_record_shortcut_page_close.webp


+ 1 - 0
assets/string/base/string.xml

@@ -183,4 +183,5 @@
     <string name="talk_search_hint">输入关键词查找</string>
     <string name="home_agenda_no_data">暂无待办</string>
     <string name="home_talk_no_data">暂无谈话记录</string>
+    <string name="record_shortcut_title">快捷触发录音--设置指引</string>
 </resources>

+ 2 - 2
lib/dialog/desktop_shortcut_dialog.dart

@@ -89,7 +89,7 @@ void showAddDesktopShortcutDialog(
 }
 
 void showAddDesktopShortcutTipsDialog(
-    {required void Function() onConfirm, required void Function() onDismiss}) {
+    {void Function()? onConfirm, void Function()? onDismiss}) {
   SmartDialog.show(
       onDismiss: onDismiss,
       builder: (_) {
@@ -123,7 +123,7 @@ void showAddDesktopShortcutTipsDialog(
                 GestureDetector(
                     onTap: () {
                       SmartDialog.dismiss();
-                      onConfirm.call();
+                      onConfirm?.call();
                     },
                     child: Container(
                         decoration: BoxDecoration(

+ 98 - 0
lib/dialog/ios_shortcut_guide_dialog.dart

@@ -0,0 +1,98 @@
+import 'package:electronic_assistant/resource/assets.gen.dart';
+import 'package:electronic_assistant/resource/colors.gen.dart';
+import 'package:electronic_assistant/utils/common_style.dart';
+import 'package:electronic_assistant/utils/expand.dart';
+import 'package:flutter/cupertino.dart';
+import 'package:flutter_screenutil/flutter_screenutil.dart';
+import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
+
+void showIosShortcutGuideDialog(
+    {void Function()? onConfirm, void Function()? onCancel}) {
+  const tag = 'showIosShortcutGuideDialog';
+
+  SmartDialog.show(
+      tag: tag,
+      backType: SmartBackType.block,
+      clickMaskDismiss: false,
+      alignment: const Alignment(0.0, 0.9),
+      builder: (_) {
+        return Container(
+          margin: EdgeInsets.symmetric(horizontal: 12.w),
+          child: IntrinsicHeight(
+            child: Container(
+              decoration: BoxDecoration(
+                  color: ColorName.white,
+                  borderRadius: BorderRadius.circular(12.w)),
+              child: Column(
+                children: [
+                  Container(
+                    decoration: BoxDecoration(
+                        gradient: LinearGradient(
+                          begin: Alignment.topCenter,
+                          end: Alignment.bottomCenter,
+                          colors: ['#6177F2'.color, '#7EBAFF'.color],
+                        ),
+                        borderRadius: BorderRadius.only(
+                            topLeft: Radius.circular(12.w),
+                            topRight: Radius.circular(12.w))),
+                    child: Stack(
+                      children: [
+                        AspectRatio(
+                            aspectRatio: 336 / 201,
+                            child: Assets.images.dialogIosAddShortcutGuide
+                                .image(width: double.infinity)),
+                        Align(
+                          alignment: Alignment.topRight,
+                          child: Padding(
+                            padding: EdgeInsets.all(16.w),
+                            child: GestureDetector(
+                              onTap: () {
+                                SmartDialog.dismiss(tag: tag);
+                                onCancel?.call();
+                              },
+                              child: Assets.images.iconDesktopShortcutClose
+                                  .image(width: 26.w, height: 26.w),
+                            ),
+                          ),
+                        )
+                      ],
+                    ),
+                  ),
+                  SizedBox(height: 20.w),
+                  Text('轻敲背面,快捷录音',
+                      style: TextStyle(
+                          color: ColorName.primaryTextColor, fontSize: 18.sp)),
+                  SizedBox(height: 6.w),
+                  Text(
+                    textAlign: TextAlign.center,
+                    '想更快打开录音吗?\n设置快捷方式,让小听更快听见~',
+                    style: TextStyle(
+                        fontSize: 14.sp, color: ColorName.secondaryTextColor),
+                  ),
+                  SizedBox(height: 24.w),
+                  GestureDetector(
+                    onTap: () {
+                      SmartDialog.dismiss(tag: tag);
+                      onConfirm?.call();
+                    },
+                    child: Container(
+                      decoration: getCommonDecoration(8.w),
+                      width: 304.w,
+                      height: 48.w,
+                      child: Center(
+                        child: Text('立即设置',
+                            style: TextStyle(
+                                fontSize: 16.sp,
+                                color: ColorName.white,
+                                fontWeight: FontWeight.bold)),
+                      ),
+                    ),
+                  ),
+                  SizedBox(height: 20.w),
+                ],
+              ),
+            ),
+          ),
+        );
+      });
+}

+ 0 - 1
lib/module/record/controller.dart

@@ -48,7 +48,6 @@ class RecordController extends BaseController {
     recordHandler.onClose();
   }
 
-  RxInt count = 0.obs; // 使用 .obs 将其转换为 Rx 类型
   void addShortcut() {
     DesktopShortcutUtils.requestAddDesktopShortcut();
   }

+ 3 - 1
lib/module/record/view.dart

@@ -1,3 +1,5 @@
+import 'dart:io';
+
 import 'package:electronic_assistant/base/base_page.dart';
 import 'package:electronic_assistant/module/record/constants.dart';
 import 'package:electronic_assistant/module/record/controller.dart';
@@ -177,7 +179,7 @@ class RecordPage extends BasePage<RecordController> {
             Padding(
               padding: EdgeInsets.only(left: 8.w, right: 16.w),
               child: Text(
-                '添加到桌面',
+                Platform.isIOS ? '添加到快捷方式' : '添加到桌面',
                 style: TextStyle(color: ColorName.white, fontSize: 14.w),
               ),
             )

+ 11 - 0
lib/module/shortcut/controller.dart

@@ -0,0 +1,11 @@
+import 'package:electronic_assistant/base/base_controller.dart';
+
+class ShortCutController extends BaseController {
+  void onAddIosShortCut() {
+    //TODO 调用ios快捷指令
+  }
+
+  void onShowIosShortcutVideo() {
+    //TODO 调用ios系统默认视频查看
+  }
+}

+ 239 - 0
lib/module/shortcut/view.dart

@@ -0,0 +1,239 @@
+import 'package:electronic_assistant/base/base_controller.dart';
+import 'package:electronic_assistant/base/base_page.dart';
+import 'package:electronic_assistant/resource/colors.gen.dart';
+import 'package:electronic_assistant/resource/string.gen.dart';
+import 'package:electronic_assistant/router/app_pages.dart';
+import 'package:electronic_assistant/utils/common_style.dart';
+import 'package:electronic_assistant/utils/expand.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter/src/widgets/framework.dart';
+import 'package:flutter_screenutil/flutter_screenutil.dart';
+import 'package:get/get.dart';
+import 'package:get/get_core/src/get_main.dart';
+
+import '../../resource/assets.gen.dart';
+import 'controller.dart';
+
+class ShortCutPage extends BasePage<ShortCutController> {
+  const ShortCutPage({super.key});
+
+  static Future? start() {
+    return Get.toNamed(RoutePath.recordShortcut);
+  }
+
+  @override
+  Color backgroundColor() {
+    return '#F6F6F6'.color;
+  }
+
+  @override
+  Widget buildBody(BuildContext context) {
+    return Scaffold(
+        backgroundColor: Colors.transparent,
+        appBar: _buildAppBar(),
+        body: _buildShortcutContainer());
+  }
+
+  Widget _buildShortcutContainer() {
+    return SingleChildScrollView(
+        child: Container(
+            padding: EdgeInsets.all(12.w),
+            margin: EdgeInsets.symmetric(horizontal: 12.w, vertical: 12.w),
+            decoration: const BoxDecoration(
+              color: Colors.white,
+              borderRadius: BorderRadius.all(Radius.circular(12)),
+            ),
+            child: Column(
+              children: [
+                SizedBox(height: 8.w),
+                Row(
+                  children: [
+                    getStep('1'),
+                    SizedBox(width: 6.w),
+                    Text(
+                      '点击',
+                      style: TextStyle(
+                          fontSize: 14.sp, color: ColorName.primaryTextColor),
+                    ),
+                    Text(
+                      '【添加快捷指令】',
+                      style: TextStyle(
+                          fontSize: 14.sp, color: ColorName.colorPrimary),
+                    ),
+                  ],
+                ),
+                SizedBox(height: 32.w),
+                GestureDetector(
+                  onTap: controller.onAddIosShortCut,
+                  child: Container(
+                      width: 240.w,
+                      height: 48.w,
+                      decoration: getCommonDecoration(8.w),
+                      child: Center(
+                          child: Text('添加快捷方式',
+                              style: TextStyle(
+                                  fontSize: 16.sp, color: ColorName.white)))),
+                ),
+                SizedBox(height: 32.w),
+                Row(
+                  children: [
+                    getStep('2'),
+                    SizedBox(width: 6.w),
+                    Text(
+                      '依照教程,设置权限',
+                      style: TextStyle(
+                          fontSize: 14.sp, color: ColorName.primaryTextColor),
+                    )
+                  ],
+                ),
+                SizedBox(height: 12.w),
+                Container(
+                  padding: EdgeInsets.only(left: 32.w),
+                  child: _buildTwoStepDesc(),
+                ),
+                SizedBox(height: 12.w),
+                Container(
+                  margin: EdgeInsets.only(left: 24.w),
+                  child: GestureDetector(
+                    onTap: controller.onShowIosShortcutVideo,
+                    child: AspectRatio(
+                        aspectRatio: 852 / 444,
+                        child: Assets.images.bgIosShortcutVideoPreview.image()),
+                  ),
+                ),
+                SizedBox(height: 32.w),
+                Row(
+                  children: [
+                    getStep('3'),
+                    SizedBox(width: 6.w),
+                    Text(
+                      '快点下手机背面,体验快捷录音吧~',
+                      style: TextStyle(
+                          fontSize: 14.sp, color: ColorName.primaryTextColor),
+                    )
+                  ],
+                ),
+                SizedBox(height: 8.w),
+              ],
+            )));
+  }
+
+  Widget _buildTwoStepDesc() {
+    return Column(
+      children: [
+        Row(
+          crossAxisAlignment: CrossAxisAlignment.start,
+          children: [
+            Container(
+              decoration: const BoxDecoration(
+                color: ColorName.secondaryTextColor,
+                shape: BoxShape.circle,
+              ),
+              width: 3.w,
+              height: 3.w,
+              margin: EdgeInsets.only(right: 10.w, top: 8.w),
+            ),
+            Expanded(
+              child: RichText(
+                  text: TextSpan(
+                      style: TextStyle(
+                          fontSize: 13.sp, color: ColorName.secondaryTextColor),
+                      children: const [
+                    TextSpan(text: "在手机"),
+                    TextSpan(
+                        text: "【设置】",
+                        style: TextStyle(color: ColorName.colorPrimary)),
+                    TextSpan(text: "中点击"),
+                    TextSpan(
+                        text: "【辅助功能】",
+                        style: TextStyle(color: ColorName.colorPrimary)),
+                    TextSpan(text: "-"),
+                    TextSpan(
+                        text: "【触控】",
+                        style: TextStyle(color: ColorName.colorPrimary)),
+                    TextSpan(text: ",滑动至底部找到"),
+                    TextSpan(
+                        text: "【轻点背面】",
+                        style: TextStyle(color: ColorName.colorPrimary)),
+                  ])),
+            )
+          ],
+        ),
+        Row(
+          crossAxisAlignment: CrossAxisAlignment.start,
+          children: [
+            Container(
+              decoration: const BoxDecoration(
+                color: ColorName.secondaryTextColor,
+                shape: BoxShape.circle,
+              ),
+              width: 3.w,
+              height: 3.w,
+              margin: EdgeInsets.only(right: 10.w, top: 8.w),
+            ),
+            Expanded(
+              child: RichText(
+                  text: TextSpan(
+                      style: TextStyle(
+                          fontSize: 13.sp, color: ColorName.secondaryTextColor),
+                      children: const [
+                    TextSpan(text: "进入"),
+                    TextSpan(
+                        text: "【轻点背面】",
+                        style: TextStyle(color: ColorName.colorPrimary)),
+                    TextSpan(text: ",找到"),
+                    TextSpan(
+                        text: "【轻点两下/三下】",
+                        style: TextStyle(color: ColorName.colorPrimary)),
+                    TextSpan(text: ",选"),
+                    TextSpan(
+                        text: "【小听-录音】",
+                        style: TextStyle(color: ColorName.colorPrimary)),
+                  ])),
+            )
+          ],
+        )
+      ],
+    );
+  }
+
+  Widget getStep(String step) {
+    return Container(
+      width: 20.w,
+      height: 20.w,
+      decoration: const BoxDecoration(
+        color: ColorName.colorPrimary, // Set the background color
+        shape: BoxShape.circle, // Set the shape to circle
+      ),
+      child: Center(
+        child: Text(step,
+            style:
+                TextStyle(fontSize: 14.sp, color: ColorName.white, height: 1)),
+      ),
+    );
+  }
+
+  AppBar _buildAppBar() {
+    return AppBar(
+      scrolledUnderElevation: 0,
+      leading: IconButton(
+        icon: SizedBox(
+            width: 24.w,
+            height: 24.w,
+            child: Assets.images.iconRecordShortcutPageClose.image()),
+        // Custom icon
+        onPressed: () {
+          Get.back();
+        },
+      ),
+      title: Text(StringName.recordShortcutTitle.tr,
+          style: TextStyle(
+              fontSize: 17.sp,
+              color: ColorName.primaryTextColor,
+              fontWeight: FontWeight.bold)),
+      centerTitle: true,
+      backgroundColor: Colors.transparent,
+      elevation: 0,
+    );
+  }
+}

+ 6 - 0
lib/router/app_pages.dart

@@ -11,6 +11,8 @@ import 'package:electronic_assistant/module/main/drawer/complaint/view.dart';
 import 'package:electronic_assistant/module/main/drawer/controller.dart';
 import 'package:electronic_assistant/module/modelexplain/view.dart';
 import 'package:electronic_assistant/module/record/controller.dart';
+import 'package:electronic_assistant/module/shortcut/controller.dart';
+import 'package:electronic_assistant/module/shortcut/view.dart';
 import 'package:electronic_assistant/module/splash/controller.dart';
 import 'package:electronic_assistant/module/store/controller.dart';
 import 'package:electronic_assistant/module/store/view.dart';
@@ -86,6 +88,8 @@ abstract class RoutePath {
   static const templateList = '/templateList';
 
   static const templateDetail = '/templateDetail';
+
+  static const recordShortcut = '/recordShortcut';
 }
 
 class AppBinding extends Bindings {
@@ -114,6 +118,7 @@ class AppBinding extends Bindings {
     lazyPut(() => TemplateDetailController());
     lazyPut(() => HomeTalkController());
     lazyPut(() => HomeAgendaController());
+    lazyPut(() => ShortCutController());
   }
 
   void lazyPut<S>(InstanceBuilderCallback<S> builder) {
@@ -147,4 +152,5 @@ final generalPages = [
   GetPage(name: RoutePath.templateList, page: () => const TemplateListPage()),
   GetPage(
       name: RoutePath.templateDetail, page: () => const TemplateDetailPage()),
+  GetPage(name: RoutePath.recordShortcut, page: () => const ShortCutPage()),
 ];

+ 24 - 10
lib/utils/desktop_shortcut_utils.dart

@@ -13,6 +13,8 @@ import 'package:get/get.dart';
 import 'package:get/get_core/src/get_main.dart';
 import 'package:url_launcher/url_launcher.dart';
 import '../dialog/desktop_shortcut_dialog.dart';
+import '../dialog/ios_shortcut_guide_dialog.dart';
+import '../module/shortcut/view.dart';
 import 'android_shortcut.dart';
 
 class DesktopShortcutUtils {
@@ -54,20 +56,28 @@ class DesktopShortcutUtils {
       nextCallback();
       return;
     }
-    showAddDesktopShortcutDialog(onConfirm: () {
-      if (Platform.isAndroid) {
+    if (Platform.isAndroid) {
+      showAddDesktopShortcutDialog(onConfirm: () {
         showAddDesktopShortcutTipsDialog(onConfirm: () {
           androidShortCut.addRecordShortcut();
         }, onDismiss: () {
           nextCallback();
         });
-      } else if (Platform.isIOS) {
-        _launchUrl();
+      }, onCancel: () {
         nextCallback();
-      }
-    }, onCancel: () {
-      nextCallback();
-    });
+      });
+    } else if (Platform.isAndroid) {
+      showIosShortcutGuideDialog(
+        onConfirm: () async {
+          await ShortCutPage.start();
+          nextCallback();
+        },
+        onCancel: () {
+          nextCallback();
+        },
+      );
+    }
+
     _setShowOnce();
   }
 
@@ -94,9 +104,13 @@ class DesktopShortcutUtils {
           },
           onDismiss: () {});
     } else if (Platform.isIOS) {
-      //TODO IOS
-      _launchUrl();
+      showIosShortcutGuideDialog(
+        onConfirm: () {
+          ShortCutPage.start();
+        },
+      );
     }
+
     _setShowOnce();
   }