diff --git a/star_lock/images/main/monitorBg.png b/star_lock/images/main/monitorBg.png new file mode 100644 index 00000000..38d0dec0 Binary files /dev/null and b/star_lock/images/main/monitorBg.png differ diff --git a/star_lock/lib/app_settings/app_colors.dart b/star_lock/lib/app_settings/app_colors.dart index f593132e..9e7a287d 100644 --- a/star_lock/lib/app_settings/app_colors.dart +++ b/star_lock/lib/app_settings/app_colors.dart @@ -126,4 +126,5 @@ class AppColors { static const blueViewBgColor = Color.fromRGBO(223, 237, 254, 1); //蓝色背景板 139 148 176 static const msgNoticeTextColor = Color.fromRGBO(139, 148, 176, 1); //消息提醒字体颜色 + static const alphaBgViewColor = Color.fromRGBO(0, 0, 0, 0.2); //透明度背景 } 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 013d18d3..a4a6a6e1 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/realTimePicture/realTimePicture_logic.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/realTimePicture/realTimePicture_logic.dart @@ -36,6 +36,67 @@ class RealTimePictureLogic extends BaseGetXController { }); } + /// 收到UDP发送的状态 + StreamSubscription? _getUDPStatusRefreshUIEvent; + void _getUDPStatusRefreshUIAction() { + _getUDPStatusRefreshUIEvent = + eventBus.on().listen((event) { + state.udpStatus.value = event.udpStatus; + if (state.udpStatus.value == 8) { + // 接听成功了,然后刷新界面的时间 60秒以后自动挂断 + 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) { + // 超过60秒了 + state.oneMinuteTimeTimer.cancel(); + state.oneMinuteTime.value = 0; + // 挂断 + UDPSenderManage.sendMainProtocol( + command: 150, + commandTypeIsCalling: 1, + subCommand: 30, + lockID: state.getLockID.value, + lockIP: UDPManage().host, + userMobile: await state.userMobile, + userMobileIP: await state.userMobileIP, + endData: []); + + // 关闭当前界面 + Get.back(); + } + }); + } + }); + } + + //查询监视状态 + udpQueryMonitoringStatusAction() async { + UDPSenderManage.sendMainProtocol( + command: 152, + commandTypeIsCalling: 1, + subCommand: 20, + lockID: state.getLockID.value, + lockIP: UDPManage().host, + userMobile: await state.userMobile, + userMobileIP: await state.userMobileIP, + endData: []); + } + + /// 监视 + udpMonitorAction() async { + UDPSenderManage.sendMainProtocol( + command: 152, + commandTypeIsCalling: 1, + subCommand: 1, + lockID: state.getLockID.value, + lockIP: UDPManage().host, + userMobile: await state.userMobile, + userMobileIP: await state.userMobileIP, + endData: []); + } + /// 接听 udpAnswerAction() async { UDPSenderManage.sendMainProtocol( @@ -52,7 +113,7 @@ class RealTimePictureLogic extends BaseGetXController { /// 挂断 udpHangUpAction() async { UDPSenderManage.sendMainProtocol( - command: 150, + command: 152, commandTypeIsCalling: 1, subCommand: 30, lockID: UDPManage().lockId, @@ -65,7 +126,7 @@ class RealTimePictureLogic extends BaseGetXController { /// 开门 udpOpenDoorAction() async { UDPSenderManage.sendMainProtocol( - command: 150, + command: 152, commandTypeIsCalling: 1, subCommand: 10, lockID: UDPManage().lockId, @@ -348,6 +409,7 @@ class RealTimePictureLogic extends BaseGetXController { print("onReady()"); _getTVDataRefreshUIAction(); + _getUDPStatusRefreshUIAction(); initRecorder(); } @@ -363,6 +425,10 @@ class RealTimePictureLogic extends BaseGetXController { // TODO: implement onClose print("锁详情界面销毁了"); _getTVDataRefreshUIEvent!.cancel(); + _getUDPStatusRefreshUIEvent!.cancel(); + if (state.oneMinuteTimeTimer != null) { + state.oneMinuteTimeTimer.cancel(); + } stopProcessing(); } } 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 1f2f280e..0b503d2c 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/realTimePicture/realTimePicture_page.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/realTimePicture/realTimePicture_page.dart @@ -24,7 +24,6 @@ class _RealTimePicturePageState extends State void initState() { super.initState(); - // listeningAnimations(); state.animationController = AnimationController(duration: const Duration(seconds: 1), vsync: this); state.animationController.repeat(); @@ -39,6 +38,8 @@ class _RealTimePicturePageState extends State state.animationController.forward(); } }); + + logic.udpMonitorAction(); } @override @@ -47,17 +48,28 @@ class _RealTimePicturePageState extends State width: 1.sw, height: 1.sh, child: Stack( + alignment: Alignment.center, children: [ Obx(() => state.listData.value.isEmpty - ? Container(color: Colors.black) + ? Image.asset( + 'images/main/monitorBg.png', + width: ScreenUtil().screenWidth, + height: ScreenUtil().screenHeight, + fit: BoxFit.cover, + ) : Image.memory( state.listData.value, - // key: ValueKey(state.listData.value.hashCode), gaplessPlayback: true, width: 1.sw, height: 1.sh, fit: BoxFit.cover, )), + Positioned( + bottom: 300.h, + child: Text( + '正在创建安全连接...', + style: TextStyle(color: Colors.black, fontSize: 26.sp), + )), Positioned( bottom: 10.w, child: Container( @@ -65,7 +77,7 @@ class _RealTimePicturePageState extends State // height: 300.h, margin: EdgeInsets.all(30.w), decoration: BoxDecoration( - color: const Color(0xC83C3F41), + color: Colors.black.withOpacity(0.2), borderRadius: BorderRadius.circular(20.h)), child: Column( children: [ @@ -277,17 +289,26 @@ class _RealTimePicturePageState extends State return Positioned( left: ScreenUtil().screenWidth / 2 - 220.w / 2, top: ScreenUtil().screenHeight / 2 - 220.w / 2 - 150.h, - child: RotationTransition( - //设置动画的旋转中心 - alignment: Alignment.center, - //动画控制器 - turns: state.animationController, - //将要执行动画的子view - child: Image.asset( - 'images/main/realTime_connecting.png', - width: 220.w, - height: 220.w, + child: GestureDetector( + child: RotationTransition( + //设置动画的旋转中心 + alignment: Alignment.center, + //动画控制器 + turns: state.animationController, + //将要执行动画的子view + child: AnimatedOpacity( + opacity: 0.5, + duration: const Duration(seconds: 2), + child: Image.asset( + 'images/main/realTime_connecting.png', + width: 220.w, + height: 220.w, + ), + ), ), + onTap: () { + print('点击重新连接'); + }, ), ); } diff --git a/star_lock/lib/main/lockDetail/lockDetail/realTimePicture/realTimePicture_state.dart b/star_lock/lib/main/lockDetail/lockDetail/realTimePicture/realTimePicture_state.dart index fe01bd43..c8da8ff5 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/realTimePicture/realTimePicture_state.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/realTimePicture/realTimePicture_state.dart @@ -25,11 +25,19 @@ class RealTimePictureState { late final VoiceProcessor? voiceProcessor; + late Timer oneMinuteTimeTimer = + Timer(const Duration(seconds: 1), () {}); // 定时器超过60秒关闭当前界面 var oneMinuteTime = 0.obs; // 定时器秒数 + var getLockID = ''.obs; //lockID + // 定时器如果发送了接听的命令 而没收到回复就每秒重复发送10次 late Timer answerTimer; late Timer hangUpTimer; late Timer openDoorTimer; late AnimationController animationController; + + RealTimePictureState() { + getLockID.value = Get.arguments["lockId"].toString(); + } }