diff --git a/star_lock/images/main/icon_addCard.png b/star_lock/images/main/icon_addCard.png new file mode 100644 index 00000000..0e254979 Binary files /dev/null and b/star_lock/images/main/icon_addCard.png differ diff --git a/star_lock/images/main/locked_bg.png b/star_lock/images/main/locked_bg.png new file mode 100644 index 00000000..04f5fa5f Binary files /dev/null and b/star_lock/images/main/locked_bg.png differ diff --git a/star_lock/lib/main.dart b/star_lock/lib/main.dart index 5442c6c9..bb92014a 100644 --- a/star_lock/lib/main.dart +++ b/star_lock/lib/main.dart @@ -9,6 +9,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_sound/flutter_sound.dart'; import 'package:get/get.dart'; import 'package:permission_handler/permission_handler.dart'; +import 'package:star_lock/talk/udp/udp_talkClass.dart'; import 'package:star_lock/tools/app_manager.dart'; import 'package:star_lock/tools/bindings/app_binding.dart'; import 'package:star_lock/tools/device_info_service.dart'; @@ -175,6 +176,9 @@ class _MyAppState extends State with WidgetsBindingObserver, BaseWidget { } else if (state == AppLifecycleState.paused) { // 应用进入后台 print("应用进入后台"); + if (UDPTalkClass().isBeCall == true) { + UDPTalkClass().playLocalAudio(); + } } } } @@ -233,4 +237,3 @@ Future getMicrophonePermission() async { } return false; } - diff --git a/star_lock/lib/main/lockDetail/card/addICCard/addICCard_page.dart b/star_lock/lib/main/lockDetail/card/addICCard/addICCard_page.dart index 1c65025e..676c6b41 100644 --- a/star_lock/lib/main/lockDetail/card/addICCard/addICCard_page.dart +++ b/star_lock/lib/main/lockDetail/card/addICCard/addICCard_page.dart @@ -24,7 +24,8 @@ class _AddICCardPageState extends State { return Scaffold( backgroundColor: AppColors.mainBackgroundColor, appBar: TitleAppBar( - barTitle: "${TranslationLoader.lanKeys!.add!.tr}${TranslationLoader.lanKeys!.card!.tr}", + barTitle: + "${TranslationLoader.lanKeys!.add!.tr}${TranslationLoader.lanKeys!.card!.tr}", haveBack: true, backgroundColor: AppColors.mainColor, ), @@ -32,22 +33,35 @@ class _AddICCardPageState extends State { crossAxisAlignment: CrossAxisAlignment.center, // mainAxisAlignment: MainAxisAlignment.center, children: [ - SizedBox(height: 420.h), - CupertinoActivityIndicator(radius: 25.h,), + SizedBox(height: 200.h), + Image.asset( + 'images/main/icon_addCard.png', + width: 234.w, + height: 211.h, + fit: BoxFit.cover, + ), + SizedBox(height: 90.h), + CupertinoActivityIndicator( + radius: 25.h, + ), SizedBox(height: 120.h), Container( width: 1.sw, height: 50.h, // padding: EdgeInsets.only(left: 30.w, right: 30.w, top: 10.h, bottom: 10.h), - margin: EdgeInsets.only(left: 15.w, right: 15.w, top: 10.h, bottom: 10.h), + margin: EdgeInsets.only( + left: 15.w, right: 15.w, top: 10.h, bottom: 10.h), // color: AppColors.blackColor, decoration: BoxDecoration( color: AppColors.blackColor, borderRadius: BorderRadius.circular(10.w), ), child: Center( - child: Obx(() => Text(state.ifConnectScuess.value ? "已连接到锁,请将卡靠近锁的读卡区" : "尝试连接设备...", style:TextStyle(color: Colors.white, fontSize: 24.sp))) - ), + child: Obx(() => Text( + state.ifConnectScuess.value + ? "已连接到锁,请将卡靠近锁的读卡区" + : "尝试连接设备...", + style: TextStyle(color: Colors.white, fontSize: 24.sp)))), ), ], ), diff --git a/star_lock/lib/main/lockDetail/lockDetail/realTimePicture/realTimePicture_logic.dart b/star_lock/lib/main/lockDetail/lockDetail/realTimePicture/realTimePicture_logic.dart index a4a6a6e1..452e1de1 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/realTimePicture/realTimePicture_logic.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/realTimePicture/realTimePicture_logic.dart @@ -6,6 +6,7 @@ import 'package:flutter_voice_processor/flutter_voice_processor.dart'; import 'package:get/get.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:star_lock/main/lockDetail/lockDetail/realTimePicture/realTimePicture_state.dart'; +import 'package:star_lock/talk/call/callTalk.dart'; import '../../../../talk/call/g711.dart'; import '../../../../talk/udp/udp_manage.dart'; @@ -62,6 +63,7 @@ class RealTimePictureLogic extends BaseGetXController { userMobile: await state.userMobile, userMobileIP: await state.userMobileIP, endData: []); + CallTalk().stopPcmSound(); // 关闭当前界面 Get.back(); diff --git a/star_lock/lib/main/lockDetail/lockDetail/realTimePicture/realTimePicture_page.dart b/star_lock/lib/main/lockDetail/lockDetail/realTimePicture/realTimePicture_page.dart index 0b503d2c..95663ece 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/realTimePicture/realTimePicture_page.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/realTimePicture/realTimePicture_page.dart @@ -3,6 +3,7 @@ import 'package:flutter/services.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/main/lockDetail/lockDetail/realTimePicture/realTimePicture_logic.dart'; +import 'package:star_lock/talk/call/callTalk.dart'; import '../../../../app_settings/app_colors.dart'; import '../../../../tools/showTFView.dart'; @@ -39,6 +40,11 @@ class _RealTimePicturePageState extends State } }); + // 延迟10秒后自动暂停动画 + Future.delayed(const Duration(seconds: 10), () { + state.animationController.stop(); + }); + logic.udpMonitorAction(); } @@ -188,7 +194,7 @@ class _RealTimePicturePageState extends State bottomBtnItemWidget( "images/main/icon_lockDetail_hangUp.png", "挂断", Colors.red, () async { logic.stopProcessing(); - + CallTalk().stopPcmSound(); // 挂断 logic.udpHangUpAction(); }), @@ -307,7 +313,7 @@ class _RealTimePicturePageState extends State ), ), onTap: () { - print('点击重新连接'); + state.animationController.forward(); }, ), ); diff --git a/star_lock/lib/main/lockDetail/monitoring/monitoring/lockMonitoring_logic.dart b/star_lock/lib/main/lockDetail/monitoring/monitoring/lockMonitoring_logic.dart index a4b04980..e14baf60 100644 --- a/star_lock/lib/main/lockDetail/monitoring/monitoring/lockMonitoring_logic.dart +++ b/star_lock/lib/main/lockDetail/monitoring/monitoring/lockMonitoring_logic.dart @@ -1,4 +1,3 @@ - import 'dart:async'; import 'dart:convert'; import 'dart:math'; @@ -7,6 +6,7 @@ import 'package:flutter/services.dart'; import 'package:flutter_voice_processor/flutter_voice_processor.dart'; import 'package:get/get.dart'; import 'package:permission_handler/permission_handler.dart'; +import 'package:star_lock/talk/call/callTalk.dart'; import '../../../../talk/call/g711.dart'; import '../../../../talk/udp/udp_manage.dart'; @@ -41,14 +41,16 @@ class LockMonitoringLogic extends BaseGetXController { /// 收到UDP发送的状态 StreamSubscription? _getUDPStatusRefreshUIEvent; void _getUDPStatusRefreshUIAction() { - _getUDPStatusRefreshUIEvent = eventBus.on().listen((event) { + _getUDPStatusRefreshUIEvent = + eventBus.on().listen((event) { state.udpStatus.value = event.udpStatus; - if(state.udpStatus.value == 8){ + if (state.udpStatus.value == 8) { // 接听成功了,然后刷新界面的时间 60秒以后自动挂断 - state.oneMinuteTimeTimer = Timer.periodic(const Duration(seconds:1), (Timer t) async { + state.oneMinuteTimeTimer = + Timer.periodic(const Duration(seconds: 1), (Timer t) async { state.oneMinuteTime.value++; // Get.log('state.oneMinuteTime.value:${state.oneMinuteTime.value}'); - if(state.oneMinuteTime.value >= 60){ + if (state.oneMinuteTime.value >= 60) { // 超过60秒了 state.oneMinuteTimeTimer.cancel(); state.oneMinuteTime.value = 0; @@ -63,6 +65,7 @@ class LockMonitoringLogic extends BaseGetXController { userMobileIP: await state.userMobileIP, endData: []); + CallTalk().stopPcmSound(); // 关闭当前界面 Get.back(); } @@ -81,8 +84,7 @@ class LockMonitoringLogic extends BaseGetXController { lockIP: UDPManage().host, userMobile: await state.userMobile, userMobileIP: await state.userMobileIP, - endData: [] - ); + endData: []); } /// 挂断 @@ -128,7 +130,9 @@ class LockMonitoringLogic extends BaseGetXController { while (start < audioData.length) { // await Future.delayed(const Duration(milliseconds: 50)); - int end = (start + length > audioData.length) ? audioData.length : start + length; + int end = (start + length > audioData.length) + ? audioData.length + : start + length; List sublist = audioData.sublist(start, end); sendRecordData({ "bytes": sublist, @@ -165,7 +169,9 @@ class LockMonitoringLogic extends BaseGetXController { errorListener(VoiceProcessorException error) { print("VoiceProcessorException: $error"); - }; + } + + ; state.voiceProcessor?.addFrameListener(frameListener); state.voiceProcessor?.addErrorListener(errorListener); @@ -173,15 +179,10 @@ class LockMonitoringLogic extends BaseGetXController { if (await state.voiceProcessor?.hasRecordAudioPermission() ?? false) { await state.voiceProcessor?.start(320, 8000); bool? isRecording = await state.voiceProcessor?.isRecording(); - - } else { - - } + } else {} } on PlatformException catch (ex) { Get.log("PlatformException: $ex"); - } finally { - - } + } finally {} } Future stopProcessing() async { @@ -189,9 +190,7 @@ class LockMonitoringLogic extends BaseGetXController { await state.voiceProcessor?.stop(); } on PlatformException catch (ex) { Get.log("PlatformException: $ex"); - } finally { - - } + } finally {} } void onError(Object e) { @@ -199,7 +198,6 @@ class LockMonitoringLogic extends BaseGetXController { } sendRecordData(Map args) async { - List bytes = args["bytes"]; // int udpSendDataFrameNumber = args["udpSendDataFrameNumber"]; String? lockID = args["lockID"]; @@ -218,7 +216,7 @@ class LockMonitoringLogic extends BaseGetXController { // while(list.isNotEmpty) { state.udpSendDataFrameNumber++; - if (state.udpSendDataFrameNumber >= 65536) state.udpSendDataFrameNumber=1; + if (state.udpSendDataFrameNumber >= 65536) state.udpSendDataFrameNumber = 1; // 57 List topBytes = []; @@ -281,7 +279,8 @@ class LockMonitoringLogic extends BaseGetXController { topBytes[6] = (state.udpSendDataFrameNumber & 0x000000FF); topBytes[7] = ((state.udpSendDataFrameNumber & 0x0000FF00) >> 8); - print("udpSendDataFrameNumber:${state.udpSendDataFrameNumber} topBytes[63]:${topBytes[6]} topBytes[64]:${topBytes[7]}"); + print( + "udpSendDataFrameNumber:${state.udpSendDataFrameNumber} topBytes[63]:${topBytes[6]} topBytes[64]:${topBytes[7]}"); topBytes.addAll(bytes); Get.log("setVoiceBytes:$topBytes"); @@ -293,8 +292,7 @@ class LockMonitoringLogic extends BaseGetXController { lockIP: lockIP, userMobile: userMobile, userMobileIP: userMobileIP, - endData: topBytes - ); + endData: topBytes); // UDPManage().sendData(topBytes); } @@ -324,7 +322,16 @@ class LockMonitoringLogic extends BaseGetXController { } int search(int val) { - List table = [0xFF, 0x1FF, 0x3FF, 0x7FF, 0xFFF, 0x1FFF, 0x3FFF, 0x7FFF]; + List table = [ + 0xFF, + 0x1FF, + 0x3FF, + 0x7FF, + 0xFFF, + 0x1FFF, + 0x3FFF, + 0x7FFF + ]; int size = 8; for (int i = 0; i < size; i++) { if (val <= table[i]) { @@ -392,9 +399,10 @@ class LockMonitoringLogic extends BaseGetXController { void onClose() { // TODO: implement onClose print("锁详情界面销毁了"); + CallTalk().stopPcmSound(); _getTVDataRefreshUIEvent!.cancel(); _getUDPStatusRefreshUIEvent!.cancel(); - if(state.oneMinuteTimeTimer != null){ + if (state.oneMinuteTimeTimer != null) { state.oneMinuteTimeTimer.cancel(); } stopProcessing(); diff --git a/star_lock/lib/main/lockDetail/monitoring/monitoring/lockMonitoring_page.dart b/star_lock/lib/main/lockDetail/monitoring/monitoring/lockMonitoring_page.dart index 1bfca06f..a75674bd 100644 --- a/star_lock/lib/main/lockDetail/monitoring/monitoring/lockMonitoring_page.dart +++ b/star_lock/lib/main/lockDetail/monitoring/monitoring/lockMonitoring_page.dart @@ -1,8 +1,8 @@ - import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; +import 'package:star_lock/talk/call/callTalk.dart'; import '../../../../app_settings/app_colors.dart'; import '../../../../talk/udp/udp_manage.dart'; @@ -43,12 +43,15 @@ class _LockMonitoringPageState extends State { top: ScreenUtil().statusBarHeight + 30.h, width: 1.sw, child: Obx(() { - var sec = (state.oneMinuteTime.value % 60).toString().padLeft(2,'0'); - var min = (state.oneMinuteTime.value ~/ 60).toString().padLeft(2,'0'); + var sec = + (state.oneMinuteTime.value % 60).toString().padLeft(2, '0'); + var min = + (state.oneMinuteTime.value ~/ 60).toString().padLeft(2, '0'); return Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - Text("$min:$sec", style: TextStyle(fontSize: 26.sp, color: Colors.white)), + Text("$min:$sec", + style: TextStyle(fontSize: 26.sp, color: Colors.white)), // SizedBox(width: 30.w), // GestureDetector( // onTap: () { @@ -66,8 +69,7 @@ class _LockMonitoringPageState extends State { // ), // ), // ), - ] - ); + ]); }), ), Positioned( @@ -155,45 +157,44 @@ class _LockMonitoringPageState extends State { Widget bottomBottomBtnWidget() { return Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ // 接听 - Obx(() => bottomBtnItemWidget(getAnswerBtnImg(), getAnswerBtnName(), Colors.white, () async { - //获取麦克风权限 - await logic.getPermissionStatus().then((value) async { - if (!value) { - return; - } + Obx(() => bottomBtnItemWidget( + getAnswerBtnImg(), getAnswerBtnName(), Colors.white, () async { + //获取麦克风权限 + await logic.getPermissionStatus().then((value) async { + if (!value) { + return; + } - // state.isSenderAudioData.value = false; - print("发送接听了"); - // 刚进来是接听状态,然后改为长按对讲 - logic.udpAnswerAction(); - }); - }, - longPress: (){ - // 开始长按 - print("onLongPress"); - state.listAudioData.value = []; - if (state.udpStatus.value == 8) { - state.udpStatus.value = 9; - } - // logic.readG711Data(); - logic.startProcessing(); - }, - longPressUp: () async { - // 长按结束 - print("onLongPressUp"); - if (state.udpStatus.value == 9) { - state.udpStatus.value = 8; - } + // state.isSenderAudioData.value = false; + print("发送接听了"); + // 刚进来是接听状态,然后改为长按对讲 + logic.udpAnswerAction(); + }); + }, longPress: () { + // 开始长按 + print("onLongPress"); + state.listAudioData.value = []; + if (state.udpStatus.value == 8) { + state.udpStatus.value = 9; } - ) - ), - bottomBtnItemWidget("images/main/icon_lockDetail_hangUp.png", "挂断", Colors.red, () async { + // logic.readG711Data(); + logic.startProcessing(); + }, longPressUp: () async { + // 长按结束 + print("onLongPressUp"); + if (state.udpStatus.value == 9) { + state.udpStatus.value = 8; + } + })), + bottomBtnItemWidget( + "images/main/icon_lockDetail_hangUp.png", "挂断", Colors.red, () async { logic.stopProcessing(); - + CallTalk().stopPcmSound(); // 挂断 logic.udpHangUpAction(); }), - bottomBtnItemWidget("images/main/icon_lockDetail_monitoringUnlock.png", "开锁", AppColors.mainColor, () { + bottomBtnItemWidget("images/main/icon_lockDetail_monitoringUnlock.png", + "开锁", AppColors.mainColor, () { showDeletPasswordAlertDialog(context); }) ]); @@ -202,26 +203,28 @@ class _LockMonitoringPageState extends State { String getAnswerBtnImg() { switch (state.udpStatus.value) { case 8: - return "images/main/icon_lockDetail_monitoringUnTalkback.png"; + return "images/main/icon_lockDetail_monitoringUnTalkback.png"; case 9: - return "images/main/icon_lockDetail_monitoringTalkback.png"; + return "images/main/icon_lockDetail_monitoringTalkback.png"; default: - return "images/main/icon_lockDetail_monitoringAnswerCalls.png"; + return "images/main/icon_lockDetail_monitoringAnswerCalls.png"; } } String getAnswerBtnName() { switch (state.udpStatus.value) { case 8: - return "长按说话"; + return "长按说话"; case 9: - return "松开发送"; + return "松开发送"; default: - return "接听"; + return "接听"; } } - Widget bottomBtnItemWidget(String iconUrl, String name, Color backgroundColor, Function() onClick, {Function()? longPress, Function()? longPressUp}) { + Widget bottomBtnItemWidget( + String iconUrl, String name, Color backgroundColor, Function() onClick, + {Function()? longPress, Function()? longPressUp}) { var wh = 80.w; return GestureDetector( onTap: onClick, @@ -285,6 +288,5 @@ class _LockMonitoringPageState extends State { @override void dispose() { super.dispose(); - } } diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyManage/passwordKeyManage_tabbar.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyManage/passwordKeyManage_tabbar.dart index a9cd295e..c51b786c 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyManage/passwordKeyManage_tabbar.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyManage/passwordKeyManage_tabbar.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; +import 'package:star_lock/tools/eventBusEventManage.dart'; import '../../../../app_settings/app_colors.dart'; import '../../../../tools/CustomUnderlineTabIndicator.dart'; @@ -13,9 +14,7 @@ class PasswordKeyManageTabbarPage extends StatefulWidget { final LockListInfoItemEntity keyInfo; PasswordKeyManageTabbarPage( - {Key? key, - required this.initialIndex, - required this.keyInfo}) + {Key? key, required this.initialIndex, required this.keyInfo}) : super(key: key); @override State createState() => @@ -44,6 +43,15 @@ class _PasswordKeyManageTabbarPageState vsync: this, length: _itemTabs.length, initialIndex: widget.initialIndex); + _tabController.addListener(handleTabIndex); + } + + int handleTabIndex() { + // 获取当前选定的标签索引 + int currentIndex = _tabController.index; + // 根据索引可以得知用户点击了哪个 item + eventBus.fire(GetPasswordTypeUpdateIndex(currentIndex)); + return currentIndex; } @override @@ -102,7 +110,7 @@ class _PasswordKeyManageTabbarPageState controller: _tabController, children: _itemTabs .map((ItemView item) => PasswordKeyPerpetualPage( - type: item.type, + type: _tabController.index.toString(), getKeyInfo: widget.keyInfo, )) .toList(), diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart index 4fc142eb..71de3f8c 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart @@ -4,6 +4,7 @@ import 'package:flutter_reactive_ble/flutter_reactive_ble.dart'; import 'package:star_lock/blue/io_type.dart'; import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_state.dart'; import 'package:star_lock/network/api_repository.dart'; +import 'package:star_lock/tools/eventBusEventManage.dart'; import 'package:star_lock/tools/toast.dart'; import '../../../../blue/blue_manage.dart'; @@ -18,6 +19,15 @@ import '../../../../tools/storage.dart'; class PasswordKeyPerpetualLogic extends BaseGetXController { final PasswordKeyPerpetualState state = PasswordKeyPerpetualState(); + /// 收到点击密码类型更新 + StreamSubscription? getPasswordTypeUpdateIndexEvent; + void getPasswordTypeUpdateIndexAction() { + getPasswordTypeUpdateIndexEvent = + eventBus.on().listen((event) { + state.widgetType.value = event.passwordType; + }); + } + /** 单次 1 只能在开始时间后6小时内使用一次 永久 2 从开始时间开始永久有效,必需在开始时间24小时内使用一次,否则将失效 @@ -39,20 +49,19 @@ class PasswordKeyPerpetualLogic extends BaseGetXController { String getFailureDateTime = '0'; String getEffectiveDateTime = '0'; String lockId = state.keyInfo.value.lockId.toString(); - int passwordType = int.parse(state.widgetType.value); - String getKeyType = passwordType.toString(); - if (passwordType == 0) { + String getKeyType = state.widgetType.value.toString(); + if (state.widgetType.value == 0) { //永久 getKeyType = '2'; - } else if (passwordType == 1) { + } else if (state.widgetType.value == 1) { //限时 getKeyType = '3'; - } else if (passwordType == 2) { + } else if (state.widgetType.value == 2) { //单次 getKeyType = '1'; - } else if (passwordType == 3) { + } else if (state.widgetType.value == 3) { //自定义 - } else if (passwordType == 4) { + } else if (state.widgetType.value == 4) { //循环 if (state.loopModeStr.value == '周末') { getKeyType = '5'; @@ -75,15 +84,14 @@ class PasswordKeyPerpetualLogic extends BaseGetXController { } else if (state.loopModeStr.value == '星期日') { getKeyType = '14'; } - } else if (passwordType == 5) { + } else if (state.widgetType.value == 5) { //清空码 getKeyType = '4'; } - print('得到的类型为getKeyType$getKeyType'); - if (state.widgetType.value != '0' && - state.widgetType.value != '2' && - state.widgetType.value != '5') { + if (state.widgetType.value != 0 && + state.widgetType.value != 2 && + state.widgetType.value != 5) { getFailureDateTime = state.failureDateTime.value.millisecondsSinceEpoch.toString(); getEffectiveDateTime = @@ -223,7 +231,8 @@ class PasswordKeyPerpetualLogic extends BaseGetXController { // 设置自定义密码 Future senderCustomPasswords() async { - BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState state) async { + BlueManage().bludSendData(BlueManage().connectDeviceName, + (DeviceConnectionState state) async { if (state == DeviceConnectionState.connected) { var publicKey = await Storage.getStringList(saveBluePublicKey); List publicKeyDataList = changeStringListToIntList(publicKey!); @@ -257,6 +266,7 @@ class PasswordKeyPerpetualLogic extends BaseGetXController { super.onReady(); _initReplySubscription(); + getPasswordTypeUpdateIndexAction(); } @override diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart index 3c8f66b9..ebae5be7 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart @@ -5,6 +5,7 @@ import 'package:flutter/services.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/app_settings/app_colors.dart'; +import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyManage/passwordKeyManage_tabbar.dart'; import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart'; import 'package:star_lock/tools/pickers/pickers.dart'; import 'package:star_lock/tools/pickers/style/default_style.dart'; @@ -54,8 +55,6 @@ class _PasswordKeyPerpetualPageState extends State { @override Widget build(BuildContext context) { - state.widgetType.value = widget.type; - return SingleChildScrollView( child: Obx(() => indexChangeWidget()), ); @@ -65,7 +64,7 @@ class _PasswordKeyPerpetualPageState extends State { if (state.isSendSuccess.value == true) { return sendElectronicKeySucceed(); } else { - switch (int.parse(widget.type)) { + switch (state.widgetType.value) { case 0: { // 永久 @@ -186,7 +185,7 @@ class _PasswordKeyPerpetualPageState extends State { action: () { Pickers.showDatePicker(context, mode: DateMode.YMDH, onConfirm: (p) { - if (int.parse(widget.type) == 3) { + if (state.widgetType.value == 3) { // 自定义 state.effectiveDateTime.value = DateTime.parse( '${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}'); @@ -216,7 +215,7 @@ class _PasswordKeyPerpetualPageState extends State { action: () { Pickers.showDatePicker(context, mode: DateMode.YMDH, onConfirm: (p) { - if (int.parse(widget.type) == 3) { + if (state.widgetType.value == 3) { // 自定义 state.failureDateTime.value = DateTime.parse( '${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}'); @@ -400,7 +399,6 @@ class _PasswordKeyPerpetualPageState extends State { onClick: () async { var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); if (isDemoMode == false) { - int getWidgetNumber = int.parse(widget.type); DateTime startDateTime = DateTime( state.effectiveDateTime.value.year, state.effectiveDateTime.value.month, @@ -413,7 +411,7 @@ class _PasswordKeyPerpetualPageState extends State { state.failureDateTime.value.hour); //自定义密码 - if (getWidgetNumber == 3) { + if (state.widgetType.value == 3) { logic.getStartDate(state.effectiveDateTime.value); if (state.nameController.text.isEmpty) { Toast.show(msg: '请输入姓名'); @@ -440,7 +438,7 @@ class _PasswordKeyPerpetualPageState extends State { } //限时 - if (getWidgetNumber == 1) { + if (state.widgetType.value == 1) { if (!startDateTime.isBefore(endDateTime) || startDateTime.isAtSameMomentAs(endDateTime)) { Toast.show(msg: '失效时间需大于生效时间'); @@ -448,7 +446,7 @@ class _PasswordKeyPerpetualPageState extends State { } } //循环密码 - if (getWidgetNumber == 4) { + if (state.widgetType.value == 4) { if (!startDateTime.isBefore(endDateTime) || startDateTime.isAtSameMomentAs(endDateTime)) { Toast.show(msg: '结束时间需大于当前时间'); diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_state.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_state.dart index b598460c..a5f20071 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_state.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_state.dart @@ -43,6 +43,6 @@ class PasswordKeyPerpetualState { var loopEndHours = DateTime.now().hour.obs; var loopModeStr = '周末'.obs; //循环模式 - final widgetType = ''.obs; + final widgetType = 0.obs; final keyInfo = LockListInfoItemEntity().obs; } diff --git a/star_lock/lib/talk/call/callTalk.dart b/star_lock/lib/talk/call/callTalk.dart index 335e33cf..9316a486 100644 --- a/star_lock/lib/talk/call/callTalk.dart +++ b/star_lock/lib/talk/call/callTalk.dart @@ -153,6 +153,9 @@ class CallTalk { //停止接收音频数据 void stopPcmSound() { + FlutterPcmSound.setup(sampleRate: 8000, channelCount: 1); + FlutterPcmSound.pause(); + FlutterPcmSound.clear(); FlutterPcmSound.stop(); } } diff --git a/star_lock/lib/talk/udp/udp_talkClass.dart b/star_lock/lib/talk/udp/udp_talkClass.dart index 7cb332e4..62a28123 100644 --- a/star_lock/lib/talk/udp/udp_talkClass.dart +++ b/star_lock/lib/talk/udp/udp_talkClass.dart @@ -1,5 +1,4 @@ import 'dart:async'; - import 'package:audioplayers/audioplayers.dart'; import 'package:fast_gbk/fast_gbk.dart'; import 'package:flutter/material.dart'; @@ -71,11 +70,7 @@ class UDPTalkClass { UDPManage().sendData(data); }); - // _getFirstFrameGoPushAction(); - // Future.delayed(const Duration(seconds: 1), () { - // 在这里写要延迟执行的代码 - Get.toNamed(Routers.lockMonitoringPage, arguments: {"lockId": "111"}); - // }); + Get.toNamed(Routers.lockMonitoringPage, arguments: {"lockId": "111"}); } playLocalAudio(); @@ -84,19 +79,6 @@ class UDPTalkClass { } } - void _getFirstFrameGoPushAction() { - // 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus - StreamSubscription _GetFirstFrameGoPushEvent = - eventBus.on().listen((event) { - if (event.isFirstFrame == true) { - Future.delayed(const Duration(seconds: 1), () { - // 在这里写要延迟执行的代码 - Get.toNamed(Routers.lockMonitoringPage, arguments: {"lockId": "111"}); - }); - } - }); - } - // 判断是否是call的本人 Future isCallMe(List? data) async { final loginData = await Storage.getLoginData(); diff --git a/star_lock/lib/tools/eventBusEventManage.dart b/star_lock/lib/tools/eventBusEventManage.dart index eb2a6e51..6e60b3fc 100644 --- a/star_lock/lib/tools/eventBusEventManage.dart +++ b/star_lock/lib/tools/eventBusEventManage.dart @@ -67,3 +67,9 @@ class GetFirstFrameGoPush { bool isFirstFrame; GetFirstFrameGoPush(this.isFirstFrame); } + +/// 获取到实时点击的密码类型更新typeIndex +class GetPasswordTypeUpdateIndex { + int passwordType; + GetPasswordTypeUpdateIndex(this.passwordType); +}