浏览代码

查找手机兼容

carlos 1 年之前
父节点
当前提交
a8c7ed9453
共有 1 个文件被更改,包括 26 次插入1 次删除
  1. 26 1
      app/lib/module/root/root_controller.dart

+ 26 - 1
app/lib/module/root/root_controller.dart

@@ -119,15 +119,30 @@ class RooViewController extends GetxController with WatchRequestOption {
     });
   }
 
+  bool isH210 =
+      (GlobalConfig.prefs.getString(PreferenceConst.PRE_DEVICE_MODEL) ?? '') == "H210";
   @override
   void replyFromWatch(data) {
     if (data is WatchReceiverRespBean) {
       switch (data.commandType) {
         case WatchResponseType.findPhone: //查找手机
+        if(isH210) {
           AvoidDoubleExecute.execute(Callback(notice: () {
             playSound();
           }), seconds: 1);
-          break;
+        } else {
+          if(data.status == 1) {
+            if(findPhoneTimer == null) {
+              startFindPhoneTimer();
+            }
+          } else {
+            if(findPhoneTimer != null) {
+              findPhoneTimer!.cancel();
+            }
+            findPhoneTimer = null;
+          }
+        }
+        break;
       }
     }
 
@@ -208,6 +223,16 @@ class RooViewController extends GetxController with WatchRequestOption {
     );
   }
 
+  Timer? findPhoneTimer;
+  void startFindPhoneTimer() {
+    const Duration duration = Duration(seconds: 3);
+    findPhoneTimer = Timer.periodic(duration, (timer) {
+      AvoidDoubleExecute.execute(Callback(notice: () {
+        playSound();
+      }), seconds: 1);
+    });
+  }
+
   ///启动应用自动连接设备
   void _doConnectDevice(BluetoothState? value) async {
     switch (value) {