diff --git a/lib/main/lockDetail/card/cardDetail/cardDetail_logic.dart b/lib/main/lockDetail/card/cardDetail/cardDetail_logic.dart index 73b63254..41648b25 100755 --- a/lib/main/lockDetail/card/cardDetail/cardDetail_logic.dart +++ b/lib/main/lockDetail/card/cardDetail/cardDetail_logic.dart @@ -1,8 +1,8 @@ + import 'dart:async'; import 'package:flutter_blue_plus/flutter_blue_plus.dart'; import 'package:get/get.dart'; -import 'package:star_lock/blue/io_type.dart'; import 'package:star_lock/login/login/entity/LoginEntity.dart'; import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/eventBusEventManage.dart'; diff --git a/lib/main/lockDetail/card/cardDetail/cardDetail_page.dart b/lib/main/lockDetail/card/cardDetail/cardDetail_page.dart index de804c88..ca0d70b8 100755 --- a/lib/main/lockDetail/card/cardDetail/cardDetail_page.dart +++ b/lib/main/lockDetail/card/cardDetail/cardDetail_page.dart @@ -197,6 +197,8 @@ class _CardDetailPageState extends State with RouteAware { margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w, bottom: 30.w), padding: EdgeInsets.only(top: 25.w, bottom: 25.w), onClick: () { + logic.checkNetworkSituation(); + ShowTipView().showIosTipWithContentDialog('确定要删除吗?'.tr, () async { state.isDeletCard.value = true; logic.senderAddICCard(); diff --git a/lib/main/lockDetail/card/cardList/cardList_logic.dart b/lib/main/lockDetail/card/cardList/cardList_logic.dart index 92fed5e3..e88131fc 100755 --- a/lib/main/lockDetail/card/cardList/cardList_logic.dart +++ b/lib/main/lockDetail/card/cardList/cardList_logic.dart @@ -1,15 +1,13 @@ + import 'dart:async'; import 'package:flutter_blue_plus/flutter_blue_plus.dart'; import 'package:get/get.dart'; -import 'package:star_lock/blue/io_type.dart'; import 'package:star_lock/login/login/entity/LoginEntity.dart'; import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/dateTool.dart'; import '../../../../blue/blue_manage.dart'; import '../../../../blue/io_protocol/io_addICCardWithTimeCycleCoercion.dart'; -import '../../../../blue/io_protocol/io_checkingCardStatus.dart'; -import '../../../../blue/io_protocol/io_checkingUserInfoCount.dart'; import '../../../../blue/io_reply.dart'; import '../../../../blue/io_tool/io_tool.dart'; import '../../../../blue/io_tool/manager_event_bus.dart'; diff --git a/lib/main/lockDetail/card/cardList/cardList_page.dart b/lib/main/lockDetail/card/cardList/cardList_page.dart index 7e201210..77e5e9d1 100755 --- a/lib/main/lockDetail/card/cardList/cardList_page.dart +++ b/lib/main/lockDetail/card/cardList/cardList_page.dart @@ -1,10 +1,10 @@ + import 'package:flutter/material.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_slidable/flutter_slidable.dart'; import 'package:get/get.dart'; import 'package:star_lock/main/lockDetail/card/cardList/cardList_state.dart'; -import 'package:star_lock/main/lockMian/lockMain/lockMain_logic.dart'; import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; @@ -69,11 +69,8 @@ class _CardListPageState extends State with RouteAware { onPressed: () async { final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); if (isDemoMode == false) { - final bool isNetWork = - LockMainLogic.to()?.judgeTheNetwork() ?? false; - if (!isNetWork) { - return; - } + logic.checkNetworkSituation(); + ShowTipView().showIosTipWithContentDialog( '重置后,该锁的卡都将被删除哦,确认要重置吗?'.tr, () async { state.isDeletAll = true; @@ -145,6 +142,8 @@ class _CardListPageState extends State with RouteAware { children: [ SlidableAction( onPressed: (BuildContext context) { + logic.checkNetworkSituation(); + ShowTipView().showIosTipWithContentDialog( '确定要删除吗?'.tr, () async { state.isDeletAll = false; diff --git a/lib/main/lockDetail/face/faceDetail/faceDetail_page.dart b/lib/main/lockDetail/face/faceDetail/faceDetail_page.dart index 54bf087f..73c70435 100755 --- a/lib/main/lockDetail/face/faceDetail/faceDetail_page.dart +++ b/lib/main/lockDetail/face/faceDetail/faceDetail_page.dart @@ -1,3 +1,4 @@ + import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -77,7 +78,7 @@ class _FaceDetailPageState extends State with RouteAware { action: () async { if (state.keyType.value == 2 || state.keyType.value == 1) { // 限时 - var data = await Get.toNamed( + final data = await Get.toNamed( Routers.otherTypeKeyChangeDatePage, arguments: { 'pushType': 3, @@ -92,7 +93,7 @@ class _FaceDetailPageState extends State with RouteAware { } } else if (state.keyType.value == 4) { // 循环 - var data = await Get.toNamed( + final data = await Get.toNamed( Routers.otherTypeKeyChangeValidityDatePage, arguments: { 'pushType': 3, @@ -117,7 +118,7 @@ class _FaceDetailPageState extends State with RouteAware { isHaveDirection: true, isHaveLine: true, action: () async { - var data = await Get.toNamed( + final data = await Get.toNamed( Routers.otherTypeKeyChangeValidityDatePage, arguments: { 'pushType': 3, @@ -141,7 +142,7 @@ class _FaceDetailPageState extends State with RouteAware { '${DateTool().dateToHNString(state.startTime.value)}-${DateTool().dateToHNString(state.endTime.value)}', isHaveDirection: true, action: () async { - var data = await Get.toNamed( + final data = await Get.toNamed( Routers.otherTypeKeyChangeValidityDatePage, arguments: { 'pushType': 3, @@ -206,6 +207,8 @@ class _FaceDetailPageState extends State with RouteAware { left: 30.w, right: 30.w, top: 30.w, bottom: 30.w), padding: EdgeInsets.only(top: 25.w, bottom: 25.w), onClick: () { + logic.checkNetworkSituation(); + ShowTipView().showIosTipWithContentDialog('确定要删除吗?'.tr, () async { state.isDeletFace.value = true; diff --git a/lib/main/lockDetail/face/faceList/faceList_logic.dart b/lib/main/lockDetail/face/faceList/faceList_logic.dart index 8a1bb0fa..05494f98 100755 --- a/lib/main/lockDetail/face/faceList/faceList_logic.dart +++ b/lib/main/lockDetail/face/faceList/faceList_logic.dart @@ -4,13 +4,10 @@ import 'dart:async'; import 'package:flutter_blue_plus/flutter_blue_plus.dart'; import 'package:get/get.dart'; import 'package:star_lock/blue/io_protocol/io_addFace.dart'; -import 'package:star_lock/blue/io_protocol/io_queryingFaceStatus.dart'; import 'package:star_lock/login/login/entity/LoginEntity.dart'; import 'package:star_lock/main/lockDetail/face/faceList/faceList_state.dart'; import 'package:star_lock/tools/baseGetXController.dart'; -import '../../../../app_settings/app_settings.dart'; import '../../../../blue/blue_manage.dart'; -import '../../../../blue/io_protocol/io_checkingUserInfoCount.dart'; import '../../../../blue/io_reply.dart'; import '../../../../blue/io_tool/io_tool.dart'; import '../../../../blue/io_tool/manager_event_bus.dart'; @@ -342,7 +339,7 @@ class FaceListLogic extends BaseGetXController { } // 重置所有的人脸 - void clearAllFacesData() async { + Future clearAllFacesData() async { String faceId = ''; String type = '1'; if (state.isDeletAll == false) { diff --git a/lib/main/lockDetail/face/faceList/faceList_page.dart b/lib/main/lockDetail/face/faceList/faceList_page.dart index 6b1ec731..614350f4 100755 --- a/lib/main/lockDetail/face/faceList/faceList_page.dart +++ b/lib/main/lockDetail/face/faceList/faceList_page.dart @@ -1,9 +1,10 @@ + import 'package:flutter/material.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/face/faceList/faceList_state.dart'; import 'package:star_lock/main/lockDetail/fingerprint/fingerprintList/fingerprintListData_entity.dart'; -import 'package:star_lock/main/lockMian/lockMain/lockMain_logic.dart'; import 'package:star_lock/tools/keySearchWidget.dart'; import 'package:star_lock/tools/left_slide/left_slide_actions.dart'; import 'package:star_lock/tools/showTipView.dart'; @@ -27,14 +28,16 @@ class FaceListPage extends StatefulWidget { } class _FaceListPageState extends State with RouteAware { - final logic = Get.put(FaceListLogic()); - final state = Get.find().state; + final FaceListLogic logic = Get.put(FaceListLogic()); + final FaceListState state = Get.find().state; Future getHttpData() async { - var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); + final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); if (isDemoMode == false) { logic.getFaceListData().then((FingerprintListDataEntity value) { - if (mounted) setState(() {}); + if (mounted) { + setState(() {}); + } }); } } @@ -55,32 +58,29 @@ class _FaceListPageState extends State with RouteAware { barTitle: TranslationLoader.lanKeys!.face!.tr, haveBack: true, backgroundColor: AppColors.mainColor, - actionsList: [ + actionsList: [ TextButton( child: Text( TranslationLoader.lanKeys!.reset!.tr, style: TextStyle(color: Colors.white, fontSize: 24.sp), ), onPressed: () async { - var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); + final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); if (isDemoMode == false) { - final bool isNetWork = - LockMainLogic.to()?.judgeTheNetwork() ?? false; - if (!isNetWork) { - return; - } + logic.checkNetworkSituation(); + // showDeletAlertDialog(context); ShowTipView().showIosTipWithContentDialog( - "重置后,该锁的人脸都将被删除哦,确认要重置吗?", () async { + '重置后,该锁的人脸都将被删除哦,确认要重置吗?', () async { state.isDeletAll = true; - state.deletKeyID = "1"; + state.deletKeyID = '1'; state.deletFaceNo = 0; logic.senderAddFace(); }); } else { // Get.toNamed(Routers.selectLockTypePage); - logic.showToast("演示模式"); + logic.showToast('演示模式'); } }, ), @@ -95,7 +95,7 @@ class _FaceListPageState extends State with RouteAware { getHttpData(); }, child: Column( - children: [ + children: [ KeySearchWidget( editingController: state.searchController, onSubmittedAction: () { @@ -111,10 +111,10 @@ class _FaceListPageState extends State with RouteAware { btnName: '${TranslationLoader.lanKeys!.add!.tr}${TranslationLoader.lanKeys!.face!.tr}', onClick: () async { - var data = - await Get.toNamed(Routers.addFaceTypePage, arguments: { - "lockId": state.lockId.value, - "fromType": 1 // 1从添加钥匙列表进入 2从考勤添加员工入口进入 + final data = + await Get.toNamed(Routers.addFaceTypePage, arguments: { + 'lockId': state.lockId.value, + 'fromType': 1 // 1从添加钥匙列表进入 2从考勤添加员工入口进入 }); if (data != null) { logic.pageNo = 1; @@ -134,8 +134,8 @@ class _FaceListPageState extends State with RouteAware { return Obx(() => state.faceItemListData.value.isNotEmpty ? ListView.separated( itemCount: state.faceItemListData.value.length, - itemBuilder: (c, index) { - FingerprintItemData getFaceItemData = + itemBuilder: (BuildContext c, int index) { + final FingerprintItemData getFaceItemData = state.faceItemListData.value[index]; // 人脸 if (index < state.faceItemListData.value.length) { @@ -143,7 +143,7 @@ class _FaceListPageState extends State with RouteAware { tag: getFaceItemData.faceName!, key: Key(getFaceItemData.faceName!), actionsWidth: 60, - actions: [ + actions: [ _buildDeleteBtn(getFaceItemData), ], decoration: const BoxDecoration( @@ -154,9 +154,9 @@ class _FaceListPageState extends State with RouteAware { getFaceItemData.faceName!, logic.getKeyType(getFaceItemData), logic.getKeyDateType(getFaceItemData), () async { - var data = - await Get.toNamed(Routers.faceDetailPage, arguments: { - "faceItemData": getFaceItemData, + final data = + await Get.toNamed(Routers.faceDetailPage, arguments: { + 'faceItemData': getFaceItemData, }); if (data != null) { logic.pageNo = 1; @@ -182,7 +182,7 @@ class _FaceListPageState extends State with RouteAware { return GestureDetector( onTap: () { // 省略: 弹出是否删除的确认对话框。 - ShowTipView().showIosTipWithContentDialog("确定要删除吗?".tr, () async { + ShowTipView().showIosTipWithContentDialog('确定要删除吗?'.tr, () async { state.isDeletAll = false; state.deletKeyID = faceItemData.faceId.toString(); state.deletFaceNo = int.parse(faceItemData.faceNumber!); @@ -243,21 +243,21 @@ class _FaceListPageState extends State with RouteAware { // // borderRadius: BorderRadius.circular(10.w), // ), child: Row( - children: [ + children: [ SizedBox(width: 30.w), Image.asset(lockTypeIcon, width: 60.w, height: 60.w), SizedBox(width: 20.w), Expanded( child: Column( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Row( // mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ + children: [ SizedBox( width: 1.sw - 110.w - 100.w, child: Row( - children: [ + children: [ Flexible( child: Text(lockTypeTitle, maxLines: 1, @@ -277,7 +277,7 @@ class _FaceListPageState extends State with RouteAware { SizedBox(height: 5.h), Row( mainAxisAlignment: MainAxisAlignment.start, - children: [ + children: [ Flexible( child: Text(showTime, maxLines: 1, @@ -301,7 +301,6 @@ class _FaceListPageState extends State with RouteAware { @override void didChangeDependencies() { - // TODO: implement didChangeDependencies super.didChangeDependencies(); /// 路由订阅 @@ -310,7 +309,6 @@ class _FaceListPageState extends State with RouteAware { @override void dispose() { - // TODO: implement dispose /// 取消路由订阅 AppRouteObserver().routeObserver.unsubscribe(this); super.dispose(); @@ -328,7 +326,9 @@ class _FaceListPageState extends State with RouteAware { void didPop() { super.didPop(); logic.cancelBlueConnetctToastTimer(); - if (EasyLoading.isShow) EasyLoading.dismiss(animation: true); + if (EasyLoading.isShow) { + EasyLoading.dismiss(animation: true); + } state.ifCurrentScreen.value = false; } @@ -344,7 +344,9 @@ class _FaceListPageState extends State with RouteAware { void didPushNext() { super.didPushNext(); logic.cancelBlueConnetctToastTimer(); - if (EasyLoading.isShow) EasyLoading.dismiss(animation: true); + if (EasyLoading.isShow) { + EasyLoading.dismiss(animation: true); + } state.ifCurrentScreen.value = false; } } diff --git a/lib/main/lockDetail/face/faceList/faceList_state.dart b/lib/main/lockDetail/face/faceList/faceList_state.dart index 364e7601..9434719b 100755 --- a/lib/main/lockDetail/face/faceList/faceList_state.dart +++ b/lib/main/lockDetail/face/faceList/faceList_state.dart @@ -2,21 +2,21 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:star_lock/main/lockDetail/fingerprint/fingerprintList/fingerprintListData_entity.dart'; -class FaceListState { - final TextEditingController searchController = TextEditingController(); - final lockId = 0.obs; - - // 因为删除跟添加人脸用的同一个协议 所以这里用做判断 - var isDeletAll = false; - var deletKeyID = ""; - var deletFaceNo = 0; - - final faceItemListData = [].obs; - - var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示 +class FaceListState { // 是否是当前界面,用于判断是否需要针对当前界面进行展示 FaceListState() { Map map = Get.arguments; - lockId.value = map["lockId"]; + lockId.value = map['lockId']; } + final TextEditingController searchController = TextEditingController(); + final RxInt lockId = 0.obs; + + // 因为删除跟添加人脸用的同一个协议 所以这里用做判断 + bool isDeletAll = false; + String deletKeyID = ''; + int deletFaceNo = 0; + + final RxList faceItemListData = [].obs; + + RxBool ifCurrentScreen = true.obs; } diff --git a/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_page.dart b/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_page.dart index cf099f1e..d7cce814 100755 --- a/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_page.dart +++ b/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_page.dart @@ -211,6 +211,8 @@ class _FingerprintDetailPageState extends State left: 30.w, right: 30.w, top: 30.w, bottom: 30.w), padding: EdgeInsets.only(top: 25.w, bottom: 25.w), onClick: () { + logic.checkNetworkSituation(); + ShowTipView().showIosTipWithContentDialog('确定要删除吗?'.tr, () async { state.isDeletFingerprint.value = true; diff --git a/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart b/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart index c654e693..3871fce9 100755 --- a/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart +++ b/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart @@ -70,11 +70,8 @@ class _FingerprintListPageState extends State onPressed: () async { final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); if (isDemoMode == false) { - final bool isNetWork = - LockMainLogic.to()?.judgeTheNetwork() ?? false; - if (!isNetWork) { - return; - } + logic.checkNetworkSituation(); + ShowTipView().showIosTipWithContentDialog( '重置后,该锁的指纹都将被删除哦,确认要重置吗?'.tr, () async { state.isDeletAll = true; diff --git a/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_page.dart b/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_page.dart index db0c1a52..8e3c7b1a 100755 --- a/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_page.dart +++ b/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_page.dart @@ -1,7 +1,7 @@ + import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:flutter/widgets.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_logic.dart'; @@ -243,6 +243,8 @@ class _PasswordKeyDetailPageState extends State left: 30.w, right: 30.w, top: 30.w, bottom: 30.w), padding: EdgeInsets.only(top: 25.w, bottom: 25.w), onClick: () { + logic.checkNetworkSituation(); + ShowTipView().showIosTipWithContentDialog('确定要删除吗?'.tr, () { state.isDeletPasswordKey.value = true; logic.senderCustomPasswords(); diff --git a/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_logic.dart b/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_logic.dart index 6e093bb8..07de005a 100755 --- a/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_logic.dart +++ b/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_logic.dart @@ -307,12 +307,12 @@ class PasswordKeyListLogic extends BaseGetXController { } // 获取用户信息此处用作判断网络是否能获取成功 - Future getUserInfoRequest() async { - final MinePersonInfoEntity entity = await ApiRepository.to.getUserInfo(); - if (entity.errorCode!.codeIsSuccessful) { - senderResetPasswords(); - } - } + // Future getUserInfoRequest() async { + // final MinePersonInfoEntity entity = await ApiRepository.to.getUserInfo(); + // if (entity.errorCode!.codeIsSuccessful) { + // senderResetPasswords(); + // } + // } //使用期限 String getUseDateStr(PasswordKeyListItem indexEntity) { diff --git a/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart b/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart index 7403cf35..591c9243 100755 --- a/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart +++ b/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart @@ -78,7 +78,7 @@ class _PasswordKeyListPageState extends State return; } ShowTipView().showIosTipWithContentDialog( - '该锁的密码都将被删除'.tr, logic.getUserInfoRequest); + '该锁的密码都将被删除'.tr, logic.senderResetPasswords); } else { logic.showToast('演示模式'.tr); } @@ -155,6 +155,8 @@ class _PasswordKeyListPageState extends State children: [ SlidableAction( onPressed: (BuildContext context) { + logic.checkNetworkSituation(); + ShowTipView().showIosTipWithContentDialog( '确定要删除吗?'.tr, () async { state.itemData = passwordKeyListItem; diff --git a/lib/main/lockMian/lockMain/lockMain_logic.dart b/lib/main/lockMian/lockMain/lockMain_logic.dart index ae2daf05..b4d2ba83 100755 --- a/lib/main/lockMian/lockMain/lockMain_logic.dart +++ b/lib/main/lockMian/lockMain/lockMain_logic.dart @@ -110,6 +110,8 @@ class LockMainLogic extends BaseGetXController { // 从无网络到有网络 state.networkConnectionStatus.value = 1; getStarLockInfo(isUnShowLoading: true); + }else if(result == ConnectivityResult.none){ + state.networkConnectionStatus.value = 0; } }); } diff --git a/lib/tools/baseGetXController.dart b/lib/tools/baseGetXController.dart index a69b56e0..b26b372c 100755 --- a/lib/tools/baseGetXController.dart +++ b/lib/tools/baseGetXController.dart @@ -11,6 +11,7 @@ import 'package:system_settings/system_settings.dart'; import 'package:url_launcher/url_launcher.dart'; import '../common/XSConstantMacro/XSConstantMacro.dart'; +import '../main/lockMian/lockMain/lockMain_logic.dart'; import 'NativeInteractionTool.dart'; import 'dateTool.dart'; import 'manager/client_manager.dart'; @@ -176,6 +177,13 @@ class BaseGetXController extends GetxController { }); } + void checkNetworkSituation (){ + final bool isNetWork = LockMainLogic.to()?.judgeTheNetwork() ?? false; + if (!isNetWork) { + return; + } + } + String getUseKeyTypeStr(int? startDate, int? endDate, int? keyType) { String useDateStr = ''; if (keyType == XSConstantMacro.keyTypeTime) {