From 21ce56ff0f0d09d24d15c373eda2e2e67f91b7ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=8F=E5=B0=91=E9=98=B3?= <786612630@qq.com> Date: Fri, 3 May 2024 10:13:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8D=87=E7=BA=A7=E7=95=8C=E9=9D=A2=EF=BC=8C=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E5=AF=86=E7=A0=81=E6=97=A5=E6=9C=9F=E8=B7=9F=E7=A6=BB?= =?UTF-8?q?=E7=BA=BF=E5=AF=86=E7=A0=81=E6=97=A5=E6=9C=9F=E5=88=86=E7=A6=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lockEscalation/lockEscalation_page.dart | 149 +++++++++--------- .../passwordKey_perpetual_logic.dart | 28 ++-- .../passwordKey_perpetual_page.dart | 56 +++++-- .../passwordKey_perpetual_state.dart | 3 + star_lock/lib/network/api_repository.dart | 17 +- 5 files changed, 142 insertions(+), 111 deletions(-) diff --git a/star_lock/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_page.dart b/star_lock/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_page.dart index 3ed29ee8..65a81e09 100644 --- a/star_lock/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_page.dart +++ b/star_lock/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_page.dart @@ -61,7 +61,8 @@ class _LockEscalationPageState extends State { width: 10.w, ), Text( - TranslationLoader.lanKeys!.haveNewVersion!.tr, + // TranslationLoader.lanKeys!.haveNewVersion!.tr, + "未发现新版本", style: TextStyle( fontSize: 24.sp, fontWeight: FontWeight.w600), ) @@ -75,80 +76,6 @@ class _LockEscalationPageState extends State { style: TextStyle( fontSize: 18.sp, color: AppColors.darkGrayTextColor), ), - SizedBox( - height: 10.h, - ), - Obx(() { - return !logic.state.otaUpdateIng.value - ? Stack( - children: [ - Container( - margin: EdgeInsets.only(top: 8, bottom: 8), - width: Get.width, - child: Center( - child: Text( - // "${TranslationLoader.lanKeys!.newVersion!.tr}:1.0.1", - "未发现新版本", - style: TextStyle( - color: AppColors.mainColor, - fontSize: 18.sp), - ), - ), - ), - Positioned( - right: 80.w, - child: GestureDetector( - onTap: () { - logic.otaUpdate(); - }, - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Text( - '手动升级', - style: TextStyle( - color: AppColors.mainColor, - fontSize: 18.sp, - fontWeight: FontWeight.w400), - ), - ), - ), - ) - ], - ) - : Padding( - padding: EdgeInsets.symmetric( - horizontal: 50.w, vertical: 15.h), - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - Text( - '固件传输中', - style: TextStyle( - color: AppColors.mainColor, - fontSize: 18.sp, - fontWeight: FontWeight.w400), - ), - SizedBox( - width: 10.w, - ), - Expanded( - child: ClipRRect( - borderRadius: BorderRadius.all( - Radius.circular(10.r)), - child: LinearProgressIndicator( - value: logic - .state.otaProgress.value, // 50% 进度 - backgroundColor: Colors.grey[200], - valueColor: - AlwaysStoppedAnimation( - AppColors.mainColor), - ), - ), - ), - ], - ), - ); - }), SizedBox( height: 40.h, ), @@ -159,6 +86,78 @@ class _LockEscalationPageState extends State { onClick: () {}) : SizedBox(); }), + SizedBox( + height: 10.h, + ), + Obx(() { + return !logic.state.otaUpdateIng.value + ? Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + // Container( + // margin: EdgeInsets.only(top: 8, bottom: 8), + // width: Get.width, + // child: Center( + // child: Text( + // // "${TranslationLoader.lanKeys!.newVersion!.tr}:1.0.1", + // "未发现新版本", + // style: TextStyle( + // color: AppColors.mainColor, + // fontSize: 18.sp), + // ), + // ), + // ), + GestureDetector( + onTap: () { + logic.otaUpdate(); + }, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Text( + '手动升级', + style: TextStyle( + color: AppColors.mainColor, + fontSize: 18.sp, + fontWeight: FontWeight.w400), + ), + ), + ) + ], + ) + : Padding( + padding: EdgeInsets.symmetric( + horizontal: 50.w, vertical: 15.h), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + '固件传输中', + style: TextStyle( + color: AppColors.mainColor, + fontSize: 18.sp, + fontWeight: FontWeight.w400), + ), + SizedBox( + width: 10.w, + ), + Expanded( + child: ClipRRect( + borderRadius: BorderRadius.all( + Radius.circular(10.r)), + child: LinearProgressIndicator( + value: logic + .state.otaProgress.value, // 50% 进度 + backgroundColor: Colors.grey[200], + valueColor: + AlwaysStoppedAnimation( + AppColors.mainColor), + ), + ), + ), + ], + ), + ); + }), ], ), )); diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart index b732cc68..4e82c36a 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart @@ -143,17 +143,17 @@ class PasswordKeyPerpetualLogic extends BaseGetXController { //是否为永久 if (state.isPermanent.value == false) { getKeyType = '3'; - getEffectiveDateTime = DateTool().dateToTimestamp(state.beginTime.value, 1).toString(); - getFailureDateTime = DateTool().dateToTimestamp(state.endTime.value, 1).toString(); + getEffectiveDateTime = DateTool().dateToTimestamp(state.customBeginTime.value, 1).toString(); + getFailureDateTime = DateTool().dateToTimestamp(state.customEndTime.value, 1).toString(); } var entity = await ApiRepository.to.addPasswordKey( - lockId, - state.nameController.text, - state.pwdController.text, - getKeyType, - getEffectiveDateTime, - getFailureDateTime, - '1'); + lockId:lockId, + keyboardPwdName:state.nameController.text, + keyboardPwd:state.pwdController.text, + keyboardPwdType:getKeyType, + startDate:getEffectiveDateTime, + endDate:getFailureDateTime, + addType:'1'); if (entity.errorCode!.codeIsSuccessful) { state.isSendSuccess.value = true; state.sendSucceedType.value = state.widgetType.value; @@ -234,8 +234,8 @@ class PasswordKeyPerpetualLogic extends BaseGetXController { pwdNo: state.isAdministrator.value == true ? 254 : 0, pwd:state.pwdController.text, useCountLimit: 0xff, - startTime: DateTool().dateToTimestamp(state.beginTime.value, 1)~/1000, - endTime: DateTool().dateToTimestamp(state.endTime.value, 1)~/1000, + startTime: DateTool().dateToTimestamp(state.customBeginTime.value, 1)~/1000, + endTime: DateTool().dateToTimestamp(state.customEndTime.value, 1)~/1000, needAuthor: 1, isBeforeAddUser: false, signKey: signKeyDataList, @@ -265,8 +265,8 @@ class PasswordKeyPerpetualLogic extends BaseGetXController { // 设置自定义密码 Future senderCustomPasswords() async { - var startDate = DateTool().dateToTimestamp(state.beginTime.value, 1); - var endDate = DateTool().dateToTimestamp(state.endTime.value, 1); + var startDate = DateTool().dateToTimestamp(state.customBeginTime.value, 1); + var endDate = DateTool().dateToTimestamp(state.customEndTime.value, 1); //非永久 须有时限 if (state.isPermanent.value == false) { if (startDate < DateTool().dateToTimestamp(DateTool().getNowDateWithType(3), 1)) { @@ -359,7 +359,7 @@ class PasswordKeyPerpetualLogic extends BaseGetXController { case 3: //自定义 if (state.isPermanent.value == false) { - '类型:自定义-限时\n有效期:${state.beginTime.value} -- ${state.endTime.value}'; + '类型:自定义-限时\n有效期:${state.customBeginTime.value} -- ${state.customEndTime.value}'; } else { useDateStr = '类型:自定义-永久'; } diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart index 894276a8..6a49f621 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart @@ -139,7 +139,7 @@ class _PasswordKeyPerpetualPageState extends State wit children: [ keyIfPerpetualWidget(), state.isPermanent.value == false - ? keyTimeLimitWidget() + ? keyCustomTimeLimitWidget() : Container(), perpetualKeyWidget( false, @@ -228,14 +228,9 @@ class _PasswordKeyPerpetualPageState extends State wit context, maxDate: PDuration(year: DateTime.now().year + 3, month: DateTime.now().month, day: DateTime.now().day, hour: 24), // minDate: PDuration.now(), - mode: state.widgetType.value == 3 ? DateMode.YMDHM:DateMode.YMDH, + mode: DateMode.YMDHM, onConfirm: (p) { - if (state.widgetType.value == 3) { - // 自定义 - state.beginTime.value = DateTool().getYMDHNDateString(p, 1); - } else { - state.beginTime.value = DateTool().getYMDHNDateString(p, 4); - } + state.beginTime.value = DateTool().getYMDHNDateString(p, 4); }); }), ), @@ -251,12 +246,7 @@ class _PasswordKeyPerpetualPageState extends State wit minDate: PDuration(year: DateTime.now().year, month: DateTime.now().month, day: DateTime.now().day), mode: DateMode.YMDH, onConfirm: (p) { - if (state.widgetType.value == 3) { - // 自定义 - state.endTime.value = DateTool().getYMDHNDateString(p, 1); - } else { - state.endTime.value = DateTool().getYMDHNDateString(p, 4); - } + state.endTime.value = DateTool().getYMDHNDateString(p, 4); }); }), Container(height: 10.h), @@ -264,6 +254,44 @@ class _PasswordKeyPerpetualPageState extends State wit ); } + // 自定义限时顶部选择日期 + Widget keyCustomTimeLimitWidget() { + return Column( + children: [ + CommonItem( + leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr, + rightTitle: state.customBeginTime.value, + isHaveLine: true, + isHaveDirection: true, + action: () { + Pickers.showDatePicker( + context, + // maxDate: PDuration(year: DateTime.now().year + 3, month: DateTime.now().month, day: DateTime.now().day, hour: 24), + // minDate: PDuration.now(), + mode: DateMode.YMDHM, + onConfirm: (p) { + state.customBeginTime.value = DateTool().getYMDHNDateString(p, 1); + }); + }), + CommonItem( + leftTitel: TranslationLoader.lanKeys!.failureTime!.tr, + rightTitle: state.customEndTime.value, + isHaveDirection: true, + action: () { + Pickers.showDatePicker(context, + // maxDate传入三年以后得今天的时间 + // maxDate: PDuration(year: DateTime.now().year + 3, month: DateTime.now().month, day: DateTime.now().day), + // minDate: PDuration(year: DateTime.now().year, month: DateTime.now().month, day: DateTime.now().day), + mode: DateMode.YMDHM, + onConfirm: (p) { + state.customEndTime.value = DateTool().getYMDHNDateString(p, 1); + }); + }), + Container(height: 10.h), + ], + ); + } + // 自定义是否永久 Widget keyIfPerpetualWidget() { return Column( diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_state.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_state.dart index ea1dab13..e9867c2e 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_state.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_state.dart @@ -25,6 +25,9 @@ class PasswordKeyPerpetualState { var loopEndHours = DateTime.now().hour.obs; var loopModeStr = '周末'.obs; //循环模式 + var customBeginTime = DateTool().getNowDateWithType(2).obs; //默认为当前时间 开始时间 + var customEndTime = DateTool().getNowDateWithType(2).obs;//默认为当前时间 结束时间 + final widgetType = 0.obs; final sendSucceedType = 0.obs; final keyInfo = LockListInfoItemEntity().obs; diff --git a/star_lock/lib/network/api_repository.dart b/star_lock/lib/network/api_repository.dart index 91121755..79fe0661 100644 --- a/star_lock/lib/network/api_repository.dart +++ b/star_lock/lib/network/api_repository.dart @@ -466,14 +466,15 @@ class ApiRepository { //自定义密码 Future addPasswordKey( - String lockId, - String keyboardPwdName, - String keyboardPwd, - String keyboardPwdType, - String startDate, - String endDate, - String addType, - ) async { + { + required String lockId, + required String keyboardPwdName, + required String keyboardPwd, + required String keyboardPwdType, + required String startDate, + required String endDate, + required String addType, + }) async { final res = await apiProvider.addKeyboardPwd(lockId, keyboardPwdName, keyboardPwd, keyboardPwdType, startDate, endDate, addType); return PasswordKeyEntity.fromJson(res.body);