diff --git a/star_lock/images/lockSet_liveVideo.png b/star_lock/images/lockSet_liveVideo.png new file mode 100644 index 00000000..394a8fb1 Binary files /dev/null and b/star_lock/images/lockSet_liveVideo.png differ diff --git a/star_lock/lib/appRouters.dart b/star_lock/lib/appRouters.dart index e908a97d..1e62292e 100644 --- a/star_lock/lib/appRouters.dart +++ b/star_lock/lib/appRouters.dart @@ -12,6 +12,7 @@ import 'package:star_lock/main/lockDetail/lcokSet/catEyeSet/catEyeSet/catEyeSet_ import 'package:star_lock/main/lockDetail/lcokSet/catEyeSet/videoSlot/videoSlot_page.dart'; import 'package:star_lock/main/lockDetail/lcokSet/faceUnlock/faceUnlock_page.dart'; import 'package:star_lock/main/lockDetail/lcokSet/familyDetails/familyDetails_page.dart'; +import 'package:star_lock/main/lockDetail/lcokSet/liveVideo/liveVideo_page.dart'; import 'package:star_lock/main/lockDetail/lcokSet/lockUser/lockUser_page.dart'; import 'package:star_lock/main/lockDetail/lcokSet/motorPower/motorPower_page.dart'; import 'package:star_lock/main/lockDetail/lcokSet/msgNotification/msgNotification/msgNotification_page.dart'; @@ -414,6 +415,7 @@ abstract class Routers { static const doorLockLogPage = '/doorLockLogPage'; //门锁日志 static const catEyeCustomModePage = '/catEyeCustomModePage'; //猫眼自定义模式 static const videoSlotPage = '/videoSlotPage'; //录像时段 + static const liveVideoPage = '/liveVideoPage'; //实时画面 } abstract class AppRouters { @@ -1005,5 +1007,6 @@ abstract class AppRouters { name: Routers.catEyeCustomModePage, page: () => const CatEyeCustomModePage()), GetPage(name: Routers.videoSlotPage, page: (() => const VideoSlotPage())), + GetPage(name: Routers.liveVideoPage, page: (() => const LiveVideoPage())) ]; } diff --git a/star_lock/lib/main.dart b/star_lock/lib/main.dart index 08fb6721..317f32f1 100644 --- a/star_lock/lib/main.dart +++ b/star_lock/lib/main.dart @@ -1,12 +1,8 @@ import 'package:aliyun_push/aliyun_push.dart'; -import 'package:audioplayers/audioplayers.dart'; -// import 'package:audioplayers/audioplayers.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; -import 'package:flutter_pcm_sound/flutter_pcm_sound.dart'; 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'; @@ -16,7 +12,6 @@ import 'package:star_lock/tools/device_info_service.dart'; import 'package:star_lock/tools/platform_info_services.dart'; import 'package:star_lock/tools/storage.dart'; import 'package:star_lock/tools/xs_aliyunPush.dart'; -// import 'package:star_lock/tools/store_service.dart'; import 'package:star_lock/translations/app_dept.dart'; import 'package:star_lock/translations/trans_lib.dart'; @@ -54,12 +49,6 @@ class MyApp extends StatefulWidget { // final RouteObserver routeObserver = RouteObserver(); class _MyAppState extends State with WidgetsBindingObserver, BaseWidget { - final _aliyunPush = AliyunPush(); - var _deviceId = ""; - // final audioPlayer = AudioPlayer(); - final FlutterSoundPlayer _audioPlayer = FlutterSoundPlayer(); - late List allDataBytes; - @override Widget build(BuildContext context) { return ScreenUtilInit( @@ -139,47 +128,31 @@ class _MyAppState extends State with WidgetsBindingObserver, BaseWidget { //初始化阿里云推送 void initAliyunPush() { - XSAliyunPushProvider().init(_aliyunPush); + final aliyunPush = AliyunPush(); + XSAliyunPushProvider().init(aliyunPush); XSAliyunPushProvider().initAliyunPush(); if (Platform.isAndroid) { XSAliyunPushProvider().initAliyunThirdPush(); } - //暂不使用DeviceID推送 - _aliyunPush.getDeviceId().then((deviceId) async { + //暂使用DeviceID推送 + aliyunPush.getDeviceId().then((deviceId) async { + // print('得到的DeviceId$deviceId'); final data = await Storage.getString('userLoginData'); - if (data!.isNotEmpty) { + if (data!.isNotEmpty && deviceId.isNotEmpty) { XSAliyunPushProvider() .pushBindDeviceID(deviceId, Platform.isAndroid ? 10 : 20); } }); - - // //使用userid根据账号推送 - // _aliyunPush.bindAccount(Storage.getUid().toString()).then((value) { - // print("得到了value$value"); - // }); } @override void dispose() { - WidgetsBinding.instance?.removeObserver(this); + WidgetsBinding.instance.removeObserver(this); super.dispose(); } - void didChangeAppLifecycleState(AppLifecycleState state) { - if (state == AppLifecycleState.resumed) { - // 应用进入前台 - print("应用进入前台"); - } else if (state == AppLifecycleState.paused) { - // 应用进入后台 - print("应用进入后台"); - if (UDPTalkClass().isBeCall == true) { - UDPTalkClass().playLocalAudio(); - } - } - } -} // 设置国际化信息 Future _initTranslation() async => TranslationLoader.loadTranslation( diff --git a/star_lock/lib/main/lockDetail/lcokSet/catEyeSet/catEyeCustomMode/catEyeCustomMode_page.dart b/star_lock/lib/main/lockDetail/lcokSet/catEyeSet/catEyeCustomMode/catEyeCustomMode_page.dart index e2b13e7b..e7cba823 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/catEyeSet/catEyeCustomMode/catEyeCustomMode_page.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/catEyeSet/catEyeCustomMode/catEyeCustomMode_page.dart @@ -63,6 +63,9 @@ class _CatEyeCustomModePageState extends State { isHaveLine: false, isHaveDirection: true, isHaveRightWidget: false, + action: () { + Get.toNamed(Routers.liveVideoPage); + }, ) ], )); diff --git a/star_lock/lib/main/lockDetail/lcokSet/catEyeSet/catEyeWorkMode/catEyeWorkMode_page.dart b/star_lock/lib/main/lockDetail/lcokSet/catEyeSet/catEyeWorkMode/catEyeWorkMode_page.dart index 653ff378..bab2a18c 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/catEyeSet/catEyeWorkMode/catEyeWorkMode_page.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/catEyeSet/catEyeWorkMode/catEyeWorkMode_page.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/appRouters.dart'; +import 'package:star_lock/tools/submitBtn.dart'; import '../../../../../app_settings/app_colors.dart'; import '../../../../../tools/titleAppBar.dart'; @@ -114,10 +115,12 @@ class _CatEyeWorkModePageState extends State { ), ), onTap: () { + //自定义模式跳转 if (clickIndex == 3) { Get.toNamed(Routers.catEyeCustomModePage); } else { - // Get.toNamed(Routes.catEyeWorkModeDetailPage); + //其他模式弹框 + showBottomSheet(context, clickIndex); } }, ), @@ -159,34 +162,119 @@ class _CatEyeWorkModePageState extends State { } //显示底部弹框的功能 - void showBottomSheet(BuildContext context) { - //用于在底部打开弹框的效果 + void showBottomSheet(BuildContext context, int clickIndex) { showModalBottomSheet( builder: (BuildContext context) { //构建弹框中的内容 - return _buildBottomSheetWidget(context); + if (clickIndex == 0) { + return _buildBottomSheetWidget(context, '省电模式', '有人按门铃或发生\n异常事件时', + '不录像', '/', '有人按门铃或发生\n异常事件时'); + } else if (clickIndex == 1) { + return _buildBottomSheetWidget(context, '逗留抓拍模式', + '有人出现、按门铃\n或发生异常事件时', '逗留达到10秒', '约1.5米', '随时'); + } else if (clickIndex == 2) { + return _buildBottomSheetWidget( + context, '实时监控模式', '有人出现、按门铃\n或发生异常事件时', '立即录像', '约1.5米', '随时'); + } else { + return Container(); + } }, context: context); } - _buildBottomSheetWidget(BuildContext context) { + _buildBottomSheetWidget(BuildContext context, String modeTitle, String tips1, + String tips2, String tips3, String tips4) { return Container( margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 20.h), child: Column( children: [ Row( children: [ - Text( - '省电模式', - style: TextStyle( - fontSize: 24.sp, - color: Colors.black, - fontWeight: FontWeight.w500), - ) + //居中显示 + Expanded( + child: Center( + child: Text( + modeTitle, + style: TextStyle( + fontSize: 26.sp, + color: Colors.black, + fontWeight: FontWeight.w600), + ), + ), + ), ], - ) + ), + SizedBox( + height: 40.h, + ), + _buildRowWidget('录像时机', tips1), + _buildRowWidget('有人出现时录像', tips2), + _buildRowWidget('人体侦测距离', tips3), + _buildRowWidget('查看实时画面', tips4), + _buildIKnowBtn(), ], ), ); } + + _buildRowWidget(String titleStr, String subTitleStr) { + return Container( + margin: EdgeInsets.only(top: 26.h, bottom: 26.h), + child: Row( + //Row两端对齐的方法 + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + titleStr, + style: TextStyle( + fontSize: 24.sp, + color: Colors.black, + fontWeight: FontWeight.w600), + ), + Expanded( + child: SizedBox( + width: 20.sp, + ), + ), + Text( + subTitleStr, + textAlign: TextAlign.right, + style: TextStyle( + fontSize: 20.sp, + color: AppColors.placeholderTextColor, + ), + ), + SizedBox( + width: 20.sp, + ), + ], + ), + ); + } + + _buildIKnowBtn() { + return GestureDetector( + child: Container( + width: ScreenUtil().screenWidth - 40.w, + height: 80.h, + margin: EdgeInsets.only(top: 40.h, bottom: 40.h), + decoration: BoxDecoration( + color: AppColors.btnDisableColor, + borderRadius: BorderRadius.circular(80.h / 2), + ), + child: Center( + child: Text( + '我知道了', + style: TextStyle( + color: AppColors.darkGrayTextColor, + fontSize: 24.sp, + fontWeight: FontWeight.w500), + ), + ), + ), + onTap: () { + Navigator.pop(context); + }, + ); + } } diff --git a/star_lock/lib/main/lockDetail/lcokSet/liveVideo/liveVideo_logic.dart b/star_lock/lib/main/lockDetail/lcokSet/liveVideo/liveVideo_logic.dart new file mode 100644 index 00000000..2ad94803 --- /dev/null +++ b/star_lock/lib/main/lockDetail/lcokSet/liveVideo/liveVideo_logic.dart @@ -0,0 +1,6 @@ +import 'package:star_lock/main/lockDetail/lcokSet/liveVideo/liveVideo_state.dart'; +import 'package:star_lock/tools/baseGetXController.dart'; + +class LiveVideoLogic extends BaseGetXController { + final LiveVideoState state = LiveVideoState(); +} diff --git a/star_lock/lib/main/lockDetail/lcokSet/liveVideo/liveVideo_page.dart b/star_lock/lib/main/lockDetail/lcokSet/liveVideo/liveVideo_page.dart new file mode 100644 index 00000000..688b4d5e --- /dev/null +++ b/star_lock/lib/main/lockDetail/lcokSet/liveVideo/liveVideo_page.dart @@ -0,0 +1,144 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/lcokSet/liveVideo/liveVideo_logic.dart'; +import 'package:star_lock/translations/trans_lib.dart'; + +import '../../../../../app_settings/app_colors.dart'; +import '../../../../../tools/titleAppBar.dart'; + +class LiveVideoPage extends StatefulWidget { + const LiveVideoPage({Key? key}) : super(key: key); + + @override + State createState() => _LiveVideoPageState(); +} + +class _LiveVideoPageState extends State { + final logic = Get.put(LiveVideoLogic()); + final state = Get.find().state; + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: AppColors.mainBackgroundColor, + appBar: TitleAppBar( + barTitle: '实时画面', + haveBack: true, + backgroundColor: AppColors.mainColor, + actionsList: [ + TextButton( + child: Text( + TranslationLoader.lanKeys!.save!.tr, + style: TextStyle(color: Colors.white, fontSize: 24.sp), + ), + onPressed: () { + Get.back(); + }, + ), + ], + ), + body: Column( + children: [ + SizedBox( + height: 80.h, + ), + Image.asset( + 'images/lockSet_liveVideo.png', + height: 541.h, + width: 255.w, + ), + SizedBox( + height: 86.h, + ), + _buildTipsView('发生事件时查看\n', '仅当门锁发生事件或有人按门铃时,才能在门锁首页查看实时画面。', 0), + SizedBox( + height: 16.h, + ), + _buildTipsView('实时查看\n', + '指定时问内,无论门锁是否发生安全事件或有人按门铃,都能在门锁首页随时查看实时画面;电池续航时问将会缩短。', 1), + ], + )); + } + + Widget _buildTipsView(String titleStr, String subTitle, int clickIndex) { + return Obx(() => GestureDetector( + child: Container( + width: ScreenUtil().screenWidth - 40.w, + margin: EdgeInsets.only(left: 20.w, right: 20.w, bottom: 10.h), + decoration: BoxDecoration( + color: clickIndex == 0 + ? (state.isLiveView.value == false + ? AppColors.blueViewBgColor + : AppColors.greyBackgroundColor) + : (state.isLiveView.value == true + ? AppColors.blueViewBgColor + : AppColors.greyBackgroundColor), + borderRadius: BorderRadius.circular(10.0), + ), + child: Padding( + padding: EdgeInsets.only( + left: 20.w, top: 30.h, bottom: 30.h, right: 20.w), + child: Row( + children: [ + clickIndex == 0 + ? (state.isLiveView.value == false + ? Image.asset( + 'images/mine/icon_mine_blueSelect.png', + width: 20.w, + height: 14.w, + ) + : SizedBox( + width: 20.w, + height: 14.w, + )) + : (state.isLiveView.value == true + ? Image.asset( + 'images/mine/icon_mine_blueSelect.png', + width: 20.w, + height: 14.w, + ) + : SizedBox( + width: 20.w, + height: 14.w, + )), + SizedBox(width: 10.w), + Expanded( + child: _buildRichText( + titleStr, + subTitle, + clickIndex == 0 + ? (state.isLiveView.value == false ? true : false) + : (state.isLiveView.value == true + ? true + : false)), + ), + ], + )), + ), + onTap: () { + state.isLiveView.value = !state.isLiveView.value; + }, + )); + } + + Widget _buildRichText(String titleStr, String subTitle, bool isClick) { + //高亮样式 + final TextStyle titleStyle = TextStyle( + color: isClick ? AppColors.blueTextTipsColor : Colors.black, + fontSize: 24.sp, + fontWeight: FontWeight.w500); + //默认样式 + final TextStyle subTipsStyle = TextStyle( + color: isClick + ? AppColors.blueTextTipsColor + : AppColors.placeholderTextColor, + fontSize: 20.sp); + + late InlineSpan tipsPreviewSpan = TextSpan(children: [ + TextSpan(text: titleStr, style: titleStyle), + TextSpan(text: subTitle, style: subTipsStyle), + ]); + return RichText(text: tipsPreviewSpan); + } +} diff --git a/star_lock/lib/main/lockDetail/lcokSet/liveVideo/liveVideo_state.dart b/star_lock/lib/main/lockDetail/lcokSet/liveVideo/liveVideo_state.dart new file mode 100644 index 00000000..d239cc81 --- /dev/null +++ b/star_lock/lib/main/lockDetail/lcokSet/liveVideo/liveVideo_state.dart @@ -0,0 +1,5 @@ +import 'package:get/get.dart'; + +class LiveVideoState { + var isLiveView = false.obs; //是否实时查看 +} diff --git a/star_lock/lib/tools/xs_aliyunPush.dart b/star_lock/lib/tools/xs_aliyunPush.dart index 6858289e..d735ad18 100644 --- a/star_lock/lib/tools/xs_aliyunPush.dart +++ b/star_lock/lib/tools/xs_aliyunPush.dart @@ -3,7 +3,6 @@ import 'dart:io'; import 'package:aliyun_push/aliyun_push.dart'; import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; -import 'package:star_lock/tools/toast.dart'; class XSAliyunPushProvider { late AliyunPush _aliyunPush = AliyunPush(); @@ -17,29 +16,29 @@ class XSAliyunPushProvider { } Future _onNotification(Map message) async { - // Toast.show(msg: 'onNotification: $message'); + print('onNotification: $message'); } Future _onAndroidNotificationReceivedInApp( Map message) async { - // Toast.show(msg: 'onAndroidNotificationReceivedInApp: $message'); + print('onAndroidNotificationReceivedInApp: $message'); } Future _onMessage(Map message) async { - // Toast.show(msg: 'onMessage: $message'); + print('onMessage: $message'); } Future _onNotificationOpened(Map message) async { - // Toast.show(msg: 'onNotificationOpened: $message'); + print('onNotificationOpened: $message'); } Future _onNotificationRemoved(Map message) async { - // Toast.show(msg: 'onNotificationRemoved: $message'); + print('onNotificationRemoved: $message'); } Future _onAndroidNotificationClickedWithNoAction( Map message) async { - // Toast.show(msg: 'onAndroidNotificationClickedWithNoAction: $message'); + print('onAndroidNotificationClickedWithNoAction: $message'); } Future _onIOSChannelOpened(Map message) async {}