From 7aa487038c9e2e7faff12149f7aa48d7c8441d61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=8F=E5=B0=91=E9=98=B3?= <786612630@qq.com> Date: Mon, 3 Jun 2024 13:50:07 +0800 Subject: [PATCH 01/12] =?UTF-8?q?1=E3=80=81=E4=BF=AE=E6=94=B9=E5=BE=AA?= =?UTF-8?q?=E7=8E=AF=2023:00=EF=BD=9E24:00=20=E4=B8=8D=E8=83=BD=E5=BC=80?= =?UTF-8?q?=E9=94=81=E9=97=AE=E9=A2=98=E3=80=822=E3=80=81=E4=BF=AE?= =?UTF-8?q?=E6=94=B9TAPD=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- images/lan/lan_en.json | 2 +- images/lan/lan_zh.json | 2 +- .../register/starLock_register_logic.dart | 27 +-- .../register/starLock_register_page.dart | 70 ++++---- .../register/starLock_register_state.dart | 38 ++-- .../common/countryRegionEntity.dart | 22 +-- .../selectCountryRegion/common/index.dart | 5 +- .../selectCountryRegion/common/utils.dart | 2 +- .../selectCountryRegion_page.dart | 48 ++--- .../authorizedAdmin/authorizedAdmin_page.dart | 2 +- .../authorizedAdminList_logic.dart | 15 +- .../authorizedAdminList_page.dart | 16 +- .../authorizedAdminList_state.dart | 4 +- .../volumeAuthorizationLock_logic.dart | 18 +- .../volumeAuthorizationLock_state.dart | 6 +- .../card/addCardType/addCardType_page.dart | 2 +- .../card/cardDetail/cardDetail_page.dart | 6 +- .../electronicKeyList_logic.dart | 28 ++- .../electronicKeyList_page.dart | 45 +++-- .../electronicKeyList_state.dart | 6 +- .../entity/ElectronicKeyListEntity.dart | 78 +++++---- .../face/addFaceType/addFaceType_page.dart | 2 +- .../face/faceDetail/faceDetail_logic.dart | 72 ++++---- .../face/faceDetail/faceDetail_page.dart | 111 ++++++------ .../addFingerprintType_page.dart | 2 +- .../fingerprintDetail_page.dart | 30 ++-- .../fingerprintList/fingerprintList_page.dart | 61 +++---- .../basicInformation_page.dart | 4 +- .../uploadElectricQuantity_logic.dart | 26 +-- .../lockSet/lockSet/lockSet_page.dart | 164 +++++++++--------- .../passwordKeyDetail_page.dart | 76 ++++---- .../passwordKey_perpetual_logic.dart | 7 +- .../passwordKey_perpetual_page.dart | 33 ++-- lib/mine/mine/starLockMine_page.dart | 6 +- .../getDeviceList_page.dart | 18 +- .../addAuthorizedAdministrator_page.dart | 2 +- .../authorizedAdministratorList_page.dart | 15 +- .../expireLockList_page.dart | 44 +++-- .../lockUserManageList_page.dart | 48 +++-- lib/tools/pickers/pickers.dart | 5 +- .../time_picker/route/date_picker_route.dart | 22 ++- lib/tools/pickers/time_picker/time_utils.dart | 5 +- lib/tools/showTipView.dart | 6 +- lib/tools/submitBtn.dart | 51 +++--- 44 files changed, 644 insertions(+), 608 deletions(-) diff --git a/images/lan/lan_en.json b/images/lan/lan_en.json index 784fe650..72ee6f7f 100755 --- a/images/lan/lan_en.json +++ b/images/lan/lan_en.json @@ -680,7 +680,7 @@ "密码生成后,请在当日23:59前使用一次进行激活,否则过0点后未激活则失效。密码激活后,有效期内不限次数使用。": "After the password is generated, please use it once for activation before 23:59 on the same day, otherwise it will be invalid after 0 o'clock. After the password is activated, it can be used unlimited times within the validity period.", "密码生成后,请在当日23:59前使用,否则过0点后失效。清空码用于清空今天0点之前生成的所有密码。": "After the password is generated, please use it before 23:59 on the same day, otherwise it will be invalid after 0 o'clock. The clear code is used to clear all the passwords generated before 0 o'clock today.", "密码生成后,请在当日23:59前使用,否则过0点后失效。": "After the password is generated, please use it before 23:59 on the same day, otherwise it will be invalid after 0 o'clock.", - "清空密码底部提示": "The password is valid until 24 o 'clock on the day of emptying\n Empty Content 1: All passwords generated before 0:00 of the day (Passwords generated after 0:00 of the day are not affected by clearing passwords and can continue to be used) \nEmpty content 2: Clear passwords Clear all custom passwords (used and unused) immediately after use \nTo completely clear all passwords, use the Reset All Passwords feature", + "清空密码底部提示": "The password is valid until 23:59 on the day of emptying\n Empty Content 1: All passwords generated before 0:00 of the day (Passwords generated after 0:00 of the day are not affected by clearing passwords and can continue to be used) \nEmpty content 2: Clear passwords Clear all custom passwords (used and unused) immediately after use \nTo completely clear all passwords, use the Reset All Passwords feature", "相机": "camera", "相册": "photos", "读写": "storage", diff --git a/images/lan/lan_zh.json b/images/lan/lan_zh.json index a01ba195..0c1c249f 100755 --- a/images/lan/lan_zh.json +++ b/images/lan/lan_zh.json @@ -683,7 +683,7 @@ "密码生成后,请在当日23:59前使用一次进行激活,否则过0点后未激活则失效。密码激活后,有效期内不限次数使用。": "密码生成后,请在当日23:59前使用一次进行激活,否则过0点后未激活则失效。密码激活后,有效期内不限次数使用。", "密码生成后,请在当日23:59前使用,否则过0点后失效。清空码用于清空今天0点之前生成的所有密码。": "密码生成后,请在当日23:59前使用,否则过0点后失效。清空码用于清空今天0点之前生成的所有密码。", "密码生成后,请在当日23:59前使用,否则过0点后失效。": "密码生成后,请在当日23:59前使用,否则过0点后失效。", - "清空密码底部提示": "清空密码当日24点前有效\n清空内容1:当日0点前生成的所有密码(当日0点后生成的密码,不受清空密码影响,可继续使用)\n清空内容2:清空密码使用后,立即清除所有自定义密码(含使用过和未使用过的)\n如需彻底清除所有密码,请使用重置所有密码功能", + "清空密码底部提示": "清空密码当日23:59前有效\n清空内容1:当日0点前生成的所有密码(当日0点后生成的密码,不受清空密码影响,可继续使用)\n清空内容2:清空密码使用后,立即清除所有自定义密码(含使用过和未使用过的)\n如需彻底清除所有密码,请使用重置所有密码功能", "密码不一致哦": "密码不一致哦", "相机": "相机", "相册": "相册", diff --git a/lib/login/register/starLock_register_logic.dart b/lib/login/register/starLock_register_logic.dart index 39fd7561..6d7e0137 100755 --- a/lib/login/register/starLock_register_logic.dart +++ b/lib/login/register/starLock_register_logic.dart @@ -1,8 +1,11 @@ + import 'dart:async'; import 'package:flutter/material.dart'; 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/login/register/entity/SendValidationCodeEntity.dart'; import '../../network/api_repository.dart'; import '../../tools/baseGetXController.dart'; @@ -13,7 +16,7 @@ class StarLockRegisterLogic extends BaseGetXController { late Timer _timer; void _startTimer() { - _timer = Timer.periodic(1.seconds, (timer) { + _timer = Timer.periodic(1.seconds, (Timer timer) { if (state.currentSecond > 1) { state.currentSecond--; } else { @@ -29,33 +32,33 @@ class StarLockRegisterLogic extends BaseGetXController { // _timer = null; } - void register() async { - AppLog.log("state.pwd.value:${state.pwd.value} state.surePwd.value:${state.surePwd.value}"); + Future register() async { + // AppLog.log("state.pwd.value:${state.pwd.value} state.surePwd.value:${state.surePwd.value}"); if(state.pwd.value != state.surePwd.value){ - showToast("密码不一致哦".tr); + showToast('密码不一致哦'.tr); return; } - var entity = await ApiRepository.to.register( + final LoginEntity entity = await ApiRepository.to.register( receiverType: state.isIphoneType.value == true ? 1 : 2, countryCode: int.parse(state.countryCode.value), account: state.phoneOrEmailStr.value, password: state.pwd.value, verificationCode: state.verificationCode.value); if (entity.errorCode!.codeIsSuccessful) { - showToast("注册成功".tr); - Get.back(result:{ - "phoneOrEmailStr":state.phoneOrEmailStr.value, - "pwd":state.pwd.value + showToast('注册成功'.tr); + Get.back(result:{ + 'phoneOrEmailStr':state.phoneOrEmailStr.value, + 'pwd':state.pwd.value }); } } - void sendValidationCode() async { - var entity = await ApiRepository.to.sendValidationCodeUnLogin( + Future sendValidationCode() async { + final SendValidationCodeEntity entity = await ApiRepository.to.sendValidationCodeUnLogin( // state.countryCode.value, countryCode: state.countryCode.value.toString(), account: state.phoneOrEmailStr.value, - channel: state.isIphoneType.value ? "1" : "2", + channel: state.isIphoneType.value ? '1' : '2', codeType: '1', xWidth: state.xWidth.value.toString()); if (entity.errorCode!.codeIsSuccessful) { diff --git a/lib/login/register/starLock_register_page.dart b/lib/login/register/starLock_register_page.dart index ea90d00e..334740fe 100755 --- a/lib/login/register/starLock_register_page.dart +++ b/lib/login/register/starLock_register_page.dart @@ -1,14 +1,16 @@ + 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/app_settings/app_settings.dart'; +import 'package:star_lock/login/register/starLock_register_state.dart'; import '../../appRouters.dart'; import '../../app_settings/app_colors.dart'; import '../../common/XSConstantMacro/XSConstantMacro.dart'; -import '../../tools/tf_loginInput.dart'; import '../../tools/submitBtn.dart'; +import '../../tools/tf_loginInput.dart'; import '../../tools/titleAppBar.dart'; import '../../translations/trans_lib.dart'; import 'starLock_register_logic.dart'; @@ -21,8 +23,8 @@ class StarLockRegisterPage extends StatefulWidget { } class _StarLockRegisterPageState extends State { - final logic = Get.put(StarLockRegisterLogic()); - final state = Get.find().state; + final StarLockRegisterLogic logic = Get.put(StarLockRegisterLogic()); + final StarLockRegisterState state = Get.find().state; @override Widget build(BuildContext context) { @@ -35,7 +37,7 @@ class _StarLockRegisterPageState extends State { backgroundColor: AppColors.mainColor), body: ListView( padding: EdgeInsets.only(top: 40.h, left: 40.w, right: 40.w), - children: [ + children: [ topSelectCountryAndRegionWidget(), middleTFWidget(), Obx(() { @@ -67,11 +69,11 @@ class _StarLockRegisterPageState extends State { Widget topSelectCountryAndRegionWidget() { return Column( - children: [ + children: [ SizedBox(height: 50.h), Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Container( width: 340.w, height: 60.h, @@ -81,7 +83,7 @@ class _StarLockRegisterPageState extends State { border: Border.all(width: 1.0, color: AppColors.greyLineColor)), child: Row( - children: [ + children: [ GestureDetector( onTap: () { state.isIphoneType.value = true; @@ -141,19 +143,19 @@ class _StarLockRegisterPageState extends State { SizedBox(height: 60.h), GestureDetector( onTap: () async { - var result = await Get.toNamed(Routers.selectCountryRegionPage); + final result = await Get.toNamed(Routers.selectCountryRegionPage); if (result != null) { result as Map; state.countryCode.value = result['code']; state.countryName.value = result['countryName']; } AppLog.log( - "路由返回值: $result, countryCode:${logic.state.countryCode}"); + '路由返回值: $result, countryCode:${logic.state.countryCode}'); }, child: Obx(() => SizedBox( height: 70.h, child: Row( - children: [ + children: [ SizedBox(width: 5.w), Expanded( child: Text( @@ -163,7 +165,7 @@ class _StarLockRegisterPageState extends State { SizedBox(width: 20.w), Row( mainAxisAlignment: MainAxisAlignment.end, - children: [ + children: [ Text( state.isIphoneType.value ? '${state.countryName.value} +${state.countryCode.value}' @@ -194,7 +196,7 @@ class _StarLockRegisterPageState extends State { Widget middleTFWidget() { return Column( - children: [ + children: [ Obx(() => LoginInput( controller: state.phoneOrEmailController, onchangeAction: (v) { @@ -207,7 +209,7 @@ class _StarLockRegisterPageState extends State { child: Image.asset( state.isIphoneType.value ? 'images/icon_login_account.png' - : "images/icon_login_email.png", + : 'images/icon_login_email.png', width: 30.w, height: 30.w, ), @@ -215,7 +217,7 @@ class _StarLockRegisterPageState extends State { hintText: "${TranslationLoader.lanKeys!.pleaseEnter!.tr}${state.isIphoneType.value ? "手机号".tr : TranslationLoader.lanKeys!.email!.tr}", keyboardType: TextInputType.number, - inputFormatters: [ + inputFormatters: [ // FilteringTextInputFormatter.allow(RegExp('[0-9]')), LengthLimitingTextInputFormatter(30), ])), @@ -236,8 +238,8 @@ class _StarLockRegisterPageState extends State { ), ), hintText: - "${TranslationLoader.lanKeys!.pleaseEnter!.tr}${TranslationLoader.lanKeys!.password!.tr}", - inputFormatters: [ + '${TranslationLoader.lanKeys!.pleaseEnter!.tr}${TranslationLoader.lanKeys!.password!.tr}', + inputFormatters: [ LengthLimitingTextInputFormatter(20), ]), SizedBox(height: 15.w), @@ -263,13 +265,13 @@ class _StarLockRegisterPageState extends State { ), ), hintText: - "${TranslationLoader.lanKeys!.sure!.tr}${TranslationLoader.lanKeys!.password!.tr}", - inputFormatters: [ + '${TranslationLoader.lanKeys!.sure!.tr}${TranslationLoader.lanKeys!.password!.tr}', + inputFormatters: [ LengthLimitingTextInputFormatter(20), ]), SizedBox(height: 10.w), Row( - children: [ + children: [ Expanded( child: LoginInput( controller: state.codeController, @@ -284,8 +286,8 @@ class _StarLockRegisterPageState extends State { ), ), hintText: - "${TranslationLoader.lanKeys!.pleaseEnter!.tr}${TranslationLoader.lanKeys!.verificationCode!.tr}", - inputFormatters: [ + '${TranslationLoader.lanKeys!.pleaseEnter!.tr}${TranslationLoader.lanKeys!.verificationCode!.tr}', + inputFormatters: [ LengthLimitingTextInputFormatter(20), ]), ), @@ -297,14 +299,14 @@ class _StarLockRegisterPageState extends State { state.phoneOrEmailStrIsOK.value && state.canResend.value ? () async { // Navigator.pushNamed(context, Routers.safetyVerificationPage, arguments: {"countryCode":"+86", "account":state.phoneOrEmailStr.value}); - var result = await Navigator.pushNamed( + final Object? result = await Navigator.pushNamed( context, Routers.safetyVerificationPage, - arguments: { - "countryCode": state.countryCode, - "account": state.phoneOrEmailStr.value + arguments: { + 'countryCode': state.countryCode, + 'account': state.phoneOrEmailStr.value }); state.xWidth.value = - (result as Map)['xWidth']; + (result! as Map)['xWidth']; logic.sendValidationCode(); } : null, @@ -337,7 +339,7 @@ class _StarLockRegisterPageState extends State { Widget _buildBottomAgreement() { return Row( mainAxisAlignment: MainAxisAlignment.start, - children: [ + children: [ Obx(() => GestureDetector( onTap: () { state.agree.value = !state.agree.value; @@ -358,7 +360,7 @@ class _StarLockRegisterPageState extends State { text: TextSpan( text: TranslationLoader.lanKeys!.readAndAgree!.tr, style: TextStyle(color: const Color(0xff333333), fontSize: 20.sp), - children: [ + children: [ WidgetSpan( alignment: PlaceholderAlignment.middle, child: GestureDetector( @@ -367,9 +369,9 @@ class _StarLockRegisterPageState extends State { style: TextStyle( color: AppColors.mainColor, fontSize: 20.sp)), onTap: () { - Get.toNamed(Routers.webviewShowPage, arguments: { - "url": XSConstantMacro.userAgreementURL, - "title": '用户协议'.tr + Get.toNamed(Routers.webviewShowPage, arguments: { + 'url': XSConstantMacro.userAgreementURL, + 'title': '用户协议'.tr }); }, )), @@ -381,9 +383,9 @@ class _StarLockRegisterPageState extends State { style: TextStyle( color: AppColors.mainColor, fontSize: 20.sp)), onTap: () { - Get.toNamed(Routers.webviewShowPage, arguments: { - "url": XSConstantMacro.privacyPolicyURL, - "title": '隐私政策'.tr + Get.toNamed(Routers.webviewShowPage, arguments: { + 'url': XSConstantMacro.privacyPolicyURL, + 'title': '隐私政策'.tr }); }, )), diff --git a/lib/login/register/starLock_register_state.dart b/lib/login/register/starLock_register_state.dart index 41625bac..7d7fe883 100755 --- a/lib/login/register/starLock_register_state.dart +++ b/lib/login/register/starLock_register_state.dart @@ -5,37 +5,37 @@ import 'package:get/get.dart'; import '../../translations/trans_lib.dart'; class StarLockRegisterState { + + StarLockRegisterState() { + resetResend(); + } final TextEditingController phoneOrEmailController = TextEditingController(); final TextEditingController pwdController = TextEditingController(); final TextEditingController sureController = TextEditingController(); final TextEditingController codeController = TextEditingController(); - var countryCode = "86".obs; - var countryName = '中国'.tr.obs; + RxString countryCode = '86'.obs; + RxString countryName = '中国'.tr.obs; - var phoneOrEmailStr = ''.obs; - var phoneOrEmailStrIsOK = false.obs; - var pwd = ''.obs; - var surePwd = ''.obs; - var verificationCode = ''.obs; - var xWidth = ''.obs; // 滑动验证码滑动位置 - var isIphoneType = true.obs; - var canSub = false.obs; - var agree = false.obs; + RxString phoneOrEmailStr = ''.obs; + RxBool phoneOrEmailStrIsOK = false.obs; + RxString pwd = ''.obs; + RxString surePwd = ''.obs; + RxString verificationCode = ''.obs; + RxString xWidth = ''.obs; // 滑动验证码滑动位置 + RxBool isIphoneType = true.obs; + RxBool canSub = false.obs; + RxBool agree = false.obs; bool get isEmail => RegexUtil.isEmail(phoneOrEmailStr.value); bool get isIphone => RegexUtil.isMobileSimple(phoneOrEmailStr.value); bool get pwdIsOK => pwd.value.isNotEmpty && surePwd.value.isNotEmpty; bool get codeIsOK => verificationCode.value.isNotEmpty; - var canResend = false.obs; - var btnText = ''.obs; - var totalSeconds = 120; - var currentSecond = 120; - - StarLockRegisterState() { - resetResend(); - } + RxBool canResend = false.obs; + RxString btnText = ''.obs; + int totalSeconds = 120; + int currentSecond = 120; void resetResend() { canResend.value = totalSeconds == currentSecond; diff --git a/lib/login/selectCountryRegion/common/countryRegionEntity.dart b/lib/login/selectCountryRegion/common/countryRegionEntity.dart index 48e448ee..a4974f2c 100755 --- a/lib/login/selectCountryRegion/common/countryRegionEntity.dart +++ b/lib/login/selectCountryRegion/common/countryRegionEntity.dart @@ -3,10 +3,6 @@ import 'dart:convert'; import 'package:azlistview/azlistview.dart'; class CountryRegionEntity { - int? errorCode; - String? description; - String? errorMsg; - List? dataList; CountryRegionEntity( {this.errorCode, this.description, this.errorMsg, this.dataList}); @@ -22,6 +18,10 @@ class CountryRegionEntity { }); } } + int? errorCode; + String? description; + String? errorMsg; + List? dataList; Map toJson() { final Map data = {}; @@ -36,13 +36,6 @@ class CountryRegionEntity { } class CountryRegionModel extends ISuspensionBean { - int? countryId; - String? name; - String? code; - String? flag; - String? abbreviation; - String? group; - String? tagIndex; CountryRegionModel( {this.countryId, @@ -61,6 +54,13 @@ class CountryRegionModel extends ISuspensionBean { abbreviation = json['abbreviation']; group = json['group']; } + int? countryId; + String? name; + String? code; + String? flag; + String? abbreviation; + String? group; + String? tagIndex; Map toJson() { final Map data = {}; diff --git a/lib/login/selectCountryRegion/common/index.dart b/lib/login/selectCountryRegion/common/index.dart index 3896be7b..330b98b4 100755 --- a/lib/login/selectCountryRegion/common/index.dart +++ b/lib/login/selectCountryRegion/common/index.dart @@ -1,7 +1,6 @@ -export 'utils.dart'; - export 'dart:convert'; export 'package:common_utils/common_utils.dart'; - export 'package:lpinyin/lpinyin.dart'; + +export 'utils.dart'; diff --git a/lib/login/selectCountryRegion/common/utils.dart b/lib/login/selectCountryRegion/common/utils.dart index 81c20761..08556380 100755 --- a/lib/login/selectCountryRegion/common/utils.dart +++ b/lib/login/selectCountryRegion/common/utils.dart @@ -48,7 +48,7 @@ class Utils { height: 80.h, child: Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ SizedBox( width: 20.w, ), diff --git a/lib/login/selectCountryRegion/selectCountryRegion_page.dart b/lib/login/selectCountryRegion/selectCountryRegion_page.dart index 826e4baf..c04ecfbb 100755 --- a/lib/login/selectCountryRegion/selectCountryRegion_page.dart +++ b/lib/login/selectCountryRegion/selectCountryRegion_page.dart @@ -21,8 +21,8 @@ class SelectCountryRegionPage extends StatefulWidget { } class _SelectCountryRegionPageState extends State { - List countriesList = []; - List topCountriesList = []; + List countriesList = []; + List topCountriesList = []; TextEditingController searchController = TextEditingController(); @override @@ -30,19 +30,17 @@ class _SelectCountryRegionPageState extends State { super.initState(); SuspensionUtil.setShowSuspensionStatus(countriesList.cast()); - Future.delayed(const Duration(milliseconds: 20), () { - getCountriesListRequest(); - }); + Future.delayed(const Duration(milliseconds: 20), getCountriesListRequest); } //请求国家/地区json文件 Future getCountriesListRequest() async { - CountryRegionEntity entity = await ApiRepository.to.getCountryRegion('1'); + final CountryRegionEntity entity = await ApiRepository.to.getCountryRegion('1'); countriesList.clear(); if (entity.errorCode!.codeIsSuccessful) { countriesList.addAll(entity.dataList!); - for(CountryRegionModel model in countriesList){ - if(model.name! == "中国"){ + for(final CountryRegionModel model in countriesList){ + if(model.name! == '中国'){ topCountriesList.add(model); break; } @@ -56,10 +54,12 @@ class _SelectCountryRegionPageState extends State { } void _handleList(List list) { - if (list.isEmpty) return; + if (list.isEmpty) { + return; + } for (int i = 0, length = list.length; i < length; i++) { - CountryRegionModel countryModel = list[i]; - String tag = countryModel.group!; + final CountryRegionModel countryModel = list[i]; + final String tag = countryModel.group!; if (RegExp('[A-Z]').hasMatch(tag)) { list[i].tagIndex = tag; } else { @@ -85,12 +85,12 @@ class _SelectCountryRegionPageState extends State { backgroundColor: const Color(0xFFFFFFFF), appBar: TitleAppBar( barTitle: - "${TranslationLoader.lanKeys!.select!.tr} ${TranslationLoader.lanKeys!.countryAndRegion!.tr}", + '${TranslationLoader.lanKeys!.select!.tr} ${TranslationLoader.lanKeys!.countryAndRegion!.tr}', haveBack: true, backgroundColor: AppColors.mainColor, ), body: Column( - children: [ + children: [ KeySearchWidget( editingController: searchController, backgroundColor: AppColors.mainBackgroundColor, @@ -98,9 +98,9 @@ class _SelectCountryRegionPageState extends State { if(searchController.text.isEmpty){ getCountriesListRequest(); }else{ - var searchList = []; + final List searchList = []; for (int i = 0, length = countriesList.length; i < length; i++) { - CountryRegionModel countryModel = countriesList[i]; + final CountryRegionModel countryModel = countriesList[i]; if(countryModel.name!.contains(searchController.text) || countryModel.code!.contains(searchController.text)){ searchList.add(countryModel); } @@ -116,25 +116,25 @@ class _SelectCountryRegionPageState extends State { visible: searchController.text.isEmpty, child: Utils.getSusItem(context, '★') ), - countriesList.isNotEmpty ? Visibility( + if (countriesList.isNotEmpty) Visibility( visible: searchController.text.isEmpty, child: Utils.getListItem(context, topCountriesList[0], () { - CountryRegionModel model = topCountriesList[0]; - Map resultMap = {}; + final CountryRegionModel model = topCountriesList[0]; + final Map resultMap = {}; resultMap['code'] = model.code ?? ''; resultMap['countryId'] = model.countryId.toString() ?? ''; resultMap['countryName'] = model.name ?? '' ; Navigator.pop(context, resultMap); }) - ): Container(), + ) else Container(), Expanded( child: AzListView( data: countriesList, itemCount: countriesList.length, itemBuilder: (BuildContext context, int index) { - CountryRegionModel model = countriesList[index]; + final CountryRegionModel model = countriesList[index]; return Utils.getListItem(context, model, () { - Map resultMap = {}; + final Map resultMap = {}; resultMap['code'] = model.code; resultMap['countryId'] = model.countryId.toString(); resultMap['countryName'] = model.name; @@ -144,11 +144,11 @@ class _SelectCountryRegionPageState extends State { }, padding: EdgeInsets.zero, susItemBuilder: (BuildContext context, int index) { - CountryRegionModel model = countriesList[index]; - String tag = model.getSuspensionTag(); + final CountryRegionModel model = countriesList[index]; + final String tag = model.getSuspensionTag(); return Utils.getSusItem(context, tag); }, - indexBarData: const ['★', ...kIndexBarData], + indexBarData: const ['★', ...kIndexBarData], ), ), ], diff --git a/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart b/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart index d1e2bb3d..9bf86204 100755 --- a/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart +++ b/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart @@ -396,7 +396,7 @@ class _AuthorizedAdminPageState extends State maxLines: 1, inputFormatters: [ FilteringTextInputFormatter.deny('\n'), - LengthLimitingTextInputFormatter(30), + LengthLimitingTextInputFormatter(50), ], style: TextStyle( fontSize: 22.sp, color: AppColors.darkGrayTextColor), diff --git a/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_logic.dart b/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_logic.dart index c89ecb27..e9c2595e 100755 --- a/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_logic.dart +++ b/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_logic.dart @@ -1,3 +1,4 @@ + import 'dart:async'; import 'package:star_lock/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_state.dart'; @@ -13,7 +14,7 @@ class AuthorizedAdminListLogic extends BaseGetXController { //请求电子钥匙列表 Future mockNetworkDataRequest() async { - ElectronicKeyListEntity entity = await ApiRepository.to.electronicKeyList( + final ElectronicKeyListEntity entity = await ApiRepository.to.electronicKeyList( endDate: '0', keyId: CommonDataManage().currentKeyInfo.keyId.toString(), keyStatus: '', @@ -39,10 +40,10 @@ class AuthorizedAdminListLogic extends BaseGetXController { //删除电子钥匙名称请求 Future deleteKeyRequest(String keyId, int includeUnderlings) async { - ElectronicKeyListEntity entity = await ApiRepository.to.deleteElectronicKey( + final ElectronicKeyListEntity entity = await ApiRepository.to.deleteElectronicKey( keyId: keyId, includeUnderlings: includeUnderlings); if (entity.errorCode!.codeIsSuccessful) { - showToast("删除成功"); + showToast('删除成功'); pageNo = 1; mockNetworkDataRequest(); } @@ -61,20 +62,12 @@ class AuthorizedAdminListLogic extends BaseGetXController { @override void onReady() { - // TODO: implement onReady super.onReady(); _getAuthorizedAdminPageRefreshUIAction(); } - @override - void onInit() { - // TODO: implement onInit - super.onInit(); - } - @override void onClose() { - // TODO: implement onClose super.onClose(); _getAuthorizedAdminPageRefreshUIEvent?.cancel(); } diff --git a/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart b/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart index 1fa9edf5..8ba90466 100755 --- a/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart +++ b/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart @@ -1,3 +1,4 @@ + import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_slidable/flutter_slidable.dart'; @@ -12,6 +13,7 @@ import 'package:star_lock/tools/storage.dart'; import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; import '../../../../tools/EasyRefreshTool.dart'; +import '../../../../tools/customNetworkImage.dart'; import '../../../../tools/showTipView.dart'; import '../../../../tools/submitBtn.dart'; import '../../../../tools/titleAppBar.dart'; @@ -139,7 +141,7 @@ class _AuthorizedAdminListPageState extends State { ], ), child: _electronicKeyItem( - 'images/controls_user.png', + indexEntity.headUrl!, indexEntity.keyName!, useDateStr, keyStatus, @@ -195,10 +197,18 @@ class _AuthorizedAdminListPageState extends State { child: Row( children: [ SizedBox(width: 30.w), - Image.asset( - avatarURL, + SizedBox( width: 60.w, height: 60.w, + child: ClipRRect( + borderRadius: BorderRadius.circular(30.w), + child: CustomNetworkImage( + url: avatarURL, + defaultUrl: 'images/controls_user.png', + width: 105.w, + height: 105.h, + ), + ), ), SizedBox(width: 20.w), Expanded( diff --git a/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_state.dart b/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_state.dart index 89c703d2..4d66521c 100755 --- a/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_state.dart +++ b/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_state.dart @@ -7,8 +7,8 @@ class AuthorizedAdminListState { // final keyInfo = LockListInfoItemEntity().obs; // final lockMainEntity = LockMainEntity().obs; - final itemDataList = [].obs; - final searchStr = ''.obs; + final RxList itemDataList = [].obs; + final RxString searchStr = ''.obs; // AuthorizedAdminListState() { // Map map = Get.arguments; diff --git a/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_logic.dart b/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_logic.dart index 0c4ab05b..339c84de 100755 --- a/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_logic.dart +++ b/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_logic.dart @@ -1,12 +1,9 @@ -import 'dart:ffi'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:get/get.dart'; -import 'package:star_lock/main/lockDetail/authorizedAdmin/authorizedAdmin/notice_template_entity.dart'; import 'package:star_lock/main/lockDetail/lockSet/basicInformation/basicInformation/KeyDetailEntity.dart'; import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; -import 'package:star_lock/tools/commonDataManage.dart'; import 'volumeAuthorizationLock_state.dart'; @@ -15,6 +12,16 @@ class VolumeAuthorizationLockLogic extends BaseGetXController { //发送批量授权管理员 Future addAuthorizedAdminRequest() async { + if (state.keyNameController.text.isEmpty) { + showToast('请输入接收者姓名'); + return; + } + + if (state.lockIdList.isEmpty) { + showToast('请选择锁'.tr); + return; + } + String getFailureDateTime = '0'; String getEffectiveDateTime = '0'; if (state.selectWidgetType.value == '1') { @@ -23,11 +30,6 @@ class VolumeAuthorizationLockLogic extends BaseGetXController { getEffectiveDateTime = state.effectiveDateTime.value.millisecondsSinceEpoch.toString(); } - - if (state.lockIdList.isEmpty) { - showToast('请选择锁'.tr); - return; - } final KeyDetailEntity entity = await ApiRepository.to.addAuthorizedAdmin( createUser: state.isCreateUser.value ? '1' : '0', endDate: getFailureDateTime, diff --git a/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_state.dart b/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_state.dart index 9e9996d3..8e1a79a3 100755 --- a/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_state.dart +++ b/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_state.dart @@ -4,10 +4,8 @@ import 'package:get/get.dart'; class VolumeAuthorizationLockState { final FlutterContactPicker contactPicker = FlutterContactPicker(); - final TextEditingController emailOrPhoneController = - TextEditingController(); //邮箱/手机号输入框 - final TextEditingController keyNameController = - TextEditingController(); //钥匙名输入框 + final TextEditingController emailOrPhoneController = TextEditingController(); //邮箱/手机号输入框 + final TextEditingController keyNameController = TextEditingController(); //钥匙名输入框 late Contact contact; RxList lockIdList = [].obs; RxBool isSendSuccess = false.obs; diff --git a/lib/main/lockDetail/card/addCardType/addCardType_page.dart b/lib/main/lockDetail/card/addCardType/addCardType_page.dart index 6ef366d4..81ba1349 100755 --- a/lib/main/lockDetail/card/addCardType/addCardType_page.dart +++ b/lib/main/lockDetail/card/addCardType/addCardType_page.dart @@ -323,7 +323,7 @@ class _AddCardPageState extends State maxLines: 1, inputFormatters: [ FilteringTextInputFormatter.deny('\n'), - LengthLimitingTextInputFormatter(18), + LengthLimitingTextInputFormatter(50), ], style: TextStyle( fontSize: 22.sp, color: AppColors.darkGrayTextColor), diff --git a/lib/main/lockDetail/card/cardDetail/cardDetail_page.dart b/lib/main/lockDetail/card/cardDetail/cardDetail_page.dart index 96166bd2..93d9b332 100755 --- a/lib/main/lockDetail/card/cardDetail/cardDetail_page.dart +++ b/lib/main/lockDetail/card/cardDetail/cardDetail_page.dart @@ -1,6 +1,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; @@ -62,7 +63,10 @@ class _CardDetailPageState extends State with RouteAware { Get.back(); state.typeName.value = state.changeNameController.text; logic.editICCardData(); - }); + }, inputFormatters: [ + FilteringTextInputFormatter.deny('\n'), + LengthLimitingTextInputFormatter(50), + ]); })), Obx(() => Visibility( visible: state.keyType.value == 4 || diff --git a/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_logic.dart b/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_logic.dart index 2da4162c..eaa35ab1 100755 --- a/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_logic.dart +++ b/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_logic.dart @@ -15,7 +15,7 @@ class ElectronicKeyListLogic extends BaseGetXController { //请求电子钥匙列表 Future mockNetworkDataRequest() async { - ElectronicKeyListEntity entity = await ApiRepository.to.electronicKeyList( + final ElectronicKeyListEntity entity = await ApiRepository.to.electronicKeyList( endDate: '0', keyId: CommonDataManage().currentKeyInfo.keyId.toString(), keyStatus: '', @@ -27,11 +27,11 @@ class ElectronicKeyListLogic extends BaseGetXController { searchStr: state.searchController.text); if (entity.errorCode!.codeIsSuccessful) { if (pageNo == 1) { - state.itemDataList.value = entity.data!.itemList!; + state.itemDataList.value = entity.data!.itemList; pageNo++; } else { - if (entity.data!.itemList!.isNotEmpty) { - state.itemDataList.value.addAll(entity.data!.itemList!); + if (entity.data!.itemList.isNotEmpty) { + state.itemDataList.value.addAll(entity.data!.itemList); pageNo++; } } @@ -41,10 +41,10 @@ class ElectronicKeyListLogic extends BaseGetXController { //电子钥匙重置请求 Future resetElectronicKeyListRequest() async { - ElectronicKeyListEntity entity = await ApiRepository.to + final ElectronicKeyListEntity entity = await ApiRepository.to .resetElectronicKey(CommonDataManage().currentKeyInfo.lockId.toString(), '0'); if (entity.errorCode!.codeIsSuccessful) { - showToast("重置成功".tr, something: (){ + showToast('重置成功'.tr, something: (){ pageNo = 1; mockNetworkDataRequest(); }); @@ -53,20 +53,20 @@ class ElectronicKeyListLogic extends BaseGetXController { //删除电子钥匙名称请求 Future deleteKeyRequest(String keyId, int includeUnderlings) async { - ElectronicKeyListEntity entity = + final ElectronicKeyListEntity entity = await ApiRepository.to.deleteElectronicKey( keyId:keyId, includeUnderlings:includeUnderlings ); if (entity.errorCode!.codeIsSuccessful) { - showToast("删除成功".tr,something: (){ + showToast('删除成功'.tr,something: (){ pageNo = 1; mockNetworkDataRequest(); }); } } - deletKeyLogic(ElectronicKeyListItem electronicKeyListItem){ + void deletKeyLogic(ElectronicKeyListItem electronicKeyListItem){ if(electronicKeyListItem.keyRight == 1){ // 授权管理员 ShowTipView().showDeleteAdministratorIsHaveAllDataDialog('同时删除其发送的所有钥匙,钥匙删除后不能恢复'.tr, (isAllData) { @@ -74,7 +74,7 @@ class ElectronicKeyListLogic extends BaseGetXController { }); }else{ // 普通用户 - ShowTipView().showIosTipWithContentDialog("删除钥匙会在用户APP连网后生效".tr,(){ + ShowTipView().showIosTipWithContentDialog('删除钥匙会在用户APP连网后生效'.tr,(){ deleteKeyRequest(electronicKeyListItem.keyId.toString(), 0); }); } @@ -92,21 +92,13 @@ class ElectronicKeyListLogic extends BaseGetXController { @override void onReady() { - // TODO: implement onReady super.onReady(); _getElectronicKeyListRefreshUIAction(); } - @override - void onInit() { - // TODO: implement onInit - super.onInit(); - } - @override void onClose() { - // TODO: implement onClose super.onClose(); _getElectronicKeyListRefreshUIEvent?.cancel(); diff --git a/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart b/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart index 504bef2a..67e38704 100755 --- a/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart +++ b/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart @@ -13,6 +13,7 @@ import 'package:star_lock/tools/storage.dart'; import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; import '../../../../tools/EasyRefreshTool.dart'; +import '../../../../tools/customNetworkImage.dart'; import '../../../../tools/keySearchWidget.dart'; import '../../../../tools/showTipView.dart'; import '../../../../tools/submitBtn.dart'; @@ -39,7 +40,7 @@ class _ElectronicKeyListPageState extends State { Future mockRequest() async { // 获取是否是演示模式 演示模式不获取接口 - bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); + final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); if (isDemoMode == false) { logic.mockNetworkDataRequest().then((ElectronicKeyListEntity value) { setState(() {}); @@ -130,7 +131,7 @@ class _ElectronicKeyListPageState extends State { shrinkWrap: true, itemCount: state.itemDataList.value.length, itemBuilder: (BuildContext c, int index) { - ElectronicKeyListItem indexEntity = state.itemDataList.value[index]; + final ElectronicKeyListItem indexEntity = state.itemDataList.value[index]; String useDateStr = ''; //使用期限 String keyStatus = ''; //钥匙状态 @@ -166,12 +167,12 @@ class _ElectronicKeyListPageState extends State { ], ), child: _electronicKeyItem( - 'images/controls_user.png', + indexEntity.headUrl!, indexEntity.keyName!, useDateStr, keyStatus, isAdminKey, - indexEntity.remoteEnable == 1 ? true : false, () { + indexEntity.remoteEnable == 1, () { Navigator.pushNamed( context, Routers.electronicKeyDetailPage, arguments: { @@ -198,13 +199,13 @@ class _ElectronicKeyListPageState extends State { //使用期限 String getUseDateStr(ElectronicKeyListItem indexEntity) { String useDateStr = ''; - DateTime sendDateStr = + final DateTime sendDateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.sendDate!); if (indexEntity.keyType == XSConstantMacro.keyTypeTime) { //限期 - DateTime startDateStr = + final DateTime startDateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.startDate!); - DateTime endDateStr = + final DateTime endDateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.endDate!); useDateStr = '${startDateStr.toLocal().toString().substring(0, 16)}-${endDateStr.toLocal().toString().substring(0, 16)}'; @@ -233,11 +234,24 @@ class _ElectronicKeyListPageState extends State { child: Row( children: [ SizedBox(width: 30.w), - Image.asset( - avatarURL, + SizedBox( width: 60.w, height: 60.w, + child: ClipRRect( + borderRadius: BorderRadius.circular(30.w), + child: CustomNetworkImage( + url: avatarURL, + defaultUrl: 'images/controls_user.png', + width: 105.w, + height: 105.h, + ), + ), ), + // Image.asset( + // avatarURL, + // width: 60.w, + // height: 60.w, + // ), SizedBox(width: 20.w), Expanded( child: Column( @@ -259,25 +273,20 @@ class _ElectronicKeyListPageState extends State { color: AppColors.blackColor)), ), SizedBox(width: 5.w), - isRemteUnlocking - ? Image.asset( + if (isRemteUnlocking) Image.asset( 'images/icon_electronicKey_remteUnlocking.png', width: 24.w, height: 20.w, - ) - : Container(), + ) else Container(), SizedBox(width: 5.w), - isAdminKey - ? Image.asset( + if (isAdminKey) Image.asset( 'images/icon_electronicKey_admin.png', width: 24.w, height: 20.w, - ) - : Container(), + ) else Container(), ], ), ), - // Expanded(child: SizedBox(width: 20.w,)), SizedBox(width: 10.w), Text( diff --git a/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_state.dart b/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_state.dart index 7d7f503e..6167e4b4 100755 --- a/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_state.dart +++ b/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_state.dart @@ -8,9 +8,9 @@ class ElectronicKeyListState { TextEditingController searchController = TextEditingController(); //邮箱/手机号输入框 // final keyInfo = LockListInfoItemEntity().obs; // final lockMainEntity = LockMainEntity().obs; - var pageNum = 1.obs; //请求页码 - final pageSize = 20.obs; //请求每页数据条数 - final itemDataList = [].obs; + RxInt pageNum = 1.obs; //请求页码 + final RxInt pageSize = 20.obs; //请求每页数据条数 + final RxList itemDataList = [].obs; // ElectronicKeyListState() { // Map map = Get.arguments; diff --git a/lib/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart b/lib/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart index 01e23f3c..1d5bba49 100755 --- a/lib/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart +++ b/lib/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart @@ -1,8 +1,4 @@ class ElectronicKeyListEntity { - int? errorCode; - String? description; - String? errorMsg; - ElectronicKeyListData? data; ElectronicKeyListEntity( {this.errorCode, this.description, this.errorMsg, this.data}); @@ -15,6 +11,10 @@ class ElectronicKeyListEntity { ? ElectronicKeyListData.fromJson(json['data']) : null; } + int? errorCode; + String? description; + String? errorMsg; + ElectronicKeyListData? data; Map toJson() { final Map data = {}; @@ -29,11 +29,6 @@ class ElectronicKeyListEntity { } class ElectronicKeyListData { - late List itemList; - int? pageNo; - int? pageSize; - int? pages; - int? total; ElectronicKeyListData( {required this.itemList, @@ -54,6 +49,11 @@ class ElectronicKeyListData { pages = json['pages']; total = json['total']; } + late List itemList; + int? pageNo; + int? pageSize; + int? pages; + int? total; Map toJson() { final Map data = {}; @@ -67,29 +67,6 @@ class ElectronicKeyListData { } class ElectronicKeyListItem { - int? keyId; - int? lockId; - String? username; - String? lockName; - String? lockAlias; - int? userType; - String? keyName; - int? keyStatus; - int? startDate; - int? endDate; - int? keyRight; - int? keyType; - String? senderUsername; - String? remarks; - int? isCameraEnable; - int? faceAuthentication; - int? sendDate; - int? remoteEnable; - int? appUnlockMustOnline; - List? weekDays; - int? isOnlyManageSelf; - UserIdCard? userIdCard; - int? uid; ElectronicKeyListItem({ this.keyId, @@ -115,13 +92,14 @@ class ElectronicKeyListItem { this.isOnlyManageSelf, this.userIdCard, this.uid, + this.headUrl }); ElectronicKeyListItem.fromJson(Map json) { keyId = json['keyId']; lockId = json['lockId']; - json['username'] != null ? username = json['username'] : ""; - json['lockName'] != null ? lockName = json['lockName'] : ""; + json['username'] != null ? username = json['username'] : ''; + json['lockName'] != null ? lockName = json['lockName'] : ''; lockAlias = json['lockAlias']; userType = json['userType']; keyName = json['keyName']; @@ -131,7 +109,7 @@ class ElectronicKeyListItem { keyRight = json['keyRight']; keyType = json['keyType']; senderUsername = json['senderUsername']; - json['remarks'] != null ? remarks = json['remarks'] : ""; + json['remarks'] != null ? remarks = json['remarks'] : ''; json['isCameraEnable'] != null ? isCameraEnable = json['isCameraEnable'] : 0; @@ -147,7 +125,32 @@ class ElectronicKeyListItem { ? userIdCard = UserIdCard.fromJson(json['userIdCard']) : null; uid = json['uid']; + headUrl = json['headUrl']; } + int? keyId; + int? lockId; + String? username; + String? lockName; + String? lockAlias; + int? userType; + String? keyName; + int? keyStatus; + int? startDate; + int? endDate; + int? keyRight; + int? keyType; + String? senderUsername; + String? remarks; + int? isCameraEnable; + int? faceAuthentication; + int? sendDate; + int? remoteEnable; + int? appUnlockMustOnline; + List? weekDays; + int? isOnlyManageSelf; + UserIdCard? userIdCard; + int? uid; + String? headUrl; Map toJson() { final Map data = {}; @@ -176,13 +179,12 @@ class ElectronicKeyListItem { data['userIdCard'] = userIdCard!.toJson(); } data['uid'] = uid; + data['headUrl'] = headUrl; return data; } } class UserIdCard { - String? realName; - String? idCardNumber; UserIdCard({this.realName, this.idCardNumber}); @@ -190,6 +192,8 @@ class UserIdCard { realName = json['realName']; idCardNumber = json['idCardNumber']; } + String? realName; + String? idCardNumber; Map toJson() { final Map data = {}; diff --git a/lib/main/lockDetail/face/addFaceType/addFaceType_page.dart b/lib/main/lockDetail/face/addFaceType/addFaceType_page.dart index b89f68fe..5ea6fe84 100755 --- a/lib/main/lockDetail/face/addFaceType/addFaceType_page.dart +++ b/lib/main/lockDetail/face/addFaceType/addFaceType_page.dart @@ -306,7 +306,7 @@ class _AddFaceTypePageState extends State with SingleTickerProv maxLines: 1, inputFormatters: [ FilteringTextInputFormatter.deny('\n'), - LengthLimitingTextInputFormatter(18), + LengthLimitingTextInputFormatter(50), ], style: TextStyle( fontSize: 22.sp, color: AppColors.darkGrayTextColor), diff --git a/lib/main/lockDetail/face/faceDetail/faceDetail_logic.dart b/lib/main/lockDetail/face/faceDetail/faceDetail_logic.dart index 774e722f..166762c4 100755 --- a/lib/main/lockDetail/face/faceDetail/faceDetail_logic.dart +++ b/lib/main/lockDetail/face/faceDetail/faceDetail_logic.dart @@ -1,10 +1,10 @@ + import 'dart:async'; import 'package:flutter_blue_plus/flutter_blue_plus.dart'; import 'package:get/get.dart'; -import 'package:star_lock/app_settings/app_settings.dart'; import 'package:star_lock/blue/io_protocol/io_addFace.dart'; -import 'package:star_lock/blue/io_type.dart'; +import 'package:star_lock/login/login/entity/LoginEntity.dart'; import 'package:star_lock/main/lockDetail/face/faceDetail/faceDetail_state.dart'; import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/dateTool.dart'; @@ -23,7 +23,7 @@ class FaceDetailLogic extends BaseGetXController { late StreamSubscription _replySubscription; void _initReplySubscription() { _replySubscription = - EventBusManager().eventBus!.on().listen((reply) { + EventBusManager().eventBus!.on().listen((Reply reply) { // 添加人脸开始(此处用作删除人脸) if ((reply is SenderAddFaceReply) && (state.ifCurrentScreen.value == true)) { _replyAddFaceBegin(reply); @@ -33,7 +33,7 @@ class FaceDetailLogic extends BaseGetXController { // 添加人脸开始 Future _replyAddFaceBegin(Reply reply) async { - int status = reply.data[2]; + final int status = reply.data[2]; switch (status) { case 0x00: @@ -49,14 +49,14 @@ class FaceDetailLogic extends BaseGetXController { break; case 0x06: //无权限 - var privateKey = await Storage.getStringList(saveBluePrivateKey); - List getPrivateKeyList = changeStringListToIntList(privateKey!); + final List? privateKey = await Storage.getStringList(saveBluePrivateKey); + final List getPrivateKeyList = changeStringListToIntList(privateKey!); - var signKey = await Storage.getStringList(saveBlueSignKey); - List signKeyDataList = changeStringListToIntList(signKey!); + final List? signKey = await Storage.getStringList(saveBlueSignKey); + final List signKeyDataList = changeStringListToIntList(signKey!); - var token = reply.data.sublist(5, 9); - var saveStrList = changeIntListToStringList(token); + final List token = reply.data.sublist(5, 9); + final List saveStrList = changeIntListToStringList(token); Storage.setStringList(saveBlueToken, saveStrList); IoSenderManage.senderAddFaceCommand( @@ -101,14 +101,14 @@ class FaceDetailLogic extends BaseGetXController { BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected) { - var privateKey = await Storage.getStringList(saveBluePrivateKey); - List getPrivateKeyList = changeStringListToIntList(privateKey!); + final List? privateKey = await Storage.getStringList(saveBluePrivateKey); + final List getPrivateKeyList = changeStringListToIntList(privateKey!); - var token = await Storage.getStringList(saveBlueToken); - List getTokenList = changeStringListToIntList(token!); + final List? token = await Storage.getStringList(saveBlueToken); + final List getTokenList = changeStringListToIntList(token!); - var signKey = await Storage.getStringList(saveBlueSignKey); - List signKeyDataList = changeStringListToIntList(signKey!); + final List? signKey = await Storage.getStringList(saveBlueSignKey); + final List signKeyDataList = changeStringListToIntList(signKey!); IoSenderManage.senderAddFaceCommand( keyID:state.keyId.value.toString(), @@ -143,36 +143,36 @@ class FaceDetailLogic extends BaseGetXController { } // 删除人脸 - void deletFaceData() async { - var entity = await ApiRepository.to.deleteFaceData( + Future deletFaceData() async { + final LoginEntity entity = await ApiRepository.to.deleteFaceData( faceId: state.faceItemData.value.faceId!, lockId: state.faceItemData.value.lockId!, ); if (entity.errorCode!.codeIsSuccessful) { - showToast("删除成功", something: () { - Get.back(result: "addScuess"); + showToast('删除成功', something: () { + Get.back(result: 'addScuess'); }); } } // 修改人脸名称 - void updateFaceNameData() async { - var entity = await ApiRepository.to.updateFaceName( + Future updateFaceNameData() async { + final LoginEntity entity = await ApiRepository.to.updateFaceName( lockId: state.faceItemData.value.lockId!, faceId: state.faceItemData.value.faceId!, faceName: state.changeNameController.text, ); if (entity.errorCode!.codeIsSuccessful) { state.typeName.value = state.changeNameController.text; - showToast("修改成功", something: () { - Get.back(result: "addScuess"); + showToast('修改成功', something: () { + Get.back(result: 'addScuess'); }); } } // 修改人脸有效期 - void editFaceData() async { - var entity = await ApiRepository.to.updateFaceValidity( + Future editFaceData() async { + final LoginEntity entity = await ApiRepository.to.updateFaceValidity( lockId: state.faceItemData.value.lockId!, faceId: state.faceItemData.value.faceId!, startDate: int.parse(state.startDate.value), @@ -182,13 +182,13 @@ class FaceDetailLogic extends BaseGetXController { faceType: state.keyType.value, weekDay: state.weekDay.value, faceName: state.changeNameController.text, - addType: "1", + addType: '1', isCoerced: state.isStressFace.value ? 2 : 1, faceRight: state.isAdministrator.value ? 1 : 0, ); if (entity.errorCode!.codeIsSuccessful) { - showToast("修改成功", something: () { - Get.back(result: "addScuess"); + showToast('修改成功', something: () { + Get.back(result: 'addScuess'); }); } } @@ -196,33 +196,25 @@ class FaceDetailLogic extends BaseGetXController { String getKeyTypeShowDateTime() { String useDateStr = ''; if (state.keyType.value == 1) { - useDateStr = "永久"; + useDateStr = '永久'; } else if (state.keyType.value == 2) { useDateStr = - "${DateTool().dateToYMDHNString(state.startDate.value)}\n${DateTool().dateToYMDHNString(state.endDate.value)}"; + '${DateTool().dateToYMDHNString(state.startDate.value)}\n${DateTool().dateToYMDHNString(state.endDate.value)}'; } else if (state.keyType.value == 4) { useDateStr = - "${DateTool().dateToYMDString(state.startDate.value)}\n${DateTool().dateToYMDString(state.endDate.value)}"; + '${DateTool().dateToYMDString(state.startDate.value)}\n${DateTool().dateToYMDString(state.endDate.value)}'; } return useDateStr; } @override void onReady() { - // TODO: implement onReady super.onReady(); _initReplySubscription(); } - @override - void onInit() { - // TODO: implement onInit - super.onInit(); - } - @override void onClose() { - // TODO: implement onClose super.onClose(); _replySubscription.cancel(); diff --git a/lib/main/lockDetail/face/faceDetail/faceDetail_page.dart b/lib/main/lockDetail/face/faceDetail/faceDetail_page.dart index 577361ba..3c9541ca 100755 --- a/lib/main/lockDetail/face/faceDetail/faceDetail_page.dart +++ b/lib/main/lockDetail/face/faceDetail/faceDetail_page.dart @@ -1,9 +1,11 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.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/faceDetail/faceDetail_logic.dart'; +import 'package:star_lock/main/lockDetail/face/faceDetail/faceDetail_state.dart'; import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; @@ -23,22 +25,22 @@ class FaceDetailPage extends StatefulWidget { } class _FaceDetailPageState extends State with RouteAware { - final logic = Get.put(FaceDetailLogic()); - final state = Get.find().state; + final FaceDetailLogic logic = Get.put(FaceDetailLogic()); + final FaceDetailState state = Get.find().state; @override Widget build(BuildContext context) { return Scaffold( backgroundColor: AppColors.mainBackgroundColor, appBar: TitleAppBar( - barTitle: "人脸详情", + barTitle: '人脸详情', haveBack: true, backgroundColor: AppColors.mainColor, ), body: ListView( - children: [ + children: [ Obx(() => CommonItem( - leftTitel: "人脸号", + leftTitel: '人脸号', rightTitle: state.typeNumber.value, isHaveDirection: false, isHaveLine: true)), @@ -51,23 +53,24 @@ class _FaceDetailPageState extends State with RouteAware { // showCupertinoAlertDialog(context); 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); + logic.showToast('请输入姓名'.tr); return; } Get.back(); state.typeName.value = state.changeNameController.text; logic.updateFaceNameData(); - }); + }, inputFormatters: [ + FilteringTextInputFormatter.deny('\n'), + LengthLimitingTextInputFormatter(50), + ]); })), 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, @@ -80,14 +83,14 @@ class _FaceDetailPageState extends State with RouteAware { // 限时 var data = await Get.toNamed( Routers.otherTypeKeyChangeDatePage, - arguments: { - "pushType": 3, - "fingerprintItemData": state.faceItemData.value, + arguments: { + 'pushType': 3, + 'fingerprintItemData': state.faceItemData.value, }); if (data != null) { setState(() { - state.startDate.value = data["beginTimeTimestamp"]; - state.endDate.value = data["endTimeTimestamp"]; + state.startDate.value = data['beginTimeTimestamp']; + state.endDate.value = data['endTimeTimestamp']; state.keyType.value = 2; }); } @@ -95,23 +98,23 @@ class _FaceDetailPageState extends State with RouteAware { // 循环 var data = await Get.toNamed( Routers.otherTypeKeyChangeValidityDatePage, - arguments: { - "pushType": 3, - "fingerprintItemData": state.faceItemData.value, + arguments: { + 'pushType': 3, + 'fingerprintItemData': state.faceItemData.value, }); if (data != null) { setState(() { - state.startDate.value = data["starDate"]; - state.endDate.value = data["endDate"]; - state.startTime.value = data["starTime"]; - state.endTime.value = data["endTime"]; - state.weekDay.value = data["validityValue"]; + state.startDate.value = data['starDate']; + state.endDate.value = data['endDate']; + state.startTime.value = data['starTime']; + state.endTime.value = data['endTime']; + state.weekDay.value = data['validityValue']; }); } } }))), 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(','), @@ -120,41 +123,41 @@ class _FaceDetailPageState extends State with RouteAware { action: () async { var data = await Get.toNamed( Routers.otherTypeKeyChangeValidityDatePage, - arguments: { - "pushType": 3, - "fingerprintItemData": state.faceItemData.value, + arguments: { + 'pushType': 3, + 'fingerprintItemData': state.faceItemData.value, }); if (data != null) { setState(() { - state.startDate.value = data["starDate"]; - state.endDate.value = data["endDate"]; - state.startTime.value = data["starTime"]; - state.endTime.value = data["endTime"]; - state.weekDay.value = data["validityValue"]; + state.startDate.value = data['starDate']; + state.endDate.value = data['endDate']; + state.startTime.value = data['starTime']; + state.endTime.value = data['endTime']; + state.weekDay.value = data['validityValue']; }); } })))), Obx(() => Visibility( - visible: state.keyType.value == 4 ? true : false, + visible: state.keyType.value == 4, child: Obx(() => CommonItem( - leftTitel: "有效时间", + leftTitel: '有效时间', rightTitle: - "${DateTool().dateToHNString(state.startTime.value)}-${DateTool().dateToHNString(state.endTime.value)}", + '${DateTool().dateToHNString(state.startTime.value)}-${DateTool().dateToHNString(state.endTime.value)}', isHaveDirection: true, action: () async { var data = await Get.toNamed( Routers.otherTypeKeyChangeValidityDatePage, - arguments: { - "pushType": 3, - "fingerprintItemData": state.faceItemData.value, + arguments: { + 'pushType': 3, + 'fingerprintItemData': state.faceItemData.value, }); if (data != null) { setState(() { - state.startDate.value = data["starDate"]; - state.endDate.value = data["endDate"]; - state.startTime.value = data["starTime"]; - state.endTime.value = data["endTime"]; - state.weekDay.value = data["validityValue"]; + state.startDate.value = data['starDate']; + state.endDate.value = data['endDate']; + state.startTime.value = data['starTime']; + state.endTime.value = data['endTime']; + state.weekDay.value = data['validityValue']; }); } })))), @@ -177,8 +180,8 @@ class _FaceDetailPageState extends State with RouteAware { // isHaveLine: true, // rightWidget: SizedBox(width: 60.w, height: 50.h, child: _isStressFace()))), Obx(() => CommonItem( - leftTitel: "是否为管理员".tr, - rightTitle: "", + leftTitel: '是否为管理员'.tr, + rightTitle: '', isTipsImg: false, isHaveRightWidget: true, rightWidget: @@ -186,10 +189,10 @@ class _FaceDetailPageState extends State with RouteAware { 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': 4, 'id': state.faceItemData.value.faceId.toString(), 'recordName': state.faceItemData.value.faceName @@ -206,7 +209,7 @@ 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: () { - ShowTipView().showIosTipWithContentDialog("确定要删除吗?".tr, + ShowTipView().showIosTipWithContentDialog('确定要删除吗?'.tr, () async { state.isDeletFace.value = true; logic.senderAddFace(); @@ -223,7 +226,7 @@ class _FaceDetailPageState extends State with RouteAware { trackColor: CupertinoColors.systemGrey5, thumbColor: CupertinoColors.white, value: state.isStressFace.value, - onChanged: (value) { + onChanged: (bool value) { setState(() { state.isStressFace.value = value; state.isDeletFace.value = false; @@ -240,7 +243,7 @@ class _FaceDetailPageState extends State with RouteAware { trackColor: CupertinoColors.systemGrey5, thumbColor: CupertinoColors.white, value: state.isAdministrator.value, - onChanged: (value) { + onChanged: (bool value) { // state.isAdministrator.value = value; // state.isDeletFace.value = false; // logic.senderAddFace(); @@ -250,7 +253,6 @@ class _FaceDetailPageState extends State with RouteAware { @override void didChangeDependencies() { - // TODO: implement didChangeDependencies super.didChangeDependencies(); /// 路由订阅 @@ -259,7 +261,6 @@ class _FaceDetailPageState extends State with RouteAware { @override void dispose() { - // TODO: implement dispose /// 取消路由订阅 AppRouteObserver().routeObserver.unsubscribe(this); super.dispose(); diff --git a/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_page.dart b/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_page.dart index 3f771e6f..278ff3ef 100755 --- a/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_page.dart +++ b/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_page.dart @@ -383,7 +383,7 @@ class _AddFingerprintTypePageState extends State with Si maxLines: 1, inputFormatters: [ FilteringTextInputFormatter.deny('\n'), - LengthLimitingTextInputFormatter(18), + LengthLimitingTextInputFormatter(50), ], style: TextStyle(fontSize: 22.sp, color: AppColors.darkGrayTextColor), controller: state.nameController, diff --git a/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_page.dart b/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_page.dart index f6d80e57..e7582d58 100755 --- a/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_page.dart +++ b/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_page.dart @@ -1,5 +1,6 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; @@ -41,7 +42,7 @@ class _FingerprintDetailPageState extends State children: [ Obx(() => CommonItem( leftTitel: - "${TranslationLoader.lanKeys!.fingerprint!.tr}${TranslationLoader.lanKeys!.number!.tr}", + '${TranslationLoader.lanKeys!.fingerprint!.tr}${TranslationLoader.lanKeys!.number!.tr}', rightTitle: state.typeNumber.value, isHaveDirection: false, isHaveLine: true)), @@ -53,7 +54,7 @@ class _FingerprintDetailPageState extends State 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); @@ -62,14 +63,15 @@ class _FingerprintDetailPageState extends State Get.back(); state.typeName.value = state.changeNameController.text; logic.editFingerprintsData(); - }); + }, inputFormatters: [ + FilteringTextInputFormatter.deny('\n'), + LengthLimitingTextInputFormatter(50), + ]); })), 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, @@ -115,7 +117,7 @@ class _FingerprintDetailPageState extends State } }))), 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(','), @@ -140,7 +142,7 @@ class _FingerprintDetailPageState extends State } })))), Obx(() => Visibility( - visible: state.keyType.value == 4 ? true : false, + visible: state.keyType.value == 4, child: Obx(() => CommonItem( leftTitel: '有效时间'.tr, rightTitle: @@ -259,7 +261,6 @@ class _FingerprintDetailPageState extends State @override void didChangeDependencies() { - // TODO: implement didChangeDependencies super.didChangeDependencies(); /// 路由订阅 @@ -268,7 +269,6 @@ class _FingerprintDetailPageState extends State @override void dispose() { - // TODO: implement dispose /// 取消路由订阅 AppRouteObserver().routeObserver.unsubscribe(this); super.dispose(); @@ -286,7 +286,9 @@ class _FingerprintDetailPageState extends State void didPop() { super.didPop(); logic.cancelBlueConnetctToastTimer(); - if (EasyLoading.isShow) EasyLoading.dismiss(animation: true); + if (EasyLoading.isShow) { + EasyLoading.dismiss(animation: true); + } state.ifCurrentScreen.value = false; state.sureBtnState.value = 0; } @@ -303,7 +305,9 @@ class _FingerprintDetailPageState extends State void didPushNext() { super.didPushNext(); logic.cancelBlueConnetctToastTimer(); - if (EasyLoading.isShow) EasyLoading.dismiss(animation: true); + if (EasyLoading.isShow) { + EasyLoading.dismiss(animation: true); + } state.ifCurrentScreen.value = false; state.sureBtnState.value = 0; } diff --git a/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart b/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart index 0ce9a349..94bda667 100755 --- a/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart +++ b/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart @@ -5,6 +5,7 @@ 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/fingerprint/fingerprintList/fingerprintList_state.dart'; import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; @@ -30,11 +31,11 @@ class FingerprintListPage extends StatefulWidget { } class _FingerprintListPageState extends State with RouteAware { - final logic = Get.put(FingerprintListLogic()); - final state = Get.find().state; + final FingerprintListLogic logic = Get.put(FingerprintListLogic()); + final FingerprintListState state = Get.find().state; Future getHttpData() async { - var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); + final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); if (isDemoMode == false) { logic.getFingerprintsListData().then((FingerprintListDataEntity value){ if (mounted) { @@ -59,23 +60,23 @@ class _FingerprintListPageState extends State with RouteAwa barTitle: TranslationLoader.lanKeys!.fingerprint!.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) { - ShowTipView().showIosTipWithContentDialog("重置后,该锁的指纹都将被删除哦,确认要重置吗?".tr, () async { + ShowTipView().showIosTipWithContentDialog('重置后,该锁的指纹都将被删除哦,确认要重置吗?'.tr, () async { state.isDeletAll = true; - state.deletKeyID = "1"; + state.deletKeyID = '1'; state.deletFingerNo = 0; logic.senderAddFingerprint(); }); } else { - logic.showToast("演示模式".tr); + logic.showToast('演示模式'.tr); } }, ), @@ -90,7 +91,7 @@ class _FingerprintListPageState extends State with RouteAwa getHttpData(); }, child: Column( - children: [ + children: [ KeySearchWidget( editingController: state.searchController, onSubmittedAction: () { @@ -105,10 +106,10 @@ class _FingerprintListPageState extends State with RouteAwa AddBottomWhiteBtn( btnName: '${TranslationLoader.lanKeys!.add!.tr}${TranslationLoader.lanKeys!.fingerprint!.tr}', onClick: () async { - var data = - await Get.toNamed(Routers.addFingerprintTypePage, arguments: { - "lockId": state.lockId.value, - "fromType": 1 // 1从添加钥匙列表进入 2从考勤添加员工入口进入 + final data = + await Get.toNamed(Routers.addFingerprintTypePage, arguments: { + 'lockId': state.lockId.value, + 'fromType': 1 // 1从添加钥匙列表进入 2从考勤添加员工入口进入 }); if (data != null) { logic.pageNo = 1; @@ -128,18 +129,18 @@ class _FingerprintListPageState extends State with RouteAwa ? SlidableAutoCloseBehavior( child: ListView.separated( itemCount: state.fingerprintItemListData.value.length, - itemBuilder: (c, index) { - FingerprintItemData fingerprintItemData = state.fingerprintItemListData.value[index]; + itemBuilder: (BuildContext c, int index) { + final FingerprintItemData fingerprintItemData = state.fingerprintItemListData.value[index]; // 指纹 return Slidable( key:ValueKey(fingerprintItemData.fingerprintId), endActionPane: ActionPane( extentRatio: 0.2, motion: const ScrollMotion(), - children: [ + children: [ SlidableAction( onPressed: (BuildContext context){ - ShowTipView().showIosTipWithContentDialog("确定要删除吗?".tr, () async { + ShowTipView().showIosTipWithContentDialog('确定要删除吗?'.tr, () async { state.isDeletAll = false; state.deletKeyID = fingerprintItemData.fingerprintId.toString(); state.deletFingerNo = int.parse(fingerprintItemData.fingerprintNumber!); @@ -158,10 +159,10 @@ class _FingerprintListPageState extends State with RouteAwa fingerprintItemData.fingerprintName!, logic.getKeyType(fingerprintItemData), logic.getKeyDateType(fingerprintItemData), () async { - var data = await Get.toNamed( + final data = await Get.toNamed( Routers.fingerprintDetailPage, - arguments: { - "fingerprintItemData": fingerprintItemData, + arguments: { + 'fingerprintItemData': fingerprintItemData, }); if (data != null) { logic.pageNo = 1; @@ -192,21 +193,21 @@ class _FingerprintListPageState extends State with RouteAwa // // 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: ifInvalidation.isNotEmpty ? 1.sw - 110.w - 100.w : 1.sw - 110.w - 50.w, child: Row( - children: [ + children: [ Flexible( child: Text( lockTypeTitle, @@ -228,7 +229,7 @@ class _FingerprintListPageState extends State with RouteAwa SizedBox(height: 5.h), Row( mainAxisAlignment: MainAxisAlignment.start, - children: [ + children: [ Flexible( child: Text(showTime, maxLines: 1, @@ -252,7 +253,6 @@ class _FingerprintListPageState extends State with RouteAwa @override void didChangeDependencies() { - // TODO: implement didChangeDependencies super.didChangeDependencies(); /// 路由订阅 @@ -261,7 +261,6 @@ class _FingerprintListPageState extends State with RouteAwa @override void dispose() { - // TODO: implement dispose /// 取消路由订阅 AppRouteObserver().routeObserver.unsubscribe(this); super.dispose(); @@ -279,7 +278,9 @@ class _FingerprintListPageState extends State with RouteAwa void didPop() { super.didPop(); logic.cancelBlueConnetctToastTimer(); - if (EasyLoading.isShow) EasyLoading.dismiss(animation: true); + if (EasyLoading.isShow) { + EasyLoading.dismiss(animation: true); + } state.ifCurrentScreen.value = false; } @@ -295,7 +296,9 @@ class _FingerprintListPageState extends State with RouteAwa 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/lockSet/basicInformation/basicInformation/basicInformation_page.dart b/lib/main/lockDetail/lockSet/basicInformation/basicInformation/basicInformation_page.dart index df445e77..3af8a092 100755 --- a/lib/main/lockDetail/lockSet/basicInformation/basicInformation/basicInformation_page.dart +++ b/lib/main/lockDetail/lockSet/basicInformation/basicInformation/basicInformation_page.dart @@ -121,7 +121,7 @@ class _BasicInformationPageState extends State { }))), Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.lockGrouping!.tr, - rightTitle: state.lockBasicInfo.value.groupName!.tr ?? '', + rightTitle: state.lockBasicInfo.value.groupName ?? '', isHaveLine: true, isHaveDirection: true, action: () async { @@ -150,7 +150,7 @@ class _BasicInformationPageState extends State { }), )), Obx(() => Visibility( - visible: state.lockBasicInfo.value.lockName!.contains('T9A'), + visible: (state.lockBasicInfo.value.lockName ?? '').contains('T9A'), child: CommonItem( leftTitel: '当前网络'.tr, rightTitle: state.lockBasicInfo.value.network ?? '-', diff --git a/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_logic.dart b/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_logic.dart index 95244889..d279194f 100755 --- a/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_logic.dart +++ b/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_logic.dart @@ -21,18 +21,18 @@ class UploadElectricQuantityLogic extends BaseGetXController { //电量更新请求 Future uploadElectricQuantityRequest(String electricQuantity, String electricQuantityStandby) async { - KeyOperationRecordEntity entity = await ApiRepository.to.uploadElectricQuantity( + final KeyOperationRecordEntity entity = await ApiRepository.to.uploadElectricQuantity( electricQuantity:electricQuantity, electricQuantityStandby: electricQuantityStandby, lockId: state.lockSetInfoData.value.lockId.toString(), isUnShowLoading: false ); if (entity.errorCode!.codeIsSuccessful) { - showToast("锁电量更新成功".tr, something: () { + showToast('锁电量更新成功'.tr, something: () { eventBus .fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value)); eventBus.fire( - LockSetChangeSetRefreshLockDetailWithType(0, electricQuantity)); + LockSetChangeSetRefreshLockDetailWithType(4, electricQuantity)); eventBus.fire(RefreshLockListInfoDataEvent()); }); } @@ -54,8 +54,8 @@ class UploadElectricQuantityLogic extends BaseGetXController { (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected) { dismissEasyLoading(); - var privateKey = await Storage.getStringList(saveBluePrivateKey); - List getPrivateKeyList = changeStringListToIntList(privateKey!); + final privateKey = await Storage.getStringList(saveBluePrivateKey); + final List getPrivateKeyList = changeStringListToIntList(privateKey!); IoSenderManage.senderGetStarLockStatuInfo( lockID: BlueManage().connectDeviceName, userID: await Storage.getUid(), @@ -89,7 +89,7 @@ class UploadElectricQuantityLogic extends BaseGetXController { // 获取星锁状态 Future _replyGetStarLockStatusInfo(Reply reply) async { - int status = reply.data[2]; + final int status = reply.data[2]; switch (status) { case 0x00: //成功 @@ -98,11 +98,11 @@ class UploadElectricQuantityLogic extends BaseGetXController { cancelBlueConnetctToastTimer(); // 电池剩余电量 - var battRemCap = reply.data[132]; + final battRemCap = reply.data[132]; state.lockSetInfoData.value.lockBasicInfo!.electricQuantity = battRemCap; // 备用电池剩余电量 - var battRemCapStandby = reply.data[133]; + final battRemCapStandby = reply.data[133]; state.lockSetInfoData.value.lockBasicInfo!.electricQuantityStandby = battRemCapStandby; state.uploadElectricQuantityDate.value = DateTime.now().millisecondsSinceEpoch; @@ -111,8 +111,8 @@ class UploadElectricQuantityLogic extends BaseGetXController { break; case 0x06: //无权限 - var privateKey = await Storage.getStringList(saveBluePrivateKey); - List getPrivateKeyList = changeStringListToIntList(privateKey!); + final privateKey = await Storage.getStringList(saveBluePrivateKey); + final List getPrivateKeyList = changeStringListToIntList(privateKey!); IoSenderManage.senderGetStarLockStatuInfo( lockID: BlueManage().connectDeviceName, userID: await Storage.getUid(), @@ -130,7 +130,7 @@ class UploadElectricQuantityLogic extends BaseGetXController { // 从服务器获取锁的时间 开锁时传入 void getServerDatetime() async{ - var entity = await ApiRepository.to.getServerDatetimeData(); + final entity = await ApiRepository.to.getServerDatetimeData(); if(entity.errorCode!.codeIsSuccessful){ state.differentialTime = entity.data!.date! ~/ 1000 - DateTime.now().millisecondsSinceEpoch ~/ 1000; getLocalNetTime(); @@ -143,8 +143,8 @@ class UploadElectricQuantityLogic extends BaseGetXController { } int getLocalNetTime(){ - DateTime utcTime = DateTime.fromMillisecondsSinceEpoch(getUTCNetTime()*1000, isUtc: true); - DateTime localTime = utcTime.toLocal(); + final DateTime utcTime = DateTime.fromMillisecondsSinceEpoch(getUTCNetTime()*1000, isUtc: true); + final DateTime localTime = utcTime.toLocal(); // AppLog.log('getUTCNetTime: ${getUTCNetTime()}'); // AppLog.log('UTC time: $utcTime'); diff --git a/lib/main/lockDetail/lockSet/lockSet/lockSet_page.dart b/lib/main/lockDetail/lockSet/lockSet/lockSet_page.dart index 1734eaef..6ff90c13 100755 --- a/lib/main/lockDetail/lockSet/lockSet/lockSet_page.dart +++ b/lib/main/lockDetail/lockSet/lockSet/lockSet_page.dart @@ -3,6 +3,8 @@ 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/lockSet/lockSet/checkingInInfoData_entity.dart'; +import 'package:star_lock/main/lockDetail/lockSet/lockSet/lockSet_state.dart'; import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; @@ -25,8 +27,8 @@ class LockSetPage extends StatefulWidget { } class _LockSetPageState extends State with RouteAware { - final logic = Get.put(LockSetLogic()); - final state = Get.find().state; + final LockSetLogic logic = Get.put(LockSetLogic()); + final LockSetState state = Get.find().state; Future getHttpData() async { logic.getLockSettingInfoData().then((LockSetInfoEntity value) { @@ -36,7 +38,6 @@ class _LockSetPageState extends State with RouteAware { @override void initState() { - // TODO: implement initState super.initState(); logic.initLoadDataAction(() { @@ -59,7 +60,7 @@ class _LockSetPageState extends State with RouteAware { getHttpData(); }, child: Column( - children: [ + children: [ Expanded( child: Obx(() => ListView( children: getListWidget(), @@ -83,25 +84,25 @@ class _LockSetPageState extends State with RouteAware { // 普通用户 List getNormalWidget() { - var showWidgetArr = [ + final List showWidgetArr = [ // 基本信息 CommonItem( leftTitel: TranslationLoader.lanKeys!.basicInformation!.tr, - rightTitle: "", + rightTitle: '', isHaveLine: false, isHaveDirection: true, action: () { Get.toNamed(Routers.basicInformationPage, - arguments: {'lockSetInfoData': state.lockSetInfoData.value}); + arguments: {'lockSetInfoData': state.lockSetInfoData.value}); }), SizedBox(height: 10.h), // 自动闭锁 Obx(() => Visibility( - visible: state.lockFeature.value.autoLock == 1 ? true : false, + visible: state.lockFeature.value.autoLock == 1, child: CommonItem( leftTitel: TranslationLoader.lanKeys!.automaticBlocking!.tr, rightTitle: (state.lockSettingInfo.value.autoLock ?? 0) > 0 - ? "${state.lockSetInfoData.value.lockSettingInfo!.autoLockSecond ?? 0}s" + ? '${state.lockSetInfoData.value.lockSettingInfo!.autoLockSecond ?? 0}s' : TranslationLoader.lanKeys!.closed!.tr, isHaveLine: true, isHaveDirection: true, @@ -110,14 +111,14 @@ class _LockSetPageState extends State with RouteAware { // ? "${state.lockSetInfoData.value.lockSetting!.autoLockSecond ?? 0}s" // : TranslationLoader.lanKeys!.closed!.tr), action: () { - Get.toNamed(Routers.automaticBlockingPage, arguments: { + Get.toNamed(Routers.automaticBlockingPage, arguments: { 'lockSetInfoData': state.lockSetInfoData.value, // 'lockBasicInfo': state.lockBasicInfo.value }); }))), // 常开模式 Obx(() => Visibility( - visible: state.lockFeature.value.passageMode == 1 ? true : false, + visible: state.lockFeature.value.passageMode == 1, child: CommonItem( leftTitel: TranslationLoader.lanKeys!.normallyOpenMode!.tr, rightTitle: (state.lockSettingInfo.value.passageMode ?? 0) == 1 @@ -126,7 +127,7 @@ class _LockSetPageState extends State with RouteAware { isHaveLine: true, isHaveDirection: true, action: () { - Get.toNamed(Routers.normallyOpenModePage, arguments: { + Get.toNamed(Routers.normallyOpenModePage, arguments: { 'lockSetInfoData': state.lockSetInfoData.value, 'lockBasicInfo': state.lockBasicInfo.value }); @@ -135,11 +136,11 @@ class _LockSetPageState extends State with RouteAware { visible: true, child: CommonItem( leftTitel: TranslationLoader.lanKeys!.lockTime!.tr, - rightTitle: "", + rightTitle: '', isHaveLine: true, isHaveDirection: true, action: () { - Get.toNamed(Routers.lockTimePage, arguments: { + Get.toNamed(Routers.lockTimePage, arguments: { 'lockSetInfoData': state.lockSetInfoData.value }); })), @@ -164,16 +165,16 @@ class _LockSetPageState extends State with RouteAware { // 授权管理员、超级管理员字段 List getAllWidget() { - var showWidgetArr = [ + final List showWidgetArr = [ // 基本信息 CommonItem( leftTitel: TranslationLoader.lanKeys!.basicInformation!.tr, - rightTitle: "", + rightTitle: '', isHaveLine: false, isHaveDirection: true, action: () { Get.toNamed(Routers.basicInformationPage, - arguments: {'lockSetInfoData': state.lockSetInfoData.value}); + arguments: {'lockSetInfoData': state.lockSetInfoData.value}); }), SizedBox(height: 10.h), //by DaisyWu 田总:移至锁详情配件区 @@ -226,11 +227,11 @@ class _LockSetPageState extends State with RouteAware { // SizedBox(height: 10.h), // 自动闭锁 Obx(() => Visibility( - visible: state.lockFeature.value.autoLock == 1 ? true : false, + visible: state.lockFeature.value.autoLock == 1, child: CommonItem( leftTitel: TranslationLoader.lanKeys!.automaticBlocking!.tr, rightTitle: state.lockSettingInfo.value.autoLock! > 0 - ? "${state.lockSetInfoData.value.lockSettingInfo!.autoLockSecond}s" + ? '${state.lockSetInfoData.value.lockSettingInfo!.autoLockSecond}s' : TranslationLoader.lanKeys!.closed!.tr, isHaveLine: true, isHaveDirection: true, @@ -239,13 +240,13 @@ class _LockSetPageState extends State with RouteAware { // ? "${state.lockSetInfoData.value.lockSetting!.autoLockSecond ?? 0}s" // : TranslationLoader.lanKeys!.closed!.tr), action: () { - Get.toNamed(Routers.automaticBlockingPage, arguments: { + Get.toNamed(Routers.automaticBlockingPage, arguments: { 'lockSetInfoData': state.lockSetInfoData.value }); }))), // 锁声音 Obx(() { - var titleStr = ""; + String titleStr = ''; if ((state.lockSettingInfo.value.lockSound ?? 0) == 1) { switch (state.lockSettingInfo.value.lockSoundVolume ?? 0) { case 1: @@ -268,21 +269,21 @@ class _LockSetPageState extends State with RouteAware { titleStr = TranslationLoader.lanKeys!.closed!.tr; } return Visibility( - visible: state.lockFeature.value.lockSound == 1 ? true : false, + visible: state.lockFeature.value.lockSound == 1, child: CommonItem( leftTitel: TranslationLoader.lanKeys!.lockSound!.tr, rightTitle: titleStr, isHaveLine: true, isHaveDirection: true, action: () { - Get.toNamed(Routers.lockSoundSetPage, arguments: { + Get.toNamed(Routers.lockSoundSetPage, arguments: { 'lockSetInfoData': state.lockSetInfoData.value }); })); }), // 防撬报警 Obx(() => Visibility( - visible: state.lockFeature.value.antiPrySwitch == 1 ? true : false, + visible: state.lockFeature.value.antiPrySwitch == 1, child: CommonItem( leftTitel: TranslationLoader.lanKeys!.burglarAlarm!.tr, rightTitle: (state.lockSettingInfo.value.antiPrySwitch ?? 0) == 1 @@ -291,14 +292,14 @@ class _LockSetPageState extends State with RouteAware { isHaveLine: true, isHaveDirection: true, action: () { - Get.toNamed(Routers.burglarAlarmPage, arguments: { + Get.toNamed(Routers.burglarAlarmPage, arguments: { 'lockSetInfoData': state.lockSetInfoData.value }); }))), SizedBox(height: 10.h), // 常开模式 Obx(() => Visibility( - visible: state.lockFeature.value.passageMode == 1 ? true : false, + visible: state.lockFeature.value.passageMode == 1, // visible: true, child: CommonItem( leftTitel: TranslationLoader.lanKeys!.normallyOpenMode!.tr, @@ -308,13 +309,13 @@ class _LockSetPageState extends State with RouteAware { isHaveLine: true, isHaveDirection: true, action: () { - Get.toNamed(Routers.normallyOpenModePage, arguments: { + Get.toNamed(Routers.normallyOpenModePage, arguments: { 'lockSetInfoData': state.lockSetInfoData.value }); }))), // 远程开锁 Obx(() => Visibility( - visible: state.lockFeature.value.remoteUnlock == 1 ? true : false, + visible: state.lockFeature.value.remoteUnlock == 1, child: CommonItem( leftTitel: TranslationLoader.lanKeys!.remoteUnlocking!.tr, rightTitle: (state.lockSettingInfo.value.remoteUnlock ?? 0) == 1 @@ -323,16 +324,13 @@ class _LockSetPageState extends State with RouteAware { isHaveLine: true, isHaveDirection: true, action: () { - Get.toNamed(Routers.remoteUnlockingPage, arguments: { + Get.toNamed(Routers.remoteUnlockingPage, arguments: { 'lockSetInfoData': state.lockSetInfoData.value }); }))), // 重置键 Obx(() => Visibility( - visible: (state.lockBasicInfo.value.isLockOwner == 1 && - state.lockFeature.value.resetSwitch == 1) - ? true - : false, + visible: state.lockBasicInfo.value.isLockOwner == 1 && state.lockFeature.value.resetSwitch == 1, child: CommonItem( leftTitel: TranslationLoader.lanKeys!.resetButton!.tr, rightTitle: (state.lockSettingInfo.value.resetSwitch ?? 0) == 1 @@ -341,7 +339,7 @@ class _LockSetPageState extends State with RouteAware { isHaveLine: true, isHaveDirection: true, action: () { - Get.toNamed(Routers.resetButtonPage, arguments: { + Get.toNamed(Routers.resetButtonPage, arguments: { 'lockSetInfoData': state.lockSetInfoData.value }); }))), @@ -350,14 +348,14 @@ class _LockSetPageState extends State with RouteAware { // Obx(() => // 面容开锁 Visibility( - visible: state.lockFeature.value.d3Face == 1 ? true : false, + visible: state.lockFeature.value.d3Face == 1, child: CommonItem( leftTitel: TranslationLoader.lanKeys!.faceUnlocks!.tr, - rightTitle: "", + rightTitle: '', isHaveLine: true, isHaveDirection: true, action: () { - Get.toNamed(Routers.faceUnlockPage, arguments: { + Get.toNamed(Routers.faceUnlockPage, arguments: { 'lockSetInfoData': state.lockSetInfoData.value }); })), @@ -367,23 +365,23 @@ class _LockSetPageState extends State with RouteAware { visible: true, child: CommonItem( leftTitel: TranslationLoader.lanKeys!.messageReminding!.tr, - rightTitle: "", + rightTitle: '', isHaveLine: true, isHaveDirection: true, action: () { Get.toNamed(Routers.msgNotificationPage, - arguments: {'lockId': state.lockSetInfoData.value.lockId}); + arguments: {'lockId': state.lockSetInfoData.value.lockId}); })), //猫眼设置 Obx(() => Visibility( - visible: state.lockFeature.value.isSupportCatEye == 1 ? true : false, + visible: state.lockFeature.value.isSupportCatEye == 1, child: CommonItem( leftTitel: TranslationLoader.lanKeys!.catEyeSet!.tr, - rightTitle: "", + rightTitle: '', isHaveLine: true, isHaveDirection: true, action: () { - Get.toNamed(Routers.catEyeSetPage, arguments: { + Get.toNamed(Routers.catEyeSetPage, arguments: { 'lockSetInfoData': state.lockSetInfoData.value }); }))), @@ -415,23 +413,23 @@ class _LockSetPageState extends State with RouteAware { // Obx(() => // 开门方向设置 Visibility( - visible: state.lockFeature.value.openDirection == 1 ? true : false, + visible: state.lockFeature.value.openDirection == 1, child: CommonItem( leftTitel: TranslationLoader.lanKeys!.openingDirectionSet!.tr, - rightTitle: "", + rightTitle: '', isHaveDirection: true, isHaveLine: true, action: () { - Get.toNamed(Routers.openDoorDirectionPage, arguments: { + Get.toNamed(Routers.openDoorDirectionPage, arguments: { 'lockSetInfoData': state.lockSetInfoData.value }); })), // 电机功率设置 Visibility( - visible: state.lockFeature.value.motorTorsion == 1 ? true : false, + visible: state.lockFeature.value.motorTorsion == 1, child: CommonItem( leftTitel: TranslationLoader.lanKeys!.motorPowerSetting!.tr, - rightTitle: "", + rightTitle: '', isHaveLine: true, isHaveDirection: true, action: () { @@ -481,7 +479,7 @@ class _LockSetPageState extends State with RouteAware { : false, child: CommonItem( leftTitel: TranslationLoader.lanKeys!.checkingIn!.tr, - rightTitle: "", + rightTitle: '', isHaveLine: true, isHaveRightWidget: true, rightWidget: _openCheckInSwitch())), @@ -489,13 +487,10 @@ class _LockSetPageState extends State with RouteAware { // 开锁提醒 Obx( () => Visibility( - visible: state.lockBasicInfo.value.isLockOwner == 1 && - state.lockFeature.value.unlockReminder == 1 - ? true - : false, + visible: state.lockBasicInfo.value.isLockOwner == 1 && state.lockFeature.value.unlockReminder == 1, child: CommonItem( leftTitel: TranslationLoader.lanKeys!.unlockReminder!.tr, - rightTitle: "", + rightTitle: '', isHaveLine: true, isHaveRightWidget: true, rightWidget: _lockRemindSwitch())), @@ -503,14 +498,11 @@ class _LockSetPageState extends State with RouteAware { // APP开锁时是否需联网 Obx( () => Visibility( - visible: state.lockBasicInfo.value.isLockOwner == 1 && - state.lockFeature.value.appUnlockOnline == 1 - ? true - : false, + visible: state.lockBasicInfo.value.isLockOwner == 1 && state.lockFeature.value.appUnlockOnline == 1, child: CommonItem( leftTitel: TranslationLoader .lanKeys!.whetherInternetRequiredWhenUnlocking!.tr, - rightTitle: "", + rightTitle: '', isHaveLine: false, isHaveRightWidget: true, rightWidget: _openLockNeedOnlineSwitch()), @@ -520,15 +512,15 @@ class _LockSetPageState extends State with RouteAware { // wifi配网 Obx( () => Visibility( - visible: state.lockFeature.value.wifi == 1 ? true : false, + visible: state.lockFeature.value.wifi == 1, child: CommonItem( leftTitel: TranslationLoader.lanKeys!.wifiDistributionNetwork!.tr, - rightTitle: "", + rightTitle: '', isHaveLine: true, isHaveDirection: true, action: () { - Get.toNamed(Routers.wifiListPage, arguments: { + Get.toNamed(Routers.wifiListPage, arguments: { 'lockSetInfoData': state.lockSetInfoData.value }); // Get.toNamed(Routers.configuringWifiPage, arguments: { @@ -542,11 +534,11 @@ class _LockSetPageState extends State with RouteAware { visible: true, child: CommonItem( leftTitel: TranslationLoader.lanKeys!.lockTime!.tr, - rightTitle: "", + rightTitle: '', isHaveLine: true, isHaveDirection: true, action: () { - Get.toNamed(Routers.lockTimePage, arguments: { + Get.toNamed(Routers.lockTimePage, arguments: { 'lockSetInfoData': state.lockSetInfoData.value }); })), @@ -572,7 +564,7 @@ class _LockSetPageState extends State with RouteAware { visible: true, child: CommonItem( leftTitel: TranslationLoader.lanKeys!.uploadData!.tr, - rightTitle: "", + rightTitle: '', isHaveLine: true, isHaveDirection: true, action: () { @@ -598,7 +590,7 @@ class _LockSetPageState extends State with RouteAware { visible: true, child: CommonItem( leftTitel: TranslationLoader.lanKeys!.lockEscalation!.tr, - rightTitle: "", + rightTitle: '', isHaveLine: false, isHaveDirection: true, action: () { @@ -626,7 +618,7 @@ class _LockSetPageState extends State with RouteAware { } Widget rightText(String rightTitle) { - return Text(rightTitle ?? "", + return Text(rightTitle ?? '', textAlign: TextAlign.end, style: TextStyle(fontSize: 22.sp, color: AppColors.darkGrayTextColor)); } @@ -637,15 +629,15 @@ class _LockSetPageState extends State with RouteAware { activeColor: CupertinoColors.activeBlue, trackColor: CupertinoColors.systemGrey5, thumbColor: CupertinoColors.white, - value: state.isAttendance.value == 1 ? true : false, - onChanged: (value) { - logic.openCheckingInData((checkingInInfoDataEntity) { + value: state.isAttendance.value == 1, + onChanged: (bool value) { + logic.openCheckingInData((CheckingInInfoDataEntity checkingInInfoDataEntity) { if (checkingInInfoDataEntity.data!.companyId == 0) { // logic.showCupertinoAlertDialog(context); - ShowTipView().showIosTipWithContentDialog("创建公司后,考勤功能才能使用".tr, () { + ShowTipView().showIosTipWithContentDialog('创建公司后,考勤功能才能使用'.tr, () { // 删除锁 Get.toNamed(Routers.checkInCreatCompanyPage, - arguments: {'lockSetInfoData': state.lockSetInfoData.value}); + arguments: {'lockSetInfoData': state.lockSetInfoData.value}); }); } else { logic.setLockSetGeneralSetting(); @@ -661,11 +653,9 @@ class _LockSetPageState extends State with RouteAware { activeColor: CupertinoColors.activeBlue, trackColor: CupertinoColors.systemGrey5, thumbColor: CupertinoColors.white, - value: state.isLockPickingReminder.value == 1 ? true : false, - onChanged: (value) { - setState(() { - logic.setLockPickingReminder(); - }); + value: state.isLockPickingReminder.value == 1, + onChanged: (bool value) { + setState(logic.setLockPickingReminder); }, ); } @@ -676,8 +666,8 @@ class _LockSetPageState extends State with RouteAware { activeColor: CupertinoColors.activeBlue, trackColor: CupertinoColors.systemGrey5, thumbColor: CupertinoColors.white, - value: (state.isOpenLockNeedOnline.value) == 1 ? true : false, - onChanged: (value) { + value: state.isOpenLockNeedOnline.value == 1, + onChanged: (bool value) { setState(() { logic.sendBurglarAlarm(55); }); @@ -721,8 +711,8 @@ class _LockSetPageState extends State with RouteAware { activeColor: CupertinoColors.activeBlue, trackColor: CupertinoColors.systemGrey5, thumbColor: CupertinoColors.white, - value: (state.isOpenBlueBroadcast.value) == 1 ? true : false, - onChanged: (value) { + value: state.isOpenBlueBroadcast.value == 1, + onChanged: (bool value) { setState(() { logic.sendBurglarAlarm(56); }); @@ -736,15 +726,14 @@ class _LockSetPageState extends State with RouteAware { trackColor: CupertinoColors.systemGrey5, thumbColor: CupertinoColors.white, value: false, - onChanged: (value) { - logic.showToast("功能暂未开放"); + onChanged: (bool value) { + logic.showToast('功能暂未开放'); }, ); } @override void didChangeDependencies() { - // TODO: implement didChangeDependencies super.didChangeDependencies(); /// 路由订阅 @@ -753,7 +742,6 @@ class _LockSetPageState extends State with RouteAware { @override void dispose() { - // TODO: implement dispose /// 取消路由订阅 AppRouteObserver().routeObserver.unsubscribe(this); super.dispose(); @@ -773,7 +761,9 @@ class _LockSetPageState extends State with RouteAware { super.didPop(); logic.cancelBlueConnetctToastTimer(); - if (EasyLoading.isShow) EasyLoading.dismiss(animation: true); + if (EasyLoading.isShow) { + EasyLoading.dismiss(animation: true); + } // if (state.deletWaitScanTimer != null) { // state.deletWaitScanTimer!.cancel(); // } @@ -798,7 +788,9 @@ class _LockSetPageState extends State with RouteAware { 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/passwordKey/passwordKeyDetail/passwordKeyDetail_page.dart b/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_page.dart index b18f41ed..02f683ab 100755 --- a/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_page.dart +++ b/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_page.dart @@ -4,6 +4,7 @@ import 'package:flutter/services.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_logic.dart'; +import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_state.dart'; import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart'; import 'package:star_lock/tools/showTFView.dart'; import 'package:star_lock/tools/showTipView.dart'; @@ -24,10 +25,9 @@ class PasswordKeyDetailPage extends StatefulWidget { State createState() => _PasswordKeyDetailPageState(); } -class _PasswordKeyDetailPageState extends State - with RouteAware { - final logic = Get.put(PasswordKeyDetailLogic()); - final state = Get.find().state; +class _PasswordKeyDetailPageState extends State with RouteAware { + final PasswordKeyDetailLogic logic = Get.put(PasswordKeyDetailLogic()); + final PasswordKeyDetailState state = Get.find().state; @override Widget build(BuildContext context) { @@ -37,22 +37,20 @@ class _PasswordKeyDetailPageState extends State barTitle: TranslationLoader.lanKeys!.passwordDetail!.tr, haveBack: true, backgroundColor: AppColors.mainColor, - actionsList: [ + actionsList: [ IconButton( icon: Image.asset( 'images/icon_bar_share.png', height: 30.h, width: 30.w, ), - onPressed: () { - _openModalBottomSheet(); - }, + onPressed: _openModalBottomSheet, ), ], ), body: SingleChildScrollView( child: Column( - children: [ + children: [ Obx(() => Visibility( visible: state.itemData.value.isCustom! == 1, child: CommonItem( @@ -64,8 +62,7 @@ class _PasswordKeyDetailPageState extends State Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.password!.tr, rightTitle: state.keyboardPwd.value, - isHaveDirection: - state.itemData.value.isCustom! == 1 ? true : false, + isHaveDirection: state.itemData.value.isCustom! == 1, isHaveLine: true, action: () { if (state.itemData.value.isCustom! != 1) { @@ -85,11 +82,10 @@ class _PasswordKeyDetailPageState extends State context, state.inputNameController); })), Obx(() => CommonItem( - leftTitel: "有效期", + leftTitel: '有效期', rightTitle: logic.getUseDateStr(), isHaveLine: state.isCirculation.value, - isHaveDirection: - state.itemData.value.isCustom! == 1 ? true : false, + isHaveDirection: state.itemData.value.isCustom! == 1, allHeight: state.itemData.value.keyboardPwdType == 3 ? 90.h : 65.h, action: () async { @@ -98,14 +94,14 @@ class _PasswordKeyDetailPageState extends State } var backData = await Get.toNamed( Routers.passwordKeyDetailChangeDatePage, - arguments: { + arguments: { 'itemData': state.itemData.value, }); if (backData != null) { state.itemData.value.startDate = - int.parse(backData["beginTimeTimestamp"]); + int.parse(backData['beginTimeTimestamp']); state.itemData.value.endDate = - int.parse(backData["endTimeTimestamp"]); + int.parse(backData['endTimeTimestamp']); // 改了日期之后,永久只能改限时的 state.itemData.value.keyboardPwdType = 3; setState(() {}); @@ -132,10 +128,10 @@ class _PasswordKeyDetailPageState extends State Obx(() => Visibility( visible: state.itemData.value.isCustom! == 1, child: Column( - children: [ + children: [ CommonItem( - leftTitel: "是否为管理员".tr, - rightTitle: "", + leftTitel: '是否为管理员'.tr, + rightTitle: '', isTipsImg: false, isHaveRightWidget: true, rightWidget: SizedBox( @@ -146,10 +142,10 @@ class _PasswordKeyDetailPageState extends State )), CommonItem( leftTitel: TranslationLoader.lanKeys!.operatingRecord!.tr, - rightTitle: "", + rightTitle: '', isHaveDirection: true, action: () { - Get.toNamed(Routers.lockOperatingRecordPage, arguments: { + Get.toNamed(Routers.lockOperatingRecordPage, arguments: { 'type': 1, 'id': state.itemData.value.keyboardPwdId.toString(), 'recordName': state.itemData.value.keyboardPwdName @@ -169,8 +165,8 @@ class _PasswordKeyDetailPageState extends State side: BorderSide(width: 1, color: AppColors.mainColor)), onPressed: () { Navigator.pushNamed(context, Routers.cardListPage, - arguments: { - "lockId": state.itemData.value.lockId, + arguments: { + 'lockId': state.itemData.value.lockId, }); }, child: Text( @@ -191,8 +187,8 @@ class _PasswordKeyDetailPageState extends State side: BorderSide(width: 1, color: AppColors.mainColor)), onPressed: () { Navigator.pushNamed(context, Routers.fingerprintListPage, - arguments: { - "lockId": state.itemData.value.lockId, + arguments: { + 'lockId': state.itemData.value.lockId, }); }, child: Text( @@ -214,8 +210,8 @@ class _PasswordKeyDetailPageState extends State onPressed: () { Navigator.pushNamed( context, Routers.remoteControlListPage, - arguments: { - "lockId": state.itemData.value.lockId, + arguments: { + 'lockId': state.itemData.value.lockId, }); }, child: Text( @@ -235,7 +231,7 @@ 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: () { - ShowTipView().showIosTipWithContentDialog("确定要删除吗?".tr, () { + ShowTipView().showIosTipWithContentDialog('确定要删除吗?'.tr, () { state.isDeletPasswordKey.value = true; logic.senderCustomPasswords(); }); @@ -247,15 +243,15 @@ class _PasswordKeyDetailPageState extends State Widget bottomTip(){ return Column( - children: [ + children: [ Container( padding: EdgeInsets.all(20.w), child: Row( // crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ Expanded( child: Text( - "密码生成后,请在当日23:59前使用一次进行激活,否则过0点后未激活则失效。".tr, + '密码生成后,请在当日23:59前使用一次进行激活,否则过0点后未激活则失效。'.tr, textAlign: TextAlign.start, style: TextStyle(fontSize: 20.sp), )), @@ -273,7 +269,7 @@ class _PasswordKeyDetailPageState extends State trackColor: CupertinoColors.systemGrey5, thumbColor: CupertinoColors.white, value: state.isAdministrator.value, - onChanged: (value) { + onChanged: (bool value) { // state.isAdministrator.value = value; // state.isDeletPasswordKey.value = false; // logic.senderCustomPasswords(); @@ -297,11 +293,11 @@ class _PasswordKeyDetailPageState extends State state.ifCurrentScreen.value = true; return ShowTFView( title: inputController == state.inputNameController - ? "${TranslationLoader.lanKeys!.amend!.tr}${TranslationLoader.lanKeys!.name!.tr}" - : "${TranslationLoader.lanKeys!.amend!.tr}${TranslationLoader.lanKeys!.password!.tr}", + ? '${TranslationLoader.lanKeys!.amend!.tr}${TranslationLoader.lanKeys!.name!.tr}' + : '${TranslationLoader.lanKeys!.amend!.tr}${TranslationLoader.lanKeys!.password!.tr}', tipTitle: inputController.text.isNotEmpty ? inputController.text - : "请输入6-9位密码", + : '请输入6-9位密码', controller: inputController, keyboardType: inputController == state.inputNameController ? TextInputType.text @@ -317,7 +313,7 @@ class _PasswordKeyDetailPageState extends State if (inputController.text.isEmpty || inputController.text.length < 6 || inputController.text.length > 9) { - logic.showToast("请输入6-9位密码"); + logic.showToast('请输入6-9位密码'); return; } } @@ -346,7 +342,7 @@ class _PasswordKeyDetailPageState extends State constraints: BoxConstraints(maxHeight: 270.h), builder: (BuildContext context) { return Column( - children: [ + children: [ SizedBox( width: ScreenUtil().screenWidth, height: 180.h, @@ -377,7 +373,7 @@ class _PasswordKeyDetailPageState extends State } List initBottomSheetList() { - List widgetList = []; + List widgetList = []; widgetList.add(buildCenter3('images/icon_wechat.png', '微信好友', 0)); widgetList.add(buildCenter3('images/icon_message.png', '短信', 1)); @@ -397,7 +393,7 @@ class _PasswordKeyDetailPageState extends State EdgeInsets.only(top: 20.w, bottom: 20.w, left: 10.w, right: 10.w), child: Column( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Image.asset( imageName, width: 50.w, diff --git a/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart b/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart index a6cdee70..2dd0de75 100755 --- a/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart +++ b/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart @@ -215,8 +215,6 @@ class PasswordKeyPerpetualLogic extends BaseGetXController { ); if (entity.errorCode!.codeIsSuccessful) { senderCustomPasswords(); - } else { - showToast('${entity.errorMsg}'); } } @@ -438,7 +436,7 @@ class PasswordKeyPerpetualLogic extends BaseGetXController { case 3: //自定义 if (state.isPermanent.value == false) { - '类型:自定义-限时\n有效期:${state.customBeginTime.value} -- ${state.customEndTime.value}'; + useDateStr = '类型:自定义-限时\n有效期:${state.customBeginTime.value} -- ${state.customEndTime.value}'; } else { useDateStr = '类型:自定义-永久'; } @@ -466,7 +464,6 @@ class PasswordKeyPerpetualLogic extends BaseGetXController { @override void onReady() { - // TODO: implement onReady super.onReady(); _initReplySubscription(); @@ -475,13 +472,11 @@ class PasswordKeyPerpetualLogic extends BaseGetXController { @override void onInit() { - // TODO: implement onInit super.onInit(); } @override void onClose() { - // TODO: implement onClose _replySubscription.cancel(); } } diff --git a/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart b/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart index bfc15647..52dd0b5d 100755 --- a/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart +++ b/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart @@ -223,8 +223,7 @@ class _PasswordKeyPerpetualPageState extends State return Column( children: [ Visibility( - visible: - CommonDataManage().currentKeyInfo.vendor == 'XHJ' ? false : true, + visible: CommonDataManage().currentKeyInfo.vendor == 'XHJ', child: CommonItem( leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr, rightTitle: state.beginTime.value, @@ -333,7 +332,7 @@ class _PasswordKeyPerpetualPageState extends State Widget keyIfAdministratorWidget() { return Visibility( visible: - CommonDataManage().currentKeyInfo.isLockOwner == 1 ? true : false, + CommonDataManage().currentKeyInfo.isLockOwner == 1, child: Column( children: [ // SizedBox(height: 10.h), @@ -375,14 +374,12 @@ class _PasswordKeyPerpetualPageState extends State showPickerView(context, pickerDataList); }), Visibility( - visible: (CommonDataManage().currentKeyInfo.vendor == + visible: CommonDataManage().currentKeyInfo.vendor == IoModelVendor.vendor_XL && (CommonDataManage().currentKeyInfo.model == IoModelVendor.model_XL_BLE || CommonDataManage().currentKeyInfo.model == - IoModelVendor.model_XL_WIFI)) - ? true - : false, + IoModelVendor.model_XL_WIFI), child: CommonItem( leftTitel: '结束日期', rightTitle: state.endTime.value, @@ -411,7 +408,7 @@ class _PasswordKeyPerpetualPageState extends State state.loopEffectiveDate.value = DateTool().getYMDHNDateString(p, 5); state.loopStartHours.value = p.hour!; - }); + }, hourShow24: true); }), CommonItem( leftTitel: TranslationLoader.lanKeys!.failureTime!.tr, @@ -425,7 +422,7 @@ class _PasswordKeyPerpetualPageState extends State state.loopFailureDate.value = DateTool().getYMDHNDateString(p, 5); state.loopEndHours.value = p.hour!; - }); + }, hourShow24: true); }), ], ); @@ -620,7 +617,7 @@ class _PasswordKeyPerpetualPageState extends State ); } - _switch() { + CupertinoSwitch _switch() { return CupertinoSwitch( activeColor: CupertinoColors.activeBlue, trackColor: CupertinoColors.systemGrey5, @@ -694,7 +691,7 @@ class _PasswordKeyPerpetualPageState extends State onTap: (int index) { FocusScope.of(context).requestFocus(FocusNode()); }, - tabs: _itemTabs.map((ItemView item) => _tab(item)).toList(), + tabs: _itemTabs.map(_tab).toList(), isScrollable: true, indicatorColor: Colors.red, unselectedLabelColor: Colors.black, @@ -718,14 +715,9 @@ class _PasswordKeyPerpetualPageState extends State Tab _tab(ItemView item) { return Tab( // text: item.title, - child: Container( - // width: item.title.length > 2 ? 1.sw / 8 : 1.sw / 12, - // margin: EdgeInsets.all(10.w), - // color: Colors.red, - child: Text( - item.title, - textAlign: TextAlign.center, - ), + child: Text( + item.title, + textAlign: TextAlign.center, ), ); } @@ -735,7 +727,7 @@ class _PasswordKeyPerpetualPageState extends State child: TabBarView( controller: state.tabController, children: _itemTabs - .map((ItemView item) => Obx(() => indexChangeWidget())) + .map((ItemView item) => Obx(indexChangeWidget)) .toList(), ), ); @@ -827,7 +819,6 @@ class _PasswordKeyPerpetualPageState extends State @override void dispose() { - // TODO: implement dispose /// 取消路由订阅 AppRouteObserver().routeObserver.unsubscribe(this); super.dispose(); diff --git a/lib/mine/mine/starLockMine_page.dart b/lib/mine/mine/starLockMine_page.dart index 641e15e5..f13d35d6 100755 --- a/lib/mine/mine/starLockMine_page.dart +++ b/lib/mine/mine/starLockMine_page.dart @@ -1,10 +1,10 @@ + import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart'; import 'package:star_lock/flavors.dart'; import 'package:star_lock/mine/mine/starLockMine_state.dart'; -import 'package:star_lock/tools/commonDataManage.dart'; import '../../appRouters.dart'; import '../../app_settings/app_colors.dart'; @@ -80,7 +80,7 @@ class StarLockMinePageState extends State with BaseWidget { child: ClipRRect( borderRadius: BorderRadius.circular(52.5.w), child: CustomNetworkImage( - url: state.userHeadUrl.value ?? "", + url: state.userHeadUrl.value, defaultUrl: 'images/controls_user.png', width: 105.w, height: 105.h, @@ -99,7 +99,7 @@ class StarLockMinePageState extends State with BaseWidget { // logic.showToast('请先添加锁'); // } else { Get.toNamed(Routers.advancedFeaturesWebPage, - arguments: { + arguments: { 'webBuyType': XSConstantMacro.webBuyTypeVip, }); // } diff --git a/lib/mine/mineSet/authorityManagement/getDeviceList_page.dart b/lib/mine/mineSet/authorityManagement/getDeviceList_page.dart index 58756911..ddb2b122 100755 --- a/lib/mine/mineSet/authorityManagement/getDeviceList_page.dart +++ b/lib/mine/mineSet/authorityManagement/getDeviceList_page.dart @@ -28,7 +28,7 @@ class _GetDeviceListPageState extends State { body: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ Padding( padding: EdgeInsets.only( left: 30.w, top: 16.w, right: 30.w, bottom: 16.w), @@ -48,25 +48,25 @@ class _GetDeviceListPageState extends State { //设备列表 Widget _permissionDeviceList() { return Column( - children: [ + children: [ Expanded( child: ListView.separated( - itemBuilder: (context, index) { + itemBuilder: (BuildContext context, int index) { if (index == 0) { return _buildDeviceWidget( - context, index, 'images/icon_lock.png', "大门锁"); + context, index, 'images/icon_lock.png', '大门锁'); } else if (index == 1) { return _buildDeviceWidget( - context, index, 'images/icon_lock.png', "办公室锁"); + context, index, 'images/icon_lock.png', '办公室锁'); } else if (index == 2) { return _buildDeviceWidget( - context, index, 'images/icon_lock.png', "会议室锁"); + context, index, 'images/icon_lock.png', '会议室锁'); } else { return _buildDeviceWidget( - context, index, 'images/icon_lock.png', "宴会厅锁"); + context, index, 'images/icon_lock.png', '宴会厅锁'); } }, - separatorBuilder: (context, index) { + separatorBuilder: (BuildContext context, int index) { return const Divider( height: 1, color: AppColors.greyLineColor, @@ -94,7 +94,7 @@ class _GetDeviceListPageState extends State { color: Colors.white, width: ScreenUtil().screenWidth, child: Row( - children: [ + children: [ SizedBox( width: 30.w, ), diff --git a/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministrator_page.dart b/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministrator_page.dart index f6b34274..3a0d0adc 100755 --- a/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministrator_page.dart +++ b/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministrator_page.dart @@ -225,7 +225,7 @@ class _AddAuthorizedAdministratorPageState maxLines: 1, inputFormatters: [ FilteringTextInputFormatter.deny('\n'), - LengthLimitingTextInputFormatter(18), + LengthLimitingTextInputFormatter(50), ], style: TextStyle( fontSize: 22.sp, color: AppColors.darkGrayTextColor), diff --git a/lib/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdministratorList_page.dart b/lib/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdministratorList_page.dart index 8463a9b1..a792ca1c 100755 --- a/lib/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdministratorList_page.dart +++ b/lib/mine/mineSet/authorizedAdministrator/authorizedAdministrator/authorizedAdministratorList_page.dart @@ -14,6 +14,7 @@ import '../../../../../tools/titleAppBar.dart'; import '../../../../../translations/trans_lib.dart'; import '../../../../common/XSConstantMacro/XSConstantMacro.dart'; import '../../../../tools/EasyRefreshTool.dart'; +import '../../../../tools/customNetworkImage.dart'; import '../../../../tools/showTipView.dart'; import '../../../../tools/storage.dart'; import 'authorizedAdministratorList_logic.dart'; @@ -195,7 +196,19 @@ class _AuthorizedAdministratorListPageState SizedBox( width: 30.w, ), - Image.asset('images/controls_user.png', width: 60.w, height: 60.w), + SizedBox( + width: 60.w, + height: 60.w, + child: ClipRRect( + borderRadius: BorderRadius.circular(30.w), + child: CustomNetworkImage( + url: itemData.headUrl ?? '', + defaultUrl: 'images/controls_user.png', + width: 105.w, + height: 105.h, + ), + ), + ), SizedBox(width: 20.w), Expanded( child: Column( diff --git a/lib/mine/mineSet/lockUserManage/expireLockList/expireElectronicKey/expireLockList_page.dart b/lib/mine/mineSet/lockUserManage/expireLockList/expireElectronicKey/expireLockList_page.dart index e60c8a13..425330da 100755 --- a/lib/mine/mineSet/lockUserManage/expireLockList/expireElectronicKey/expireLockList_page.dart +++ b/lib/mine/mineSet/lockUserManage/expireLockList/expireElectronicKey/expireLockList_page.dart @@ -5,10 +5,12 @@ import 'package:flutter_slidable/flutter_slidable.dart'; import 'package:get/get.dart'; import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart'; import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireElectronicKey/expireLockList_entity.dart'; +import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireElectronicKey/expireLockList_state.dart'; import '../../../../../appRouters.dart'; import '../../../../../app_settings/app_colors.dart'; import '../../../../../tools/EasyRefreshTool.dart'; +import '../../../../../tools/customNetworkImage.dart'; import '../../../../../tools/noData.dart'; import 'expireLockList_logic.dart'; @@ -20,8 +22,8 @@ class ExpireLockListPage extends StatefulWidget { } class _ExpireLockListPageState extends State { - final logic = Get.put(ExpireLockListLogic()); - final state = Get.find().state; + final ExpireLockListLogic logic = Get.put(ExpireLockListLogic()); + final ExpireLockListState state = Get.find().state; Future getHttpData() async { logic.expireLockListRequest().then((ExpireLockListEntity value){ @@ -46,7 +48,7 @@ class _ExpireLockListPageState extends State { onLoad: (){ getHttpData(); }, - child: Obx(() => _buildMainUI()) + child: Obx(_buildMainUI) ); } @@ -56,14 +58,14 @@ class _ExpireLockListPageState extends State { : SlidableAutoCloseBehavior( child: ListView.separated( itemCount: state.dataList.length, - itemBuilder: (c, index) { + itemBuilder: (BuildContext c, int index) { ExpireLockItem indexEntity = state.dataList[index]; return Slidable( key:ValueKey(indexEntity.uid), endActionPane: ActionPane( extentRatio: 0.2, motion: const ScrollMotion(), - children: [ + children: [ SlidableAction( onPressed: (BuildContext context){ logic.deletKeyLogic(indexEntity); @@ -93,9 +95,9 @@ class _ExpireLockListPageState extends State { onTap: () async { if(itemData.keyType! == 4){ // 循环 - var data = await Get.toNamed(Routers.electronicKeyPeriodValidityPage, arguments: { - "pushType": 0, - "expireLockItem": itemData, + var data = await Get.toNamed(Routers.electronicKeyPeriodValidityPage, arguments: { + 'pushType': 0, + 'expireLockItem': itemData, }); if(data != null) { // setState(() { @@ -109,9 +111,9 @@ class _ExpireLockListPageState extends State { getHttpData(); } }else{ - var data = await Get.toNamed(Routers.electronicKeyDetailChangeDate, arguments: { - "pushType": 0, - "expireLockItem": itemData, + var data = await Get.toNamed(Routers.electronicKeyDetailChangeDate, arguments: { + 'pushType': 0, + 'expireLockItem': itemData, }); if(data != null) { setState(() { @@ -129,14 +131,22 @@ class _ExpireLockListPageState extends State { height: 90.h, color: Colors.white, child: Row( - children: [ + children: [ SizedBox( width: 30.w, ), - Image.asset( - 'images/controls_user.png', + SizedBox( width: 60.w, height: 60.w, + child: ClipRRect( + borderRadius: BorderRadius.circular(30.w), + child: CustomNetworkImage( + url: itemData.headUrl ?? '', + defaultUrl: 'images/controls_user.png', + width: 105.w, + height: 105.h, + ), + ), ), SizedBox( width: 20.w, @@ -144,10 +154,10 @@ class _ExpireLockListPageState extends State { Expanded( child: Column( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Row( mainAxisAlignment: MainAxisAlignment.start, - children: [ + children: [ Text( itemData.nickname ?? '', style: TextStyle( @@ -167,7 +177,7 @@ class _ExpireLockListPageState extends State { SizedBox(height: 10.h), Row( mainAxisAlignment: MainAxisAlignment.start, - children: [ + children: [ Text( logic.getExpireDateStr(itemData), style: TextStyle( diff --git a/lib/mine/mineSet/lockUserManage/lockUserManageList/lockUserManageList_page.dart b/lib/mine/mineSet/lockUserManage/lockUserManageList/lockUserManageList_page.dart index 9b0754e0..101d64b7 100755 --- a/lib/mine/mineSet/lockUserManage/lockUserManageList/lockUserManageList_page.dart +++ b/lib/mine/mineSet/lockUserManage/lockUserManageList/lockUserManageList_page.dart @@ -3,6 +3,7 @@ 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/electronicKey/massSendElectronicKey/massSendLockGroupList/lockUserList/lockUserList_entity.dart'; +import 'package:star_lock/mine/mineSet/lockUserManage/lockUserManageList/lockUserManageList_state.dart'; import 'package:star_lock/tools/noData.dart'; import '../../../../../appRouters.dart'; @@ -10,6 +11,7 @@ import '../../../../../app_settings/app_colors.dart'; import '../../../../../tools/titleAppBar.dart'; import '../../../../../translations/trans_lib.dart'; import '../../../../tools/EasyRefreshTool.dart'; +import '../../../../tools/customNetworkImage.dart'; import '../../../../tools/keySearchWidget.dart'; import '../../../../tools/showIosTipView.dart'; import 'lockUserManageList_logic.dart'; @@ -22,12 +24,14 @@ class LockUserManageListPage extends StatefulWidget { } class _LockUserManageListPageState extends State { - final logic = Get.put(LockUserManageListLogic()); - final state = Get.find().state; + final LockUserManageListLogic logic = Get.put(LockUserManageListLogic()); + final LockUserManageListState state = Get.find().state; Future getHttpData() async { logic.lockUserListRequest().then((LockUserListEntity value) { - if (mounted) setState(() {}); + if (mounted) { + setState(() {}); + } }); } @@ -46,7 +50,7 @@ class _LockUserManageListPageState extends State { barTitle: TranslationLoader.lanKeys!.lockUserManagement!.tr, haveBack: true, backgroundColor: AppColors.mainColor, - actionsList: [ + actionsList: [ TextButton( child: Text( TranslationLoader.lanKeys!.aboutToExpire!.tr, @@ -67,7 +71,7 @@ class _LockUserManageListPageState extends State { getHttpData(); }, child: Column( - children: [ + children: [ KeySearchWidget( editingController: state.searchController, onSubmittedAction: () { @@ -89,7 +93,7 @@ class _LockUserManageListPageState extends State { onPressed: () { Navigator.pushNamed( context, Routers.massSendElectronicKeyManagePage) - .then((value) { + .then((Object? value) { logic.lockUserListRequest(); }); }, @@ -121,22 +125,22 @@ class _LockUserManageListPageState extends State { : SlidableAutoCloseBehavior( child: ListView.separated( itemCount: state.dataList.length, - itemBuilder: (c, index) { - LockUserItemData indexEntity = state.dataList[index]; + itemBuilder: (BuildContext c, int index) { + final LockUserItemData indexEntity = state.dataList[index]; if (index < state.dataList.length) { return Slidable( key: ValueKey(indexEntity.uid), endActionPane: ActionPane( extentRatio: 0.2, motion: const ScrollMotion(), - children: [ + children: [ SlidableAction( onPressed: (BuildContext context) { showIosTipViewDialog(context, indexEntity); }, backgroundColor: Colors.red, foregroundColor: Colors.white, - label: '删除', + label: '删除'.tr, padding: EdgeInsets.only(left: 5.w, right: 5.w), ), ], @@ -161,7 +165,7 @@ class _LockUserManageListPageState extends State { return GestureDetector( onTap: () { Navigator.pushNamed(context, Routers.ownedKeyListPage, - arguments: {'uid': itemData.uid}); + arguments: {'uid': itemData.uid}); }, child: Container( height: 90.h, @@ -171,14 +175,20 @@ class _LockUserManageListPageState extends State { // borderRadius: BorderRadius.circular(10.w), // ), child: Row( - children: [ + children: [ + SizedBox(width: 30.w), SizedBox( - width: 30.w, - ), - Image.asset( - 'images/controls_user.png', width: 60.w, height: 60.w, + child: ClipRRect( + borderRadius: BorderRadius.circular(30.w), + child: CustomNetworkImage( + url: itemData.headUrl ?? '', + defaultUrl: 'images/controls_user.png', + width: 105.w, + height: 105.h, + ), + ), ), SizedBox( width: 20.w, @@ -186,10 +196,10 @@ class _LockUserManageListPageState extends State { Expanded( child: Column( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: [ Row( mainAxisAlignment: MainAxisAlignment.start, - children: [ + children: [ Text( itemData.nickname ?? '', style: TextStyle( @@ -200,7 +210,7 @@ class _LockUserManageListPageState extends State { SizedBox(height: 5.h), Row( mainAxisAlignment: MainAxisAlignment.start, - children: [ + children: [ Text( itemData.userid ?? '', style: TextStyle( diff --git a/lib/tools/pickers/pickers.dart b/lib/tools/pickers/pickers.dart index 44e6691d..baa58556 100755 --- a/lib/tools/pickers/pickers.dart +++ b/lib/tools/pickers/pickers.dart @@ -182,7 +182,8 @@ class Pickers { DateCallback? onChanged, DateCallback? onConfirm, Function(bool isCancel)? onCancel, - bool overlapTabBar = false}) { + bool overlapTabBar = false, + bool hourShow24 = false}) { pickerStyle ??= DefaultPickerStyle(); pickerStyle.context ??= context; @@ -212,6 +213,7 @@ class Pickers { } } + AppLog.log('picker Tip >>> hourShow24 : $hourShow24'); Navigator.of(context, rootNavigator: overlapTabBar).push(DatePickerRoute( mode: mode, initDate: selectDate, @@ -225,6 +227,7 @@ class Pickers { // theme: Theme.of(context, shadowThemeOnly: true), theme: Theme.of(context), barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel, + hourShow24: hourShow24, )); } } diff --git a/lib/tools/pickers/time_picker/route/date_picker_route.dart b/lib/tools/pickers/time_picker/route/date_picker_route.dart index ef5f3071..9f830eb5 100755 --- a/lib/tools/pickers/time_picker/route/date_picker_route.dart +++ b/lib/tools/pickers/time_picker/route/date_picker_route.dart @@ -35,6 +35,7 @@ class DatePickerRoute extends PopupRoute { this.onCancel, this.theme, this.barrierLabel, + this.hourShow24, RouteSettings? settings, }) : super(settings: settings); @@ -48,6 +49,7 @@ class DatePickerRoute extends PopupRoute { final DateCallback? onConfirm; final Function(bool isCancel)? onCancel; final PickerStyle? pickerStyle; + bool? hourShow24; @override Duration get transitionDuration => const Duration(milliseconds: 200); @@ -96,6 +98,7 @@ class DatePickerRoute extends PopupRoute { minDate: minDate, pickerStyle: pickerStyle!, route: this, + hourShow24: hourShow24 ?? false, ), ); if (theme != null) { @@ -115,6 +118,7 @@ class _PickerContentView extends StatefulWidget { required this.maxDate, required this.minDate, required this.route, + this.hourShow24 = false, }) : super(key: key); final DateMode? mode; @@ -126,9 +130,12 @@ class _PickerContentView extends StatefulWidget { late final PDuration maxDate; late final PDuration minDate; + // 是否显示24小时 + late final bool hourShow24; + @override State createState() => _PickerState( - this.mode, this.initData, this.maxDate, this.minDate, this.pickerStyle); + mode, initData, maxDate, minDate, pickerStyle, hourShow24); } class _PickerState extends State<_PickerContentView> { @@ -150,6 +157,9 @@ class _PickerState extends State<_PickerContentView> { late final PDuration maxDate; late final PDuration minDate; + // 是否显示24小时 + bool hourShow24 = false; + Animation? animation; Map scrollCtrl = {}; @@ -157,9 +167,9 @@ class _PickerState extends State<_PickerContentView> { late double pickerItemHeight; _PickerState(DateMode? mode, this._initSelectData, this.maxDate, this.minDate, - this._pickerStyle) { - this._dateItemModel = DateItemModel.parse(mode!); - this.pickerItemHeight = _pickerStyle.pickerItemHeight; + this._pickerStyle, this.hourShow24) { + _dateItemModel = DateItemModel.parse(mode!); + pickerItemHeight = _pickerStyle.pickerItemHeight; _init(); } @@ -246,7 +256,7 @@ class _PickerState extends State<_PickerContentView> { if (_dateItemModel.hour) { index = 0; int begin = 0; - int end = 23; + int end = hourShow24 ? 24 : 23; // 限制区域 if (intNotEmpty(minDate.hour)) { begin = minDate.hour!; @@ -255,7 +265,7 @@ class _PickerState extends State<_PickerContentView> { end = maxDate.hour!; } - _dateTimeData.hour = TimeUtils.calcHour(begin: begin, end: end); + _dateTimeData.hour = TimeUtils.calcHour(begin: begin, end: end, hourShow24: hourShow24); if (_initSelectData.hour != null) { index = _dateTimeData.hour.indexOf(_initSelectData.hour); diff --git a/lib/tools/pickers/time_picker/time_utils.dart b/lib/tools/pickers/time_picker/time_utils.dart index bcb183e7..e73cb579 100755 --- a/lib/tools/pickers/time_picker/time_utils.dart +++ b/lib/tools/pickers/time_picker/time_utils.dart @@ -22,9 +22,10 @@ class TimeUtils { } /// 时 - static List calcHour({int begin = 0, int end = 23}) { + static List calcHour({int begin = 0, int end = 23, bool hourShow24 = false}) { begin = begin < 0 ? 0 : begin; - end = end > 23 ? 23 : end; + int hour = hourShow24 ? 24 : 23; + end = end > hour ? hour : end; return _calcCount(begin, end); } diff --git a/lib/tools/showTipView.dart b/lib/tools/showTipView.dart index 31d2a350..c72db1b7 100755 --- a/lib/tools/showTipView.dart +++ b/lib/tools/showTipView.dart @@ -1,5 +1,6 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:get/get.dart'; import 'package:star_lock/app_settings/app_colors.dart'; @@ -95,14 +96,15 @@ class ShowTipView { } void showTFViewAlertDialog(TextEditingController controller, String title, - String tipTitle, Function sureClick) { + String tipTitle, Function sureClick, {List? inputFormatters}) { // 点击删除 开始扫描 showDialog( context: Get.context!, builder: (BuildContext context) { return ShowTFView( title: title, - tipTitle: tipTitle ?? "", + tipTitle: tipTitle, + inputFormatters: inputFormatters, controller: controller, sureClick: () { //发送删除锁请求 diff --git a/lib/tools/submitBtn.dart b/lib/tools/submitBtn.dart index 2fea82d7..53531afa 100755 --- a/lib/tools/submitBtn.dart +++ b/lib/tools/submitBtn.dart @@ -10,6 +10,20 @@ import '../app_settings/app_colors.dart'; * */ class SubmitBtn extends StatelessWidget { + + SubmitBtn({ + required this.btnName, Key? key, + this.borderRadius, + this.color, + this.padding, + this.onClick, + this.margin, + this.width, + this.backgroundColorList, + this.isDelete, + this.fontSize, + this.isDisabled, + }) : super(key: key); String? btnName; Function()? onClick; @@ -32,21 +46,6 @@ class SubmitBtn extends StatelessWidget { bool? isDisabled; - SubmitBtn({ - Key? key, - required this.btnName, - this.borderRadius, - this.color, - this.padding, - this.onClick, - this.margin, - this.width, - this.backgroundColorList, - this.isDelete, - this.fontSize, - this.isDisabled, - }) : super(key: key); - @override Widget build(BuildContext context) { return Container( @@ -113,16 +112,15 @@ class SubmitBtn extends StatelessWidget { * */ class AddBottomWhiteBtn extends StatelessWidget { + + AddBottomWhiteBtn({ + required this.btnName, Key? key, + this.onClick, + }) : super(key: key); String? btnName; Function()? onClick; - AddBottomWhiteBtn({ - Key? key, - required this.btnName, - this.onClick, - }) : super(key: key); - @override Widget build(BuildContext context) { return GestureDetector( @@ -167,16 +165,15 @@ class AddBottomWhiteBtn extends StatelessWidget { * */ class OutLineBtn extends StatelessWidget { + + OutLineBtn({ + required this.btnName, Key? key, + this.onClick, + }) : super(key: key); String? btnName; Function()? onClick; - OutLineBtn({ - Key? key, - required this.btnName, - this.onClick, - }) : super(key: key); - @override Widget build(BuildContext context) { return SizedBox( From ae0fcafb9e867164f68bbcc68e065645df73ada0 Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Mon, 3 Jun 2024 14:49:29 +0800 Subject: [PATCH 02/12] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E5=8D=A1/=E6=8C=87?= =?UTF-8?q?=E7=BA=B9/=E5=AF=86=E7=A0=81/=E6=8E=88=E6=9D=83=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=91=98=E5=88=97=E8=A1=A8=E4=BF=AE=E6=94=B9=E5=90=8D?= =?UTF-8?q?=E5=AD=97=E5=90=8E=E4=B8=8D=E6=9B=B4=E6=96=B0=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../authorizedAdminList_logic.dart | 15 +++ .../authorizedAdminList_page.dart | 7 +- .../electronicKeyDetail_page.dart | 119 +++++++++--------- .../electronicKeyList_logic.dart | 83 +++++++----- .../electronicKeyList_page.dart | 50 +++++--- .../entity/ElectronicKeyEntity.dart | 31 +++++ .../fingerprintList_logic.dart | 15 +++ .../fingerprintList/fingerprintList_page.dart | 19 +-- .../fingerprintList/fingerprint_entity.dart | 29 +++++ .../passwordKeyList/passwordKeyEntity.dart | 31 +++++ .../passwordKeyList_logic.dart | 14 +++ .../passwordKeyList/passwordKeyList_page.dart | 2 +- .../passwordKeyEntity.dart | 25 +--- lib/network/api.dart | 4 + lib/network/api_provider.dart | 29 ++++- lib/network/api_repository.dart | 24 ++++ 16 files changed, 356 insertions(+), 141 deletions(-) create mode 100755 lib/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyEntity.dart create mode 100755 lib/main/lockDetail/fingerprint/fingerprintList/fingerprint_entity.dart create mode 100755 lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyEntity.dart diff --git a/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_logic.dart b/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_logic.dart index c89ecb27..453707ad 100755 --- a/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_logic.dart +++ b/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_logic.dart @@ -1,6 +1,7 @@ import 'dart:async'; import 'package:star_lock/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_state.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyEntity.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart'; import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; @@ -59,6 +60,20 @@ class AuthorizedAdminListLogic extends BaseGetXController { }); } + //刷新单挑信息 + Future refreshIndividualKeys( + {required int lockId, required int keyId}) async { + final ElectronicKeyEntity entity = + await ApiRepository.to.electronicKey(lockId: lockId, keyId: keyId); + if (entity.errorCode!.codeIsSuccessful) { + final int index = state.itemDataList + .indexWhere((ElectronicKeyListItem item) => item.keyId == keyId); + state.itemDataList.removeAt(index); + state.itemDataList.insert(index, entity.data!); + } + } + + @override void onReady() { // TODO: implement onReady diff --git a/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart b/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart index 1fa9edf5..0dd1417f 100755 --- a/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart +++ b/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart @@ -150,8 +150,11 @@ class _AuthorizedAdminListPageState extends State { 'itemData': indexEntity, }).then((Object? val) { if (val != null) { - logic.mockNetworkDataRequest(); - setState(() {}); + logic + .refreshIndividualKeys( + lockId: indexEntity.lockId!, + keyId: indexEntity.keyId!) + .then((dynamic value) => setState(() {})); } }); }), diff --git a/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_page.dart b/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_page.dart index 1da7b39a..24f8972c 100755 --- a/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_page.dart +++ b/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_page.dart @@ -5,6 +5,7 @@ import 'package:flutter/services.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_logic.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_state.dart'; import '../../../../../appRouters.dart'; import '../../../../../app_settings/app_colors.dart'; @@ -27,8 +28,8 @@ class ElectronicKeyDetailPage extends StatefulWidget { } class _ElectronicKeyDetailPageState extends State { - final logic = Get.put(ElectronicKeyDetailLogic()); - final state = Get.find().state; + final ElectronicKeyDetailLogic logic = Get.put(ElectronicKeyDetailLogic()); + final ElectronicKeyDetailState state = Get.find().state; @override Widget build(BuildContext context) { @@ -39,7 +40,7 @@ class _ElectronicKeyDetailPageState extends State { barTitle: '钥匙详情'.tr, haveBack: true, actionsList: (state.keyType.value != 3) - ? [ + ? [ IconButton( icon: Image.asset( 'images/icon_bar_more.png', @@ -54,7 +55,7 @@ class _ElectronicKeyDetailPageState extends State { : null, backgroundColor: AppColors.mainColor), body: ListView( - children: [ + children: [ Obx(() => CommonItem( leftTitel: '姓名'.tr, rightTitle: state.keyName.value, @@ -62,7 +63,7 @@ class _ElectronicKeyDetailPageState extends State { isHaveLine: true, action: () { showCupertinoAlertDialog( - tipsTitle: "修改姓名".tr, alertEnum: ShowAlertEnum.name); + tipsTitle: '修改姓名'.tr, alertEnum: ShowAlertEnum.name); })), Obx(() => Visibility( visible: state.isRealNameAuth.value, @@ -73,7 +74,7 @@ class _ElectronicKeyDetailPageState extends State { isHaveLine: true, action: () { showCupertinoAlertDialog( - tipsTitle: "修改真实姓名".tr, + tipsTitle: '修改真实姓名'.tr, alertEnum: ShowAlertEnum.realName); }))), Obx(() => Visibility( @@ -85,7 +86,7 @@ class _ElectronicKeyDetailPageState extends State { isHaveLine: true, action: () { showCupertinoAlertDialog( - tipsTitle: "修改身份证号".tr, + tipsTitle: '修改身份证号'.tr, alertEnum: ShowAlertEnum.idCardNumber); }))), Obx(() => CommonItem( @@ -96,16 +97,14 @@ class _ElectronicKeyDetailPageState extends State { isHaveDirection: state.itemData.value.keyStatus! == XSConstantMacro.keyStatusExpired ? false - : state.keyType.value == 3 - ? false - : true, + : state.keyType.value != 3, isHaveLine: true, action: state.itemData.value.keyStatus! == XSConstantMacro.keyStatusExpired ? null : () async { if(state.itemData.value.keyStatus == XSConstantMacro.keyStatusFrozen){ - logic.showToast("冻结状态下不允许修改钥匙权限".tr); + logic.showToast('冻结状态下不允许修改钥匙权限'.tr); return; } @@ -113,14 +112,14 @@ class _ElectronicKeyDetailPageState extends State { // 限时/永久 var data = await Get.toNamed( Routers.electronicKeyDetailChangeDate, - arguments: { - "pushType": 0, - "itemData": state.itemData.value, + arguments: { + 'pushType': 0, + 'itemData': state.itemData.value, }); if (data != null) { setState(() { - state.starDate.value = data["beginTimeTimestamp"].toString(); - state.endDate.value = data["endTimeTimestamp"].toString(); + state.starDate.value = data['beginTimeTimestamp'].toString(); + state.endDate.value = data['endTimeTimestamp'].toString(); state.keyType.value = 2; }); } @@ -128,23 +127,23 @@ class _ElectronicKeyDetailPageState extends State { // 循环 var data = await Get.toNamed( Routers.electronicKeyPeriodValidityPage, - arguments: { - "pushType": 0, - "itemData": state.itemData.value, + arguments: { + 'pushType': 0, + 'itemData': state.itemData.value, }); if (data != null) { setState(() { - state.starDate.value = data["starDate"]; - state.endDate.value = data["endDate"]; - state.starTime.value = data["starTime"]; - state.endTime.value = data["endTime"]; - state.weekDay.value = data["validityValue"]; + state.starDate.value = data['starDate']; + state.endDate.value = data['endDate']; + state.starTime.value = data['starTime']; + state.endTime.value = data['endTime']; + state.weekDay.value = data['validityValue']; }); } } })), Obx(() => Visibility( - visible: state.keyType.value == 4 ? true : false, + visible: state.keyType.value == 4 , child: Obx(() => CommonItem( leftTitel: '有效日'.tr, rightTitle: logic.weekDayStr.join(','), @@ -152,63 +151,63 @@ class _ElectronicKeyDetailPageState extends State { isHaveLine: true, action: () async { if(state.itemData.value.keyStatus == XSConstantMacro.keyStatusFrozen){ - logic.showToast("冻结状态下不允许修改钥匙权限".tr); + logic.showToast('冻结状态下不允许修改钥匙权限'.tr); return; } var data = await Get.toNamed( Routers.electronicKeyPeriodValidityPage, - arguments: { - "pushType": 0, - "itemData": state.itemData.value, + arguments: { + 'pushType': 0, + 'itemData': state.itemData.value, }); if (data != null) { setState(() { - state.starDate.value = data["starDate"]; - state.endDate.value = data["endDate"]; - state.starTime.value = data["starTime"]; - state.endTime.value = data["endTime"]; - state.weekDay.value = data["validityValue"]; + state.starDate.value = data['starDate']; + state.endDate.value = data['endDate']; + state.starTime.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.starTime.value)}-${DateTool().dateToHNString(state.endTime.value)}", + '${DateTool().dateToHNString(state.starTime.value)}-${DateTool().dateToHNString(state.endTime.value)}', isHaveDirection: true, action: () async { if(state.itemData.value.keyStatus == XSConstantMacro.keyStatusFrozen){ - logic.showToast("冻结状态下不允许修改钥匙权限".tr); + logic.showToast('冻结状态下不允许修改钥匙权限'.tr); return; } var data = await Get.toNamed( Routers.electronicKeyPeriodValidityPage, - arguments: { - "pushType": 0, - "itemData": state.itemData.value, + arguments: { + 'pushType': 0, + 'itemData': state.itemData.value, }); if (data != null) { setState(() { - state.starDate.value = data["starDate"]; - state.endDate.value = data["endDate"]; - state.starTime.value = data["starTime"]; - state.endTime.value = data["endTime"]; - state.weekDay.value = data["validityValue"]; + state.starDate.value = data['starDate']; + state.endDate.value = data['endDate']; + state.starTime.value = data['starTime']; + state.endTime.value = data['endTime']; + state.weekDay.value = data['validityValue']; }); } })))), Container(height: 10.h), CommonItem( - leftTitel: "接收者".tr, - rightTitle: state.itemData.value.username ?? ""), + leftTitel: '接收者'.tr, + rightTitle: state.itemData.value.username ?? ''), const SizedBox(height: 1), CommonItem( - leftTitel: "发送人".tr, - rightTitle: state.itemData.value.senderUsername ?? ""), + leftTitel: '发送人'.tr, + rightTitle: state.itemData.value.senderUsername ?? ''), const SizedBox(height: 1), CommonItem( leftTitel: '发送时间'.tr, @@ -218,8 +217,8 @@ class _ElectronicKeyDetailPageState extends State { Visibility( visible: state.itemData.value.keyRight == 1 ? true : false, child: CommonItem( - leftTitel: "仅管理自己创建的用户".tr, - rightTitle: "", + leftTitel: '仅管理自己创建的用户'.tr, + rightTitle: '', isHaveRightWidget: true, isHaveLine: true, rightWidget: SizedBox( @@ -239,8 +238,8 @@ class _ElectronicKeyDetailPageState extends State { ? true : false, child: CommonItem( - leftTitel: "远程开锁".tr, - rightTitle: "", + leftTitel: '远程开锁'.tr, + rightTitle: '', isHaveRightWidget: true, isHaveLine: true, rightWidget: SizedBox( @@ -248,17 +247,17 @@ class _ElectronicKeyDetailPageState extends State { ), Obx(() => CommonItem( leftTitel: '实名认证'.tr, - rightTitle: "", + rightTitle: '', isHaveRightWidget: true, rightWidget: SizedBox(width: 60.w, child: _realNameAuthSwitch()))), Container(height: 10.h), CommonItem( leftTitel: '操作记录'.tr, - rightTitle: "", + rightTitle: '', isHaveDirection: true, action: () { - Get.toNamed(Routers.lockOperatingRecordPage, arguments: { + Get.toNamed(Routers.lockOperatingRecordPage, arguments: { 'type': 5, 'id': state.itemData.value.keyId.toString(), 'recordName': state.itemData.value.keyName @@ -289,7 +288,7 @@ class _ElectronicKeyDetailPageState extends State { trackColor: CupertinoColors.systemGrey5, thumbColor: CupertinoColors.white, value: state.isRealNameAuth.value, - onChanged: (value) { + onChanged: (bool value) { if (!state.isRealNameAuth.value) { logic.checkRealNameStatus(1); } else { @@ -305,7 +304,7 @@ class _ElectronicKeyDetailPageState extends State { trackColor: CupertinoColors.systemGrey5, thumbColor: CupertinoColors.white, value: state.isRemoteUnlock.value, - onChanged: (value) { + onChanged: (bool value) { state.isRemoteUnlock.value = !state.isRemoteUnlock.value; logic.updateKeyDateRequest(2); }, @@ -318,7 +317,7 @@ class _ElectronicKeyDetailPageState extends State { trackColor: CupertinoColors.systemGrey5, thumbColor: CupertinoColors.white, value: state.onlyManageYouCreatesUser.value, - onChanged: (value) { + onChanged: (bool value) { setState(() { state.onlyManageYouCreatesUser.value = !state.onlyManageYouCreatesUser.value; @@ -335,7 +334,7 @@ class _ElectronicKeyDetailPageState extends State { builder: (BuildContext context) { return ShowTFView( title: tipsTitle, - tipTitle: "请输入".tr, + tipTitle: '请输入'.tr, controller: logic.getCurrentController(alertEnum), inputFormatters: [ FilteringTextInputFormatter.deny('\n'), diff --git a/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_logic.dart b/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_logic.dart index 2da4162c..9b9b23ed 100755 --- a/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_logic.dart +++ b/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_logic.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'package:get/get.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_state.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyEntity.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart'; import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; @@ -14,24 +15,29 @@ class ElectronicKeyListLogic extends BaseGetXController { final ElectronicKeyListState state = ElectronicKeyListState(); //请求电子钥匙列表 - Future mockNetworkDataRequest() async { - ElectronicKeyListEntity entity = await ApiRepository.to.electronicKeyList( - endDate: '0', - keyId: CommonDataManage().currentKeyInfo.keyId.toString(), - keyStatus: '', - keyRight: '0', - lockId: CommonDataManage().currentKeyInfo.lockId.toString(), - pageNo: pageNo.toString(), - pageSize: pageSize.toString(), - startDate: '0', - searchStr: state.searchController.text); + Future mockNetworkDataRequest( + {bool isRefresh = false}) async { + if (isRefresh) { + pageNo = 0; + } + final ElectronicKeyListEntity entity = await ApiRepository.to + .electronicKeyList( + endDate: '0', + keyId: CommonDataManage().currentKeyInfo.keyId.toString(), + keyStatus: '', + keyRight: '0', + lockId: CommonDataManage().currentKeyInfo.lockId.toString(), + pageNo: pageNo.toString(), + pageSize: pageSize.toString(), + startDate: '0', + searchStr: state.searchController.text); if (entity.errorCode!.codeIsSuccessful) { if (pageNo == 1) { - state.itemDataList.value = entity.data!.itemList!; + state.itemDataList.value = entity.data!.itemList; pageNo++; } else { - if (entity.data!.itemList!.isNotEmpty) { - state.itemDataList.value.addAll(entity.data!.itemList!); + if (entity.data!.itemList.isNotEmpty) { + state.itemDataList.addAll(entity.data!.itemList); pageNo++; } } @@ -39,12 +45,26 @@ class ElectronicKeyListLogic extends BaseGetXController { return entity; } + //刷新单挑信息 + Future refreshIndividualKeys( + {required int lockId, required int keyId}) async { + final ElectronicKeyEntity entity = + await ApiRepository.to.electronicKey(lockId: lockId, keyId: keyId); + if (entity.errorCode!.codeIsSuccessful) { + final int index = state.itemDataList + .indexWhere((ElectronicKeyListItem item) => item.keyId == keyId); + state.itemDataList.removeAt(index); + state.itemDataList.insert(index, entity.data!); + } + } + //电子钥匙重置请求 Future resetElectronicKeyListRequest() async { - ElectronicKeyListEntity entity = await ApiRepository.to - .resetElectronicKey(CommonDataManage().currentKeyInfo.lockId.toString(), '0'); + final ElectronicKeyListEntity entity = await ApiRepository.to + .resetElectronicKey( + CommonDataManage().currentKeyInfo.lockId.toString(), '0'); if (entity.errorCode!.codeIsSuccessful) { - showToast("重置成功".tr, something: (){ + showToast('重置成功'.tr, something: () { pageNo = 1; mockNetworkDataRequest(); }); @@ -53,28 +73,28 @@ class ElectronicKeyListLogic extends BaseGetXController { //删除电子钥匙名称请求 Future deleteKeyRequest(String keyId, int includeUnderlings) async { - ElectronicKeyListEntity entity = - await ApiRepository.to.deleteElectronicKey( - keyId:keyId, - includeUnderlings:includeUnderlings - ); + final ElectronicKeyListEntity entity = await ApiRepository.to + .deleteElectronicKey( + keyId: keyId, includeUnderlings: includeUnderlings); if (entity.errorCode!.codeIsSuccessful) { - showToast("删除成功".tr,something: (){ + showToast('删除成功'.tr, something: () { pageNo = 1; mockNetworkDataRequest(); }); } } - deletKeyLogic(ElectronicKeyListItem electronicKeyListItem){ - if(electronicKeyListItem.keyRight == 1){ + deletKeyLogic(ElectronicKeyListItem electronicKeyListItem) { + if (electronicKeyListItem.keyRight == 1) { // 授权管理员 - ShowTipView().showDeleteAdministratorIsHaveAllDataDialog('同时删除其发送的所有钥匙,钥匙删除后不能恢复'.tr, (isAllData) { - deleteKeyRequest(electronicKeyListItem.keyId.toString(), isAllData ? 1 : 0); + ShowTipView().showDeleteAdministratorIsHaveAllDataDialog( + '同时删除其发送的所有钥匙,钥匙删除后不能恢复'.tr, (bool isAllData) { + deleteKeyRequest( + electronicKeyListItem.keyId.toString(), isAllData ? 1 : 0); }); - }else{ + } else { // 普通用户 - ShowTipView().showIosTipWithContentDialog("删除钥匙会在用户APP连网后生效".tr,(){ + ShowTipView().showIosTipWithContentDialog('删除钥匙会在用户APP连网后生效'.tr, () { deleteKeyRequest(electronicKeyListItem.keyId.toString(), 0); }); } @@ -82,9 +102,12 @@ class ElectronicKeyListLogic extends BaseGetXController { /// 刷新电子钥匙列表 StreamSubscription? _getElectronicKeyListRefreshUIEvent; + void _getElectronicKeyListRefreshUIAction() { // 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus - _getElectronicKeyListRefreshUIEvent = eventBus.on().listen((event) { + _getElectronicKeyListRefreshUIEvent = eventBus + .on() + .listen((ElectronicKeyListRefreshUI event) { pageNo = 1; mockNetworkDataRequest(); }); diff --git a/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart b/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart index 504bef2a..aea938fe 100755 --- a/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart +++ b/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart @@ -1,4 +1,3 @@ - import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_slidable/flutter_slidable.dart'; @@ -63,9 +62,11 @@ class _ElectronicKeyListPageState extends State { ), onPressed: () async { // 获取是否是演示模式 演示模式不获取接口 - final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); + final bool? isDemoMode = + await Storage.getBool(ifIsDemoModeOrNot); if (isDemoMode == false) { - ShowTipView().showIosTipWithContentDialog('该锁的电子钥匙都将被删除'.tr, logic.resetElectronicKeyListRequest); + ShowTipView().showIosTipWithContentDialog( + '该锁的电子钥匙都将被删除'.tr, logic.resetElectronicKeyListRequest); } else { logic.showToast('演示模式'.tr); } @@ -101,7 +102,8 @@ class _ElectronicKeyListPageState extends State { AddBottomWhiteBtn( btnName: TranslationLoader.lanKeys!.sendKey!.tr, onClick: () { - Navigator.pushNamed(context, Routers.sendElectronicKeyPage).then((Object? val) { + Navigator.pushNamed(context, Routers.sendElectronicKeyPage) + .then((Object? val) { if (val != null) { logic.pageNo = 1; mockRequest(); @@ -130,7 +132,8 @@ class _ElectronicKeyListPageState extends State { shrinkWrap: true, itemCount: state.itemDataList.value.length, itemBuilder: (BuildContext c, int index) { - ElectronicKeyListItem indexEntity = state.itemDataList.value[index]; + ElectronicKeyListItem indexEntity = + state.itemDataList.value[index]; String useDateStr = ''; //使用期限 String keyStatus = ''; //钥匙状态 @@ -138,7 +141,8 @@ class _ElectronicKeyListPageState extends State { useDateStr = getUseDateStr(indexEntity); //钥匙状态 - keyStatus = XSConstantMacro.getKeyStatusStr(indexEntity.keyStatus!); + keyStatus = + XSConstantMacro.getKeyStatusStr(indexEntity.keyStatus!); //是否为管理钥匙 bool isAdminKey = false; @@ -171,15 +175,18 @@ class _ElectronicKeyListPageState extends State { useDateStr, keyStatus, isAdminKey, - indexEntity.remoteEnable == 1 ? true : false, () { + indexEntity.remoteEnable == 1, () { Navigator.pushNamed( context, Routers.electronicKeyDetailPage, arguments: { 'itemData': indexEntity, }).then((Object? val) { if (val != null) { - logic.mockNetworkDataRequest(); - setState(() {}); + logic + .refreshIndividualKeys( + lockId: indexEntity.lockId!, + keyId: indexEntity.keyId!) + .then((dynamic value) => setState(() {})); } }); }), @@ -210,11 +217,13 @@ class _ElectronicKeyListPageState extends State { '${startDateStr.toLocal().toString().substring(0, 16)}-${endDateStr.toLocal().toString().substring(0, 16)}'; } else if (indexEntity.keyType == XSConstantMacro.keyTypeLong) { //永久 - useDateStr = '${sendDateStr.toLocal().toString().substring(0, 16)} ${"永久".tr}'; + useDateStr = + '${sendDateStr.toLocal().toString().substring(0, 16)} ${"永久".tr}'; } else if (indexEntity.keyType == XSConstantMacro.keyTypeOnce) { //单次 useDateStr = '单次'.tr; - useDateStr = '${sendDateStr.toLocal().toString().substring(0, 16)} ${"单次".tr}'; + useDateStr = + '${sendDateStr.toLocal().toString().substring(0, 16)} ${"单次".tr}'; } else if (indexEntity.keyType == XSConstantMacro.keyTypeLoop) { //循环 useDateStr = '循环'.tr; @@ -223,8 +232,14 @@ class _ElectronicKeyListPageState extends State { return useDateStr; } - Widget _electronicKeyItem(String avatarURL, String receiveUser, - String useDate, String keyStatus, bool isAdminKey, bool isRemteUnlocking, Function() action) { + Widget _electronicKeyItem( + String avatarURL, + String receiveUser, + String useDate, + String keyStatus, + bool isAdminKey, + bool isRemteUnlocking, + Function() action) { return GestureDetector( onTap: action, child: Container( @@ -261,10 +276,10 @@ class _ElectronicKeyListPageState extends State { SizedBox(width: 5.w), isRemteUnlocking ? Image.asset( - 'images/icon_electronicKey_remteUnlocking.png', - width: 24.w, - height: 20.w, - ) + 'images/icon_electronicKey_remteUnlocking.png', + width: 24.w, + height: 20.w, + ) : Container(), SizedBox(width: 5.w), isAdminKey @@ -308,5 +323,4 @@ class _ElectronicKeyListPageState extends State { ), ); } - } diff --git a/lib/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyEntity.dart b/lib/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyEntity.dart new file mode 100755 index 00000000..667aa707 --- /dev/null +++ b/lib/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyEntity.dart @@ -0,0 +1,31 @@ +import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart'; + +class ElectronicKeyEntity { + int? errorCode; + String? description; + String? errorMsg; + ElectronicKeyListItem? data; + + ElectronicKeyEntity( + {this.errorCode, this.description, this.errorMsg, this.data}); + + ElectronicKeyEntity.fromJson(Map json) { + errorCode = json['errorCode']; + description = json['description']; + errorMsg = json['errorMsg']; + data = json['data'] != null + ? ElectronicKeyListItem.fromJson(json['data']) + : null; + } + + Map toJson() { + final Map data = {}; + data['errorCode'] = errorCode; + data['description'] = description; + data['errorMsg'] = errorMsg; + if (this.data != null) { + data['data'] = this.data!.toJson(); + } + return data; + } +} diff --git a/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_logic.dart b/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_logic.dart index f7f2d2b7..178733e2 100755 --- a/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_logic.dart +++ b/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_logic.dart @@ -3,6 +3,8 @@ import 'dart:async'; import 'package:flutter_blue_plus/flutter_blue_plus.dart'; import 'package:get/get.dart'; import 'package:star_lock/login/login/entity/LoginEntity.dart'; +import 'package:star_lock/main/lockDetail/fingerprint/fingerprintList/fingerprint_entity.dart'; +import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart'; import 'package:star_lock/tools/baseGetXController.dart'; import '../../../../blue/blue_manage.dart'; import '../../../../blue/io_protocol/io_addFingerprintWithTimeCycleCoercion.dart'; @@ -427,6 +429,19 @@ class FingerprintListLogic extends BaseGetXController { return keyDateTypeStr; } + //刷新单条信息 + Future refreshIndividualKeys( + {required int fingerprintId}) async { + final FingerprintEntity entity = + await ApiRepository.to.getFingerprintsData(fingerprintId); + if (entity.errorCode!.codeIsSuccessful) { + final int index = state.fingerprintItemListData + .indexWhere((FingerprintItemData item) => item.fingerprintId == fingerprintId); + state.fingerprintItemListData.removeAt(index); + state.fingerprintItemListData.insert(index, entity.data!); + } + } + @override Future onReady() async { super.onReady(); diff --git a/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart b/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart index d18ee3bc..f2868a9b 100755 --- a/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart +++ b/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart @@ -71,14 +71,14 @@ class _FingerprintListPageState extends State var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); if (isDemoMode == false) { ShowTipView().showIosTipWithContentDialog( - "重置后,该锁的指纹都将被删除哦,确认要重置吗?".tr, () async { + '重置后,该锁的指纹都将被删除哦,确认要重置吗?'.tr, () async { state.isDeletAll = true; - state.deletKeyID = "1"; + state.deletKeyID = '1'; state.deletFingerNo = 0; logic.senderAddFingerprint(); }); } else { - logic.showToast("演示模式".tr); + logic.showToast('演示模式'.tr); } }, ), @@ -109,8 +109,8 @@ class _FingerprintListPageState extends State onClick: () async { var data = await Get.toNamed(Routers.addFingerprintTypePage, arguments: { - "lockId": state.lockId.value, - "fromType": 1 // 1从添加钥匙列表进入 2从考勤添加员工入口进入 + 'lockId': state.lockId.value, + 'fromType': 1 // 1从添加钥匙列表进入 2从考勤添加员工入口进入 }); if (data != null) { getHttpData(isRefresh: true); @@ -142,7 +142,7 @@ class _FingerprintListPageState extends State SlidableAction( onPressed: (BuildContext context) { ShowTipView().showIosTipWithContentDialog( - "确定要删除吗?".tr, () async { + '确定要删除吗?'.tr, () async { state.isDeletAll = false; state.deletKeyID = fingerprintItemData.fingerprintId.toString(); @@ -165,10 +165,13 @@ class _FingerprintListPageState extends State logic.getKeyDateType(fingerprintItemData), () async { var data = await Get.toNamed(Routers.fingerprintDetailPage, arguments: { - "fingerprintItemData": fingerprintItemData, + 'fingerprintItemData': fingerprintItemData, }); if (data != null) { - getHttpData(isRefresh: true); + logic + .refreshIndividualKeys( + fingerprintId: fingerprintItemData.fingerprintId!) + .then((dynamic value) => setState(() {})); } }), ); diff --git a/lib/main/lockDetail/fingerprint/fingerprintList/fingerprint_entity.dart b/lib/main/lockDetail/fingerprint/fingerprintList/fingerprint_entity.dart new file mode 100755 index 00000000..06e08366 --- /dev/null +++ b/lib/main/lockDetail/fingerprint/fingerprintList/fingerprint_entity.dart @@ -0,0 +1,29 @@ +import 'package:star_lock/main/lockDetail/fingerprint/fingerprintList/fingerprintListData_entity.dart'; + +class FingerprintEntity { + + FingerprintEntity( + {this.errorCode, this.description, this.errorMsg, this.data}); + + FingerprintEntity.fromJson(Map json) { + errorCode = json['errorCode']; + description = json['description']; + errorMsg = json['errorMsg']; + data = json['data'] != null ? FingerprintItemData.fromJson(json['data']) : null; + } + int? errorCode; + String? description; + String? errorMsg; + FingerprintItemData? data; + + Map toJson() { + final Map data = {}; + data['errorCode'] = errorCode; + data['description'] = description; + data['errorMsg'] = errorMsg; + if (this.data != null) { + data['data'] = this.data!.toJson(); + } + return data; + } +} diff --git a/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyEntity.dart b/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyEntity.dart new file mode 100755 index 00000000..d5fd49f6 --- /dev/null +++ b/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyEntity.dart @@ -0,0 +1,31 @@ +import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart'; + +class PasswordKeyEntity { + int? errorCode; + String? description; + String? errorMsg; + PasswordKeyListItem? data; + + PasswordKeyEntity( + {this.errorCode, this.description, this.errorMsg, this.data}); + + PasswordKeyEntity.fromJson(Map json) { + errorCode = json['errorCode']; + description = json['description']; + errorMsg = json['errorMsg']; + data = json['data'] != null + ? PasswordKeyListItem.fromJson(json['data']) + : null; + } + + Map toJson() { + final Map data = {}; + data['errorCode'] = errorCode; + data['description'] = description; + data['errorMsg'] = errorMsg; + if (this.data != null) { + data['data'] = this.data!.toJson(); + } + return data; + } +} diff --git a/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_logic.dart b/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_logic.dart index 529dcfdb..21572725 100755 --- a/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_logic.dart +++ b/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_logic.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'package:flutter_blue_plus/flutter_blue_plus.dart'; import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart'; import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart'; import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_state.dart'; import 'package:star_lock/network/api_repository.dart'; @@ -391,6 +392,19 @@ class PasswordKeyListLogic extends BaseGetXController { return useDateStr; } + //刷新单条信息 + Future refreshIndividualKeys( + {required int lockId, required int keyboardPwdId}) async { + final PasswordKeyEntity entity = + await ApiRepository.to.passwordKey(lockId, keyboardPwdId); + if (entity.errorCode!.codeIsSuccessful) { + final int index = state.itemDataList + .indexWhere((PasswordKeyListItem item) => item.keyboardPwdId == keyboardPwdId); + state.itemDataList.removeAt(index); + state.itemDataList.insert(index, entity.data!); + } + } + /// 刷新密码列表 StreamSubscription? _getPasswordListRefreshUIEvent; void _getPasswordListRefreshUIAction() { diff --git a/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart b/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart index a35c73a8..b6c79629 100755 --- a/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart +++ b/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart @@ -165,7 +165,7 @@ class _PasswordKeyListPageState extends State Navigator.pushNamed(context, Routers.passwordKeyDetailPage, arguments: {'itemData': passwordKeyListItem}) .then((Object? val) { if (val != null) { - getHttpData(isRefresh: true); + // getHttpData(isRefresh: true); } }); }), diff --git a/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyEntity.dart b/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyEntity.dart index 6bdebb48..76a10f4f 100755 --- a/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyEntity.dart +++ b/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyEntity.dart @@ -1,8 +1,10 @@ +import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart'; + class PasswordKeyEntity { int? errorCode; String? description; String? errorMsg; - PasswordKeyData? data; + PasswordKeyListItem? data; PasswordKeyEntity( {this.errorCode, this.description, this.errorMsg, this.data}); @@ -11,7 +13,7 @@ class PasswordKeyEntity { errorCode = json['errorCode']; description = json['description']; errorMsg = json['errorMsg']; - data = json['data'] != null ? PasswordKeyData.fromJson(json['data']) : null; + data = json['data'] != null ? PasswordKeyListItem.fromJson(json['data']) : null; } Map toJson() { @@ -25,22 +27,3 @@ class PasswordKeyEntity { return data; } } - -class PasswordKeyData { - String? keyboardPwd; - int? keyboardPwdId; - - PasswordKeyData({this.keyboardPwd, this.keyboardPwdId}); - - PasswordKeyData.fromJson(Map json) { - keyboardPwd = json['keyboardPwd']; - keyboardPwdId = json['keyboardPwdId']; - } - - Map toJson() { - final Map data = {}; - data['keyboardPwd'] = keyboardPwd; - data['keyboardPwdId'] = keyboardPwdId; - return data; - } -} diff --git a/lib/network/api.dart b/lib/network/api.dart index af2786e3..bebe26d3 100755 --- a/lib/network/api.dart +++ b/lib/network/api.dart @@ -30,6 +30,7 @@ abstract class Api { '/key/modifyKeyNameForAdmin'; //编辑电子钥匙名字 final String updateKeyDateURL = '/key/updateKeyDate'; //编辑电子钥匙的有效期、有效时间、有效日 final String passwordKeyListURL = '/keyboardPwd/listSendRecords'; //密码钥匙列表 + final String passwordKeyDetailURL = '/keyboardPwd/detail'; //密码获取 final String keyboardPwdResetURL = '/keyboardPwd/reset'; //密码钥匙重置 final String deleteElectronicKeyURL = '/key/delete'; //删除电子钥匙 final String deleteKeyboardPwdURL = '/keyboardPwd/delete'; //删除密码 @@ -101,6 +102,8 @@ abstract class Api { final String editCheckInSetInfoURL = '/attendanceCompany/update'; // 修改考勤设置信息 final String getFingerprintListURL = '/fingerprint/list'; // 指纹列表 + final String getFingerprintDetailURL = + '/fingerprint/detail'; // 指纹详情 final String addFingerprintURL = '/fingerprint/add'; // 添加指纹 final String editFingerprintURL = '/fingerprint/changePeriod'; // 编辑指纹 final String deleteFingerprintURL = '/fingerprint/delete'; // 删除指纹 @@ -241,4 +244,5 @@ abstract class Api { final String getNoticeTemplateURL = '/key/getNoticeTemplate'; //获取短信或者邮箱模板 final String appGetAppInfoURL = '/app/getAppInfo'; //获取APP基本信息 final String appGetFwVersionURL = '/app/getFwVersion'; //获取固件信息 + final String keydetail = ' /key/detail'; //获取钥匙详情 } diff --git a/lib/network/api_provider.dart b/lib/network/api_provider.dart index 8e0c1718..1e61ffa1 100755 --- a/lib/network/api_provider.dart +++ b/lib/network/api_provider.dart @@ -126,6 +126,16 @@ class ApiProvider extends BaseProvider { 'searchStr': searchStr })); + Future electronicKey( + int lockId, int keyId + ) => + post( + keydetail.toUrl, + jsonEncode({ + 'lockId': lockId.toString(), + 'keyId': keyId.toString(), + })); + Future sendElectronicKey( int createUser, String countryCode, @@ -439,6 +449,14 @@ class ApiProvider extends BaseProvider { 'searchStr': searchStr })); + Future passwordKey(int lockId, int keyboardPwdId,) => + post( + passwordKeyDetailURL.toUrl, + jsonEncode({ + 'lockId': lockId, + 'keyboardPwdId': keyboardPwdId + })); + Future resetPasswordKey(String lockId, String operatorUid) => post( resetPasswordURL.toUrl, jsonEncode({'lockId': lockId, 'operatorUid': operatorUid})); @@ -1097,9 +1115,18 @@ class ApiProvider extends BaseProvider { 'staffId': staffId, })); + // 获取指纹详情 + Future getFingerprintsData( + int fingerprintId) => + post( + getFingerprintDetailURL.toUrl, + jsonEncode({ + 'fingerprintId': fingerprintId, + })); + // 获取指纹列表 Future getFingerprintsListData( - String lockId, String pageNo, String pageSize, String searchStr) => + String lockId, String pageNo, String pageSize, String searchStr) => post( getFingerprintListURL.toUrl, jsonEncode({ diff --git a/lib/network/api_repository.dart b/lib/network/api_repository.dart index 6da98b73..18475248 100755 --- a/lib/network/api_repository.dart +++ b/lib/network/api_repository.dart @@ -4,10 +4,12 @@ import 'package:star_lock/login/login/app_get_version.dart'; import 'package:star_lock/login/selectCountryRegion/common/countryRegionEntity.dart'; import 'package:star_lock/main/lockDetail/authorizedAdmin/authorizedAdmin/notice_template_entity.dart'; import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_entity.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyEntity.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart'; import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/lockUserList/lockUserList_entity.dart'; import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart'; import 'package:star_lock/main/lockDetail/face/addFace/addFace_entity.dart'; +import 'package:star_lock/main/lockDetail/fingerprint/fingerprintList/fingerprint_entity.dart'; import 'package:star_lock/main/lockDetail/lockSet/basicInformation/basicInformation/KeyDetailEntity.dart'; import 'package:star_lock/main/lockDetail/lockSet/lockEscalation/version_entity.dart'; import 'package:star_lock/main/lockDetail/messageWarn/lockUser/lockUser_entity.dart'; @@ -169,6 +171,14 @@ class ApiRepository { return ElectronicKeyListEntity.fromJson(res.body); } + //获取电子钥匙 + Future electronicKey({ + required int lockId,required int keyId + }) async { + final res = await apiProvider.electronicKey(lockId,keyId); + return ElectronicKeyEntity.fromJson(res.body); + } + //发送电子钥匙 Future sendElectronicKey( {required int createUser, @@ -412,6 +422,14 @@ class ApiRepository { return PasswordKeyListEntity.fromJson(res.body); } + //密码获取 + Future passwordKey( int lockId,int keyboardPwdId) async { + final res = await apiProvider.passwordKey( + lockId, keyboardPwdId); + return PasswordKeyEntity.fromJson(res.body); + } + + //重置密码钥匙 Future resetPasswordKey( String lockId, String operatorUid) async { @@ -1289,6 +1307,12 @@ class ApiRepository { return FingerprintListDataEntity.fromJson(res.body); } + //指纹获取 + Future getFingerprintsData(int fingerprintId) async { + final res = await apiProvider.getFingerprintsData(fingerprintId); + return FingerprintEntity.fromJson(res.body); + } + // 添加指纹 Future addFingerprintsData({ required String lockId, From 22d6388bff49fd2de9e0e878d2fb2c3b29415440 Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Mon, 3 Jun 2024 15:27:15 +0800 Subject: [PATCH 03/12] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E9=97=AD=E9=94=81?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E6=8F=90=E7=A4=BA=E8=AF=AD=E4=B8=80=E7=9B=B4?= =?UTF-8?q?=E9=97=AA=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/main/lockDetail/lockDetail/lockDetail_logic.dart | 2 ++ lib/network/api_provider_base.dart | 5 +++-- lib/network/response_interceptor_log.dart | 1 - 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/main/lockDetail/lockDetail/lockDetail_logic.dart b/lib/main/lockDetail/lockDetail/lockDetail_logic.dart index bae84a18..5d481374 100755 --- a/lib/main/lockDetail/lockDetail/lockDetail_logic.dart +++ b/lib/main/lockDetail/lockDetail/lockDetail_logic.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'package:flutter/scheduler.dart'; import 'package:flutter_blue_plus/flutter_blue_plus.dart'; +import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:get/get.dart'; import 'package:intl/intl.dart'; import 'package:permission_handler/permission_handler.dart'; @@ -66,6 +67,7 @@ class LockDetailLogic extends BaseGetXController { state.iSClosedUnlockSuccessfulPopup.value = true; cancelBlueConnetctToastTimer(); state.closedUnlockSuccessfulTimer?.cancel(); + EasyLoading.dismiss(); // 如果没有点击关闭弹窗,3秒后自动关闭 state.closedUnlockSuccessfulTimer = Timer.periodic(3.seconds, (Timer timer) { diff --git a/lib/network/api_provider_base.dart b/lib/network/api_provider_base.dart index b67ae870..1c29ae6e 100755 --- a/lib/network/api_provider_base.dart +++ b/lib/network/api_provider_base.dart @@ -51,9 +51,10 @@ class BaseProvider extends GetConnect with Api { query: query, decoder: decoder, uploadProgress: uploadProgress); + if (EasyLoading.isShow && !isUnShowLoading!) { + await EasyLoading.dismiss(animation: true); + } if (res.body == null) { - if (EasyLoading.isShow) await EasyLoading.dismiss(animation: true); - // EasyLoading.showToast("Network Error!", duration: 2000.milliseconds); if (res.statusCode == null && isShowErrMsg!) { EasyLoading.showToast('网络访问失败,请检查网络是否正常'.tr, diff --git a/lib/network/response_interceptor_log.dart b/lib/network/response_interceptor_log.dart index 85890536..0de1e1e3 100755 --- a/lib/network/response_interceptor_log.dart +++ b/lib/network/response_interceptor_log.dart @@ -6,6 +6,5 @@ import 'package:star_lock/app_settings/app_settings.dart'; FutureOr responseLogInterceptor(Request request, Response response) { AppLog.log('HTTP request:${request.url}\n RESPONSE => stataCode:${response.statusCode} ${response.bodyString}'); // \n ${response.headers} - EasyLoading.dismiss(animation: true); return response; } From f9fdb1b6cebb427272b97a91ba78bebd91738967 Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Mon, 3 Jun 2024 16:11:49 +0800 Subject: [PATCH 04/12] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E9=94=81=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E5=90=8D=E5=AD=97=E8=BF=87=E9=95=BF=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- images/lan/lan_en.json | 3 +- images/lan/lan_keys.json | 3 +- images/lan/lan_zh.json | 3 +- .../lockDetail/lockDetail_main_page.dart | 3 +- .../lockDetail/lockDetail_page.dart | 32 +++++++++++++++++-- .../lockMian/lockList/lockList_xhj_page.dart | 30 +++++++++++------ lib/main/lockMian/lockMain/lockMain_page.dart | 6 ++-- 7 files changed, 59 insertions(+), 21 deletions(-) diff --git a/images/lan/lan_en.json b/images/lan/lan_en.json index 5bcbc28b..28822bac 100755 --- a/images/lan/lan_en.json +++ b/images/lan/lan_en.json @@ -861,5 +861,6 @@ "四": "Thu", "五": "Fri", "六": "Sat", - "日": "Sun" + "日": "Sun", + "星星锁": "Star lock" } diff --git a/images/lan/lan_keys.json b/images/lan/lan_keys.json index 2f33cfae..9040b3cb 100755 --- a/images/lan/lan_keys.json +++ b/images/lan/lan_keys.json @@ -893,5 +893,6 @@ "四":"四", "五":"五", "六":"六", - "日":"日" + "日":"日", + "星星锁": "星星锁" } diff --git a/images/lan/lan_zh.json b/images/lan/lan_zh.json index c9d9e29b..dc87d9c8 100755 --- a/images/lan/lan_zh.json +++ b/images/lan/lan_zh.json @@ -863,5 +863,6 @@ "四": "四", "五": "五", "六": "六", - "日": "日" + "日": "日", + "星星锁": "星星锁" } diff --git a/lib/main/lockDetail/lockDetail/lockDetail_main_page.dart b/lib/main/lockDetail/lockDetail/lockDetail_main_page.dart index 57a5b20a..a3f43790 100755 --- a/lib/main/lockDetail/lockDetail/lockDetail_main_page.dart +++ b/lib/main/lockDetail/lockDetail/lockDetail_main_page.dart @@ -46,7 +46,8 @@ class _LockDetailMainPageState extends State { xhjCall: () => Scaffold( backgroundColor: Colors.white, appBar: TitleAppBar( - barTitle: keyInfos.lockAlias, + barTitle: F.sw( + xhjCall: () => '星星锁', skyCall: () => keyInfos.lockAlias), haveBack: true, backgroundColor: Colors.white, titleColor: AppColors.blackColor, diff --git a/lib/main/lockDetail/lockDetail/lockDetail_page.dart b/lib/main/lockDetail/lockDetail/lockDetail_page.dart index f97a8481..e06f5eca 100755 --- a/lib/main/lockDetail/lockDetail/lockDetail_page.dart +++ b/lib/main/lockDetail/lockDetail/lockDetail_page.dart @@ -4,7 +4,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:intl/intl.dart'; +import 'package:intl/intl.dart' as intl; import 'package:star_lock/app_settings/app_colors.dart'; import 'package:star_lock/flavors.dart'; import 'package:star_lock/main/lockDetail/lockDetail/lockDetail_list_page.dart'; @@ -153,10 +153,22 @@ class _LockDetailPageState extends State return Scaffold( backgroundColor: Colors.white, body: Obx(() { + final String lockAlias = state.keyInfos.value.lockAlias!; return Stack( children: [ Column( children: [ + SizedBox( + height: 15.h, + ), + Padding( + padding: EdgeInsets.symmetric(horizontal: 24.w), + child: Text( + lockAlias, + textAlign: TextAlign.center, + style: TextStyle(fontSize: 24.sp, color: Colors.black), + ), + ), SizedBox( height: 35.h, ), @@ -1280,6 +1292,19 @@ class _LockDetailPageState extends State } Widget _unlockSuccessWidget() { + String lockAlias = state.keyInfos.value.lockAlias!; + final TextStyle lockAliasTextStyle = + TextStyle(color: AppColors.placeholderTextColor, fontSize: 24.sp); + final TextPainter textPainter = TextPainter( + text: TextSpan(text: lockAlias, style: lockAliasTextStyle), + maxLines: 1, + textDirection: TextDirection.ltr) + ..layout(minWidth: 0, maxWidth: double.infinity); + + final double textSizeWidth = textPainter.size.width; // 获取文本的尺寸 + if (textSizeWidth > 358.w * 2 - 20) { + lockAlias = '${lockAlias.substring(0, 25)}...'; + } return Center( child: Stack( children: [ @@ -1298,9 +1323,10 @@ class _LockDetailPageState extends State crossAxisAlignment: CrossAxisAlignment.center, children: [ Text( - state.keyInfos.value.lockAlias!, + lockAlias, style: TextStyle( color: AppColors.placeholderTextColor, fontSize: 24.sp), + maxLines: 2, ), SizedBox( height: 10.h, @@ -1337,7 +1363,7 @@ class _LockDetailPageState extends State // 获取当前时间 final DateTime now = DateTime.now(); // 格式化日期和时间 - final String formattedTime = DateFormat('MM/dd HH:mm').format(now); + final String formattedTime = intl.DateFormat('MM/dd HH:mm').format(now); return formattedTime; } diff --git a/lib/main/lockMian/lockList/lockList_xhj_page.dart b/lib/main/lockMian/lockList/lockList_xhj_page.dart index 37e18bef..8292364d 100755 --- a/lib/main/lockMian/lockList/lockList_xhj_page.dart +++ b/lib/main/lockMian/lockList/lockList_xhj_page.dart @@ -169,6 +169,25 @@ class _LockListXHJPageState extends State with RouteAware { Widget _xhjLockInfoListItem( LockListInfoItemEntity keyInfo, bool isLast, Function() action) { + String lockAlias = keyInfo.lockAlias!; + final TextStyle lockAliasTextStyle = TextStyle( + fontSize: 24.sp, + fontWeight: FontWeight.w500, + color: keyInfo.passageMode == 1 + ? AppColors.openPassageModeColor + : AppColors.darkGrayTextColor, + overflow: TextOverflow.ellipsis, + ); + final TextPainter textPainter = TextPainter( + text: TextSpan(text: lockAlias, style: lockAliasTextStyle), + maxLines: 1, + textDirection: TextDirection.ltr) + ..layout(minWidth: 0, maxWidth: double.infinity); + + final double textSizeWidth = textPainter.size.width; // 获取文本的尺寸 + if (textSizeWidth > Get.width * .6) { + lockAlias = '${lockAlias.substring(0, 14)}...'; + } return GestureDetector( onTap: action, child: Container( @@ -204,16 +223,7 @@ class _LockListXHJPageState extends State with RouteAware { ), FittedBox( fit: BoxFit.scaleDown, - child: Text(keyInfo.lockAlias!, - style: TextStyle( - fontSize: 24.sp, - fontWeight: FontWeight.w500, - color: keyInfo.passageMode == 1 - ? AppColors.openPassageModeColor - : AppColors.darkGrayTextColor, - overflow: TextOverflow.ellipsis, - ), - maxLines: 1), + child: Text(lockAlias, style: lockAliasTextStyle, maxLines: 1), ), Visibility( visible: keyInfo.passageMode == 1, diff --git a/lib/main/lockMian/lockMain/lockMain_page.dart b/lib/main/lockMian/lockMain/lockMain_page.dart index 83b0163e..393105f1 100755 --- a/lib/main/lockMian/lockMain/lockMain_page.dart +++ b/lib/main/lockMian/lockMain/lockMain_page.dart @@ -94,7 +94,7 @@ class _StarLockMainPageState extends State with BaseWidget { leftWidget: Builder( builder: (context) => IconButton( icon: Image.asset( - "images/main/mainLeft_menu_icon.png", + 'images/main/mainLeft_menu_icon.png', color: Colors.white, width: 44.w, height: 44.w, @@ -215,9 +215,7 @@ class _StarLockMainPageState extends State with BaseWidget { SizedBox( height: 160.h, ), - F.isLite - ? Container() - : SubmitBtn( + if (F.isLite) Container() else SubmitBtn( btnName: '演示模式', onClick: () { Get.toNamed(Routers.demoModeLockDetailPage); From 4f75d1a43a1e2a0240af0f5c4a2a5769464caff8 Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Mon, 3 Jun 2024 17:26:32 +0800 Subject: [PATCH 05/12] =?UTF-8?q?feat:=20xhj=20=E8=AE=BE=E5=A4=87=E5=88=97?= =?UTF-8?q?=E8=A1=A8=20=E6=B7=BB=E5=8A=A0=E6=90=9C=E7=B4=A2=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lockMian/entity/lockListInfo_entity.dart | 12 +++ .../lockMian/lockList/lockList_logic.dart | 20 +++- .../lockMian/lockList/lockList_state.dart | 10 +- .../lockMian/lockList/lockList_xhj_page.dart | 97 +++++++++++++++---- 4 files changed, 112 insertions(+), 27 deletions(-) diff --git a/lib/main/lockMian/entity/lockListInfo_entity.dart b/lib/main/lockMian/entity/lockListInfo_entity.dart index b3c62d17..ecb49bbd 100755 --- a/lib/main/lockMian/entity/lockListInfo_entity.dart +++ b/lib/main/lockMian/entity/lockListInfo_entity.dart @@ -97,6 +97,14 @@ class GroupList { } return data; } + + GroupList copy(){ + return GroupList( + groupName: groupName, + groupId: groupId, + lockList: lockList?.map((e) => e.copy()).toList(), + ); + } } class LockListInfoItemEntity { @@ -268,6 +276,10 @@ class LockListInfoItemEntity { bool isLockOwnerBool() { return isLockOwner == 1; } + + LockListInfoItemEntity copy(){ + return LockListInfoItemEntity.fromJson(toJson()); + } } class Bluetooth { diff --git a/lib/main/lockMian/lockList/lockList_logic.dart b/lib/main/lockMian/lockList/lockList_logic.dart index 14b08463..b06b7f1f 100755 --- a/lib/main/lockMian/lockList/lockList_logic.dart +++ b/lib/main/lockMian/lockList/lockList_logic.dart @@ -23,20 +23,30 @@ import '../entity/lockListInfo_entity.dart'; import 'lockList_state.dart'; class LockListLogic extends BaseGetXController { - LockListLogic(this.entity){ - } + LockListLogic(this.entity) {} LockListState state = LockListState(); - List groupDataList = []; + List _groupDataList = []; LockListInfoGroupEntity? entity; + List get groupDataList { + final List list = _groupDataList.map((e)=>e.copy()).toList(); + if (state.searchStr.value != '' && state.showSearch.value) { + list.forEach((GroupList element) { + element.lockList?.removeWhere((LockListInfoItemEntity element) => + !(element.lockAlias?.contains(state.searchStr.value) ?? true)); + }); + } + return list; + } + //设置数据 void setLockListInfoGroupEntity(LockListInfoGroupEntity entity) { this.entity = entity; if (entity.pageNo == 1) { - groupDataList = []; + _groupDataList = []; } - groupDataList.addAll(entity.groupList!); + _groupDataList.addAll(entity.groupList!); update(); } diff --git a/lib/main/lockMian/lockList/lockList_state.dart b/lib/main/lockMian/lockList/lockList_state.dart index 58c174ef..1b072405 100755 --- a/lib/main/lockMian/lockList/lockList_state.dart +++ b/lib/main/lockMian/lockList/lockList_state.dart @@ -6,10 +6,12 @@ import '../entity/lockListInfo_entity.dart'; class LockListState{ - var itemStatusIsEable = false.obs; // 列表里面item是否能点击 + RxBool itemStatusIsEable = false.obs; // 列表里面item是否能点击 LockListInfoItemEntity lockListInfoItemEntity = LockListInfoItemEntity(); // 当前选中要删除的item - var passwordTF = TextEditingController(); - var deleteAdministratorIsHaveAllData = false.obs; // 删除管理员是否有所有数据 - var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示 + TextEditingController passwordTF = TextEditingController(); + RxBool deleteAdministratorIsHaveAllData = false.obs; // 删除管理员是否有所有数据 + RxBool ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示 + RxBool showSearch = false.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示 + RxString searchStr = ''.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示 } \ No newline at end of file diff --git a/lib/main/lockMian/lockList/lockList_xhj_page.dart b/lib/main/lockMian/lockList/lockList_xhj_page.dart index 8292364d..f76baa68 100755 --- a/lib/main/lockMian/lockList/lockList_xhj_page.dart +++ b/lib/main/lockMian/lockList/lockList_xhj_page.dart @@ -43,16 +43,75 @@ class _LockListXHJPageState extends State with RouteAware { children: [ Align( alignment: Alignment.topRight, - child: IconButton( - onPressed: () { - Get.toNamed(Routers.selectLockTypePage); - }, - icon: Icon( - Icons.add_circle, - size: 48.w, - color: AppColors.mainColor, - )), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + IconButton( + onPressed: () { + state.showSearch.value = !state.showSearch.value; + }, + icon: Icon( + Icons.search, + size: 32.w, + color: AppColors.blackColor, + )), + IconButton( + onPressed: () { + Get.toNamed(Routers.selectLockTypePage); + }, + icon: Icon( + Icons.add_circle, + size: 48.w, + color: AppColors.mainColor, + )), + ], + ), ), + //椭圆形 输入框 + Obx(() { + return state.showSearch.value + ? Container( + height: 50.w, + decoration: BoxDecoration( + color: Colors.white.withOpacity(0.8), + borderRadius: BorderRadius.circular(40.w), + ), + margin: EdgeInsets.only( + left: 25.w, right: 25.w, bottom: 20.h), + child: Stack( + children: [ + Padding( + padding: EdgeInsets.only(top: 14.h, left: 20.w), + child: Icon( + Icons.search, + size: 28.w, + color: AppColors.blackColor, + ), + ), + TextField( + decoration: InputDecoration( + hintText: '搜索'.tr, + hintStyle: TextStyle( + fontSize: 24.sp, + color: AppColors.blackColor, + ), + border: InputBorder.none, + contentPadding: EdgeInsets.only( + top: 6.h, + left: 50.w, + ), + isCollapsed: true, + ), + onChanged: (String value) { + state.searchStr.value = value; + }, + autofocus: true, + ), + ], + ), + ) + : const SizedBox.shrink(); + }), Padding( padding: EdgeInsets.only(left: 45.w), child: Text( @@ -65,15 +124,17 @@ class _LockListXHJPageState extends State with RouteAware { ), ), Expanded( - child: ListView.builder( - itemCount: logic.groupDataList.length, - itemBuilder: (BuildContext context, int index) { - final GroupList itemData = logic.groupDataList[index]; - return _buildLockExpandedList(context, index, itemData); - }, - shrinkWrap: true, - physics: const AlwaysScrollableScrollPhysics(), - ), + child: Obx(() { + return ListView.builder( + itemCount: logic.groupDataList.length, + itemBuilder: (BuildContext context, int index) { + final GroupList itemData = logic.groupDataList[index]; + return _buildLockExpandedList(context, index, itemData); + }, + shrinkWrap: true, + physics: const AlwaysScrollableScrollPhysics(), + ); + }), ), ], ), From 5baa5830ac6e3ef05d9779c8099d5b8f461c49c4 Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Mon, 3 Jun 2024 18:04:11 +0800 Subject: [PATCH 06/12] =?UTF-8?q?fix:=E5=BC=80=E9=94=81=E9=A1=B5-=E7=94=B5?= =?UTF-8?q?=E5=AD=90=E9=92=A5=E5=8C=99=E3=80=81=E6=8E=88=E6=9D=83=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=91=98=20=E8=BE=93=E5=85=A5=E5=A7=93=E5=90=8D30?= =?UTF-8?q?=E4=BD=8D=EF=BC=8C=E9=80=9A=E9=80=9A=E9=94=8150=E4=BD=8D?= =?UTF-8?q?=E3=80=82=E5=8F=A6=E5=9C=A8=E8=AF=A6=E6=83=85=E9=A1=B5=E5=A7=93?= =?UTF-8?q?=E5=90=8D=E6=98=BE=E7=A4=BA=E4=B8=8D=E5=85=A8=EF=BC=8C=E9=80=9A?= =?UTF-8?q?=E9=80=9A=E9=94=81=E4=BC=9A=E6=98=BE=E7=A4=BA3=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../authorizedAdminList_page.dart | 4 +-- .../checkingInAddHolidays_page.dart | 7 ++-- .../checkingInList/checkingInList_page.dart | 2 ++ .../electronicKeyList_page.dart | 9 ++---- .../sendElectronicKey_page.dart | 19 +++++------ .../view/sendElectronicKeyView_page.dart | 8 +++-- lib/main/lockMian/lockMain/lockMain_page.dart | 32 +++++++++++++++---- 7 files changed, 51 insertions(+), 30 deletions(-) diff --git a/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart b/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart index 4faef337..cd1220d8 100755 --- a/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart +++ b/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart @@ -196,7 +196,7 @@ class _AuthorizedAdminListPageState extends State { onTap: action, child: Container( color: Colors.white, - height: 100.h, + padding: EdgeInsets.only(top: 20.h, bottom: 20.h), child: Row( children: [ SizedBox(width: 30.w), @@ -226,7 +226,7 @@ class _AuthorizedAdminListPageState extends State { children: [ Flexible( child: Text(receiveUser, - maxLines: 1, + maxLines: 3, overflow: TextOverflow.ellipsis, style: TextStyle( fontSize: 24.sp, diff --git a/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInAddHolidays/checkingInAddHolidays_page.dart b/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInAddHolidays/checkingInAddHolidays_page.dart index 4cad5ecd..45318c4e 100755 --- a/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInAddHolidays/checkingInAddHolidays_page.dart +++ b/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInAddHolidays/checkingInAddHolidays_page.dart @@ -44,7 +44,8 @@ class _CheckingInAddHolidaysPageState extends State { isHaveRightWidget: true, setHeight: false, rightWidget: getTFWidget( - '(${TranslationLoader.lanKeys!.mustFillIn!.tr})')), + '(${TranslationLoader.lanKeys!.mustFillIn!.tr})', + maxSize: 50)), Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.startDate!.tr, rightTitle: state.beginDate.value.isEmpty @@ -123,7 +124,7 @@ class _CheckingInAddHolidaysPageState extends State { ); } - Widget getTFWidget(String tfStr) { + Widget getTFWidget(String tfStr, {int maxSize = 30}) { return Expanded( child: TextField( //输入框一行 @@ -143,7 +144,7 @@ class _CheckingInAddHolidaysPageState extends State { isCollapsed: true, ), inputFormatters: [ - LengthLimitingTextInputFormatter(30), + LengthLimitingTextInputFormatter(maxSize), ], ), ); diff --git a/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_page.dart b/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_page.dart index 2e80f194..68b8ca4a 100755 --- a/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_page.dart +++ b/lib/main/lockDetail/checkingIn/checkingInList/checkingInList_page.dart @@ -433,6 +433,8 @@ class _CheckingInListPageState extends State { Expanded( child: Text( name!, + maxLines: 3, + overflow: TextOverflow.ellipsis, style: TextStyle(fontSize: 24.sp), ), ), diff --git a/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart b/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart index 7820d81c..7359179c 100755 --- a/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart +++ b/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart @@ -245,7 +245,7 @@ class _ElectronicKeyListPageState extends State { onTap: action, child: Container( color: Colors.white, - height: 90.h, + padding: EdgeInsets.only(top: 20.h, bottom: 20.h), child: Row( children: [ SizedBox(width: 30.w), @@ -262,11 +262,6 @@ class _ElectronicKeyListPageState extends State { ), ), ), - // Image.asset( - // avatarURL, - // width: 60.w, - // height: 60.w, - // ), SizedBox(width: 20.w), Expanded( child: Column( @@ -281,7 +276,7 @@ class _ElectronicKeyListPageState extends State { children: [ Flexible( child: Text(receiveUser, - maxLines: 1, + maxLines: 3, overflow: TextOverflow.ellipsis, style: TextStyle( fontSize: 24.sp, diff --git a/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_page.dart b/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_page.dart index f47c378e..187a5f10 100755 --- a/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_page.dart +++ b/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_page.dart @@ -3,6 +3,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/app_settings/app_colors.dart'; import 'package:star_lock/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_logic.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_state.dart'; import 'package:star_lock/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_page.dart'; import '../../../../../tools/CustomUnderlineTabIndicator.dart'; @@ -18,8 +19,8 @@ class SendElectronicKeyPage extends StatefulWidget { class _SendElectronicKeyPageState extends State with SingleTickerProviderStateMixin { - final logic = Get.put(SendElectronicKeyLogic()); - final state = Get.find().state; + final SendElectronicKeyLogic logic = Get.put(SendElectronicKeyLogic()); + final SendElectronicKeyState state = Get.find().state; @override void initState() { @@ -37,7 +38,7 @@ class _SendElectronicKeyPageState extends State haveBack: true, backgroundColor: AppColors.mainColor), body: Column( - children: [ + children: [ _tabBar(), _pageWidget(), ], @@ -48,10 +49,10 @@ class _SendElectronicKeyPageState extends State TabBar _tabBar() { return TabBar( controller: state.tabController, - onTap: (index) { + onTap: (int index) { FocusScope.of(context).requestFocus(FocusNode()); }, - tabs: _itemTabs.map((ItemView item) => _tab(item)).toList(), + tabs: _itemTabs.map(_tab).toList(), isScrollable: true, indicatorColor: Colors.red, unselectedLabelColor: Colors.black, @@ -97,10 +98,10 @@ class _SendElectronicKeyPageState extends State } final List _itemTabs = [ - ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, type: "0"), - ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, type: "1"), - ItemView(title: TranslationLoader.lanKeys!.once!.tr, type: "2"), - ItemView(title: TranslationLoader.lanKeys!.circulation!.tr, type: "3"), + ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, type: '0'), + ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, type: '1'), + ItemView(title: TranslationLoader.lanKeys!.once!.tr, type: '2'), + ItemView(title: TranslationLoader.lanKeys!.circulation!.tr, type: '3'), ]; } diff --git a/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_page.dart b/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_page.dart index 654cc2df..a9cedb69 100755 --- a/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_page.dart +++ b/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_page.dart @@ -143,7 +143,8 @@ class _SendElectronicKeyViewState extends State rightTitle: '', isHaveRightWidget: true, rightWidget: getTFWidget( - false, TranslationLoader.lanKeys!.enterYourName!.tr, 2, logic)), + false, TranslationLoader.lanKeys!.enterYourName!.tr, 2, logic, + maxSize: 50)), Container(height: 10.h), ], ); @@ -441,7 +442,8 @@ class _SendElectronicKeyViewState extends State // 接受者信息输入框 Widget getTFWidget(bool isHaveBtn, String tfStr, int lineIndex, - SendElectronicKeyViewLogic logic) { + SendElectronicKeyViewLogic logic, + {int maxSize = 30}) { return SizedBox( height: 65.h, width: 320.w, @@ -454,7 +456,7 @@ class _SendElectronicKeyViewState extends State maxLines: 1, inputFormatters: [ FilteringTextInputFormatter.deny('\n'), - LengthLimitingTextInputFormatter(30), + LengthLimitingTextInputFormatter(maxSize), ], // controller: _controller, autofocus: false, diff --git a/lib/main/lockMian/lockMain/lockMain_page.dart b/lib/main/lockMian/lockMain/lockMain_page.dart index 393105f1..2d52b952 100755 --- a/lib/main/lockMian/lockMain/lockMain_page.dart +++ b/lib/main/lockMian/lockMain/lockMain_page.dart @@ -124,6 +124,23 @@ class _StarLockMainPageState extends State with BaseWidget { fit: BoxFit.cover, ), ), + // decoration: BoxDecoration( + // // 设置渐变 + // gradient: LinearGradient( + // // 渐变颜色列表 + // colors: [ + // AppColors.mainColor.withOpacity(0.8), // 左上角颜色 + // AppColors.mainColor.withOpacity(0.4), // 右上角颜色 + // Colors.white, // 右下角颜色 + // Colors.white, // 左下角颜色 + // ], + // // 渐变的起始和结束位置 + // begin: Alignment.topLeft, + // end: Alignment.bottomRight, + // // 颜色停靠点,对应颜色数组的索引位置 + // stops: [0.0, 0.23, 0.47, 1], + // ), + // ), child: child, )); return child; @@ -215,12 +232,15 @@ class _StarLockMainPageState extends State with BaseWidget { SizedBox( height: 160.h, ), - if (F.isLite) Container() else SubmitBtn( - btnName: '演示模式', - onClick: () { - Get.toNamed(Routers.demoModeLockDetailPage); - }, - ) + if (F.isLite) + Container() + else + SubmitBtn( + btnName: '演示模式', + onClick: () { + Get.toNamed(Routers.demoModeLockDetailPage); + }, + ) ], ), ], From 0fe024bc9f105fbd6ec71182b37a7622fe54835c Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Tue, 4 Jun 2024 09:12:41 +0800 Subject: [PATCH 07/12] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E9=A1=B5=E6=B2=A1=E6=9C=89=E7=BA=A2=E7=82=B9?= =?UTF-8?q?=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/login/login/starLock_login_logic.dart | 2 ++ lib/login/login/starLock_login_page.dart | 10 +++--- .../messageList/messageList_xhj_page.dart | 34 ++++++++++++++++--- 3 files changed, 37 insertions(+), 9 deletions(-) diff --git a/lib/login/login/starLock_login_logic.dart b/lib/login/login/starLock_login_logic.dart index 94412022..fd45814c 100755 --- a/lib/login/login/starLock_login_logic.dart +++ b/lib/login/login/starLock_login_logic.dart @@ -58,6 +58,8 @@ class StarLockLoginLogic extends BaseGetXController { } } + + void changeAgreeState() { _resetCanNext(); } diff --git a/lib/login/login/starLock_login_page.dart b/lib/login/login/starLock_login_page.dart index 8505350c..12c8a72f 100755 --- a/lib/login/login/starLock_login_page.dart +++ b/lib/login/login/starLock_login_page.dart @@ -72,7 +72,7 @@ class _StarLockLoginPageState extends State { Obx(() => CommonItem( leftTitel: "${"你所在的".tr}${TranslationLoader.lanKeys!.countryAndRegion!.tr}", - rightTitle: "", + rightTitle: '', isHaveLine: true, isPadding: false, isHaveRightWidget: true, @@ -179,8 +179,8 @@ class _StarLockLoginPageState extends State { fontSize: 20.sp)), onTap: () { Get.toNamed(Routers.webviewShowPage, arguments: { - "url": XSConstantMacro.userAgreementURL, - "title": '用户协议'.tr + 'url': XSConstantMacro.userAgreementURL, + 'title': '用户协议'.tr }); }, )), @@ -194,8 +194,8 @@ class _StarLockLoginPageState extends State { fontSize: 20.sp)), onTap: () { Get.toNamed(Routers.webviewShowPage, arguments: { - "url": XSConstantMacro.privacyPolicyURL, - "title": '隐私政策'.tr + 'url': XSConstantMacro.privacyPolicyURL, + 'title': '隐私政策'.tr }); }, )), diff --git a/lib/mine/message/messageList/messageList_xhj_page.dart b/lib/mine/message/messageList/messageList_xhj_page.dart index 662403bb..b0837627 100755 --- a/lib/mine/message/messageList/messageList_xhj_page.dart +++ b/lib/mine/message/messageList/messageList_xhj_page.dart @@ -192,10 +192,36 @@ class _MessageListXHJPageState extends State mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ - Image.asset( - isNotRead ? 'images/news_not_read.png' : 'images/news_read.png', - width: 48.r, - height: 48.r), + if (isNotRead) + Stack( + children: [ + Image.asset( + 'images/news_not_read.png', + width: 48.r, + height: 48.r, + ), + Positioned( + right: 1.5.r, + top: 7.r, + child: Container( + width: 12.r, + height: 12.r, + decoration: const BoxDecoration( + color: Colors.red, // 小圆点颜色 + shape: BoxShape.circle, // 形状为圆形 + ), + ), + ), + ], + ) + else + SizedBox( + width: 48.r, + height: 48.r, + child: Center( + child: Image.asset('images/news_read.png', + width: 32.r, height: 32.r), + )), SizedBox(width: 15.w), Expanded( child: Column( From 0e38550b948202e56666b943517db90471fb1709 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=8F=E5=B0=91=E9=98=B3?= <786612630@qq.com> Date: Mon, 3 Jun 2024 15:23:03 +0800 Subject: [PATCH 08/12] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8B=8D=E7=85=A7?= =?UTF-8?q?=E5=A4=B4=E5=83=8F=E4=B8=8A=E4=BC=A0=E6=85=A2=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .DS_Store | Bin 10244 -> 8196 bytes .../minePersonInfo_logic.dart | 52 ++++++++++-------- .../minePersonInfo_page.dart | 2 +- .../minePersonInfo_state.dart | 11 ++-- pubspec.yaml | 3 +- 5 files changed, 38 insertions(+), 30 deletions(-) diff --git a/.DS_Store b/.DS_Store index f7e55907e64996cff1c8d6490166ef5cbccae3b2..fdfcd7d0d25a05b4ccfcfeffa86d37533538e7af 100755 GIT binary patch delta 291 zcmZn(XmOBWU|?W$DortDU;r^WfEYvza8E20o2Vx_*+7Lw6v$@~24Y5_I73dlVQ_MO zZoy_j4l$O^3LF!eIf3FJz`+d>Q{#Ec%qYB>N8&cqF{~n38au@bMswXl5+BsK<1_P@AqJ1Ip&D2B87m8f((cgf%+IaWiJ59$$SFR xlUr0OH&zHU3o?Vmf!^c>60RVx0-gPxc{0C>=VX5#4i2DiK%u~}Ii6<@GXTA?Jd*$b literal 10244 zcmeHNdvF^^8Qvmpi{zgfDAA^%A@5qfdZuz2&L&jr<4wqSK*HgGi7Mu+r5(`$ucug z2x-x3_P*P1_uISuZtwQ@`&NuGbfwi6#=?v-nKGBk62{6GGgeD7H}QI&=cO{zfbt5; zbgnR_GlQvyotcgs^IDe_B@dK5a4C5}qMPCGZ#m@(7H8?)_t%OuCY_2;8@lZ@H$Mic zth}Ofk?dQ%#D7_6*X~_?*ZU`w>Wr?@j@D@yQT=9(bj$2S$})`omaX${#zr0On8WMlRgI3@R?6uXosH_$ zzuQVl+u8w*I@L2;4|Q$V6!;jvb4!;gRn?c*EMIX&cuhl7+twYOqX{dS)J(@7GGcMf z7|FPIe^8|!x>Fh*)j^x?;t*HtwN(8^ois;vQyny8N$oIK_s48!-?V0G>e<>W120<{ z^oNG1fp%4vt#|=$cRE0*LELzuHAxh3SHgQjjTK%%W{3z zEA^2E_f!m|KGN)#eDsYEvR2l^`q>edVkg+`>^90;J^Tbe$1m|a_x2<{QF-cjMfQl_tE!za;+7>= zoJtmBHvKf_FgreD(?Y~2GP^fBksrxUlT8auwHe2*D+X5F*hz@c^L6$aR<_zAI;V~45tCL+=G-rsovUDtYpyYx1 z9;hHy4pt~Y5tYOUk_4$H2~fRs;8f0-C|1$!Ld3FY79!?zo#4pm*tq{t4&k^M{ANO# zM{A0*tqbt|^wKLrtJiO6-LgH>+qd@>XF22X*Z5atxkn)<87Hu6I-J&|e4LdCHgLAu zB{IRn*4bW0({cT#wC)^N>WP|&Yt#kneMD69h?1xY)&wM>_RVoQSJxHn;gqM4qVbyzb_I9K z^0++}OKJON2+wCN`ej)VSJHD<*Q@G|l@i_JkaLKJwOw#d|hKwC1Rn@Ud?mKNZYtE!#><-5|S>S?m_}7Irr=ulv~j z><8=-_BeZrJ;R=5e`U|H=TQbfs<9HQu>noQ!dh?*wqXaZ#U8=JhKYk6g#nW|n1hoZ z|9ZXPUU%S5+=UO~6h4fP;55D{c-J@aeLRSV@IyR~-{5Kd7U%ICp2y#%Dk&hXmexpX zr6#FaYLzxgJEdLHerZgKOOw)+`#qWCW;f)2U!>zy&ijP8p+ON^I9>d8qtF6H7Wyyw z*R2#%ppe3UcBcP`J;t7(D8qU7EGn@C3PMcK2g1hB1n99K<1Ln1qg3 z(p-0t!7&`i&3G+dhd1DjcoXixJMk{O8+YR#n(ZH=`F9&KJ()f`u}_`HQH;;c_|KNGrU~9AmO2N^!Aie*bv%uF>4Oq}9{o z1ykfTp=9R4htG88*Q@`uetPOc-_ofk$n?T>r=56z+ICW;YhqD$oB}uwA&w-KhUs%? zP-HU65eSug2#q+Do7j*D^Q459W0VBxX2h?FO4Ib)Ao__>Fw3A`66`3o$iM1RI0P+8I|IHBG_5rqZ~~Czn%?Swzko1=y;)F(3}zFp!SC1Fd{HGG&nr+ z;@P1f^uDr=Z%uUU=-PSxfPkg{26|VjmJxst6hY~$0^#B)J+LaUx)@4d7kGIAN^kUU z%tz^g7XPLKlpbjJZ=HwI12z8bg(y96U7&LzlumWM^HDl!`--D<8ugx4fj}Ng=V(8$ zKX70{luqAEk>*hPzp@?jQ-b8bW`AIRq3sX}6#}l*AV`2Ej5;*nYJ%n)36%Gsm!Qi5 z0ap%VLTrqfn5M0f3|>RqBDWG?;ZWsH0af^h$j4|)ghQ0C;(h`t58-Ec6zA|1{)lJr zCkfJGsYY5Zt&l=eSh`B8m)fN*Qbg*L2BZ;pJab@t%p0I5B)*#GC(ivTg?aqHcj5hi z(WrDNd7$Khm!=0$-V^QVqOp0g^?9S@vGy?KBb0gK?PgsmOz7Z+;FFhTh6h7 diff --git a/lib/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_logic.dart b/lib/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_logic.dart index e6c6b080..00346532 100755 --- a/lib/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_logic.dart +++ b/lib/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_logic.dart @@ -1,14 +1,19 @@ import 'dart:async'; import 'dart:io'; +import 'dart:typed_data'; +import 'package:flutter_image_compress/flutter_image_compress.dart'; import 'package:get/get.dart'; import 'package:image_picker/image_picker.dart'; import 'package:permission_handler/permission_handler.dart'; -import 'package:star_lock/app_settings/app_settings.dart'; +import 'package:star_lock/login/login/entity/LoginData.dart'; +import 'package:star_lock/login/login/entity/LoginEntity.dart'; +import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart'; import 'package:star_lock/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_entity.dart'; import 'package:star_lock/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_state.dart'; import 'package:star_lock/widget/permission/permission_dialog.dart'; import '../../../../network/api_repository.dart'; import '../../../../tools/baseGetXController.dart'; +import '../../../app_settings/app_settings.dart'; import '../../../tools/eventBusEventManage.dart'; import '../../../tools/storage.dart'; import 'minePersonGetUploadFileInfo_entity.dart'; @@ -18,7 +23,7 @@ class MinePersonInfoLogic extends BaseGetXController { //用户信息 Future getUserInfoRequest() async { - MinePersonInfoEntity entity = await ApiRepository.to.getUserInfo(); + final MinePersonInfoEntity entity = await ApiRepository.to.getUserInfo(); if (entity.errorCode!.codeIsSuccessful) { state.mineInfoData.value = entity.data!; state.headUrl.value = state.mineInfoData.value.headUrl!; @@ -27,7 +32,7 @@ class MinePersonInfoLogic extends BaseGetXController { //上传头像 先获取upToken 再调用updateUserInfo Future getUpTokenRequest(String filename, int size) async { - var entity = await ApiRepository.to.getUpToken( + final MinePersonGetUploadFileInfoEntity entity = await ApiRepository.to.getUpToken( userId: state.mineInfoData.value.uid!.toString(), filename: filename, size: size); @@ -41,18 +46,18 @@ class MinePersonInfoLogic extends BaseGetXController { MinePersonGetUploadFileInfoEntity minePersonGetUploadFileInfoEntity) async { // Map user = minePersonGetUploadFileInfoEntity.data!.formData!; - var bytes = File(state.image!.path); - var enc = await bytes.readAsBytes(); + final File bytes = File(state.image!.path); + final Uint8List enc = await bytes.readAsBytes(); // user[minePersonGetUploadFileInfoEntity.data!.fileField!] = enc; - final form = FormData(minePersonGetUploadFileInfoEntity.data!.formData!); + final FormData form = FormData(minePersonGetUploadFileInfoEntity.data!.formData!); form.files.add(MapEntry( minePersonGetUploadFileInfoEntity.data!.fileField!, MultipartFile(enc, filename: - minePersonGetUploadFileInfoEntity.data!.formData!["key"]))); + minePersonGetUploadFileInfoEntity.data!.formData!['key']))); - var entity = await ApiRepository.to.uploadFile( + final LoginEntity entity = await ApiRepository.to.uploadFile( url: minePersonGetUploadFileInfoEntity.data!.uploadUrl!, body: form); if (entity.errorCode! == -1) { // 没有返回 返回null成功 @@ -62,15 +67,15 @@ class MinePersonInfoLogic extends BaseGetXController { //更新个人信息-头像 Future updateUserInfoRequest(String headUrl) async { - var entity = await ApiRepository.to.updateUserHeadUrlInfo(headUrl: headUrl); + final PasswordKeyListEntity entity = await ApiRepository.to.updateUserHeadUrlInfo(headUrl: headUrl); if (entity.errorCode!.codeIsSuccessful) { state.headUrl.value = headUrl; state.mineInfoData.value.headUrl = state.headUrl.value; - final loginData = await Storage.getLoginData(); + final LoginData? loginData = await Storage.getLoginData(); loginData!.headUrl = headUrl; await Storage.saveLoginData(loginData); eventBus.fire(MineInfoChangeRefreshUI()); - showToast("上传成功".tr); + showToast('上传成功'.tr); } } @@ -86,34 +91,38 @@ class MinePersonInfoLogic extends BaseGetXController { ///拍摄照片 Future selectCamera() async { - XFile? photo = await state.imagePicker.pickImage( - source: ImageSource.camera, preferredCameraDevice: CameraDevice.rear); + final XFile? photo = await state.imagePicker.pickImage( + source: ImageSource.camera, + maxHeight: 250, + maxWidth: 250, + imageQuality: 80 + ); if (photo != null) { state.image = photo; - var bytes = File(state.image!.path); - var enc = await bytes.readAsBytes(); + final File bytes = File(state.image!.path); + final Uint8List enc = await bytes.readAsBytes(); getUpTokenRequest(state.image!.name, enc.length); } } ///从相册选取 Future selectImage() async { - XFile? image = await state.imagePicker.pickImage( + final XFile? image = await state.imagePicker.pickImage( source: ImageSource.gallery, maxHeight: 250, maxWidth: 250, ); if (image != null) { state.image = image; - var bytes = File(state.image!.path); - var enc = await bytes.readAsBytes(); + final File bytes = File(state.image!.path); + final Uint8List enc = await bytes.readAsBytes(); getUpTokenRequest(state.image!.name, enc.length); } } //权限判断 访问相机 Future _checkCameraPermission() async { - var status = await PermissionDialog.request(Permission.camera); + final bool status = await PermissionDialog.request(Permission.camera); if (status) { selectCamera(); } @@ -121,7 +130,7 @@ class MinePersonInfoLogic extends BaseGetXController { //权限判断 访问相册 Future _checkPhotoPermission() async { - var status = await PermissionDialog.requestPhotos(); + final bool status = await PermissionDialog.requestPhotos(); if (status) { selectImage(); } @@ -129,13 +138,11 @@ class MinePersonInfoLogic extends BaseGetXController { @override void onReady() { - // TODO: implement onReady super.onReady(); } @override void onInit() { - // TODO: implement onInit super.onInit(); getUserInfoRequest(); @@ -143,6 +150,5 @@ class MinePersonInfoLogic extends BaseGetXController { @override void onClose() { - // TODO: implement onClose } } diff --git a/lib/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_page.dart b/lib/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_page.dart index d1f59d01..552d105e 100755 --- a/lib/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_page.dart +++ b/lib/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_page.dart @@ -1,7 +1,7 @@ + import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; -import 'package:permission_handler/permission_handler.dart'; import 'package:star_lock/app_settings/app_colors.dart'; import 'package:star_lock/flavors.dart'; import 'package:star_lock/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_entity.dart'; diff --git a/lib/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_state.dart b/lib/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_state.dart index c884f770..2862e452 100755 --- a/lib/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_state.dart +++ b/lib/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_state.dart @@ -1,12 +1,13 @@ + import 'package:get/get.dart'; import 'package:image_picker/image_picker.dart'; import 'package:star_lock/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_entity.dart'; class MinePersonInfoState { - final mineInfoData = MinePersonInfoData().obs; - final headUrl = ''.obs; + final Rx mineInfoData = MinePersonInfoData().obs; + final RxString headUrl = ''.obs; - var typeStr = '2'.obs; //2:上传头像 + RxString typeStr = '2'.obs; //2:上传头像 // ImagePicker获取内容后返回的对象是XFile XFile? image; @@ -14,8 +15,8 @@ class MinePersonInfoState { // 使用ImagePicker前必须先实例化 final ImagePicker imagePicker = ImagePicker(); - var hasPhotoPermission = false.obs; //是否有相册权限 - var hasCameraPermission = false.obs; //是否有相机权限 + RxBool hasPhotoPermission = false.obs; //是否有相册权限 + RxBool hasCameraPermission = false.obs; //是否有相机权限 } diff --git a/pubspec.yaml b/pubspec.yaml index ec8ee1c1..e7502936 100755 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -205,7 +205,8 @@ dependencies: file_picker: ^5.3.1 # 错误日志监控 flutter_bugly_plugin: ^0.0.9 - + # 图片压缩 + flutter_image_compress: ^2.3.0 dependency_overrides: #强制设置google_maps_flutter_ios 为 2.5.2 From bc440ec377f171072759cdc982202258e40ef043 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=8F=E5=B0=91=E9=98=B3?= <786612630@qq.com> Date: Tue, 4 Jun 2024 09:12:41 +0800 Subject: [PATCH 09/12] =?UTF-8?q?1=E3=80=81=E4=BF=AE=E6=94=B9=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E9=94=81=E6=97=B6=E9=97=B4=E3=80=81=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E7=94=B5=E9=87=8F=E4=B8=8A=E4=BC=A0UTC=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E3=80=822=E3=80=81=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=8B=8D=E7=85=A7=E5=A4=B4=E5=83=8F=E4=B8=8A=E4=BC=A0=E6=AF=94?= =?UTF-8?q?=E8=BE=83=E6=85=A2=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io_protocol/io_getStarLockStatusInfo.dart | 2 +- .../uploadElectricQuantity_logic.dart | 46 ++--- .../uploadElectricQuantity_page.dart | 22 +-- .../uploadElectricQuantity_state.dart | 22 +-- .../lockSet/lockTime/lockTime_logic.dart | 184 ++++++++++-------- .../lockSet/lockTime/lockTime_page.dart | 10 +- .../lockSet/lockTime/lockTime_state.dart | 18 +- .../addLock/nearbyLock/nearbyLock_logic.dart | 181 +++++++++-------- .../minePersonInfo_logic.dart | 1 - lib/tools/dateTool.dart | 34 ++++ 10 files changed, 283 insertions(+), 237 deletions(-) diff --git a/lib/blue/io_protocol/io_getStarLockStatusInfo.dart b/lib/blue/io_protocol/io_getStarLockStatusInfo.dart index 1e9f064b..acdc977b 100755 --- a/lib/blue/io_protocol/io_getStarLockStatusInfo.dart +++ b/lib/blue/io_protocol/io_getStarLockStatusInfo.dart @@ -26,7 +26,7 @@ class GetStarLockStatuInfoCommand extends SenderProtocol { @override String toString() { return 'GetStarLockStatuInfoCommand{lockID: $lockID, ' - 'utcTimeStamp:$utcTimeStamp utcTimeStamp: ${DateTool().dateIntToYMDHNString(utcTimeStamp)}, unixTimeStamp:unixTimeStamp unixTimeStamp: ${DateTool().dateIntToYMDHNString(unixTimeStamp)}, ' + 'utcTimeStamp:$utcTimeStamp utcTimeStamp: ${DateTool().dateIntToYMDHNString(utcTimeStamp)}, unixTimeStamp:$unixTimeStamp unixTimeStamp: ${DateTool().dateIntToYMDHNString(unixTimeStamp)}, ' 'userID: $userID, privateKey: $privateKey}'; } diff --git a/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_logic.dart b/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_logic.dart index d279194f..9a921cdd 100755 --- a/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_logic.dart +++ b/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_logic.dart @@ -2,7 +2,9 @@ import 'dart:async'; import 'package:flutter_blue_plus/flutter_blue_plus.dart'; import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/lockSet/lockTime/getServerDatetime_entity.dart'; +import '../../../../../app_settings/app_settings.dart'; import '../../../../../blue/blue_manage.dart'; import '../../../../../blue/io_protocol/io_getStarLockStatusInfo.dart'; import '../../../../../blue/io_reply.dart'; @@ -11,6 +13,7 @@ import '../../../../../blue/io_tool/manager_event_bus.dart'; import '../../../../../blue/sender_manage.dart'; import '../../../../../network/api_repository.dart'; import '../../../../../tools/baseGetXController.dart'; +import '../../../../../tools/dateTool.dart'; import '../../../../../tools/eventBusEventManage.dart'; import '../../../../../tools/storage.dart'; import '../../../lockOperatingRecord/keyOperationRecord_entity.dart'; @@ -54,13 +57,13 @@ class UploadElectricQuantityLogic extends BaseGetXController { (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected) { dismissEasyLoading(); - final privateKey = await Storage.getStringList(saveBluePrivateKey); + final List? privateKey = await Storage.getStringList(saveBluePrivateKey); final List getPrivateKeyList = changeStringListToIntList(privateKey!); IoSenderManage.senderGetStarLockStatuInfo( lockID: BlueManage().connectDeviceName, userID: await Storage.getUid(), - utcTimeStamp: getUTCNetTime(), - unixTimeStamp: getLocalNetTime(), + utcTimeStamp: getUTCTime(), + unixTimeStamp: getLocalTime(), isBeforeAddUser: false, privateKey: getPrivateKeyList, ); @@ -79,7 +82,7 @@ class UploadElectricQuantityLogic extends BaseGetXController { late StreamSubscription _replySubscription; void _initReplySubscription() { _replySubscription = - EventBusManager().eventBus!.on().listen((reply) { + EventBusManager().eventBus!.on().listen((Reply reply) { // 获取锁状态信息 if (reply is GetStarLockStatuInfoReply) { _replyGetStarLockStatusInfo(reply); @@ -98,11 +101,11 @@ class UploadElectricQuantityLogic extends BaseGetXController { cancelBlueConnetctToastTimer(); // 电池剩余电量 - final battRemCap = reply.data[132]; + final int battRemCap = reply.data[132]; state.lockSetInfoData.value.lockBasicInfo!.electricQuantity = battRemCap; // 备用电池剩余电量 - final battRemCapStandby = reply.data[133]; + final int battRemCapStandby = reply.data[133]; state.lockSetInfoData.value.lockBasicInfo!.electricQuantityStandby = battRemCapStandby; state.uploadElectricQuantityDate.value = DateTime.now().millisecondsSinceEpoch; @@ -111,16 +114,18 @@ class UploadElectricQuantityLogic extends BaseGetXController { break; case 0x06: //无权限 - final privateKey = await Storage.getStringList(saveBluePrivateKey); + final List? privateKey = await Storage.getStringList(saveBluePrivateKey); final List getPrivateKeyList = changeStringListToIntList(privateKey!); IoSenderManage.senderGetStarLockStatuInfo( lockID: BlueManage().connectDeviceName, userID: await Storage.getUid(), - utcTimeStamp: getUTCNetTime(), - unixTimeStamp: getLocalNetTime(), + utcTimeStamp: getUTCTime(), + unixTimeStamp: getLocalTime(), isBeforeAddUser: false, privateKey: getPrivateKeyList, ); + + break; default: //失败 @@ -129,32 +134,29 @@ class UploadElectricQuantityLogic extends BaseGetXController { } // 从服务器获取锁的时间 开锁时传入 - void getServerDatetime() async{ - final entity = await ApiRepository.to.getServerDatetimeData(); + Future getServerDatetime() async{ + final GetServerDatetimeEntity entity = await ApiRepository.to.getServerDatetimeData(); if(entity.errorCode!.codeIsSuccessful){ state.differentialTime = entity.data!.date! ~/ 1000 - DateTime.now().millisecondsSinceEpoch ~/ 1000; - getLocalNetTime(); // AppLog.log("entity.data!.date! ~/ 1000:${entity.data!.date! ~/ 1000} DateTime.now().millisecondsSinceEpoch ~/ 1000:${DateTime.now().millisecondsSinceEpoch ~/ 1000} 服务器时间差:${state.differentialTime}"); } } - int getUTCNetTime(){ + int getLocalTime(){ return DateTime.now().millisecondsSinceEpoch ~/ 1000 + state.differentialTime; } - int getLocalNetTime(){ - final DateTime utcTime = DateTime.fromMillisecondsSinceEpoch(getUTCNetTime()*1000, isUtc: true); - final DateTime localTime = utcTime.toLocal(); + int getUTCTime(){ + final DateTime utcTime = DateTime.fromMillisecondsSinceEpoch(getLocalTime()*1000, isUtc: true); - // AppLog.log('getUTCNetTime: ${getUTCNetTime()}'); - // AppLog.log('UTC time: $utcTime'); - // AppLog.log('Local time: $localTime localTime.millisecondsSinceEpoch ~/ 1000:${localTime.millisecondsSinceEpoch ~/ 1000}'); - return localTime.millisecondsSinceEpoch ~/ 1000; + final String appointmentDate = DateTool().getYMDHNDateStringWithDateTime(utcTime, 1); + final int utcTimeValue = DateTool().dateToTimestamp(appointmentDate, 1); + AppLog.log('appointmentDate: $appointmentDate utcTimeValue:$utcTimeValue'); + return utcTimeValue ~/ 1000; } @override void onReady() { - // TODO: implement onReady super.onReady(); _initReplySubscription(); @@ -163,13 +165,11 @@ class UploadElectricQuantityLogic extends BaseGetXController { @override void onInit() { - // TODO: implement onInit super.onInit(); } @override void onClose() { - // TODO: implement onClose super.onClose(); _replySubscription.cancel(); } diff --git a/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_page.dart b/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_page.dart index 22f29f45..6d6fd4ff 100755 --- a/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_page.dart +++ b/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_page.dart @@ -3,9 +3,9 @@ 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/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_state.dart'; import '../../../../../app_settings/app_colors.dart'; -import '../../../../../blue/blue_manage.dart'; import '../../../../../tools/appRouteObserver.dart'; import '../../../../../tools/dateTool.dart'; import '../../../../../tools/submitBtn.dart'; @@ -22,8 +22,8 @@ class UploadElectricQuantityPage extends StatefulWidget { } class _UploadElectricQuantityPageState extends State with RouteAware { - final logic = Get.put(UploadElectricQuantityLogic()); - final state = Get.find().state; + final UploadElectricQuantityLogic logic = Get.put(UploadElectricQuantityLogic()); + final UploadElectricQuantityState state = Get.find().state; @override Widget build(BuildContext context) { @@ -36,10 +36,10 @@ class _UploadElectricQuantityPageState extends State body: Container( padding: EdgeInsets.all(30.w), child: Column( - children: [ + children: [ Row( mainAxisAlignment: MainAxisAlignment.start, - children: [ + children: [ Expanded( child: Text( TranslationLoader.lanKeys!.updateElectricQuantityTip!.tr, @@ -52,7 +52,7 @@ class _UploadElectricQuantityPageState extends State ), Obx(() => Row( mainAxisAlignment: MainAxisAlignment.start, - children: [ + children: [ Expanded( child: Text( "${"电池1".tr}:${TranslationLoader.lanKeys!.electricQuantity!.tr}:${state.lockBasicInfo.value.electricQuantity ?? ""}%", @@ -64,7 +64,7 @@ class _UploadElectricQuantityPageState extends State visible: state.lockSetInfoData.value.lockFeature!.isSupportBackupBattery == 1, child: Row( mainAxisAlignment: MainAxisAlignment.start, - children: [ + children: [ Expanded( child: Text( "${"电池2".tr}:${TranslationLoader.lanKeys!.electricQuantity!.tr}:${state.lockBasicInfo.value.electricQuantityStandby ?? ""}%", @@ -76,7 +76,7 @@ class _UploadElectricQuantityPageState extends State SizedBox(height: 10.h), Obx(() => Row( mainAxisAlignment: MainAxisAlignment.start, - children: [ + children: [ Expanded( child: Text( "${"电量更新时间".tr}:${DateTool().dateToYMDHNString(state.uploadElectricQuantityDate.value.toString())}", @@ -104,7 +104,6 @@ class _UploadElectricQuantityPageState extends State @override void didChangeDependencies() { - // TODO: implement didChangeDependencies super.didChangeDependencies(); /// 路由订阅 @@ -113,7 +112,6 @@ class _UploadElectricQuantityPageState extends State @override void dispose() { - // TODO: implement dispose /// 取消路由订阅 AppRouteObserver().routeObserver.unsubscribe(this); super.dispose(); @@ -148,7 +146,9 @@ class _UploadElectricQuantityPageState extends State void didPushNext() { super.didPushNext(); logic.cancelBlueConnetctToastTimer(); - if (EasyLoading.isShow) EasyLoading.dismiss(animation: true); + if (EasyLoading.isShow) { + EasyLoading.dismiss(animation: true); + } state.ifCurrentScreen.value = false; state.sureBtnState.value = 0; } diff --git a/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_state.dart b/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_state.dart index 0cda24a0..8d5e5eec 100755 --- a/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_state.dart +++ b/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_state.dart @@ -3,24 +3,24 @@ import 'package:get/get.dart'; import '../../lockSet/lockSetInfo_entity.dart'; -class UploadElectricQuantityState { - var lockSetInfoData = LockSetInfoData().obs; - var lockBasicInfo = LockBasicInfo().obs; - var uploadElectricQuantityDate = 0.obs; - int differentialTime = 0; - - var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示 - var sureBtnState = 0.obs;// 0普通状态可用 1不可用 +class UploadElectricQuantityState {// 0普通状态可用 1不可用 UploadElectricQuantityState() { - var map = Get.arguments; - if(map["lockSetInfoData"]!=null){ - lockSetInfoData.value = map["lockSetInfoData"]; + final map = Get.arguments; + if(map['lockSetInfoData']!=null){ + lockSetInfoData.value = map['lockSetInfoData']; if(lockSetInfoData.value.lockBasicInfo!=null){ lockBasicInfo.value = lockSetInfoData.value.lockBasicInfo!; uploadElectricQuantityDate.value = lockSetInfoData.value.lockBasicInfo!.electricQuantityDate!; } } } + Rx lockSetInfoData = LockSetInfoData().obs; + Rx lockBasicInfo = LockBasicInfo().obs; + RxInt uploadElectricQuantityDate = 0.obs; + int differentialTime = 0; + + RxBool ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示 + RxInt sureBtnState = 0.obs; } \ No newline at end of file diff --git a/lib/main/lockDetail/lockSet/lockTime/lockTime_logic.dart b/lib/main/lockDetail/lockSet/lockTime/lockTime_logic.dart index 961bdf42..f3893ea9 100755 --- a/lib/main/lockDetail/lockSet/lockTime/lockTime_logic.dart +++ b/lib/main/lockDetail/lockSet/lockTime/lockTime_logic.dart @@ -1,8 +1,11 @@ import 'dart:async'; +import 'package:date_format/date_format.dart'; import 'package:flutter_blue_plus/flutter_blue_plus.dart'; import 'package:get/get.dart'; +import 'package:star_lock/app_settings/app_settings.dart'; +import 'package:star_lock/main/lockDetail/lockSet/lockTime/getServerDatetime_entity.dart'; import '../../../../blue/blue_manage.dart'; import '../../../../blue/io_protocol/io_getStarLockStatusInfo.dart'; @@ -23,65 +26,69 @@ class LockTimeLogic extends BaseGetXController{ // 获取解析后的数据 late StreamSubscription _replySubscription; void _initReplySubscription() { - _replySubscription = EventBusManager().eventBus!.on().listen((reply) { + _replySubscription = EventBusManager().eventBus!.on().listen((Reply reply) { if(reply is TimingReply) { _replyTiming(reply); } // 获取锁状态 - // if(reply is GetStarLockStatuInfoReply && state.ifCurrentScreen.value == true) { - // _replyGetStarLockStatusInfo(reply); - // } + if(reply is GetStarLockStatuInfoReply && state.ifCurrentScreen.value == true) { + _replyGetStarLockStatusInfo(reply); + } }); } - // 获取锁状态数据解析 - // Future _replyGetStarLockStatusInfo(Reply reply) async { - // int status = reply.data[2]; - // switch (status) { - // case 0x00: - // //成功 - // cancelBlueConnetctToastTimer(); - // dismissEasyLoading(); - // - // // 有效时间 - // var indate = reply.data.sublist(149, 153); - // int indateValue = ((0xff & indate[(0)]) << 24 | - // (0xff & indate[1]) << 16 | - // (0xff & indate[2]) << 8 | - // (0xFF & indate[3])); - // state.dateTime.value = DateTool().dateToYMDHNString("$indateValue"); - // break; - // case 0x06: - // //需要鉴权 - // var privateKey = await Storage.getStringList(saveBluePrivateKey); - // List getPrivateKeyList = changeStringListToIntList(privateKey!); - // IoSenderManage.senderGetStarLockStatuInfo( - // lockID: BlueManage().connectDeviceName, - // userID: await Storage.getUid(), - // isBeforeAddUser: false, - // privateKey: getPrivateKeyList, - // ); - // break; - // default: - // //失败 - // break; - // } - // } +// 获取锁状态数据解析 + Future _replyGetStarLockStatusInfo(Reply reply) async { + final int status = reply.data[2]; + switch (status) { + case 0x00: + //成功 + cancelBlueConnetctToastTimer(); + dismissEasyLoading(); + + // 有效时间 + final List indate = reply.data.sublist(150, 154); + final int indateValue = (0xff & indate[0]) << 24 | + (0xff & indate[1]) << 16 | + (0xff & indate[2]) << 8 | + (0xFF & indate[3]); + AppLog.log('indate:$indate indateValue:$indateValue'); + state.dateTime.value = DateTool().dateToYMDHNString('$indateValue'); + break; + case 0x06: + //需要鉴权 + final List? privateKey = await Storage.getStringList(saveBluePrivateKey); + final List getPrivateKeyList = changeStringListToIntList(privateKey!); + + IoSenderManage.senderGetStarLockStatuInfo( + lockID: BlueManage().connectDeviceName, + userID: await Storage.getUid(), + utcTimeStamp: 0, + unixTimeStamp: 0, + isBeforeAddUser: false, + privateKey: getPrivateKeyList, + ); + break; + default: + //失败 + break; + } + } // 校时数据解析 Future _replyTiming(Reply reply) async { - int status = reply.data[2]; + final int status = reply.data[2]; switch(status){ case 0x00: //成功 - String dataEime = DateTool().dateToYMDHNString("${getUTCNetTime()}"); + final String dataEime = DateTool().dateToYMDHNString('${getLocalTime()}'); state.dateTime.value = dataEime; state.sureBtnState.value = 0; cancelBlueConnetctToastTimer(); dismissEasyLoading(); - showToast("锁时间更新成功".tr); + showToast('锁时间更新成功'.tr); break; case 0x06: //无权限 @@ -105,20 +112,19 @@ class LockTimeLogic extends BaseGetXController{ }); BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async { if (connectionState == BluetoothConnectionState.connected) { - var privateKey = await Storage.getStringList(saveBluePrivateKey); - List getPrivateKeyList = changeStringListToIntList(privateKey!); + final List? privateKey = await Storage.getStringList(saveBluePrivateKey); + final List getPrivateKeyList = changeStringListToIntList(privateKey!); - var token = await Storage.getStringList(saveBlueToken); - List getTokenList = changeStringListToIntList(token!); + final List? token = await Storage.getStringList(saveBlueToken); + final List getTokenList = changeStringListToIntList(token!); - var signKey = await Storage.getStringList(saveBlueSignKey); - List getSignKeyList = changeStringListToIntList(signKey!); + final List? signKey = await Storage.getStringList(saveBlueSignKey); + final List getSignKeyList = changeStringListToIntList(signKey!); IoSenderManage.senderTimingCommand( lockID:BlueManage().connectDeviceName, userID:await Storage.getUid(), - // nowTime:DateTime.now().millisecondsSinceEpoch~/1000, - nowTime: getUTCNetTime(), + nowTime: getLocalTime(), token:getTokenList, needAuthor:1, signKey:getSignKeyList, @@ -135,37 +141,39 @@ class LockTimeLogic extends BaseGetXController{ }); } - // 获取锁状态 更新电量 - // Future getStarLockStatus() async { - // showEasyLoading(); - // showBlueConnetctToastTimer(action: () { - // dismissEasyLoading(); - // }); - // BlueManage().bludSendData(BlueManage().connectDeviceName, - // (BluetoothConnectionState deviceConnectionState) async { - // if (deviceConnectionState == BluetoothConnectionState.connected) { - // dismissEasyLoading(); - // var privateKey = await Storage.getStringList(saveBluePrivateKey); - // List getPrivateKeyList = changeStringListToIntList(privateKey!); - // IoSenderManage.senderGetStarLockStatuInfo( - // lockID: BlueManage().connectDeviceName, - // userID: await Storage.getUid(), - // isBeforeAddUser: false, - // privateKey: getPrivateKeyList, - // ); - // } else if (deviceConnectionState == BluetoothConnectionState.disconnected) { - // dismissEasyLoading(); - // cancelBlueConnetctToastTimer(); - // if (state.ifCurrentScreen.value == true) { - // showBlueConnetctToast(); - // } - // } - // }); - // } +// 获取锁状态 更新时间 + Future getStarLockStatus() async { + showEasyLoading(); + showBlueConnetctToastTimer(action: () { + dismissEasyLoading(); + }); + BlueManage().blueSendData(BlueManage().connectDeviceName, + (BluetoothConnectionState deviceConnectionState) async { + if (deviceConnectionState == BluetoothConnectionState.connected) { + final List? privateKey = await Storage.getStringList(saveBluePrivateKey); + final List getPrivateKeyList = changeStringListToIntList(privateKey!); + + IoSenderManage.senderGetStarLockStatuInfo( + lockID: BlueManage().connectDeviceName, + userID: await Storage.getUid(), + utcTimeStamp: 0, + unixTimeStamp: 0, + isBeforeAddUser: false, + privateKey: getPrivateKeyList, + ); + } else if (deviceConnectionState == BluetoothConnectionState.disconnected) { + dismissEasyLoading(); + cancelBlueConnetctToastTimer(); + if (state.ifCurrentScreen.value == true) { + showBlueConnetctToast(); + } + } + }); + } // 从网关获取时间 - void getLockTimeFromGateway() async{ - var entity = await ApiRepository.to.getLockTimeFromGateway( + Future getLockTimeFromGateway() async{ + final GetServerDatetimeEntity entity = await ApiRepository.to.getLockTimeFromGateway( lockId: state.lockSetInfoData.value.lockId.toString(), ); if(entity.errorCode!.codeIsSuccessful){ @@ -174,41 +182,45 @@ class LockTimeLogic extends BaseGetXController{ } // 从服务器获取锁的时间 开锁时传入 - void getServerDatetime() async{ - var entity = await ApiRepository.to.getServerDatetimeData(); + Future getServerDatetime() async{ + final GetServerDatetimeEntity entity = await ApiRepository.to.getServerDatetimeData(); if(entity.errorCode!.codeIsSuccessful){ state.differentialTime = entity.data!.date! ~/ 1000 - DateTime.now().millisecondsSinceEpoch ~/ 1000; // AppLog.log("entity.data!.date! ~/ 1000:${entity.data!.date! ~/ 1000} DateTime.now().millisecondsSinceEpoch ~/ 1000:${DateTime.now().millisecondsSinceEpoch ~/ 1000} 服务器时间差:${state.differentialTime}"); + getStarLockStatus(); } } - int getUTCNetTime(){ + int getLocalTime(){ return DateTime.now().millisecondsSinceEpoch ~/ 1000 + state.differentialTime; } + int getUTCTime(){ + final DateTime utcTime = DateTime.fromMillisecondsSinceEpoch(getLocalTime()*1000, isUtc: true); + + final String appointmentDate = DateTool().getYMDHNDateStringWithDateTime(utcTime, 1); + final int utcTimeValue = DateTool().dateToTimestamp(appointmentDate, 1); + AppLog.log('appointmentDate: $appointmentDate utcTimeValue:$utcTimeValue'); + return utcTimeValue ~/ 1000; + } + @override void onReady() { - // TODO: implement onReady super.onReady(); _initReplySubscription(); - // getStarLockStatus(); // getLockTimeFromGateway(); getServerDatetime(); } @override void onInit() { - // TODO: implement onInit super.onInit(); - - // _getLockStatus(); } @override void onClose() { - // TODO: implement onClose super.onClose(); _replySubscription.cancel(); } diff --git a/lib/main/lockDetail/lockSet/lockTime/lockTime_page.dart b/lib/main/lockDetail/lockSet/lockTime/lockTime_page.dart index 06883e72..69643e8b 100755 --- a/lib/main/lockDetail/lockSet/lockTime/lockTime_page.dart +++ b/lib/main/lockDetail/lockSet/lockTime/lockTime_page.dart @@ -77,7 +77,6 @@ class _LockTimePageState extends State with RouteAware{ @override void didChangeDependencies() { - // TODO: implement didChangeDependencies super.didChangeDependencies(); /// 路由订阅 @@ -86,7 +85,6 @@ class _LockTimePageState extends State with RouteAware{ @override void dispose() { - // TODO: implement dispose /// 取消路由订阅 AppRouteObserver().routeObserver.unsubscribe(this); super.dispose(); @@ -104,7 +102,9 @@ class _LockTimePageState 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; state.sureBtnState.value = 0; } @@ -121,7 +121,9 @@ class _LockTimePageState 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; state.sureBtnState.value = 0; } diff --git a/lib/main/lockDetail/lockSet/lockTime/lockTime_state.dart b/lib/main/lockDetail/lockSet/lockTime/lockTime_state.dart index c28d6727..2ec98723 100755 --- a/lib/main/lockDetail/lockSet/lockTime/lockTime_state.dart +++ b/lib/main/lockDetail/lockSet/lockTime/lockTime_state.dart @@ -2,16 +2,16 @@ import 'package:get/get.dart'; import '../lockSet/lockSetInfo_entity.dart'; -class LockTimeState{ - var lockSetInfoData = LockSetInfoData().obs; - var dateTime = "".obs; - int differentialTime = 0; - - var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示 - var sureBtnState = 0.obs;// 0普通状态(可用) 1连接中(不可用) +class LockTimeState{// 0普通状态(可用) 1连接中(不可用) LockTimeState() { - var map = Get.arguments; - lockSetInfoData.value = map["lockSetInfoData"]; + final map = Get.arguments; + lockSetInfoData.value = map['lockSetInfoData']; } + Rx lockSetInfoData = LockSetInfoData().obs; + RxString dateTime = ''.obs; + int differentialTime = 0; + + RxBool ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示 + RxInt sureBtnState = 0.obs; } \ No newline at end of file diff --git a/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart b/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart index cd8e1f3a..3542b31b 100755 --- a/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart +++ b/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart @@ -13,6 +13,7 @@ import 'package:star_lock/blue/io_protocol/io_getPrivateKey.dart'; import 'package:star_lock/blue/io_protocol/io_getPublicKey.dart'; import 'package:star_lock/blue/io_protocol/io_otaUpgrade.dart'; import 'package:star_lock/blue/io_protocol/io_processOtaUpgrade.dart'; +import 'package:star_lock/main/lockDetail/lockSet/lockTime/getServerDatetime_entity.dart'; import 'package:star_lock/mine/addLock/nearbyLock/nearbyLock_page.dart'; import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/widget/permission/permission_dialog.dart'; @@ -26,6 +27,7 @@ import '../../../blue/io_tool/io_tool.dart'; import '../../../blue/io_tool/manager_event_bus.dart'; import '../../../blue/sender_manage.dart'; import '../../../network/api_repository.dart'; +import '../../../tools/dateTool.dart'; import '../../../tools/storage.dart'; import 'nearbyLock_state.dart'; @@ -68,7 +70,7 @@ class NearbyLockLogic extends BaseGetXController { void _initReplySubscription() { _replySubscription = - EventBusManager().eventBus!.on().listen((reply) { + EventBusManager().eventBus!.on().listen((Reply reply) { if (reply is GetPublicKeyReply) { _replyGetPublicKey(reply); } @@ -110,8 +112,8 @@ class NearbyLockLogic extends BaseGetXController { //成功 AppLog.log('获取公钥成功'); // 储存公钥 - var publicKey = reply.data.sublist(3); - var saveStrList = changeIntListToStringList(publicKey); + final List publicKey = reply.data.sublist(3); + final List saveStrList = changeIntListToStringList(publicKey); Storage.setStringList(saveBluePublicKey, saveStrList); // 获取私钥 @@ -140,22 +142,21 @@ class NearbyLockLogic extends BaseGetXController { reply.data.removeAt(0); // 私钥 - List privateKey = reply.data.sublist(0, 16); - var savePrivateKeyList = changeIntListToStringList(privateKey); + final List privateKey = reply.data.sublist(0, 16); + final List savePrivateKeyList = changeIntListToStringList(privateKey); Storage.setStringList(saveBluePrivateKey, savePrivateKeyList); // signKey - List signKey = reply.data.sublist(16, 32); - var saveSignKeyList = changeIntListToStringList(signKey); + final List signKey = reply.data.sublist(16, 32); + final List saveSignKeyList = changeIntListToStringList(signKey); Storage.setStringList(saveBlueSignKey, saveSignKeyList); // 时间戳 - List timestamp = reply.data.sublist(32, 36); - state.timestampValue = ((0xff & timestamp[(0)]) << 24 | + final List timestamp = reply.data.sublist(32, 36); + state.timestampValue = (0xff & timestamp[0]) << 24 | (0xff & timestamp[1]) << 16 | (0xff & timestamp[2]) << 8 | - (0xFF & timestamp[3])); - + (0xFF & timestamp[3]); showTitleEasyLoading('获取锁信息 3/3'); _getStarLockStatus(); break; @@ -167,138 +168,138 @@ class NearbyLockLogic extends BaseGetXController { // 获取星锁状态 Future _replyGetStarLockStatusInfo(Reply reply) async { - int status = reply.data[2]; + final int status = reply.data[2]; switch (status) { case 0x00: //成功 AppLog.log('获取锁状态成功'); // 厂商名称 - var index = 3; - var vendor = reply.data.sublist(index, index + 20); - var vendorStr = utf8String(vendor); + int index = 3; + final List vendor = reply.data.sublist(index, index + 20); + final String vendorStr = utf8String(vendor); state.lockInfo['vendor'] = vendorStr; // state.lockInfo["vendor"] = "XL"; index = index + 20; AppLog.log('厂商名称 vendorStr:$vendorStr'); // 锁设备类型 - var product = reply.data[index]; + final int product = reply.data[index]; state.lockInfo['product'] = product; index = index + 1; AppLog.log('锁设备类型 product:$product'); // 产品名称 - var model = reply.data.sublist(index, index + 20); - var modelStr = utf8String(model); + final List model = reply.data.sublist(index, index + 20); + final String modelStr = utf8String(model); state.lockInfo['model'] = modelStr; // state.lockInfo["model"] = "JL-BLE-01"; index = index + 20; AppLog.log('产品名称 mmodelStr:$modelStr'); // 软件版本 - var fwVersion = reply.data.sublist(index, index+20); - var fwVersionStr = utf8String(fwVersion); + final List fwVersion = reply.data.sublist(index, index+20); + final String fwVersionStr = utf8String(fwVersion); state.lockInfo['fwVersion'] = fwVersionStr; index = index + 20; AppLog.log('软件版本 fwVersionStr:$fwVersionStr'); // 硬件版本 - var hwVersion = reply.data.sublist(index, index+20); - var hwVersionStr = utf8String(hwVersion); + final List hwVersion = reply.data.sublist(index, index+20); + final String hwVersionStr = utf8String(hwVersion); state.lockInfo['hwVersion'] = hwVersionStr; index = index + 20; AppLog.log('硬件版本 hwVersionStr:$hwVersionStr'); // 厂商序列号 - var serialNum0 = reply.data.sublist(index, index + 16); - var serialNum0Str = utf8String(serialNum0); + final List serialNum0 = reply.data.sublist(index, index + 16); + final String serialNum0Str = utf8String(serialNum0); state.lockInfo['serialNum0'] = serialNum0Str; // state.lockInfo["serialNum0"] = "${DateTime.now().millisecondsSinceEpoch ~/ 10}"; index = index + 16; AppLog.log('厂商序列号 serialNum0Str:${serialNum0Str.length}'); // 成品商序列号 - var serialNum1 = reply.data.sublist(index, index + 16); - var serialNum1Str = utf8String(serialNum1); + final List serialNum1 = reply.data.sublist(index, index + 16); + final String serialNum1Str = utf8String(serialNum1); state.lockInfo['serialNum1'] = serialNum1Str; index = index + 16; AppLog.log('成品商序列号 serialNum1Str:$serialNum1Str'); // 蓝牙名称 - var btDeviceName = reply.data.sublist(index, index + 16); - var btDeviceNameStr = utf8String(btDeviceName); + final List btDeviceName = reply.data.sublist(index, index + 16); + final String btDeviceNameStr = utf8String(btDeviceName); state.lockInfo['btDeviceName'] = btDeviceNameStr; index = index + 16; AppLog.log('蓝牙名称 btDeviceNameStr:$btDeviceNameStr'); // 电池剩余电量 - var battRemCap = reply.data[index]; + final int battRemCap = reply.data[index]; state.lockInfo['electricQuantity'] = battRemCap; index = index + 1; AppLog.log('电池剩余电量 battRemCap:$battRemCap'); // 备用电池剩余电量 - var battRemCapStandby = reply.data[index]; + final int battRemCapStandby = reply.data[index]; state.lockInfo['electricQuantityStandby'] = battRemCapStandby; index = index + 1; AppLog.log('电池剩余电量 battRemCap:$battRemCap'); // 重置次数 - var restoreCounter = reply.data.sublist(index, index + 2); + final List restoreCounter = reply.data.sublist(index, index + 2); state.lockInfo['restoreCount'] = restoreCounter[0] * 256 + restoreCounter[1]; index = index + 2; AppLog.log('重置次数 restoreCounter:${restoreCounter[0] * 256 + restoreCounter[1]}'); // 重置时间 - var restoreDate = reply.data.sublist(index, index + 4); - int restoreDateValue = ((0xff & restoreDate[(0)]) << 24 | + final List restoreDate = reply.data.sublist(index, index + 4); + final int restoreDateValue = (0xff & restoreDate[0]) << 24 | (0xff & restoreDate[1]) << 16 | (0xff & restoreDate[2]) << 8 | - (0xFF & restoreDate[3])); + (0xFF & restoreDate[3]); // String restoreDateStr = DateTool().dateToYMDHNSString(restoreDateValue.toString()); state.lockInfo['restoreDate'] = restoreDateValue * 1000; index = index + 4; AppLog.log('重置时间 restoreDateValue:$restoreDateValue'); // 主控芯片型号 - var icPartNo = reply.data.sublist(index, index + 10); - var icPartNoStr = utf8String(icPartNo); + final List icPartNo = reply.data.sublist(index, index + 10); + final String icPartNoStr = utf8String(icPartNo); state.lockInfo['icPartNo'] = icPartNoStr; index = index + 10; AppLog.log('主控芯片型号 icPartNoStr:$icPartNoStr'); // 有效时间 - var indate = reply.data.sublist(index, index + 4); - int indateValue = ((0xff & indate[(0)]) << 24 | + final List indate = reply.data.sublist(index, index + 4); + final int indateValue = (0xff & indate[0]) << 24 | (0xff & indate[1]) << 16 | (0xff & indate[2]) << 8 | - (0xFF & indate[3])); + (0xFF & indate[3]); // String indateStr = DateTool().dateToYMDHNSString("$indateValue"); state.lockInfo['indate'] = indateValue * 1000; index = index + 4; AppLog.log('有效时间 indateValue:$indateValue'); // mac地址 - var macAddress = reply.data.sublist(index, index + 20); - var macAddressStr = utf8String(macAddress); + final List macAddress = reply.data.sublist(index, index + 20); + final String macAddressStr = utf8String(macAddress); state.lockInfo['mac'] = macAddressStr; index = index + 20; AppLog.log('mac地址 macAddressStr:$macAddressStr'); // 锁特征值字符串长度 - var featureValueLength = reply.data[index]; + final int featureValueLength = reply.data[index]; index = index + 1; AppLog.log('锁特征值字符串长度 featureValueLength:$featureValueLength'); // 锁特征值说明(本机能支持的功能) // 获取到锁给的字符数组 - var featureNetxLength = index + featureValueLength; + final int featureNetxLength = index + featureValueLength; if (reply.data.length < featureNetxLength) { showToast('锁数据异常,请重试'); return; } - var featureValue = reply.data.sublist(index, index + featureValueLength); - String featureValueStr = asciiString(featureValue); + final List featureValue = reply.data.sublist(index, index + featureValueLength); + final String featureValueStr = asciiString(featureValue); state.featureValue = featureValueStr; // List allFeatureValueTwoList = charListChangeIntList(featureValue); // AppLog.log("featureValueLength:$featureValueLength featureValue:$featureValue \n featureValueStr:$featureValueStr"); @@ -306,18 +307,18 @@ class NearbyLockLogic extends BaseGetXController { AppLog.log('锁特征值字符串 featureValueStr:$featureValueStr'); // 使能特征值字符串长度 - var featureEnValLength = reply.data[index]; + final int featureEnValLength = reply.data[index]; index = index + 1; AppLog.log('使能特征值字符串长度 featureEnValLength:$featureEnValLength'); // 使能锁特征值说明(本机启用的功能) - var featureEnNextLength = index + featureEnValLength; + final int featureEnNextLength = index + featureEnValLength; if (reply.data.length < featureEnNextLength) { showToast('锁数据异常,请重试'); return; } - var featureEnVal = reply.data.sublist(index, index + featureEnValLength); - String featureEnValStr = asciiString(featureEnVal); + final List featureEnVal = reply.data.sublist(index, index + featureEnValLength); + final String featureEnValStr = asciiString(featureEnVal); state.featureSettingValue = featureEnValStr; // List allFeatureEnValTwoList = charListChangeIntList(featureEnVal); // AppLog.log("featureEnValLength:$featureEnValLength featureEnVal:$featureEnVal \n featureEnValStr:$featureEnValStr"); @@ -327,11 +328,11 @@ class NearbyLockLogic extends BaseGetXController { // 支持的带参数特征值的总条目数 // var featureParaTotal = reply.data[index]; - var featureParaTotalList = reply.data.sublist(index); + final List featureParaTotalList = reply.data.sublist(index); state.featureSettingParams = featureParaTotalList; AppLog.log('featureParaTotalList:$featureParaTotalList'); - Get.toNamed(Routers.lockAddressGaoDePage, arguments: { + Get.toNamed(Routers.lockAddressGaoDePage, arguments: { 'pwdTimestamp': state.timestampValue * 1000, 'lockInfo': state.lockInfo, 'featureValue': state.featureValue, @@ -342,8 +343,8 @@ class NearbyLockLogic extends BaseGetXController { break; case 0x06: //无权限 - var privateKey = await Storage.getStringList(saveBluePrivateKey); - List getPrivateKeyList = changeStringListToIntList(privateKey!); + final List? privateKey = await Storage.getStringList(saveBluePrivateKey); + final List getPrivateKeyList = changeStringListToIntList(privateKey!); // IoSenderManage.senderGetLockStatu( // lockID:BlueManage().connectDeviceName, // userID:await Storage.getUid(), @@ -352,8 +353,8 @@ class NearbyLockLogic extends BaseGetXController { IoSenderManage.senderGetStarLockStatuInfo( lockID: BlueManage().connectDeviceName, userID: await Storage.getUid(), - utcTimeStamp: getUTCNetTime(), - unixTimeStamp: getLocalNetTime(), + utcTimeStamp: getUTCTime(), + unixTimeStamp: getLocalTime(), isBeforeAddUser: true, privateKey: getPrivateKeyList, ); @@ -373,14 +374,14 @@ class NearbyLockLogic extends BaseGetXController { // dismissEasyLoading(); AppLog.log('开始获取锁状态'); - var privateKey = await Storage.getStringList(saveBluePrivateKey); - List getPrivateKeyList = changeStringListToIntList(privateKey!); + final List? privateKey = await Storage.getStringList(saveBluePrivateKey); + final List getPrivateKeyList = changeStringListToIntList(privateKey!); IoSenderManage.senderGetStarLockStatuInfo( lockID: BlueManage().connectDeviceName, userID: await Storage.getUid(), - utcTimeStamp: getUTCNetTime(), - unixTimeStamp: getLocalNetTime(), + utcTimeStamp: getUTCTime(), + unixTimeStamp: getLocalTime(), isBeforeAddUser: true, privateKey: getPrivateKeyList, ); @@ -394,12 +395,12 @@ class NearbyLockLogic extends BaseGetXController { BlueManage().startScan(2000, (List list) { state.devices.clear(); for (int i = 0; i < list.length; i++) { - ScanResult device = list[i]; - if (((device.advertisementData.serviceUuids.isNotEmpty + final ScanResult device = list[i]; + if ((device.advertisementData.serviceUuids.isNotEmpty ? device.advertisementData.serviceUuids[0] : '') .toString()[31] != - '1')) { + '1') { state.devices.add(list[i]); } } @@ -431,16 +432,16 @@ class NearbyLockLogic extends BaseGetXController { //手动升级 Future otaUpdate() async { - var status = await PermissionDialog.requestStorage(); + final bool status = await PermissionDialog.requestStorage(); if (status != true) { return; } - FilePickerResult? result = await FilePicker.platform.pickFiles(); + final FilePickerResult? result = await FilePicker.platform.pickFiles(); if (result == null || result.files.single.path is! String) { return; } - File file = File(result.files.single.path!); - Uint8List data = await file.readAsBytes(); + final File file = File(result.files.single.path!); + final Uint8List data = await file.readAsBytes(); headJson = await getHeadFile(data); if (headJson is! Map) { return; @@ -449,9 +450,9 @@ class NearbyLockLogic extends BaseGetXController { if (otaBin == null) { return; } - String md5Str = md5.convert(otaBin!).toString(); + final String md5Str = md5.convert(otaBin!).toString(); headJson!['fwMd5'] = md5Str; - blueOTAUpgrade(headJson!, [0, 0, 0, 0]); + blueOTAUpgrade(headJson!, [0, 0, 0, 0]); } //蓝牙操作 ota 升级 @@ -463,7 +464,7 @@ class NearbyLockLogic extends BaseGetXController { BlueManage().blueSendData(deviceName!, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected) { - String uid = await Storage.getUid() ?? ''; + final String uid = await Storage.getUid() ?? ''; BlueManage().writeCharacteristicWithResponse(OTAUpgradeCommand( lockID: deviceName, userID: uid, @@ -488,29 +489,29 @@ class NearbyLockLogic extends BaseGetXController { if (!state.otaUpdateIng.value) { return; } - int length = otaBin?.length ?? 0; + final int length = otaBin?.length ?? 0; if (otaCount == 0) { //首次 - int difference = length % 240; + final int difference = length % 240; otaCount = length ~/ 240 + (difference > 0 ? 1 : 0); startSecond = DateTime.now().millisecondsSinceEpoch ~/ 1000; } if (otaCount <= otaIndex) { - int now = DateTime.now().millisecondsSinceEpoch ~/ 1000; - String msg = + final int now = DateTime.now().millisecondsSinceEpoch ~/ 1000; + final String msg = '传输完成 时间:${now - startSecond}秒 otaCount:$otaCount otaIndex:$otaIndex '; closeOTADAta(); AppLog.log(msg); // showToast(msg); return; } - int star = otaIndex * 240; + final int star = otaIndex * 240; int end = (otaIndex + 1) * 240; if (end > length) { end = length; } - int size = end - star; - List data = otaBin!.sublist(star, end); + final int size = end - star; + final List data = otaBin!.sublist(star, end); state.otaProgress.value = otaIndex / otaCount; await BlueManage().writeCharacteristicWithResponse( ProcessOtaUpgradeCommand(index: otaIndex, size: size, data: data) @@ -594,7 +595,7 @@ class NearbyLockLogic extends BaseGetXController { return null; } AppLog.log(metaStr); - var meta = jsonDecode(metaStr); + final meta = jsonDecode(metaStr); if (meta is! Map) { showToast('解析元数据失败,请选择正确的文件'.tr); return null; @@ -604,11 +605,11 @@ class NearbyLockLogic extends BaseGetXController { //检测升级文件并读取 bin Future checkFile(Uint8List data, Map meta) async { - num binOffset = 16 + (meta['metaLen'] ?? 0); + final num binOffset = 16 + (meta['metaLen'] ?? 0); // 获取固件数据部分 - Uint8List bin = data.sublist(binOffset.toInt(), data.length); + final Uint8List bin = data.sublist(binOffset.toInt(), data.length); //md5 校验有问题,暂时不解析 - String md5Str = md5.convert(bin).toString().toUpperCase(); + final String md5Str = md5.convert(bin).toString().toUpperCase(); // AppLog.log('---> $md5Str ${meta['fwMd5']}'); if (md5Str != meta['fwMd5']) { showToast('文件校验失败 0x02'.tr); @@ -622,27 +623,25 @@ class NearbyLockLogic extends BaseGetXController { } // 从服务器获取锁的时间 开锁时传入 - void getServerDatetime() async{ - var entity = await ApiRepository.to.getServerDatetimeData(); + Future getServerDatetime() async{ + final GetServerDatetimeEntity entity = await ApiRepository.to.getServerDatetimeData(); if(entity.errorCode!.codeIsSuccessful){ state.differentialTime = entity.data!.date! ~/ 1000 - DateTime.now().millisecondsSinceEpoch ~/ 1000; - getLocalNetTime(); // AppLog.log("entity.data!.date! ~/ 1000:${entity.data!.date! ~/ 1000} DateTime.now().millisecondsSinceEpoch ~/ 1000:${DateTime.now().millisecondsSinceEpoch ~/ 1000} 服务器时间差:${state.differentialTime}"); } } - int getUTCNetTime(){ + int getLocalTime(){ return DateTime.now().millisecondsSinceEpoch ~/ 1000 + state.differentialTime; } - int getLocalNetTime(){ - DateTime utcTime = DateTime.fromMillisecondsSinceEpoch(getUTCNetTime()*1000, isUtc: true); - DateTime localTime = utcTime.toLocal(); + int getUTCTime(){ + final DateTime utcTime = DateTime.fromMillisecondsSinceEpoch(getLocalTime()*1000, isUtc: true); - // AppLog.log('getUTCNetTime: ${getUTCNetTime()}'); - // AppLog.log('UTC time: $utcTime'); - // AppLog.log('Local time: $localTime localTime.millisecondsSinceEpoch ~/ 1000:${localTime.millisecondsSinceEpoch ~/ 1000}'); - return localTime.millisecondsSinceEpoch ~/ 1000; + final String appointmentDate = DateTool().getYMDHNDateStringWithDateTime(utcTime, 1); + final int utcTimeValue = DateTool().dateToTimestamp(appointmentDate, 1); + AppLog.log('appointmentDate: $appointmentDate utcTimeValue:$utcTimeValue'); + return utcTimeValue ~/ 1000; } @override diff --git a/lib/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_logic.dart b/lib/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_logic.dart index 00346532..bd2d7ebf 100755 --- a/lib/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_logic.dart +++ b/lib/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_logic.dart @@ -95,7 +95,6 @@ class MinePersonInfoLogic extends BaseGetXController { source: ImageSource.camera, maxHeight: 250, maxWidth: 250, - imageQuality: 80 ); if (photo != null) { state.image = photo; diff --git a/lib/tools/dateTool.dart b/lib/tools/dateTool.dart index 3e986e92..2da0b052 100755 --- a/lib/tools/dateTool.dart +++ b/lib/tools/dateTool.dart @@ -116,6 +116,40 @@ class DateTool { return dateStr; } + /// 根据传入的PDuration及时间类型获取时间字符串 + /// type 1: 年月日时分(2023-01-01 12:00) 2: 年月日(2023-01-01) 3: 时分(12:00) + String getYMDHNDateStringWithDateTime(DateTime p, int type) { + final int year = p.year == 0 ? DateTime.now().year : p.year; + final int month = p.month == 0 ? DateTime.now().month : p.month; + final int day = p.day == 0 ? DateTime.now().day : p.day; + final int hour = p.hour; + final int minute = p.minute; + + String dateStr = ''; + switch (type) { + case 1: + // 年月日时分(2023-01-01 12:48) + dateStr = + '$year-${month!.toString().padLeft(2, '0')}-${day.toString().padLeft(2, '0')} ${hour.toString().padLeft(2, '0')}:${minute.toString().padLeft(2, '0')}'; + break; + case 2: + // 年月日(2023-01-01) + dateStr = + '$year-${month!.toString().padLeft(2, '0')}-${day.toString().padLeft(2, '0')}'; + break; + case 3: + // 时分(12:05) + dateStr = + '${hour.toString().padLeft(2, '0')}:${minute.toString().padLeft(2, '0')}'; + break; + default: + dateStr = + '$year-${month!.toString().padLeft(2, '0')}-${day.toString().padLeft(2, '0')} ${hour.toString().padLeft(2, '0')}:${minute.toString().padLeft(2, '0')}'; + break; + } + return dateStr; + } + /// 日期转化为时间戳 /// type 0: 12:00 1: 其他 int dateToTimestamp(String dateStr, int type) { From 2610e4fea05e2aa35dc28d10a9bbc87e6219ae7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=8F=E5=B0=91=E9=98=B3?= <786612630@qq.com> Date: Tue, 4 Jun 2024 09:24:58 +0800 Subject: [PATCH 10/12] =?UTF-8?q?=E5=8F=96=E6=B6=88flutter=5Fimage=5Fcompr?= =?UTF-8?q?ess=E6=8F=92=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../minePersonInfo/minePersonInfoPage/minePersonInfo_logic.dart | 1 - pubspec.yaml | 2 -- 2 files changed, 3 deletions(-) diff --git a/lib/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_logic.dart b/lib/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_logic.dart index bd2d7ebf..02630f89 100755 --- a/lib/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_logic.dart +++ b/lib/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_logic.dart @@ -1,7 +1,6 @@ import 'dart:async'; import 'dart:io'; import 'dart:typed_data'; -import 'package:flutter_image_compress/flutter_image_compress.dart'; import 'package:get/get.dart'; import 'package:image_picker/image_picker.dart'; import 'package:permission_handler/permission_handler.dart'; diff --git a/pubspec.yaml b/pubspec.yaml index e7502936..5d821885 100755 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -205,8 +205,6 @@ dependencies: file_picker: ^5.3.1 # 错误日志监控 flutter_bugly_plugin: ^0.0.9 - # 图片压缩 - flutter_image_compress: ^2.3.0 dependency_overrides: #强制设置google_maps_flutter_ios 为 2.5.2 From c31c771ee9d3b59c22c62f0b02c5d434ba57c8d6 Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Tue, 4 Jun 2024 09:29:55 +0800 Subject: [PATCH 11/12] =?UTF-8?q?feat:=E6=B7=BB=E5=8A=A0=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pubspec.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index ec8ee1c1..3d588e18 100755 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -62,8 +62,9 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # 1.0.53+2024052803:xhj 线上环境,提审 sky 线上环境提审 # 1.0.53+2024052804:xhj 线上环境,提审 修改鑫锁名字为星星锁 # 1.0.54+2024053001:xhj 线上环境,对外发布,提交测试 +# 1.0.56+202406401:xhj 线上环境,对外发布,提交测试 -version: 1.0.54+2024053001 +version: 1.0.56+202406401 environment: sdk: '>=2.12.0 <3.0.0' From bd2f9fa4ac4690e7c584496ee7752da6a0a24bb9 Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Tue, 4 Jun 2024 14:29:51 +0800 Subject: [PATCH 12/12] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E5=8F=91=E9=80=81?= =?UTF-8?q?=E9=92=A5=E5=8C=99=E9=A1=B5=E9=9D=A2=EF=BC=8C=E7=BC=BA=E5=B0=91?= =?UTF-8?q?=E7=9F=AD=E4=BF=A1=E9=80=9A=E7=9F=A5=EF=BC=8C=E9=82=AE=E7=AE=B1?= =?UTF-8?q?=E9=80=9A=E7=9F=A5=EF=BC=8C=E5=BE=AE=E4=BF=A1=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ios/Runner.xcodeproj/project.pbxproj | 22 +++++++++++++- ios/Runner/Info.plist | 6 ++-- ios/Runner/zh-Hans.lproj/LaunchScreen.strings | 1 + ios/Runner/zh-Hans.lproj/Main.strings | 1 + .../view/sendElectronicKeyView_logic.dart | 30 +++++++++++++++++++ .../view/sendElectronicKeyView_page.dart | 22 ++++++++++++-- 6 files changed, 76 insertions(+), 6 deletions(-) create mode 100644 ios/Runner/zh-Hans.lproj/LaunchScreen.strings create mode 100644 ios/Runner/zh-Hans.lproj/Main.strings diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 238f4a2e..a7b5e0e6 100755 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -153,6 +153,8 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 0420903B2C0EEAA50073E654 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Main.strings"; sourceTree = ""; }; + 0420903C2C0EEAA60073E654 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/LaunchScreen.strings"; sourceTree = ""; }; 04BFC4482BCFE05100688FCA /* RunnerRelease-xhj.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "RunnerRelease-xhj.entitlements"; sourceTree = ""; }; 0BEB3ADCCEC961E2916B9004 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; 0D02C18E16914A687A4A1AC2 /* devDebug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = devDebug.xcconfig; path = Flutter/devDebug.xcconfig; sourceTree = ""; }; @@ -619,11 +621,12 @@ }; buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; compatibilityVersion = "Xcode 9.3"; - developmentRegion = en; + developmentRegion = "zh-Hans"; hasScannedForEncodings = 0; knownRegions = ( en, Base, + "zh-Hans", ); mainGroup = 97C146E51CF9000F007C117D; productRefGroup = 97C146EF1CF9000F007C117D /* Products */; @@ -830,6 +833,7 @@ isa = PBXVariantGroup; children = ( 97C146FB1CF9000F007C117D /* Base */, + 0420903B2C0EEAA50073E654 /* zh-Hans */, ); name = Main.storyboard; sourceTree = ""; @@ -838,6 +842,7 @@ isa = PBXVariantGroup; children = ( 97C147001CF9000F007C117D /* Base */, + 0420903C2C0EEAA60073E654 /* zh-Hans */, ); name = LaunchScreen.storyboard; sourceTree = ""; @@ -1034,6 +1039,7 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ASSETCATALOG_COMPILER_APPICON_NAME = "$(ASSET_PREFIX)AppIcon"; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; @@ -1101,6 +1107,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; @@ -1298,6 +1305,7 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ASSETCATALOG_COMPILER_APPICON_NAME = "$(ASSET_PREFIX)AppIcon"; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; @@ -1367,6 +1375,7 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ASSETCATALOG_COMPILER_APPICON_NAME = "$(ASSET_PREFIX)AppIcon"; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; @@ -1436,6 +1445,7 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ASSETCATALOG_COMPILER_APPICON_NAME = "$(ASSET_PREFIX)AppIcon"; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; @@ -1510,6 +1520,7 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ASSETCATALOG_COMPILER_APPICON_NAME = "$(ASSET_PREFIX)AppIcon"; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; @@ -1579,6 +1590,7 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ASSETCATALOG_COMPILER_APPICON_NAME = "$(ASSET_PREFIX)AppIcon"; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; @@ -1648,6 +1660,7 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ASSETCATALOG_COMPILER_APPICON_NAME = "$(ASSET_PREFIX)AppIcon"; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; @@ -1720,6 +1733,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; @@ -1776,6 +1790,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; @@ -2118,6 +2133,7 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ASSETCATALOG_COMPILER_APPICON_NAME = "$(ASSET_PREFIX)AppIcon"; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; @@ -2187,6 +2203,7 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ASSETCATALOG_COMPILER_APPICON_NAME = "$(ASSET_PREFIX)AppIcon"; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; @@ -2261,6 +2278,7 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ASSETCATALOG_COMPILER_APPICON_NAME = "$(ASSET_PREFIX)AppIcon"; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; @@ -2330,6 +2348,7 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ASSETCATALOG_COMPILER_APPICON_NAME = "$(ASSET_PREFIX)AppIcon"; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; @@ -2399,6 +2418,7 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ASSETCATALOG_COMPILER_APPICON_NAME = "$(ASSET_PREFIX)AppIcon"; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index 8c233454..101a2449 100755 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -28,14 +28,14 @@ CFBundleTypeRole None CFBundleURLIconFile - + CFBundleURLName com.sky.skysmartlock CFBundleURLSchemes skysmartlock - - + + diff --git a/ios/Runner/zh-Hans.lproj/LaunchScreen.strings b/ios/Runner/zh-Hans.lproj/LaunchScreen.strings new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/ios/Runner/zh-Hans.lproj/LaunchScreen.strings @@ -0,0 +1 @@ + diff --git a/ios/Runner/zh-Hans.lproj/Main.strings b/ios/Runner/zh-Hans.lproj/Main.strings new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/ios/Runner/zh-Hans.lproj/Main.strings @@ -0,0 +1 @@ + diff --git a/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_logic.dart b/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_logic.dart index 5d49209f..f50161ed 100755 --- a/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_logic.dart +++ b/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_logic.dart @@ -3,9 +3,11 @@ import 'package:get/get.dart'; import 'package:star_lock/appRouters.dart'; import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart'; import 'package:star_lock/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_entity.dart'; +import 'package:star_lock/main/lockDetail/authorizedAdmin/authorizedAdmin/notice_template_entity.dart'; import 'package:star_lock/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_state.dart'; import 'package:star_lock/mine/valueAddedServices/advancedFunctionRecord/advancedFunctionRecord_entity.dart'; import 'package:star_lock/network/api_repository.dart'; +import 'package:star_lock/tools/NativeInteractionTool.dart'; import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/commonDataManage.dart'; import 'package:star_lock/tools/dateTool.dart'; @@ -20,6 +22,8 @@ class SendElectronicKeyViewLogic extends BaseGetXController { SendElectronicKeyViewLogic(this.type); String type; final SendElectronicKeyViewState state = SendElectronicKeyViewState(); + int? keyId; + List get weekDayStr { return state.weekdaysList.map((e) => TimeUtils.translateWeekday(e)).toList(); @@ -176,6 +180,7 @@ class SendElectronicKeyViewLogic extends BaseGetXController { if (entity.errorCode!.codeIsSuccessful) { state.createUser.value = 0; state.isSendSuccess = true; + keyId = entity.data!.keyId; resetData(); update(); eventBus.fire(ElectronicKeyListRefreshUI()); @@ -237,6 +242,31 @@ class SendElectronicKeyViewLogic extends BaseGetXController { return currentController; } + //发送消息 + Future sendMsg({required bool isPhone}) async { + if (keyId == null) { + return; + } + final NoticeTemplateEntity entity = await ApiRepository.to + .getNoticeTemplate( + lockId: CommonDataManage().currentKeyInfo.lockId!, + keyId: keyId!, + channelType: isPhone ? 1 : 2); + if (entity.errorCode!.codeIsSuccessful) { + final List list = + entity.data!.list!.where((Item item) => item.isUse == 0).toList(); + if (list.isNotEmpty) { + final Item item = list.first!; + final String template = item.template ?? ''; + NativeInteractionTool().loadNativeShare(shareText: template); + } else { + showToast('获取模板失败 0x02'); + } + } else { + showToast('获取模板失败 0x01'); + } + } + void resetData() { state.emailOrPhoneController.text = ''; state.keyNameController.text = ''; diff --git a/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_page.dart b/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_page.dart index a9cedb69..e9af69b4 100755 --- a/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_page.dart +++ b/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_page.dart @@ -416,15 +416,33 @@ class _SendElectronicKeyViewState extends State SizedBox( height: 10.h, ), + // OutLineBtn( + // btnName: '分享'.tr, + // onClick: () { + // _openModalBottomSheet(); + // }, + // ), OutLineBtn( - btnName: '分享'.tr, + btnName: + logic.state.emailOrPhoneController.text.contains('@') ? '邮件通知' : '短信通知', onClick: () { - _openModalBottomSheet(); + if (logic.state.emailOrPhoneController.text.contains('@')) { + Get.toNamed(Routers.sendEmailNotificationPage); + } else { + logic.sendMsg(isPhone: true); + } }, ), SizedBox( height: 10.h, ), + OutLineBtn( + btnName: '微信通知', + onClick: () { + logic.sendMsg( + isPhone: logic.state.emailOrPhoneController.text.contains('@')); + }, + ), ], ); }