diff --git a/lib/main/lockDetail/card/addCardType/addCardType_logic.dart b/lib/main/lockDetail/card/addCardType/addCardType_logic.dart index c72b658a..a0068189 100755 --- a/lib/main/lockDetail/card/addCardType/addCardType_logic.dart +++ b/lib/main/lockDetail/card/addCardType/addCardType_logic.dart @@ -1,6 +1,5 @@ import 'package:get/get.dart'; -import 'package:star_lock/app_settings/app_settings.dart'; import 'package:star_lock/login/login/entity/LoginEntity.dart'; import 'package:star_lock/tools/baseGetXController.dart'; @@ -93,9 +92,4 @@ class AddCardTypeLogic extends BaseGetXController{ } } - @override - void onInit() { - super.onInit(); - } - } diff --git a/lib/main/lockDetail/card/addICCard/addICCard_entity.dart b/lib/main/lockDetail/card/addICCard/addICCard_entity.dart index c0794ecc..ff822b26 100755 --- a/lib/main/lockDetail/card/addICCard/addICCard_entity.dart +++ b/lib/main/lockDetail/card/addICCard/addICCard_entity.dart @@ -1,8 +1,4 @@ class AddICCardEntity { - int? errorCode; - String? description; - String? errorMsg; - Data? data; AddICCardEntity( {this.errorCode, this.description, this.errorMsg, this.data}); @@ -13,6 +9,10 @@ class AddICCardEntity { errorMsg = json['errorMsg']; data = json['data'] != null ? Data.fromJson(json['data']) : null; } + int? errorCode; + String? description; + String? errorMsg; + Data? data; Map toJson() { final Map data = {}; @@ -27,13 +27,13 @@ class AddICCardEntity { } class Data { - int? cardId; Data({this.cardId}); Data.fromJson(Map json) { cardId = json['cardId']; } + int? cardId; Map toJson() { final Map data = {}; diff --git a/lib/main/lockDetail/card/addICCard/addICCard_page.dart b/lib/main/lockDetail/card/addICCard/addICCard_page.dart index 3e9014c3..d1fdade1 100755 --- a/lib/main/lockDetail/card/addICCard/addICCard_page.dart +++ b/lib/main/lockDetail/card/addICCard/addICCard_page.dart @@ -27,7 +27,7 @@ class _AddICCardPageState extends State with RouteAware { 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, ), diff --git a/lib/main/lockDetail/card/cardDetail/cardDetail_page.dart b/lib/main/lockDetail/card/cardDetail/cardDetail_page.dart index 9f6ddb89..96166bd2 100755 --- a/lib/main/lockDetail/card/cardDetail/cardDetail_page.dart +++ b/lib/main/lockDetail/card/cardDetail/cardDetail_page.dart @@ -41,7 +41,7 @@ class _CardDetailPageState extends State with RouteAware { children: [ Obx(() => CommonItem( leftTitel: - "${TranslationLoader.lanKeys!.card!.tr}${TranslationLoader.lanKeys!.number!.tr}", + '${TranslationLoader.lanKeys!.card!.tr}${TranslationLoader.lanKeys!.number!.tr}', rightTitle: state.typeNumber.value, isHaveDirection: false, isHaveLine: true)), @@ -53,7 +53,7 @@ class _CardDetailPageState extends State with RouteAware { action: () { ShowTipView().showTFViewAlertDialog( state.changeNameController, - "${TranslationLoader.lanKeys!.amend!.tr}${TranslationLoader.lanKeys!.name!.tr}", + '${TranslationLoader.lanKeys!.amend!.tr}${TranslationLoader.lanKeys!.name!.tr}', '', () { if (state.changeNameController.text.isEmpty) { logic.showToast('请输入姓名'.tr); @@ -65,11 +65,9 @@ class _CardDetailPageState extends State with RouteAware { }); })), Obx(() => Visibility( - visible: (state.keyType.value == 4 || + visible: state.keyType.value == 4 || state.keyType.value == 2 || - state.keyType.value == 1) - ? true - : false, + state.keyType.value == 1, child: CommonItem( leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr, allHeight: 70.h, @@ -109,7 +107,7 @@ class _CardDetailPageState extends State with RouteAware { } }))), Obx(() => Visibility( - visible: state.keyType.value == 4 ? true : false, + visible: state.keyType.value == 4, child: Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.effectiveDay!.tr, rightTitle: state.weekDay.value.join(','), @@ -131,7 +129,7 @@ class _CardDetailPageState extends State with RouteAware { } })))), Obx(() => Visibility( - visible: state.keyType.value == 4 ? true : false, + visible: state.keyType.value == 4, child: Obx(() => CommonItem( leftTitel: '有效时间'.tr, rightTitle: '${DateTool().dateToHNString(state.starTime.value)}-${DateTool().dateToHNString(state.endTime.value)}', diff --git a/lib/main/lockDetail/face/addFaceType/addFaceType_logic.dart b/lib/main/lockDetail/face/addFaceType/addFaceType_logic.dart index 814ea5c6..6cac090b 100755 --- a/lib/main/lockDetail/face/addFaceType/addFaceType_logic.dart +++ b/lib/main/lockDetail/face/addFaceType/addFaceType_logic.dart @@ -1,4 +1,5 @@ import 'package:get/get.dart'; +import 'package:star_lock/login/login/entity/LoginEntity.dart'; import 'package:star_lock/main/lockDetail/face/addFaceType/addFaceType_state.dart'; import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/dateTool.dart'; @@ -9,31 +10,31 @@ class AddFaceTypeLogic extends BaseGetXController { AddFaceTypeState state = AddFaceTypeState(); // 添加指纹 - void addFaceData() async { - var faceType = 0; // 永久:1;限时2,单次3,循环:4 - var startDate = ""; - var endDate = ""; - var startTime = ""; - var endTime = ""; - if (state.selectType.value == "0") { + Future addFaceData() async { + int faceType = 0; // 永久:1;限时2,单次3,循环:4 + String startDate = ''; + String endDate = ''; + String startTime = ''; + String endTime = ''; + if (state.selectType.value == '0') { faceType = 1; - startDate = "0"; - endDate = "0"; - startTime = "0"; - endTime = "0"; - } else if (state.selectType.value == "1") { + startDate = '0'; + endDate = '0'; + startTime = '0'; + endTime = '0'; + } else if (state.selectType.value == '1') { faceType = 2; startDate = DateTool().dateToTimestamp(state.timeLimitBeginTime.value, 1).toString(); endDate = DateTool().dateToTimestamp(state.timeLimitEndTime.value, 1).toString(); - startTime = "0"; - endTime = "0"; + startTime = '0'; + endTime = '0'; if (startDate.isEmpty) { - showToast("请选择开始时间".tr); + showToast('请选择开始时间'.tr); return; } if (endDate.isEmpty) { - showToast("请选择结束时间".tr); + showToast('请选择结束时间'.tr); return; } @@ -43,12 +44,12 @@ class AddFaceTypeLogic extends BaseGetXController { // } if (int.parse(startDate) >= int.parse(endDate)) { - showToast("失效时间要大于生效时间".tr); + showToast('失效时间要大于生效时间'.tr); return; } - } else if (state.selectType.value == "2") { + } else if (state.selectType.value == '2') { if (state.cycleBeginTime.value.isEmpty) { - showToast("请选择有效期".tr); + showToast('请选择有效期'.tr); return; } startDate = DateTool().dateToTimestamp(state.cycleBeginTime.value, 1).toString(); @@ -59,26 +60,26 @@ class AddFaceTypeLogic extends BaseGetXController { } // 人脸 - Get.toNamed(Routers.addFacePage, arguments: { - "lockId": state.lockId.value, - "endDate": endDate, - "addType": "1", - "faceName": state.nameController.text, - "faceNumber": "123456", - "faceType": faceType, - "startDate": startDate, - "cyclicConfig": state.weekdaysList.value, - "fromType": state.fromType.value, - "isAdministrator": state.isAdministrator.value == false ? "1" : "2", - "effectiveTime": startTime, - "failureTime": endTime, - "selectType": state.selectType.value, + Get.toNamed(Routers.addFacePage, arguments: { + 'lockId': state.lockId.value, + 'endDate': endDate, + 'addType': '1', + 'faceName': state.nameController.text, + 'faceNumber': '123456', + 'faceType': faceType, + 'startDate': startDate, + 'cyclicConfig': state.weekdaysList.value, + 'fromType': state.fromType.value, + 'isAdministrator': state.isAdministrator.value == false ? '1' : '2', + 'effectiveTime': startTime, + 'failureTime': endTime, + 'selectType': state.selectType.value, }); } // 校验指纹名字是否重复 - void checkFaceNameDuplicated(String faceName) async { - var entity = await ApiRepository.to.checkFaceNameDuplicatedData( + Future checkFaceNameDuplicated(String faceName) async { + final LoginEntity entity = await ApiRepository.to.checkFaceNameDuplicatedData( lockId: state.lockId.value.toString(), faceName: faceName, ); diff --git a/lib/main/lockDetail/face/addFaceType/addFaceType_page.dart b/lib/main/lockDetail/face/addFaceType/addFaceType_page.dart index 70daec89..b89f68fe 100755 --- a/lib/main/lockDetail/face/addFaceType/addFaceType_page.dart +++ b/lib/main/lockDetail/face/addFaceType/addFaceType_page.dart @@ -1,8 +1,10 @@ + import 'package:flutter/cupertino.dart'; 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/main/lockDetail/face/addFaceType/addFaceType_state.dart'; import 'package:star_lock/tools/commonDataManage.dart'; import 'package:star_lock/tools/dateTool.dart'; import 'package:star_lock/tools/pickers/pickers.dart'; @@ -26,14 +28,12 @@ class AddFaceTypePage extends StatefulWidget { State createState() => _AddFaceTypePageState(); } -class _AddFaceTypePageState extends State - with SingleTickerProviderStateMixin { - final logic = Get.put(AddFaceTypeLogic()); - final state = Get.find().state; +class _AddFaceTypePageState extends State with SingleTickerProviderStateMixin { + final AddFaceTypeLogic logic = Get.put(AddFaceTypeLogic()); + final AddFaceTypeState state = Get.find().state; @override void initState() { - // TODO: implement initState super.initState(); state.tabController = TabController( @@ -59,11 +59,11 @@ class _AddFaceTypePageState extends State backgroundColor: AppColors.mainBackgroundColor, appBar: TitleAppBar( barTitle: - "${TranslationLoader.lanKeys!.addTip!.tr}${TranslationLoader.lanKeys!.face!.tr}", + '${TranslationLoader.lanKeys!.addTip!.tr}${TranslationLoader.lanKeys!.face!.tr}', haveBack: true, backgroundColor: AppColors.mainColor), body: Column( - children: [ + children: [ _tabBar(), _pageWidget(), ], @@ -78,7 +78,7 @@ class _AddFaceTypePageState extends State // 永久 return SingleChildScrollView( child: Column( - children: [ + children: [ perpetualKeyWidget( TranslationLoader.lanKeys!.name!.tr, TranslationLoader.lanKeys!.pleaseEnter!.tr, @@ -93,7 +93,7 @@ class _AddFaceTypePageState extends State // 限时 return SingleChildScrollView( child: Column( - children: [ + children: [ perpetualKeyWidget( TranslationLoader.lanKeys!.name!.tr, TranslationLoader.lanKeys!.pleaseEnter!.tr, @@ -109,7 +109,7 @@ class _AddFaceTypePageState extends State // 循环 return SingleChildScrollView( child: Column( - children: [ + children: [ perpetualKeyWidget( TranslationLoader.lanKeys!.name!.tr, TranslationLoader.lanKeys!.pleaseEnter!.tr, @@ -130,11 +130,11 @@ class _AddFaceTypePageState extends State Widget perpetualKeyWidget( String titleStr, String rightTitle, TextEditingController controller) { return Column( - children: [ + children: [ // Container(height: 10.h), CommonItem( leftTitel: titleStr, - rightTitle: "", + rightTitle: '', isHaveRightWidget: true, rightWidget: getTFWidget(rightTitle)), Container(height: 10.h), @@ -145,17 +145,17 @@ class _AddFaceTypePageState extends State // 限时顶部选择日期 Widget keyTimeLimitWidget() { return Column( - children: [ + children: [ Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr, rightTitle: state.timeLimitBeginTime.value, isHaveLine: true, isHaveDirection: true, action: () async { - PDuration selectDate = PDuration.parse( + final PDuration selectDate = PDuration.parse( DateTime.parse(state.timeLimitBeginTime.value)); Pickers.showDatePicker(context, - selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) { + selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (PDuration p) { state.timeLimitBeginTime.value = DateTool().getYMDHNDateString(p, 1); }); @@ -165,10 +165,10 @@ class _AddFaceTypePageState extends State rightTitle: state.timeLimitEndTime.value, isHaveDirection: true, action: () { - PDuration selectDate = PDuration.parse( + final PDuration selectDate = PDuration.parse( DateTime.tryParse(state.timeLimitEndTime.value)); Pickers.showDatePicker(context, - selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) { + selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (PDuration p) { state.timeLimitEndTime.value = DateTool().getYMDHNDateString(p, 1); }); @@ -181,16 +181,16 @@ class _AddFaceTypePageState extends State // 循环顶部选择日期 Widget keyCyclicDate() { return Column( - children: [ + children: [ Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr, rightTitle: - "${state.cycleBeginTime.value}\n${state.cycleEndTime.value}", + '${state.cycleBeginTime.value}\n${state.cycleEndTime.value}', isHaveDirection: true, isHaveLine: true, action: () async { - var result = - await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: { + final result = + await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: { 'validityValue': state.weekdaysList.value, 'starDate': state.cycleBeginTime.value, 'endDate': state.cycleEndTime.value, @@ -206,15 +206,15 @@ class _AddFaceTypePageState extends State } })), Obx(() => Visibility( - visible: state.weekdaysList.isNotEmpty ? true : false, + visible: state.weekdaysList.isNotEmpty, child: CommonItem( - leftTitel: "有效日".tr, - rightTitle: state.weekdaysList.value.join(",").toString(), + leftTitel: '有效日'.tr, + rightTitle: state.weekdaysList.value.join(',').toString(), isHaveDirection: true, isHaveLine: true, action: () async { - var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, - arguments: { + final result = await Get.toNamed(Routers.seletKeyCyclicDatePage, + arguments: { 'validityValue': state.weekdaysList.value, 'starDate': state.cycleBeginTime.value, 'endDate': state.cycleEndTime.value, @@ -232,13 +232,13 @@ class _AddFaceTypePageState extends State Obx(() => Visibility( visible: state.effectiveDateTime.value.isNotEmpty, child: CommonItem( - leftTitel: "有效时间".tr, + leftTitel: '有效时间'.tr, rightTitle: - "${state.effectiveDateTime.value}-${state.failureDateTime.value}", + '${state.effectiveDateTime.value}-${state.failureDateTime.value}', isHaveDirection: true, action: () async { - var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, - arguments: { + final result = await Get.toNamed(Routers.seletKeyCyclicDatePage, + arguments: { 'validityValue': state.weekdaysList.value, 'starDate': state.cycleBeginTime.value, 'endDate': state.cycleEndTime.value, @@ -259,14 +259,12 @@ class _AddFaceTypePageState extends State Widget keyBottomWidget() { return Column( - children: [ + children: [ Obx(() => Visibility( - visible: CommonDataManage().currentKeyInfo.isLockOwner == 1 - ? true - : false, + visible: CommonDataManage().currentKeyInfo.isLockOwner == 1, child: CommonItem( - leftTitel: "是否为管理员".tr, - rightTitle: "", + leftTitel: '是否为管理员'.tr, + rightTitle: '', isTipsImg: false, isHaveRightWidget: true, rightWidget: SizedBox( @@ -275,16 +273,16 @@ class _AddFaceTypePageState extends State SubmitBtn( btnName: TranslationLoader.lanKeys!.next!.tr, onClick: () async { - var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); + final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); if (isDemoMode == false) { if (state.nameController.text.isEmpty) { - logic.showToast("请输入姓名"); + logic.showToast('请输入姓名'); return; } logic.checkFaceNameDuplicated(state.nameController.text); } else { // Get.toNamed(Routers.selectLockTypePage); - logic.showToast("演示模式"); + logic.showToast('演示模式'); } }), ], @@ -301,7 +299,7 @@ class _AddFaceTypePageState extends State child: Row( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Expanded( child: TextField( //输入框一行 @@ -351,34 +349,34 @@ class _AddFaceTypePageState extends State trackColor: CupertinoColors.systemGrey5, thumbColor: CupertinoColors.white, value: state.isAdministrator.value, - onChanged: (value) { + onChanged: (bool value) { state.isAdministrator.value = value; }, ); } final List _itemTabs = [ - ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, selectType: "0"), - ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, selectType: "1"), + ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, selectType: '0'), + ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, selectType: '1'), ItemView( - title: TranslationLoader.lanKeys!.circulation!.tr, selectType: "2"), + title: TranslationLoader.lanKeys!.circulation!.tr, selectType: '2'), ]; final List _fromCheckInTypeItemTabs = [ - ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, selectType: "0"), - ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, selectType: "1"), + ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, selectType: '0'), + ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, selectType: '1'), ]; TabBar _tabBar() { return TabBar( controller: state.tabController, - onTap: (index) { + onTap: (int index) { FocusScope.of(context).requestFocus(FocusNode()); }, tabs: state.fromType.value == 1 - ? _itemTabs.map((ItemView item) => _tab(item)).toList() + ? _itemTabs.map(_tab).toList() : _fromCheckInTypeItemTabs - .map((ItemView item) => _tab(item)) + .map(_tab) .toList(), isScrollable: true, indicatorColor: Colors.red, @@ -413,10 +411,10 @@ class _AddFaceTypePageState extends State controller: state.tabController, children: state.fromType.value == 1 ? _itemTabs - .map((ItemView item) => Obx(() => indexChangeWidget())) + .map((ItemView item) => Obx(indexChangeWidget)) .toList() : _fromCheckInTypeItemTabs - .map((ItemView item) => Obx(() => indexChangeWidget())) + .map((ItemView item) => Obx(indexChangeWidget)) .toList(), ), ); diff --git a/lib/main/lockDetail/face/addFaceType/addFaceType_state.dart b/lib/main/lockDetail/face/addFaceType/addFaceType_state.dart index fdc8d99d..b5dcbd5b 100755 --- a/lib/main/lockDetail/face/addFaceType/addFaceType_state.dart +++ b/lib/main/lockDetail/face/addFaceType/addFaceType_state.dart @@ -1,39 +1,40 @@ + import 'package:flutter/material.dart'; import 'package:get/get.dart'; import '../../../../tools/dateTool.dart'; class AddFaceTypeState { - final lockId = 0.obs; - final selectType = "0".obs; // 0永久 1显示 2循环 - final fromType = 1.obs; // // 1从添加钥匙列表进入 2从考勤添加员工入口进入 - final isStressFingerprint = false.obs; - final isAdministrator = false.obs; // 是否为管理员 - - var timeLimitBeginTime = DateTool() - .dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString()) - .obs; // 限时开始时间 - var timeLimitEndTime = DateTool() - .dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString()) - .obs; // 限时结束时间 - - var cycleBeginTime = "".obs; // 循环开始时间 - var cycleEndTime = "".obs; // 循环结束时间 - var effectiveDateTime = "".obs; // 生效时间 - var failureDateTime = "".obs; // 失效时间 - var weekdaysList = [].obs; - var fromTypeTwoStaffName = "".obs; // 从添加员工进入 传入员工名字 - - final TextEditingController nameController = TextEditingController(); - late TabController tabController; AddFaceTypeState() { Map map = Get.arguments; - lockId.value = map["lockId"]; - fromType.value = map["fromType"]; + lockId.value = map['lockId']; + fromType.value = map['fromType']; // 1从添加钥匙列表进入 2从考勤添加员工入口进入 if (fromType.value == 2) { fromTypeTwoStaffName.value = - map["fromTypeTwoStaffName"]; // 从添加员工进入 传入员工名字 + map['fromTypeTwoStaffName']; // 从添加员工进入 传入员工名字 } } + final RxInt lockId = 0.obs; + final RxString selectType = '0'.obs; // 0永久 1显示 2循环 + final RxInt fromType = 1.obs; // // 1从添加钥匙列表进入 2从考勤添加员工入口进入 + final RxBool isStressFingerprint = false.obs; + final RxBool isAdministrator = false.obs; // 是否为管理员 + + RxString timeLimitBeginTime = DateTool() + .dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString()) + .obs; // 限时开始时间 + RxString timeLimitEndTime = DateTool() + .dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString()) + .obs; // 限时结束时间 + + RxString cycleBeginTime = ''.obs; // 循环开始时间 + RxString cycleEndTime = ''.obs; // 循环结束时间 + RxString effectiveDateTime = ''.obs; // 生效时间 + RxString failureDateTime = ''.obs; // 失效时间 + RxList weekdaysList = [].obs; + RxString fromTypeTwoStaffName = ''.obs; // 从添加员工进入 传入员工名字 + + final TextEditingController nameController = TextEditingController(); + late TabController tabController; } diff --git a/lib/main/lockDetail/fingerprint/addFingerprint/addFingerprint_page.dart b/lib/main/lockDetail/fingerprint/addFingerprint/addFingerprint_page.dart index 85db4602..28160109 100755 --- a/lib/main/lockDetail/fingerprint/addFingerprint/addFingerprint_page.dart +++ b/lib/main/lockDetail/fingerprint/addFingerprint/addFingerprint_page.dart @@ -1,11 +1,12 @@ + import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/fingerprint/addFingerprint/addFingerprint_state.dart'; import '../../../../../app_settings/app_colors.dart'; import '../../../../../tools/titleAppBar.dart'; import '../../../../../translations/trans_lib.dart'; -import '../../../../blue/blue_manage.dart'; import '../../../../tools/appRouteObserver.dart'; import 'addFingerprint_logic.dart'; @@ -16,22 +17,20 @@ class AddFingerprintPage extends StatefulWidget { State createState() => _AddFingerprintPageState(); } -class _AddFingerprintPageState extends State - with RouteAware { - final logic = Get.put(AddFingerprintLogic()); - final state = Get.find().state; +class _AddFingerprintPageState extends State with RouteAware { + final AddFingerprintLogic logic = Get.put(AddFingerprintLogic()); + final AddFingerprintState state = Get.find().state; @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.white, appBar: TitleAppBar( - barTitle: - "${TranslationLoader.lanKeys!.addTip!.tr}${TranslationLoader.lanKeys!.fingerprint!.tr}", + barTitle: '${TranslationLoader.lanKeys!.addTip!.tr}${TranslationLoader.lanKeys!.fingerprint!.tr}', haveBack: true, backgroundColor: AppColors.mainColor), body: ListView( - children: [ + children: [ SizedBox( height: 50.h, ), @@ -40,13 +39,13 @@ class _AddFingerprintPageState extends State child: Container( padding: EdgeInsets.only(left: 20.w, right: 20.w), child: Column( - children: [ + children: [ Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Expanded( child: Text( - "请将您的手指按下".tr, + '请将您的手指按下'.tr, // TranslationLoader.lanKeys!.lightTouchScreenTip!.tr, textAlign: TextAlign.center, maxLines: null, @@ -58,7 +57,7 @@ class _AddFingerprintPageState extends State ), SizedBox(height: 10.h), Text( - "(${state.regIndex.value}/${state.maxRegCount.value})", + '(${state.regIndex.value}/${state.maxRegCount.value})', // TranslationLoader.lanKeys!.lightTouchScreenTip!.tr, textAlign: TextAlign.center, maxLines: null, @@ -72,10 +71,10 @@ class _AddFingerprintPageState extends State visible: !logic.state.ifConnectScuess.value, child: Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Expanded( child: Text( - "尝试连接设备...".tr, + '尝试连接设备...'.tr, // TranslationLoader.lanKeys!.lightTouchScreenTip!.tr, textAlign: TextAlign.center, maxLines: null, @@ -103,10 +102,10 @@ class _AddFingerprintPageState extends State margin: EdgeInsets.all(10.w), child: Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Expanded( child: Text( - "根据提示,抬起手指后再进行下一次指纹采集".tr, + '根据提示,抬起手指后再进行下一次指纹采集'.tr, // TranslationLoader.lanKeys!.lightTouchScreenTip!.tr, textAlign: TextAlign.center, maxLines: null, @@ -122,7 +121,7 @@ class _AddFingerprintPageState extends State } String getIconNumber(int number) { - String iconPath = ""; + String iconPath = ''; switch (number) { case 0: iconPath = 'images/main/icon_addFingerprint_fingerprint_one.png'; @@ -151,7 +150,6 @@ class _AddFingerprintPageState extends State @override void didChangeDependencies() { - // TODO: implement didChangeDependencies super.didChangeDependencies(); /// 路由订阅 @@ -160,7 +158,6 @@ class _AddFingerprintPageState extends State @override void dispose() { - // TODO: implement dispose /// 取消路由订阅 AppRouteObserver().routeObserver.unsubscribe(this); super.dispose(); diff --git a/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_logic.dart b/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_logic.dart index 0feae0f1..7676df86 100755 --- a/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_logic.dart +++ b/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_logic.dart @@ -69,7 +69,7 @@ class AddFingerprintTypeLogic extends BaseGetXController{ 'fingerprintName': state.nameController.text, 'fingerprintNumber': '123456', 'fingerprintType': fingerprintType.toString(), - 'isCoerced': state.isStressFingerprint.value == false ? '1' : '2', // 1:非胁迫指纹 2:胁迫指纹 + 'isCoerced': state.isStressFingerprint.value == true ? '1' : '2', // 1:非胁迫指纹 2:胁迫指纹 'startDate': startDate, 'weekDay': state.weekdaysList.value, 'fromType': state.fromType.value, diff --git a/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_page.dart b/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_page.dart index e85cb83a..f0c61058 100755 --- a/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_page.dart +++ b/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_page.dart @@ -56,7 +56,7 @@ class _AddFingerprintTypePageState extends State with Si backgroundColor: AppColors.mainBackgroundColor, appBar: TitleAppBar( barTitle: - "${TranslationLoader.lanKeys!.addTip!.tr}${TranslationLoader.lanKeys!.fingerprint!.tr}", + '${TranslationLoader.lanKeys!.addTip!.tr}${TranslationLoader.lanKeys!.fingerprint!.tr}', haveBack: true, backgroundColor: AppColors.mainColor), body: Column( @@ -149,7 +149,7 @@ class _AddFingerprintTypePageState extends State with Si isHaveLine: true, isHaveDirection: true, action: () async { - PDuration selectDate = + final PDuration selectDate = PDuration.parse(DateTime.tryParse(state.timeLimitBeginTime.value)); Pickers.showDatePicker(context,selectDate:selectDate, mode: DateMode.YMDHM, onConfirm: (PDuration p) { @@ -161,7 +161,7 @@ class _AddFingerprintTypePageState extends State with Si rightTitle: state.timeLimitEndTime.value, isHaveDirection: true, action: () { - PDuration selectDate = + final PDuration selectDate = PDuration.parse(DateTime.tryParse(state.timeLimitEndTime.value)); Pickers.showDatePicker(context,selectDate:selectDate, mode: DateMode.YMDHM, onConfirm: (PDuration p) { @@ -183,7 +183,7 @@ class _AddFingerprintTypePageState extends State with Si isHaveDirection: true, isHaveLine: true, action: () async { - var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: { + final result = await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: { 'validityValue': state.weekdaysList.value, 'starDate': state.cycleBeginTime.value, 'endDate': state.cycleEndTime.value, @@ -206,7 +206,7 @@ class _AddFingerprintTypePageState extends State with Si isHaveDirection: true, isHaveLine: true, action: () async { - var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: { + final result = await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: { 'validityValue': state.weekdaysList.value, 'starDate': state.cycleBeginTime.value, 'endDate': state.cycleEndTime.value, @@ -228,7 +228,7 @@ class _AddFingerprintTypePageState extends State with Si rightTitle: '${state.effectiveDateTime.value}-${state.failureDateTime.value}', isHaveDirection: true, action: () async { - var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: { + final result = await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: { 'validityValue': state.weekdaysList.value, 'starDate': state.cycleBeginTime.value, 'endDate': state.cycleEndTime.value, @@ -280,7 +280,7 @@ class _AddFingerprintTypePageState extends State with Si SubmitBtn( btnName: TranslationLoader.lanKeys!.next!.tr, onClick: () async { - bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); + final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); if (isDemoMode == false) { if (state.nameController.text.isEmpty) { logic.showToast('请输入姓名'.tr); @@ -457,7 +457,7 @@ class _AddFingerprintTypePageState extends State with Si onTap: (int index) { FocusScope.of(context).requestFocus(FocusNode()); }, - tabs: state.fromType.value == 1 ? _itemTabs.map((ItemView item) => _tab(item)).toList() : _fromCheckInTypeItemTabs.map((ItemView item) => _tab(item)).toList(), + tabs: state.fromType.value == 1 ? _itemTabs.map(_tab).toList() : _fromCheckInTypeItemTabs.map(_tab).toList(), isScrollable: true, indicatorColor: Colors.red, unselectedLabelColor: Colors.black, @@ -491,8 +491,8 @@ class _AddFingerprintTypePageState extends State with Si controller: state.tabController, children: state.fromType.value == 1 - ? _itemTabs.map((ItemView item) => Obx(() => indexChangeWidget())).toList() - : _fromCheckInTypeItemTabs.map((ItemView item) => Obx(() => indexChangeWidget())).toList(), + ? _itemTabs.map((ItemView item) => Obx(indexChangeWidget)).toList() + : _fromCheckInTypeItemTabs.map((ItemView item) => Obx(indexChangeWidget)).toList(), ), ); } diff --git a/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_logic.dart b/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_logic.dart index 8ebc985d..a27dde10 100755 --- a/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_logic.dart +++ b/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_logic.dart @@ -54,9 +54,6 @@ class FingerprintDetailLogic extends BaseGetXController{ final List? signKey = await Storage.getStringList(saveBlueSignKey); final List signKeyDataList = changeStringListToIntList(signKey!); - // var publicKey = await Storage.getStringList(saveBluePublicKey); - // List publicKeyDataList = changeStringListToIntList(publicKey!); - final List token = reply.data.sublist(5, 9); final List saveStrList = changeIntListToStringList(token); Storage.setStringList(saveBlueToken, saveStrList); @@ -165,7 +162,7 @@ class FingerprintDetailLogic extends BaseGetXController{ weekDay: state.weekDay.value, startDate: state.starDate.value, endDate: state.endDate.value, - isCoerced: state.isStressFingerprint.value ? '2' : '1', + isCoerced: state.isStressFingerprint.value ? '1' : '2', fingerprintName: state.changeNameController.text, changeType: '1', startTime: int.parse(state.startDate.value), diff --git a/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_page.dart b/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_page.dart index f07976e5..f6d80e57 100755 --- a/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_page.dart +++ b/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_page.dart @@ -3,6 +3,7 @@ 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/fingerprint/fingerprintDetail/fingerprintDetail_state.dart'; import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; @@ -24,20 +25,20 @@ class FingerprintDetailPage extends StatefulWidget { class _FingerprintDetailPageState extends State with RouteAware { - final logic = Get.put(FingerprintDetailLogic()); - final state = Get.find().state; + final FingerprintDetailLogic logic = Get.put(FingerprintDetailLogic()); + final FingerprintDetailState state = Get.find().state; @override Widget build(BuildContext context) { return Scaffold( backgroundColor: AppColors.mainBackgroundColor, appBar: TitleAppBar( - barTitle: "指纹详情".tr, + barTitle: '指纹详情'.tr, haveBack: true, backgroundColor: AppColors.mainColor, ), body: Column( - children: [ + children: [ Obx(() => CommonItem( leftTitel: "${TranslationLoader.lanKeys!.fingerprint!.tr}${TranslationLoader.lanKeys!.number!.tr}", @@ -53,9 +54,9 @@ class _FingerprintDetailPageState extends State ShowTipView().showTFViewAlertDialog( state.changeNameController, "${TranslationLoader.lanKeys!.amend!.tr}${TranslationLoader.lanKeys!.name!.tr}", - "", () { + '', () { if (state.changeNameController.text.isEmpty) { - logic.showToast("请输入姓名".tr); + logic.showToast('请输入姓名'.tr); return; } Get.back(); @@ -81,15 +82,15 @@ class _FingerprintDetailPageState extends State // 限时 var data = await Get.toNamed( Routers.otherTypeKeyChangeDatePage, - arguments: { - "pushType": 1, - "fingerprintItemData": + arguments: { + 'pushType': 1, + 'fingerprintItemData': state.fingerprintItemData.value, }); if (data != null) { setState(() { - state.starDate.value = data["beginTimeTimestamp"]; - state.endDate.value = data["endTimeTimestamp"]; + state.starDate.value = data['beginTimeTimestamp']; + state.endDate.value = data['endTimeTimestamp']; state.keyType.value = 2; }); } @@ -97,18 +98,18 @@ class _FingerprintDetailPageState extends State // 循环 var data = await Get.toNamed( Routers.otherTypeKeyChangeValidityDatePage, - arguments: { - "pushType": 1, - "fingerprintItemData": + arguments: { + 'pushType': 1, + 'fingerprintItemData': state.fingerprintItemData.value, }); if (data != null) { setState(() { - state.starDate.value = data["starDate"]; - state.endDate.value = data["endDate"]; - state.startDate.value = data["starTime"]; - state.endTime.value = data["endTime"]; - state.weekDay.value = data["validityValue"]; + state.starDate.value = data['starDate']; + state.endDate.value = data['endDate']; + state.startDate.value = data['starTime']; + state.endTime.value = data['endTime']; + state.weekDay.value = data['validityValue']; }); } } @@ -123,42 +124,42 @@ class _FingerprintDetailPageState extends State action: () async { var data = await Get.toNamed( Routers.otherTypeKeyChangeValidityDatePage, - arguments: { - "pushType": 1, - "fingerprintItemData": + arguments: { + 'pushType': 1, + 'fingerprintItemData': state.fingerprintItemData.value, }); if (data != null) { setState(() { - state.starDate.value = data["starDate"]; - state.endDate.value = data["endDate"]; - state.startDate.value = data["starTime"]; - state.endTime.value = data["endTime"]; - state.weekDay.value = data["validityValue"]; + state.starDate.value = data['starDate']; + state.endDate.value = data['endDate']; + state.startDate.value = data['starTime']; + state.endTime.value = data['endTime']; + state.weekDay.value = data['validityValue']; }); } })))), Obx(() => Visibility( visible: state.keyType.value == 4 ? true : false, child: Obx(() => CommonItem( - leftTitel: "有效时间".tr, + leftTitel: '有效时间'.tr, rightTitle: - "${DateTool().dateToHNString(state.startDate.value)}-${DateTool().dateToHNString(state.endTime.value)}", + '${DateTool().dateToHNString(state.startDate.value)}-${DateTool().dateToHNString(state.endTime.value)}', isHaveDirection: true, action: () async { var data = await Get.toNamed( Routers.otherTypeKeyChangeValidityDatePage, - arguments: { - "pushType": 1, - "fingerprintItemData": state.fingerprintItemData.value, + arguments: { + 'pushType': 1, + 'fingerprintItemData': state.fingerprintItemData.value, }); if (data != null) { setState(() { - state.starDate.value = data["starDate"]; - state.endDate.value = data["endDate"]; - state.startDate.value = data["starTime"]; - state.endTime.value = data["endTime"]; - state.weekDay.value = data["validityValue"]; + state.starDate.value = data['starDate']; + state.endDate.value = data['endDate']; + state.startDate.value = data['starTime']; + state.endTime.value = data['endTime']; + state.weekDay.value = data['validityValue']; }); } })))), @@ -176,15 +177,15 @@ class _FingerprintDetailPageState extends State SizedBox(height: 10.h), Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.stressFingerprint!.tr, - rightTitle: "", + rightTitle: '', isTipsImg: false, isHaveRightWidget: true, isHaveLine: true, rightWidget: SizedBox( width: 60.w, height: 50.h, child: _isStressFingerprint()))), Obx(() => CommonItem( - leftTitel: "是否为管理员".tr, - rightTitle: "", + leftTitel: '是否为管理员'.tr, + rightTitle: '', isTipsImg: false, isHaveRightWidget: true, rightWidget: @@ -192,11 +193,11 @@ class _FingerprintDetailPageState extends State Container(height: 10.h), CommonItem( leftTitel: TranslationLoader.lanKeys!.operatingRecord!.tr, - rightTitle: "", + rightTitle: '', isHaveDirection: true, action: () { // 指纹 - Get.toNamed(Routers.lockOperatingRecordPage, arguments: { + Get.toNamed(Routers.lockOperatingRecordPage, arguments: { 'type': 3, 'id': state.fingerprintItemData.value.fingerprintId.toString(), 'recordName': state.fingerprintItemData.value.fingerprintName @@ -213,7 +214,7 @@ 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: () { - ShowTipView().showIosTipWithContentDialog("确定要删除吗?".tr, + ShowTipView().showIosTipWithContentDialog('确定要删除吗?'.tr, () async { state.isDeletFingerprint.value = true; logic.senderAddFingerprint(); @@ -231,7 +232,7 @@ class _FingerprintDetailPageState extends State trackColor: CupertinoColors.systemGrey5, thumbColor: CupertinoColors.white, value: state.isStressFingerprint.value, - onChanged: (value) { + onChanged: (bool value) { setState(() { state.isStressFingerprint.value = value; state.isDeletFingerprint.value = false; @@ -248,7 +249,7 @@ class _FingerprintDetailPageState extends State trackColor: CupertinoColors.systemGrey5, thumbColor: CupertinoColors.white, value: state.isAdministrator.value, - onChanged: (value) { + onChanged: (bool value) { // state.isAdministrator.value = value; // state.isDeletFingerprint.value = false; // logic.senderAddFingerprint(); diff --git a/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_state.dart b/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_state.dart index cae20610..1519ba0f 100755 --- a/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_state.dart +++ b/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_state.dart @@ -1,35 +1,15 @@ + import 'package:flutter/material.dart'; import 'package:get/get.dart'; import '../fingerprintList/fingerprintListData_entity.dart'; -class FingerprintDetailState { - final fingerprintItemData = FingerprintItemData().obs; - - final TextEditingController changeNameController = TextEditingController(); - - final typeNumber = "".obs; // 指纹号 - final typeName = "".obs; // 指纹名字 - var starDate = "".obs; // 开始时间 - var endDate = "".obs; // 结束时间 - var startDate = "".obs; // 生效时间 - var endTime = "".obs; // 失效时间 - final keyType = 0.obs; // 永久:1;限时2,单次3,循环:4 - var weekDay = [].obs; // 有效日 - var adder = "".obs; // 添加者 - var addTime = 0.obs; // 添加时间 - var keyId = 0.obs; - - var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示 - var sureBtnState = 0.obs; // 0普通状态(可用) 1连接中(不可用) - var isDeletFingerprint = true.obs; // 是否删除卡 - final isStressFingerprint = false.obs; - var isAdministrator = false.obs; // 是否为管理员 +class FingerprintDetailState { // 是否为管理员 FingerprintDetailState() { Map map = Get.arguments; - if ((map["fingerprintItemData"] != null)) { - fingerprintItemData.value = map["fingerprintItemData"]; + if (map['fingerprintItemData'] != null) { + fingerprintItemData.value = map['fingerprintItemData']; keyId.value = fingerprintItemData.value.fingerprintId!; typeNumber.value = fingerprintItemData.value.fingerprintNumber!; typeName.value = fingerprintItemData.value.fingerprintName!; @@ -41,11 +21,30 @@ class FingerprintDetailState { keyType.value = fingerprintItemData.value.fingerprintType!; adder.value = fingerprintItemData.value.senderUsername!; addTime.value = fingerprintItemData.value.createDate!; - isStressFingerprint.value = - fingerprintItemData.value.isCoerced! == 2 ? true : false; + isStressFingerprint.value = fingerprintItemData.value.isCoerced! == 1; weekDay.value = fingerprintItemData.value.weekDay!; - isAdministrator.value = - fingerprintItemData.value.fingerRight! == 1 ? true : false; + isAdministrator.value = fingerprintItemData.value.fingerRight! == 1; } } + final Rx fingerprintItemData = FingerprintItemData().obs; + + final TextEditingController changeNameController = TextEditingController(); + + final RxString typeNumber = ''.obs; // 指纹号 + final RxString typeName = ''.obs; // 指纹名字 + RxString starDate = ''.obs; // 开始时间 + RxString endDate = ''.obs; // 结束时间 + RxString startDate = ''.obs; // 生效时间 + RxString endTime = ''.obs; // 失效时间 + final RxInt keyType = 0.obs; // 永久:1;限时2,单次3,循环:4 + RxList weekDay = [].obs; // 有效日 + RxString adder = ''.obs; // 添加者 + RxInt addTime = 0.obs; // 添加时间 + RxInt keyId = 0.obs; + + RxBool ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示 + RxInt sureBtnState = 0.obs; // 0普通状态(可用) 1连接中(不可用) + RxBool isDeletFingerprint = true.obs; // 是否删除卡 + final RxBool isStressFingerprint = false.obs; + RxBool isAdministrator = false.obs; } diff --git a/lib/main/lockDetail/lockSet/lockSet/lockSet_logic.dart b/lib/main/lockDetail/lockSet/lockSet/lockSet_logic.dart index 46aebd15..39fb92f8 100755 --- a/lib/main/lockDetail/lockSet/lockSet/lockSet_logic.dart +++ b/lib/main/lockDetail/lockSet/lockSet/lockSet_logic.dart @@ -1,9 +1,9 @@ + import 'dart:async'; import 'package:flutter/scheduler.dart'; 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/main/lockMian/entity/lockListInfo_entity.dart'; import 'package:star_lock/tools/showTipView.dart'; @@ -112,11 +112,11 @@ class LockSetLogic extends BaseGetXController { // 恢复出厂设置数据解析 Future _replyFactoryDataResetKey(Reply reply) async { - List token = reply.data.sublist(2, 6); - List saveStrList = changeIntListToStringList(token); + final List token = reply.data.sublist(2, 6); + final List saveStrList = changeIntListToStringList(token); Storage.setStringList(saveBlueToken, saveStrList); - int status = reply.data[6]; + final int status = reply.data[6]; switch (status) { case 0x00: //成功 @@ -126,16 +126,16 @@ class LockSetLogic extends BaseGetXController { break; case 0x06: //无权限 - List? privateKey = + final List? privateKey = await Storage.getStringList(saveBluePrivateKey); - List getPrivateKeyList = changeStringListToIntList(privateKey!); + final List getPrivateKeyList = changeStringListToIntList(privateKey!); - List? publicKey = + final List? publicKey = await Storage.getStringList(saveBluePublicKey); - List publicKeyDataList = changeStringListToIntList(publicKey!); + final List publicKeyDataList = changeStringListToIntList(publicKey!); - List? token = await Storage.getStringList(saveBlueToken); - List getTokenList = changeStringListToIntList(token!); + final List? token = await Storage.getStringList(saveBlueToken); + final List getTokenList = changeStringListToIntList(token!); IoSenderManage.senderFactoryDataReset( lockID: BlueManage().connectDeviceName, @@ -174,7 +174,7 @@ class LockSetLogic extends BaseGetXController { // 锁设置数据解析 Future _replySetSupportFunctionsWithParameters(Reply reply) async { - int status = reply.data[2]; + final int status = reply.data[2]; switch (status) { case 0x00: //成功 @@ -292,16 +292,16 @@ class LockSetLogic extends BaseGetXController { BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async { if (connectionState == BluetoothConnectionState.connected) { - List? privateKey = + final List? privateKey = await Storage.getStringList(saveBluePrivateKey); - List getPrivateKeyList = changeStringListToIntList(privateKey!); + final List getPrivateKeyList = changeStringListToIntList(privateKey!); - List? publicKey = + final List? publicKey = await Storage.getStringList(saveBluePublicKey); - List publicKeyDataList = changeStringListToIntList(publicKey!); + final List publicKeyDataList = changeStringListToIntList(publicKey!); - List? token = await Storage.getStringList(saveBlueToken); - List getTokenList = changeStringListToIntList(token!); + final List? token = await Storage.getStringList(saveBlueToken); + final List getTokenList = changeStringListToIntList(token!); IoSenderManage.senderFactoryDataReset( lockID: BlueManage().connectDeviceName, @@ -356,16 +356,16 @@ class LockSetLogic extends BaseGetXController { BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async { if (connectionState == BluetoothConnectionState.connected) { - List? privateKey = + final List? privateKey = await Storage.getStringList(saveBluePrivateKey); - List getPrivateKeyList = changeStringListToIntList(privateKey!); + final List getPrivateKeyList = changeStringListToIntList(privateKey!); - List? token = await Storage.getStringList(saveBlueToken); - List getTokenList = changeStringListToIntList(token!); + final List? token = await Storage.getStringList(saveBlueToken); + final List getTokenList = changeStringListToIntList(token!); - List? publicKey = + final List? publicKey = await Storage.getStringList(saveBluePublicKey); - List getPublicKeyList = changeStringListToIntList(publicKey!); + final List getPublicKeyList = changeStringListToIntList(publicKey!); state.settingUpSupportFeatures = type; @@ -404,7 +404,7 @@ class LockSetLogic extends BaseGetXController { // 获取锁设置信息 Future getLockSettingInfoData() async { - LockSetInfoEntity entity = await ApiRepository.to.getLockSettingInfoData( + final LockSetInfoEntity entity = await ApiRepository.to.getLockSettingInfoData( lockId: state.lockId.toString(), ); if (entity.errorCode!.codeIsSuccessful) { @@ -432,7 +432,7 @@ class LockSetLogic extends BaseGetXController { // 开启考勤获取是否有公司 Future openCheckingInData( BlockSetCheckInCallback blockSetCheckInCallback) async { - CheckingInInfoDataEntity entity = await ApiRepository.to.openCheckingInData( + final CheckingInInfoDataEntity entity = await ApiRepository.to.openCheckingInData( lockId: state.lockSetInfoData.value.lockId.toString(), ); if (entity.errorCode!.codeIsSuccessful) { @@ -442,7 +442,7 @@ class LockSetLogic extends BaseGetXController { // 设置是否打开考勤 Future setLockSetGeneralSetting() async { - LoginEntity entity = await ApiRepository.to.setCheckInData( + final LoginEntity entity = await ApiRepository.to.setCheckInData( lockId: state.lockSetInfoData.value.lockId!, attendance: state.isAttendance.value == 1 ? 0 : 1, ); @@ -459,7 +459,7 @@ class LockSetLogic extends BaseGetXController { // 设置是否打开开锁提醒 Future setLockPickingReminder() async { - LoginEntity entity = await ApiRepository.to.setLockPickingReminderData( + final LoginEntity entity = await ApiRepository.to.setLockPickingReminderData( lockId: state.lockSetInfoData.value.lockId!, unlockReminder: state.isLockPickingReminder.value == 1 ? 0 : 1, ); @@ -476,7 +476,7 @@ class LockSetLogic extends BaseGetXController { // 设置是否打开开锁时是否需联网 Future setLockSetOpenLockNeedOnline() async { - LoginEntity entity = await ApiRepository.to.setOpenLockNeedOnlineData( + final LoginEntity entity = await ApiRepository.to.setOpenLockNeedOnlineData( lockId: state.lockSetInfoData.value.lockId!, appUnlockOnline: state.isOpenLockNeedOnline.value == 1 ? 0 : 1, ); @@ -496,7 +496,6 @@ class LockSetLogic extends BaseGetXController { // 下级界面修改成功后传递数据 StreamSubscription? _passCurrentLockInformationEvent; - void initLoadDataAction(BlockSetStateCallback blockSetStateCallback) { // 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus _passCurrentLockInformationEvent = eventBus @@ -507,7 +506,7 @@ class LockSetLogic extends BaseGetXController { } void showDeletAlertTipDialog({String? showContent = ''}) { - String content = showContent!.isEmpty + final String content = showContent!.isEmpty ? "${"删除设备失败,请确保在设备附近,设备未被连接,设备已打开".tr}${BlueManage().connectDeviceName!.contains("T9A") == true ? "。如果是全自动锁,请使屏幕变亮".tr : ""}" : showContent; ShowTipView().showSureAlertDialog(content); @@ -520,10 +519,7 @@ class LockSetLogic extends BaseGetXController { ShowTipView().showIosTipWithContentDialog('删除锁后,所有信息都会一起删除,确定删除锁吗?'.tr, () { // 删除锁 - ShowTipView().showTFViewAlertDialog( - state.passwordTF, '请输入登录密码'.tr, '请输入登录密码'.tr, () { - checkLoginPassword(); - }); + ShowTipView().showTFViewAlertDialog(state.passwordTF, '请输入登录密码'.tr, '请输入登录密码'.tr, checkLoginPassword); }); } else if (state.lockBasicInfo.value.keyRight == 1) { // 授权管理员弹框提示 @@ -535,15 +531,13 @@ class LockSetLogic extends BaseGetXController { }); } else { // 普通用户直接删除 - ShowTipView().showIosTipWithContentDialog('是否删除钥匙?'.tr, () { - deletKeyData(); - }); + ShowTipView().showIosTipWithContentDialog('是否删除钥匙?'.tr, deletKeyData); } } // 查询账户密码 Future checkLoginPassword() async { - LockListInfoEntity entity = await ApiRepository.to.checkLoginPassword( + final LockListInfoEntity entity = await ApiRepository.to.checkLoginPassword( password: state.passwordTF.text, ); if (entity.errorCode!.codeIsSuccessful) { @@ -554,7 +548,7 @@ class LockSetLogic extends BaseGetXController { // 当是锁拥有者的时候,删除锁 Future deletLockInfoData() async { - LockListInfoEntity entity = await ApiRepository.to.deletOwnerLockData( + final LockListInfoEntity entity = await ApiRepository.to.deletOwnerLockData( lockId: state.lockSetInfoData.value.lockId!, ); if (entity.errorCode!.codeIsSuccessful) { diff --git a/lib/main/lockDetail/lockSet/uploadData/uploadData_logic.dart b/lib/main/lockDetail/lockSet/uploadData/uploadData_logic.dart index 614b1594..28aa0f8e 100644 --- a/lib/main/lockDetail/lockSet/uploadData/uploadData_logic.dart +++ b/lib/main/lockDetail/lockSet/uploadData/uploadData_logic.dart @@ -54,7 +54,7 @@ class UploadDataLogic extends BaseGetXController{ } // 上传数据获取锁设置 - if (reply is UpdataLockSetReply && (state.ifCurrentScreen.value == true)) { + if (reply is UpdataLockSetReply && (state.ifCurrentScreen.value == true) && (state.ifSeletUpdataBtnState == true)) { _replyUpdataLockSetReply(reply); } }); @@ -545,7 +545,6 @@ class UploadDataLogic extends BaseGetXController{ ); } - // 上传数据获取设置 Future getUpdataLockSet() async { showEasyLoading(); diff --git a/lib/main/lockDetail/lockSet/uploadData/uploadData_page.dart b/lib/main/lockDetail/lockSet/uploadData/uploadData_page.dart index e4a24f6e..45f7dad8 100755 --- a/lib/main/lockDetail/lockSet/uploadData/uploadData_page.dart +++ b/lib/main/lockDetail/lockSet/uploadData/uploadData_page.dart @@ -44,6 +44,8 @@ class _UploadDataPageState extends State with RouteAware{ // margin: EdgeInsets.only(left: 03.w, right: 30.w, top: 20.w), padding: EdgeInsets.only(top: 20.w, bottom: 20.w), onClick: () { + state.ifSeletUpdataBtnState = true; + state.uploadPasswordPage = 0; state.uploadPasswordDataList.clear(); state.uploadCardPage = 0; diff --git a/lib/main/lockDetail/lockSet/uploadData/uploadData_state.dart b/lib/main/lockDetail/lockSet/uploadData/uploadData_state.dart index 05b700b4..d2d0ac52 100644 --- a/lib/main/lockDetail/lockSet/uploadData/uploadData_state.dart +++ b/lib/main/lockDetail/lockSet/uploadData/uploadData_state.dart @@ -4,6 +4,7 @@ import 'package:get/get.dart'; class UploadDataState{ RxBool ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示 RxInt sureBtnState = 0.obs;// 0普通状态(可用) 1连接中(不可用) + bool ifSeletUpdataBtnState = false;// 0未点击过上传数据按钮 1是点击过上传数据按钮 int countReq = 10;// 每次请求的数量 RxInt indexCount = 0.obs;// 用来显示按钮的索引 0/5 diff --git a/lib/mine/message/messageList/messageList_xhj_page.dart b/lib/mine/message/messageList/messageList_xhj_page.dart index 3ac5fe73..170e2c6d 100755 --- a/lib/mine/message/messageList/messageList_xhj_page.dart +++ b/lib/mine/message/messageList/messageList_xhj_page.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/mine/message/messageList/messageList_state.dart'; import 'package:star_lock/tools/noData.dart'; import '../../../appRouters.dart'; @@ -23,10 +24,9 @@ class MessageListXHJPage extends StatefulWidget { State createState() => _MessageListXHJPageState(); } -class _MessageListXHJPageState extends State - with TickerProviderStateMixin { - final logic = Get.put(MessageListLogic()); - final state = Get.find().state; +class _MessageListXHJPageState extends State with TickerProviderStateMixin { + final MessageListLogic logic = Get.put(MessageListLogic()); + final MessageListState state = Get.find().state; void getHttpData() { logic.messageListDataRequest().then((MessageListEntity value) { @@ -49,21 +49,21 @@ class _MessageListXHJPageState extends State ? TitleAppBar( barTitle: TranslationLoader.lanKeys!.message!.tr, haveBack: true, - actionsList: [ + actionsList: [ TextButton( child: Text( - "清空".tr, + '清空'.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) { - ShowTipView().showIosTipWithContentDialog("是否清空?".tr, + ShowTipView().showIosTipWithContentDialog('是否清空?'.tr, () async { logic.deletAllMessageDataRequest(); }); } else { - logic.showToast("演示模式".tr); + logic.showToast('演示模式'.tr); } }, ), @@ -71,7 +71,7 @@ class _MessageListXHJPageState extends State backgroundColor: AppColors.mainColor) : null, body: Column( - children: [ + children: [ SizedBox( height: 15.h, ), @@ -86,7 +86,7 @@ class _MessageListXHJPageState extends State fit: BoxFit.cover, ), borderRadius: BorderRadius.circular(20.r), - boxShadow: [ + boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.15), offset: const Offset(0, 0), @@ -98,7 +98,7 @@ class _MessageListXHJPageState extends State child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Text( '智能分析'.tr, style: TextStyle( @@ -131,15 +131,15 @@ class _MessageListXHJPageState extends State child: ListView.builder( itemCount: state.itemDataList.length, padding: EdgeInsets.only(top: 20.h), - itemBuilder: (c, index) { - MessageItemEntity messageItemEntity = + itemBuilder: (BuildContext c, int index) { + final MessageItemEntity messageItemEntity = state.itemDataList[index]; return Slidable( key: ValueKey(messageItemEntity.id), endActionPane: ActionPane( extentRatio: 0.2, motion: const ScrollMotion(), - children: [ + children: [ SlidableAction( onPressed: (BuildContext context) { logic.deletMessageDataRequest( @@ -158,8 +158,8 @@ class _MessageListXHJPageState extends State ), child: _messageListItem(messageItemEntity, () { Get.toNamed(Routers.messageDetailPage, - arguments: { - "messageItemEntity": messageItemEntity + arguments: { + 'messageItemEntity': messageItemEntity }); }), ); @@ -174,7 +174,7 @@ class _MessageListXHJPageState extends State Widget _messageListItem( MessageItemEntity messageItemEntity, Function() action) { - bool isNotRead = messageItemEntity.readAt! == 0; + final bool isNotRead = messageItemEntity.readAt! == 0; return GestureDetector( onTap: action, child: Container( @@ -183,7 +183,7 @@ class _MessageListXHJPageState extends State decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(20.w), - boxShadow: [ + boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.15), offset: const Offset(0, 0), @@ -195,7 +195,7 @@ class _MessageListXHJPageState extends State child: Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ Image.asset( isNotRead ? 'images/news_not_read.png' : 'images/news_read.png', width: 48.r, @@ -204,7 +204,7 @@ class _MessageListXHJPageState extends State Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ Text( messageItemEntity.data!, maxLines: 1, diff --git a/pubspec.yaml b/pubspec.yaml index 0717255d..33dfa7cb 100755 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -165,7 +165,7 @@ dependencies: #网络图片缓存 cached_network_image: ^3.2.0 - webview_flutter: ^4.4.2 + webview_flutter: ^4.5.0 jpush_flutter: ^2.5.1