diff --git a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart index 7831042c..8d71f90b 100644 --- a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart +++ b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart @@ -8,6 +8,7 @@ import 'package:star_lock/tools/dateTool.dart'; import 'package:star_lock/tools/pickers/pickers.dart'; import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart'; +import 'package:star_lock/tools/pickers/time_picker/model/pduration.dart'; import 'package:star_lock/tools/showTipView.dart'; import 'package:star_lock/tools/storage.dart'; @@ -28,7 +29,8 @@ class AuthorizedAdminPage extends StatefulWidget { State createState() => _AuthorizedAdminPageState(); } -class _AuthorizedAdminPageState extends State with SingleTickerProviderStateMixin { +class _AuthorizedAdminPageState extends State + with SingleTickerProviderStateMixin { final logic = Get.put(AuthorizedAdminLogic()); final state = Get.find().state; @@ -37,10 +39,8 @@ class _AuthorizedAdminPageState extends State with SingleTi // TODO: implement initState super.initState(); - state.tabController = TabController( - vsync: this, - length: _itemTabs.length, - initialIndex: 0); + state.tabController = + TabController(vsync: this, length: _itemTabs.length, initialIndex: 0); state.tabController.addListener(() { WidgetsBinding.instance.addPostFrameCallback((_) { state.seletType.value = state.tabController.index; @@ -96,7 +96,8 @@ class _AuthorizedAdminPageState extends State with SingleTi children: [ keyInfoWidget(), keyRealNameWidget(), - keyBottomWidget(TranslationLoader.lanKeys!.authorizedAdminTip!.tr) + keyBottomWidget( + TranslationLoader.lanKeys!.authorizedAdminTip!.tr) ], ), ); @@ -159,7 +160,10 @@ class _AuthorizedAdminPageState extends State with SingleTi isHaveLine: true, isHaveDirection: true, action: () { - Pickers.showDatePicker(context, mode: DateMode.YMDHM, onConfirm: (p) { + PDuration selectDate = + PDuration.parse(DateTime.tryParse(state.beginDate.value)); + Pickers.showDatePicker(context, + selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) { setState(() { state.beginDate.value = DateTool().getYMDHNDateString(p, 1); }); @@ -170,8 +174,10 @@ class _AuthorizedAdminPageState extends State with SingleTi rightTitle: state.endDate.value, isHaveDirection: true, action: () { - Pickers.showDatePicker(context, mode: DateMode.YMDHM, - onConfirm: (p) { + PDuration selectDate = + PDuration.parse(DateTime.tryParse(state.endDate.value)); + Pickers.showDatePicker(context, + selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) { setState(() { state.endDate.value = DateTool().getYMDHNDateString(p, 1); }); @@ -194,14 +200,18 @@ class _AuthorizedAdminPageState extends State with SingleTi tipsImgAction: () { ShowTipView().showSureAlertDialog("授权管理员只能查看和管理自己下发的钥匙、密码等权限"); }, - rightWidget: SizedBox(width: 60.w, height: 50.h, child: _onlyManageYouCreatesUserSwitch())), + rightWidget: SizedBox( + width: 60.w, + height: 50.h, + child: _onlyManageYouCreatesUserSwitch())), Container(height: 10.h), CommonItem( leftTitel: TranslationLoader.lanKeys!.realNameAuthentication!.tr, rightTitle: "", isTipsImg: true, tipsImgAction: () { - ShowTipView().showSureAlertDialog("人脸实名认证指的是用户在使用手机APP开锁时,需要先进行本人人脸验证,验证通过才能开锁。"); + ShowTipView().showSureAlertDialog( + "人脸实名认证指的是用户在使用手机APP开锁时,需要先进行本人人脸验证,验证通过才能开锁。"); }, isHaveRightWidget: true, rightWidget: SizedBox(width: 60.w, height: 50.h, child: _switch()), @@ -327,8 +337,8 @@ class _AuthorizedAdminPageState extends State with SingleTi Get.toNamed(Routers.sendEmailNotificationPage); } else { // _openModalBottomSheet(); - NativeInteractionTool().loadNativeShare( - shareText: state.pwdShareStr); + NativeInteractionTool() + .loadNativeShare(shareText: state.pwdShareStr); } // Get.toNamed(state.emailOrPhoneController.text.contains("@")? Routers.sendEmailNotificationPage:Routers.sendEmailNotificationPage); }, @@ -340,7 +350,8 @@ class _AuthorizedAdminPageState extends State with SingleTi btnName: '微信通知', onClick: () { // _openModalBottomSheet(); - NativeInteractionTool().loadNativeShare(shareText: state.pwdShareStr); + NativeInteractionTool() + .loadNativeShare(shareText: state.pwdShareStr); }, ), SizedBox( @@ -472,7 +483,8 @@ class _AuthorizedAdminPageState extends State with SingleTi value: state.onlyManageYouCreatesUser.value, onChanged: (value) { setState(() { - state.onlyManageYouCreatesUser.value = !state.onlyManageYouCreatesUser.value; + state.onlyManageYouCreatesUser.value = + !state.onlyManageYouCreatesUser.value; }); }, ); @@ -594,7 +606,7 @@ class _AuthorizedAdminPageState extends State with SingleTi return TabBar( controller: state.tabController, tabs: _itemTabs.map((ItemView item) => _tab(item)).toList(), - onTap: (index){ + onTap: (index) { FocusScope.of(context).requestFocus(FocusNode()); }, isScrollable: true, @@ -635,9 +647,10 @@ class _AuthorizedAdminPageState extends State with SingleTi Widget _pageWidget() { return Expanded( child: TabBarView( - controller: state.tabController, - children: _itemTabs.map((ItemView item) => Obx(() => indexChangeWidget())).toList() - ), + controller: state.tabController, + children: _itemTabs + .map((ItemView item) => Obx(() => indexChangeWidget())) + .toList()), ); } diff --git a/star_lock/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_page.dart b/star_lock/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_page.dart index e6c5decd..f3077f96 100644 --- a/star_lock/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_page.dart +++ b/star_lock/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_page.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_native_contact_picker/flutter_native_contact_picker.dart'; + // import 'package:flutter_pickers/pickers.dart'; // import 'package:flutter_pickers/time_picker/model/date_mode.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -12,6 +13,7 @@ import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/pickers/pickers.dart'; import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart'; +import 'package:star_lock/tools/pickers/time_picker/model/pduration.dart'; import '../../../../appRouters.dart'; import '../../../../tools/commonItem.dart'; @@ -169,8 +171,9 @@ class _VolumeAuthorizationLockPageState isHaveLine: true, isHaveDirection: true, action: () { - Pickers.showDatePicker(context, mode: DateMode.YMDHM, - onConfirm: (p) { + PDuration selectDate = PDuration.parse(_effectiveDateTime); + Pickers.showDatePicker(context, + selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) { setState(() { _selectEffectiveDate = '${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}'; @@ -183,8 +186,9 @@ class _VolumeAuthorizationLockPageState rightTitle: _selectFailureDate, isHaveDirection: true, action: () { - Pickers.showDatePicker(context, mode: DateMode.YMDHM, - onConfirm: (p) { + PDuration selectDate = PDuration.parse(_failureDateTime); + Pickers.showDatePicker(context, + selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) { setState(() { _selectFailureDate = '${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}'; @@ -270,10 +274,18 @@ class _VolumeAuthorizationLockPageState // contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0), hintText: tfStr, hintStyle: TextStyle(fontSize: 22.sp), - focusedBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), - disabledBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), - enabledBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), - border: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), + focusedBorder: const OutlineInputBorder( + borderSide: + BorderSide(width: 0, color: Colors.transparent)), + disabledBorder: const OutlineInputBorder( + borderSide: + BorderSide(width: 0, color: Colors.transparent)), + enabledBorder: const OutlineInputBorder( + borderSide: + BorderSide(width: 0, color: Colors.transparent)), + border: const OutlineInputBorder( + borderSide: + BorderSide(width: 0, color: Colors.transparent)), contentPadding: const EdgeInsets.symmetric(vertical: 0), ), // decoration: InputDecoration( @@ -333,22 +345,22 @@ class _VolumeAuthorizationLockPageState _effectiveDateTime.millisecondsSinceEpoch.toString(); } var entity = await ApiRepository.to.addAuthorizedAdmin( - createUser:_isCreateUser ? "1" : "0", - endDate:getFailureDateTime, - isRemoteUnlock:_isRemoteUnlock == true ? '1' : '2', - keyGroupIdList:[], - lockIdList:_lockIdList, - name:_keyNameController.text, - startDate:getEffectiveDateTime, - userid:_emailOrPhoneController.text, - countryCode:countryCode, - usernameType:'1', + createUser: _isCreateUser ? "1" : "0", + endDate: getFailureDateTime, + isRemoteUnlock: _isRemoteUnlock == true ? '1' : '2', + keyGroupIdList: [], + lockIdList: _lockIdList, + name: _keyNameController.text, + startDate: getEffectiveDateTime, + userid: _emailOrPhoneController.text, + countryCode: countryCode, + usernameType: '1', ); if (entity.errorCode!.codeIsSuccessful) { _isSendSuccess = true; setState(() {}); } else { - EasyLoading.showToast('${entity.errorMsg}',duration: 2000.milliseconds); + EasyLoading.showToast('${entity.errorMsg}', duration: 2000.milliseconds); if (entity.errorCode == 425) { //用户未注册 _isCreateUser = true; diff --git a/star_lock/lib/main/lockDetail/card/addCardType/addCardType_page.dart b/star_lock/lib/main/lockDetail/card/addCardType/addCardType_page.dart index 5a0209ec..d7137ea9 100644 --- a/star_lock/lib/main/lockDetail/card/addCardType/addCardType_page.dart +++ b/star_lock/lib/main/lockDetail/card/addCardType/addCardType_page.dart @@ -1,4 +1,3 @@ - import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -6,6 +5,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/tools/pickers/pickers.dart'; import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart'; +import 'package:star_lock/tools/pickers/time_picker/model/pduration.dart'; import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; @@ -25,7 +25,8 @@ class AddCardPage extends StatefulWidget { State createState() => _AddCardPageState(); } -class _AddCardPageState extends State with SingleTickerProviderStateMixin { +class _AddCardPageState extends State + with SingleTickerProviderStateMixin { final logic = Get.put(AddCardTypeLogic()); final state = Get.find().state; @@ -36,7 +37,9 @@ class _AddCardPageState extends State with SingleTickerProviderStat state.tabController = TabController( vsync: this, - length: state.fromType.value == 1 ? _itemTabs.length : _fromCheckInTypeItemTabs.length, + length: state.fromType.value == 1 + ? _itemTabs.length + : _fromCheckInTypeItemTabs.length, initialIndex: 0); state.tabController.addListener(() { WidgetsBinding.instance.addPostFrameCallback((_) { @@ -48,14 +51,14 @@ class _AddCardPageState extends State with SingleTickerProviderStat } }); } - + @override Widget build(BuildContext context) { return Scaffold( backgroundColor: AppColors.mainBackgroundColor, appBar: TitleAppBar( barTitle: - "${TranslationLoader.lanKeys!.addTip!.tr}${TranslationLoader.lanKeys!.card!.tr}", + "${TranslationLoader.lanKeys!.addTip!.tr}${TranslationLoader.lanKeys!.card!.tr}", haveBack: true, backgroundColor: AppColors.mainColor), body: Column( @@ -148,9 +151,12 @@ class _AddCardPageState extends State with SingleTickerProviderStat isHaveLine: true, isHaveDirection: true, action: () async { - Pickers.showDatePicker(context, mode: DateMode.YMDHM, - onConfirm: (p) { - state.timeLimitBeginTime.value = DateTool().getYMDHNDateString(p, 1); + PDuration selectDate = PDuration.parse( + DateTime.parse(state.timeLimitBeginTime.value)); + Pickers.showDatePicker(context, + selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) { + state.timeLimitBeginTime.value = + DateTool().getYMDHNDateString(p, 1); }); })), Obx(() => CommonItem( @@ -158,9 +164,12 @@ class _AddCardPageState extends State with SingleTickerProviderStat rightTitle: state.timeLimitEndTime.value, isHaveDirection: true, action: () { - Pickers.showDatePicker(context, mode: DateMode.YMDHM, - onConfirm: (p) { - state.timeLimitEndTime.value = DateTool().getYMDHNDateString(p, 1); + PDuration selectDate = + PDuration.parse(DateTime.tryParse(state.timeLimitEndTime.value)); + Pickers.showDatePicker(context, + selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) { + state.timeLimitEndTime.value = + DateTool().getYMDHNDateString(p, 1); }); })), Container(height: 10.h), @@ -174,11 +183,13 @@ class _AddCardPageState extends State with SingleTickerProviderStat children: [ Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr, - rightTitle:"${state.cycleBeginTime.value}\n${state.cycleEndTime.value}", + rightTitle: + "${state.cycleBeginTime.value}\n${state.cycleEndTime.value}", isHaveDirection: true, isHaveLine: true, action: () async { - var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: { + var result = + await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: { 'validityValue': state.weekdaysList.value, 'starDate': state.cycleBeginTime.value, 'endDate': state.cycleEndTime.value, @@ -201,13 +212,14 @@ class _AddCardPageState extends State with SingleTickerProviderStat isHaveDirection: true, isHaveLine: true, action: () async { - var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: { - 'validityValue': state.weekdaysList.value, - 'starDate': state.cycleBeginTime.value, - 'endDate': state.cycleEndTime.value, - 'starTime': state.effectiveDateTime.value, - 'endTime': state.failureDateTime.value - }); + var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, + arguments: { + 'validityValue': state.weekdaysList.value, + 'starDate': state.cycleBeginTime.value, + 'endDate': state.cycleEndTime.value, + 'starTime': state.effectiveDateTime.value, + 'endTime': state.failureDateTime.value + }); if (result != null && result.isNotEmpty) { state.weekdaysList.value = result['validityValue']; state.cycleBeginTime.value = result['starDate']; @@ -220,16 +232,18 @@ class _AddCardPageState extends State with SingleTickerProviderStat visible: state.effectiveDateTime.value.isNotEmpty, child: CommonItem( leftTitel: "有效时间".tr, - rightTitle: "${state.effectiveDateTime.value}-${state.failureDateTime.value}", + rightTitle: + "${state.effectiveDateTime.value}-${state.failureDateTime.value}", isHaveDirection: true, action: () async { - var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: { - 'validityValue': state.weekdaysList.value, - 'starDate': state.cycleBeginTime.value, - 'endDate': state.cycleEndTime.value, - 'starTime': state.effectiveDateTime.value, - 'endTime': state.failureDateTime.value - }); + var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, + arguments: { + 'validityValue': state.weekdaysList.value, + 'starDate': state.cycleBeginTime.value, + 'endDate': state.cycleEndTime.value, + 'starTime': state.effectiveDateTime.value, + 'endTime': state.failureDateTime.value + }); if (result != null && result.isNotEmpty) { state.weekdaysList.value = result['validityValue']; state.cycleBeginTime.value = result['starDate']; @@ -250,7 +264,8 @@ class _AddCardPageState extends State with SingleTickerProviderStat rightTitle: "", isTipsImg: false, isHaveRightWidget: true, - rightWidget: SizedBox(width: 60.w, height: 50.h, child: _isAdmin()))), + rightWidget: + SizedBox(width: 60.w, height: 50.h, child: _isAdmin()))), SizedBox(height: 10.h), Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.stressCard!.tr, @@ -260,14 +275,13 @@ class _AddCardPageState extends State with SingleTickerProviderStat rightWidget: SizedBox( width: 60.w, height: 50.h, child: _isStressFingerprint()))), Container( - color: Colors.white, - padding: EdgeInsets.only(left:20.w, right: 20.w, bottom: 20.h), - child: Text( - "${"当被胁迫要求强行开锁时,使用胁迫卡会触发报警,报警信息回推送给管理员,该功能需要锁联网。".tr}\n${"请不要将胁迫卡用于日常开锁".tr}", - style: TextStyle( - fontSize: 22.sp, color: AppColors.darkGrayTextColor), - ) - ), + color: Colors.white, + padding: EdgeInsets.only(left: 20.w, right: 20.w, bottom: 20.h), + child: Text( + "${"当被胁迫要求强行开锁时,使用胁迫卡会触发报警,报警信息回推送给管理员,该功能需要锁联网。".tr}\n${"请不要将胁迫卡用于日常开锁".tr}", + style: TextStyle( + fontSize: 22.sp, color: AppColors.darkGrayTextColor), + )), SizedBox(height: 30.h), SubmitBtn( btnName: TranslationLoader.lanKeys!.next!.tr, @@ -368,13 +382,14 @@ class _AddCardPageState extends State with SingleTickerProviderStat ); } - final List _itemTabs = [ + final List _itemTabs = [ ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, selectType: "0"), ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, selectType: "1"), - ItemView(title: TranslationLoader.lanKeys!.circulation!.tr, selectType: "2"), + ItemView( + title: TranslationLoader.lanKeys!.circulation!.tr, selectType: "2"), ]; - final List _fromCheckInTypeItemTabs = [ + final List _fromCheckInTypeItemTabs = [ ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, selectType: "0"), ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, selectType: "1"), ]; @@ -385,7 +400,11 @@ class _AddCardPageState extends State with SingleTickerProviderStat onTap: (index) { FocusScope.of(context).requestFocus(FocusNode()); }, - tabs: state.fromType.value == 1 ? _itemTabs.map((ItemView item) => _tab(item)).toList() : _fromCheckInTypeItemTabs.map((ItemView item) => _tab(item)).toList(), + tabs: state.fromType.value == 1 + ? _itemTabs.map((ItemView item) => _tab(item)).toList() + : _fromCheckInTypeItemTabs + .map((ItemView item) => _tab(item)) + .toList(), isScrollable: true, indicatorColor: Colors.red, unselectedLabelColor: Colors.black, @@ -417,14 +436,16 @@ class _AddCardPageState extends State with SingleTickerProviderStat return Expanded( child: TabBarView( controller: state.tabController, - children: - state.fromType.value == 1 - ? _itemTabs.map((ItemView item) => Obx(() => indexChangeWidget())).toList() - : _fromCheckInTypeItemTabs.map((ItemView item) => Obx(() => indexChangeWidget())).toList(), + children: state.fromType.value == 1 + ? _itemTabs + .map((ItemView item) => Obx(() => indexChangeWidget())) + .toList() + : _fromCheckInTypeItemTabs + .map((ItemView item) => Obx(() => indexChangeWidget())) + .toList(), ), ); } - } class ItemView { @@ -433,4 +454,3 @@ class ItemView { final String title; final String selectType; } - diff --git a/star_lock/lib/main/lockDetail/card/otherTypeKeyChangeDate/otherTypeKeyChangeDate_page.dart b/star_lock/lib/main/lockDetail/card/otherTypeKeyChangeDate/otherTypeKeyChangeDate_page.dart index fc5dfe48..ab6de185 100644 --- a/star_lock/lib/main/lockDetail/card/otherTypeKeyChangeDate/otherTypeKeyChangeDate_page.dart +++ b/star_lock/lib/main/lockDetail/card/otherTypeKeyChangeDate/otherTypeKeyChangeDate_page.dart @@ -1,4 +1,3 @@ - import 'dart:ffi'; import 'package:flutter/material.dart'; @@ -7,6 +6,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/tools/pickers/pickers.dart'; import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart'; +import 'package:star_lock/tools/pickers/time_picker/model/pduration.dart'; import '../../../../app_settings/app_colors.dart'; import '../../../../tools/appRouteObserver.dart'; @@ -24,7 +24,8 @@ class OtherTypeKeyChangeDatePage extends StatefulWidget { _OtherTypeKeyChangeDatePageState(); } -class _OtherTypeKeyChangeDatePageState extends State with RouteAware { +class _OtherTypeKeyChangeDatePageState extends State + with RouteAware { final logic = Get.put(OtherTypeKeyChangeDateLogic()); final state = Get.find().state; @@ -44,14 +45,20 @@ class _OtherTypeKeyChangeDatePageState extends State style: TextStyle(color: Colors.white, fontSize: 24.sp), ), onPressed: () { - state.beginTimeTimestamp.value = DateTool().dateToTimestamp(state.beginTime.value, 1); - state.endTimeTimestamp.value = DateTool().dateToTimestamp(state.endTime.value, 1); - if (state.beginTimeTimestamp.value > state.endTimeTimestamp.value || state.beginTimeTimestamp.value == state.endTimeTimestamp.value) { + state.beginTimeTimestamp.value = + DateTool().dateToTimestamp(state.beginTime.value, 1); + state.endTimeTimestamp.value = + DateTool().dateToTimestamp(state.endTime.value, 1); + if (state.beginTimeTimestamp.value > + state.endTimeTimestamp.value || + state.beginTimeTimestamp.value == + state.endTimeTimestamp.value) { logic.showToast("失效时间需大于生效时间".tr); return; } - if (state.endTimeTimestamp.value < DateTime.now().millisecondsSinceEpoch) { + if (state.endTimeTimestamp.value < + DateTime.now().millisecondsSinceEpoch) { logic.showToast("生效时间需大于当前时间".tr); return; } @@ -92,8 +99,10 @@ class _OtherTypeKeyChangeDatePageState extends State isHaveLine: true, isHaveDirection: true, action: () { - Pickers.showDatePicker(context, mode: DateMode.YMDHM, - onConfirm: (p) { + PDuration selectDate = + PDuration.parse(DateTime.tryParse(state.beginTime.value)); + Pickers.showDatePicker(context, + selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) { setState(() { state.beginTime.value = DateTool().getYMDHNDateString(p, 1); }); @@ -104,8 +113,10 @@ class _OtherTypeKeyChangeDatePageState extends State rightTitle: state.endTime.value, isHaveDirection: true, action: () { - Pickers.showDatePicker(context, mode: DateMode.YMDHM, - onConfirm: (p) { + PDuration selectDate = + PDuration.parse(DateTime.tryParse(state.endTime.value)); + Pickers.showDatePicker(context, + selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) { setState(() { state.endTime.value = DateTool().getYMDHNDateString(p, 1); }); @@ -165,5 +176,4 @@ class _OtherTypeKeyChangeDatePageState extends State state.ifCurrentScreen.value = false; state.sureBtnState.value = 0; } - } diff --git a/star_lock/lib/main/lockDetail/card/otherTypeKeyChangeValidityDate/otherTypeKeyChangeValidityDate_page.dart b/star_lock/lib/main/lockDetail/card/otherTypeKeyChangeValidityDate/otherTypeKeyChangeValidityDate_page.dart index ba01936e..13217817 100644 --- a/star_lock/lib/main/lockDetail/card/otherTypeKeyChangeValidityDate/otherTypeKeyChangeValidityDate_page.dart +++ b/star_lock/lib/main/lockDetail/card/otherTypeKeyChangeValidityDate/otherTypeKeyChangeValidityDate_page.dart @@ -3,6 +3,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/tools/pickers/pickers.dart'; import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart'; +import 'package:star_lock/tools/pickers/time_picker/model/pduration.dart'; import '../../../../app_settings/app_colors.dart'; import '../../../../tools/commonItem.dart'; @@ -20,7 +21,8 @@ class OtherTypeKeyChangeValidityDatePage extends StatefulWidget { _OtherTypeKeyChangeValidityDatePageState(); } -class _OtherTypeKeyChangeValidityDatePageState extends State { +class _OtherTypeKeyChangeValidityDatePageState + extends State { final logic = Get.put(OtherTypeKeyChangeValidityDateLogic()); final state = Get.find().state; @@ -44,17 +46,23 @@ class _OtherTypeKeyChangeValidityDatePageState extends State= state.endDateTimestamp.value) { + if (state.starDateTimestamp.value >= + state.endDateTimestamp.value) { logic.showToast("失效日期要大于生效日期".tr); return; } - if (state.starTimeTimestamp.value >= state.endTimeTimestamp.value) { + if (state.starTimeTimestamp.value >= + state.endTimeTimestamp.value) { logic.showToast("失效时间要大于生效时间".tr); return; } @@ -98,20 +106,27 @@ class _OtherTypeKeyChangeValidityDatePageState extends State CommonItem( leftTitel: "失效日期".tr, rightTitle: state.endDate.value, isHaveDirection: true, action: () { - Pickers.showDatePicker(context, mode: DateMode.YMD, - onConfirm: (p) { - state.endDate.value = DateTool().getYMDHNDateString(p, 2); - }); + PDuration selectDate = + PDuration.parse(DateTime.tryParse(state.endDate.value)); + Pickers.showDatePicker(context, + selectDate: selectDate, + mode: DateMode.YMD, onConfirm: (p) { + state.endDate.value = DateTool().getYMDHNDateString(p, 2); + }); })), Container(height: 10.h), ], @@ -135,7 +150,7 @@ class _OtherTypeKeyChangeValidityDatePageState extends State { isHaveDirection: true, isHaveLine: true, action: () { - Pickers.showDatePicker(context, mode: DateMode.HM, - onConfirm: (p) { + PDuration selectDate = PDuration.parse(DateTool().dateToDateTime(state.beginTime.value, 0)); + Pickers.showDatePicker(context, + selectDate: selectDate, mode: DateMode.HM, onConfirm: (p) { setState(() { state.beginTime.value = DateTool().getYMDHNDateString(p, 3); - state.beginTimeTimestamp.value = DateTool().dateToTimestamp(state.beginTime.value, 0).toString(); + state.beginTimeTimestamp.value = DateTool() + .dateToTimestamp(state.beginTime.value, 0) + .toString(); }); }); })), @@ -59,11 +63,14 @@ class _CheckingInSetWorkTimePageState extends State { rightTitle: state.endTime.value, isHaveDirection: true, action: () { - Pickers.showDatePicker(context, mode: DateMode.HM, - onConfirm: (p) { + PDuration selectDate = PDuration.parse(DateTool().dateToDateTime(state.endTime.value, 0)); + Pickers.showDatePicker(context, + selectDate: selectDate, mode: DateMode.HM, onConfirm: (p) { setState(() { state.endTime.value = DateTool().getYMDHNDateString(p, 3); - state.endTimeTimestamp.value = DateTool().dateToTimestamp(state.endTime.value, 0).toString(); + state.endTimeTimestamp.value = DateTool() + .dateToTimestamp(state.endTime.value, 0) + .toString(); }); }); })), @@ -87,7 +94,8 @@ class _CheckingInSetWorkTimePageState extends State { return; } - if (int.parse(state.beginTimeTimestamp.value) >= int.parse(state.endTimeTimestamp.value)) { + if (int.parse(state.beginTimeTimestamp.value) >= + int.parse(state.endTimeTimestamp.value)) { logic.showToast("结束时间必须要比开始时间晚,请重新选择"); return; } diff --git a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetailChangeDate/electronicKeyDetailChangeDate_page.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetailChangeDate/electronicKeyDetailChangeDate_page.dart index ee8a2fdd..a04a8fbb 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetailChangeDate/electronicKeyDetailChangeDate_page.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetailChangeDate/electronicKeyDetailChangeDate_page.dart @@ -5,6 +5,7 @@ import 'package:get/get.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetailChangeDate/electronicKeyDetailChangeDate_logic.dart'; import 'package:star_lock/tools/pickers/pickers.dart'; import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart'; +import 'package:star_lock/tools/pickers/time_picker/model/pduration.dart'; import '../../../../../app_settings/app_colors.dart'; import '../../../../../tools/commonItem.dart'; @@ -59,27 +60,30 @@ class _ElectronicKeyDetailChangeDateState isHaveLine: true, isHaveDirection: true, action: () { - Pickers.showDatePicker(context, mode: DateMode.YMDHM, - onConfirm: (p) { - setState(() { - state.beginTime.value = DateTool().getYMDHNDateString(p, 1); - }); - }); + PDuration selectDate = + PDuration.parse(DateTime.tryParse(state.beginTime.value)); + Pickers.showDatePicker(context, + selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) { + setState(() { + state.beginTime.value = DateTool().getYMDHNDateString(p, 1); + }); + }); })), Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.failureTime!.tr, rightTitle: state.endTime.value, isHaveDirection: true, action: () { - Pickers.showDatePicker(context, mode: DateMode.YMDHM, - onConfirm: (p) { - setState(() { - state.endTime.value = DateTool().getYMDHNDateString(p, 1); - }); - }); + PDuration selectDate = + PDuration.parse(DateTime.tryParse(state.endTime.value)); + Pickers.showDatePicker(context, + selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) { + setState(() { + state.endTime.value = DateTool().getYMDHNDateString(p, 1); + }); + }); })), ], ); } - } diff --git a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyPeriodValidity/electronicKeyPeriodValidity_page.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyPeriodValidity/electronicKeyPeriodValidity_page.dart index 96ca4eed..0142e9de 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyPeriodValidity/electronicKeyPeriodValidity_page.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyPeriodValidity/electronicKeyPeriodValidity_page.dart @@ -3,6 +3,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/tools/pickers/pickers.dart'; import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart'; +import 'package:star_lock/tools/pickers/time_picker/model/pduration.dart'; import '../../../../../app_settings/app_colors.dart'; import '../../../../../tools/commonItem.dart'; @@ -20,7 +21,8 @@ class ElectronicKeyPeriodValidityPage extends StatefulWidget { _ElectronicKeyPeriodValidityPageState(); } -class _ElectronicKeyPeriodValidityPageState extends State { +class _ElectronicKeyPeriodValidityPageState + extends State { final logic = Get.put(ElectronicKeyPeriodValidityLogic()); final state = Get.find().state; @@ -46,9 +48,7 @@ class _ElectronicKeyPeriodValidityPageState extends State CommonItem( leftTitel: "失效日期".tr, rightTitle: state.endDate.value, isHaveDirection: true, action: () { - Pickers.showDatePicker(context, mode: DateMode.YMD, - onConfirm: (p) { - state.endDate.value = DateTool().getYMDHNDateString(p, 2); - }); + PDuration selectDate = + PDuration.parse(DateTime.tryParse(state.endDate.value)); + Pickers.showDatePicker(context, + selectDate: selectDate, + mode: DateMode.YMD, onConfirm: (p) { + state.endDate.value = DateTool().getYMDHNDateString(p, 2); + }); })), Container(height: 10.h), ], @@ -105,7 +112,7 @@ class _ElectronicKeyPeriodValidityPageState extends State Container( - width: 40.w, - height: 40.w, - margin: EdgeInsets.all(10.w), - decoration: BoxDecoration( - color: state.weekDay.value.contains(index) - ? AppColors.mainColor - : Colors.white, - border: Border.all(width: 1, color: AppColors.btnDisableColor), - borderRadius: BorderRadius.circular(30.w), - ), - child: Center( - child: Text( + width: 40.w, + height: 40.w, + margin: EdgeInsets.all(10.w), + decoration: BoxDecoration( + color: state.weekDay.value.contains(index) + ? AppColors.mainColor + : Colors.white, + border: Border.all(width: 1, color: AppColors.btnDisableColor), + borderRadius: BorderRadius.circular(30.w), + ), + child: Center( + child: Text( dateStr, style: TextStyle( fontSize: 20.sp, @@ -182,7 +189,7 @@ class _ElectronicKeyPeriodValidityPageState extends State CommonItem( leftTitel: - "${TranslationLoader.lanKeys!.begin!.tr}${TranslationLoader.lanKeys!.time!.tr}", + "${TranslationLoader.lanKeys!.begin!.tr}${TranslationLoader.lanKeys!.time!.tr}", rightTitle: state.starTime.value, isHaveDirection: true, isHaveLine: true, action: () { - Pickers.showDatePicker(context, mode: DateMode.HM, - onConfirm: (p) { - setState(() { - state.starTime.value = DateTool().getYMDHNDateString(p, 3); - }); - }); + PDuration selectDate = PDuration.parse(DateTool().dateToDateTime(state.starTime.value, 0)); + Pickers.showDatePicker(context, + selectDate: selectDate, + mode: DateMode.HM, onConfirm: (p) { + setState(() { + state.starTime.value = + DateTool().getYMDHNDateString(p, 3); + }); + }); })), Obx(() => CommonItem( leftTitel: - "${TranslationLoader.lanKeys!.end!.tr}${TranslationLoader.lanKeys!.time!.tr}", + "${TranslationLoader.lanKeys!.end!.tr}${TranslationLoader.lanKeys!.time!.tr}", rightTitle: state.endTime.value, isHaveDirection: true, action: () { - Pickers.showDatePicker(context, mode: DateMode.HM, - onConfirm: (p) { - setState(() { - state.endTime.value = DateTool().getYMDHNDateString(p, 3); - }); - }); + PDuration selectDate = PDuration.parse(DateTool().dateToDateTime(state.endTime.value, 0)); + Pickers.showDatePicker(context, + selectDate: selectDate, + mode: DateMode.HM, onConfirm: (p) { + setState(() { + state.endTime.value = + DateTool().getYMDHNDateString(p, 3); + }); + }); })), Container(height: 10.h), ], diff --git a/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendElectronicKey/massSendElectronicKey_page.dart b/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendElectronicKey/massSendElectronicKey_page.dart index 3b9d58b8..128557d8 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendElectronicKey/massSendElectronicKey_page.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendElectronicKey/massSendElectronicKey_page.dart @@ -1,4 +1,3 @@ - import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -6,6 +5,7 @@ import 'package:get/get.dart'; import 'package:star_lock/app_settings/app_colors.dart'; import 'package:star_lock/tools/pickers/pickers.dart'; import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart'; +import 'package:star_lock/tools/pickers/time_picker/model/pduration.dart'; import '../../../../../../tools/commonItem.dart'; import '../../../../../../tools/submitBtn.dart'; @@ -48,7 +48,9 @@ class _MassSendElectronicKeyPageState extends State { state.type.value = widget.type; return SingleChildScrollView( - child: state.isDemoMode ? indexChangeWidget() : Obx(() => indexChangeWidget()), + child: state.isDemoMode + ? indexChangeWidget() + : Obx(() => indexChangeWidget()), ); } @@ -178,7 +180,8 @@ class _MassSendElectronicKeyPageState extends State { rightWidget: Text( '${state.countryName.value} +${state.countryCode.value}', textAlign: TextAlign.end, - style: TextStyle(fontSize: 22.sp, color: AppColors.darkGrayTextColor), + style: + TextStyle(fontSize: 22.sp, color: AppColors.darkGrayTextColor), ), action: () async { var result = await Navigator.pushNamed( @@ -223,20 +226,24 @@ class _MassSendElectronicKeyPageState extends State { isHaveLine: true, isHaveDirection: true, action: () { - Pickers.showDatePicker(context, mode: DateMode.YMDHM, - onConfirm: (p) { - state.beginTime.value = DateTool().getYMDHNDateString(p, 1); - }); + PDuration selectDate = + PDuration.parse(DateTime.tryParse(state.beginTime.value)); + Pickers.showDatePicker(context, + selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) { + state.beginTime.value = DateTool().getYMDHNDateString(p, 1); + }); })), Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.failureTime!.tr, rightTitle: state.endTime.value, isHaveDirection: true, action: () { - Pickers.showDatePicker(context, mode: DateMode.YMDHM, - onConfirm: (p) { - state.endTime.value = DateTool().getYMDHNDateString(p, 1); - }); + PDuration selectDate = + PDuration.parse(DateTime.tryParse(state.endTime.value)); + Pickers.showDatePicker(context, + selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) { + state.endTime.value = DateTool().getYMDHNDateString(p, 1); + }); })), Container(height: 10.h), ], @@ -268,15 +275,15 @@ class _MassSendElectronicKeyPageState extends State { isHaveDirection: true, isHaveLine: true, action: () async { - var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, - arguments: { - 'validityValue': state.weekdaysList.value, - 'starDate': state.beginTime.value, - 'endDate': state.endTime.value, - 'starTime': state.effectiveDateTime.value, - 'endTime': state.failureDateTime.value - }); - if(result != null && result.isNotEmpty){ + var result = + await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: { + 'validityValue': state.weekdaysList.value, + 'starDate': state.beginTime.value, + 'endDate': state.endTime.value, + 'starTime': state.effectiveDateTime.value, + 'endTime': state.failureDateTime.value + }); + if (result != null && result.isNotEmpty) { state.weekdaysList.value = result['validityValue']; state.beginTime.value = result['starDate']; state.endTime.value = result['endDate']; @@ -300,40 +307,41 @@ class _MassSendElectronicKeyPageState extends State { 'starTime': state.effectiveDateTime.value, 'endTime': state.failureDateTime.value }); - if(result != null && result.isNotEmpty){ + if (result != null && result.isNotEmpty) { state.weekdaysList.value = result['validityValue']; state.beginTime.value = result['starDate']; state.endTime.value = result['endDate']; state.effectiveDateTime.value = result['starTime']; state.failureDateTime.value = result['endTime']; } - }) - )), + }))), Obx(() => Visibility( - visible: state.effectiveDateTime.value.isNotEmpty, - child: CommonItem( - leftTitel: "有效时间".tr, - rightTitle: "${state.effectiveDateTime.value}-${state.failureDateTime.value}", - isHaveDirection: true, - action: () async { - var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, - arguments: { - 'validityValue': state.weekdaysList.value, - 'starDate': state.beginTime.value, - 'endDate': state.endTime.value, - 'starTime': state.effectiveDateTime.value, - 'endTime': state.failureDateTime.value - }); - if(result != null && result.isNotEmpty){ - state.weekdaysList.value = result['validityValue']; - state.beginTime.value = result['starDate']; - state.endTime.value = result['endDate']; - state.effectiveDateTime.value = result['starTime']; - state.failureDateTime.value = result['endTime']; - Get.back(result: result); - } - }), - )), + visible: state.effectiveDateTime.value.isNotEmpty, + child: CommonItem( + leftTitel: "有效时间".tr, + rightTitle: + "${state.effectiveDateTime.value}-${state.failureDateTime.value}", + isHaveDirection: true, + action: () async { + var result = await Get.toNamed( + Routers.seletKeyCyclicDatePage, + arguments: { + 'validityValue': state.weekdaysList.value, + 'starDate': state.beginTime.value, + 'endDate': state.endTime.value, + 'starTime': state.effectiveDateTime.value, + 'endTime': state.failureDateTime.value + }); + if (result != null && result.isNotEmpty) { + state.weekdaysList.value = result['validityValue']; + state.beginTime.value = result['starDate']; + state.endTime.value = result['endDate']; + state.effectiveDateTime.value = result['starTime']; + state.failureDateTime.value = result['endTime']; + Get.back(result: result); + } + }), + )), Container(height: 10.h), ], ); @@ -364,5 +372,4 @@ class _MassSendElectronicKeyPageState extends State { }, ); } - } diff --git a/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_page.dart b/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_page.dart index b0a05134..fcdd9649 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_page.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_page.dart @@ -1,4 +1,3 @@ - import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -11,6 +10,7 @@ import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/pickers/pickers.dart'; import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart'; +import 'package:star_lock/tools/pickers/time_picker/model/pduration.dart'; import 'package:star_lock/tools/showTipView.dart'; import 'package:star_lock/tools/storage.dart'; @@ -31,7 +31,8 @@ class SendElectronicKeyPage extends StatefulWidget { State createState() => _SendElectronicKeyPageState(); } -class _SendElectronicKeyPageState extends State with SingleTickerProviderStateMixin { +class _SendElectronicKeyPageState extends State + with SingleTickerProviderStateMixin { final logic = Get.put(SendElectronicKeyLogic()); final state = Get.find().state; @@ -46,10 +47,8 @@ class _SendElectronicKeyPageState extends State with Sing getDemoMode(); - state.tabController = TabController( - vsync: this, - length: _itemTabs.length, - initialIndex: 0); + state.tabController = + TabController(vsync: this, length: _itemTabs.length, initialIndex: 0); state.tabController.addListener(() { WidgetsBinding.instance.addPostFrameCallback((_) { state.seletType.value = state.tabController.index; @@ -203,9 +202,12 @@ class _SendElectronicKeyPageState extends State with Sing isHaveLine: true, isHaveDirection: true, action: () { - Pickers.showDatePicker(context, mode: DateMode.YMDHM, - onConfirm: (p) { - state.timeLimitBeginTime.value = DateTool().getYMDHNDateString(p, 1); + PDuration selectDate = PDuration.parse( + DateTime.parse(state.timeLimitBeginTime.value)); + Pickers.showDatePicker(context, + selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) { + state.timeLimitBeginTime.value = + DateTool().getYMDHNDateString(p, 1); }); })), Obx(() => CommonItem( @@ -213,9 +215,12 @@ class _SendElectronicKeyPageState extends State with Sing rightTitle: state.timeLimitEndTime.value, isHaveDirection: true, action: () { - Pickers.showDatePicker(context, mode: DateMode.YMDHM, - onConfirm: (p) { - state.timeLimitEndTime.value = DateTool().getYMDHNDateString(p, 1); + PDuration selectDate = + PDuration.parse(DateTime.tryParse(state.timeLimitEndTime.value)); + Pickers.showDatePicker(context, + selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) { + state.timeLimitEndTime.value = + DateTool().getYMDHNDateString(p, 1); }); })), Container(height: 10.h), @@ -232,7 +237,8 @@ class _SendElectronicKeyPageState extends State with Sing rightTitle: "", isTipsImg: true, tipsImgAction: () { - ShowTipView().showSureAlertDialog("人脸实名认证指的是用户在使用手机APP开锁时,需要先进行本人人脸验证,验证通过才能开锁。".tr); + ShowTipView().showSureAlertDialog( + "人脸实名认证指的是用户在使用手机APP开锁时,需要先进行本人人脸验证,验证通过才能开锁。".tr); }, isHaveRightWidget: true, rightWidget: SizedBox( @@ -250,19 +256,20 @@ class _SendElectronicKeyPageState extends State with Sing children: [ Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr, - rightTitle: "${state.cycleBeginTime.value}\n${state.cycleEndTime.value}", + rightTitle: + "${state.cycleBeginTime.value}\n${state.cycleEndTime.value}", isHaveDirection: true, isHaveLine: true, action: () async { - var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, - arguments: { - 'validityValue': state.weekdaysList.value, - 'starDate': state.cycleBeginTime.value, - 'endDate': state.cycleEndTime.value, - 'starTime': state.effectiveDateTime.value, - 'endTime': state.failureDateTime.value - }); - if(result != null && result.isNotEmpty){ + var result = + await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: { + 'validityValue': state.weekdaysList.value, + 'starDate': state.cycleBeginTime.value, + 'endDate': state.cycleEndTime.value, + 'starTime': state.effectiveDateTime.value, + 'endTime': state.failureDateTime.value + }); + if (result != null && result.isNotEmpty) { state.weekdaysList.value = result['validityValue']; state.cycleBeginTime.value = result['starDate']; state.cycleEndTime.value = result['endDate']; @@ -286,20 +293,20 @@ class _SendElectronicKeyPageState extends State with Sing 'starTime': state.effectiveDateTime.value, 'endTime': state.failureDateTime.value }); - if(result != null && result.isNotEmpty){ + if (result != null && result.isNotEmpty) { state.weekdaysList.value = result['validityValue']; state.cycleBeginTime.value = result['starDate']; state.cycleEndTime.value = result['endDate']; state.effectiveDateTime.value = result['starTime']; state.failureDateTime.value = result['endTime']; } - }) - )), + }))), Obx(() => Visibility( visible: state.effectiveDateTime.value.isNotEmpty, child: CommonItem( leftTitel: "有效时间".tr, - rightTitle: "${state.effectiveDateTime.value}-${state.failureDateTime.value}", + rightTitle: + "${state.effectiveDateTime.value}-${state.failureDateTime.value}", isHaveDirection: true, action: () async { var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, @@ -310,15 +317,14 @@ class _SendElectronicKeyPageState extends State with Sing 'starTime': state.effectiveDateTime.value, 'endTime': state.failureDateTime.value }); - if(result != null && result.isNotEmpty){ + if (result != null && result.isNotEmpty) { state.weekdaysList.value = result['validityValue']; state.cycleBeginTime.value = result['starDate']; state.cycleEndTime.value = result['endDate']; state.effectiveDateTime.value = result['starTime']; state.failureDateTime.value = result['endTime']; } - }) - )), + }))), ], ); } @@ -568,7 +574,9 @@ class _SendElectronicKeyPageState extends State with Sing return Visibility( visible: state.isDemoMode ? false - : (CommonDataManage().currentKeyInfo.lockSetting!.remoteUnlock == 1 ? true : false), + : (CommonDataManage().currentKeyInfo.lockSetting!.remoteUnlock == 1 + ? true + : false), child: Column( children: [ CommonItem( @@ -647,7 +655,7 @@ class _SendElectronicKeyPageState extends State with Sing TabBar _tabBar() { return TabBar( controller: state.tabController, - onTap: (index){ + onTap: (index) { FocusScope.of(context).requestFocus(FocusNode()); }, tabs: _itemTabs.map((ItemView item) => _tab(item)).toList(), @@ -689,10 +697,10 @@ class _SendElectronicKeyPageState extends State with Sing Widget _pageWidget() { return Expanded( child: TabBarView( - controller: state.tabController, - children: _itemTabs - .map((ItemView item) => Obx(() => indexChangeWidget())).toList() - ), + controller: state.tabController, + children: _itemTabs + .map((ItemView item) => Obx(() => indexChangeWidget())) + .toList()), ); } diff --git a/star_lock/lib/main/lockDetail/face/addFaceType/addFaceType_page.dart b/star_lock/lib/main/lockDetail/face/addFaceType/addFaceType_page.dart index 2fa1e028..fd62abee 100644 --- a/star_lock/lib/main/lockDetail/face/addFaceType/addFaceType_page.dart +++ b/star_lock/lib/main/lockDetail/face/addFaceType/addFaceType_page.dart @@ -6,6 +6,7 @@ import 'package:get/get.dart'; import 'package:star_lock/tools/dateTool.dart'; import 'package:star_lock/tools/pickers/pickers.dart'; import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart'; +import 'package:star_lock/tools/pickers/time_picker/model/pduration.dart'; import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; @@ -24,7 +25,8 @@ class AddFaceTypePage extends StatefulWidget { State createState() => _AddFaceTypePageState(); } -class _AddFaceTypePageState extends State with SingleTickerProviderStateMixin { +class _AddFaceTypePageState extends State + with SingleTickerProviderStateMixin { final logic = Get.put(AddFaceTypeLogic()); final state = Get.find().state; @@ -35,7 +37,9 @@ class _AddFaceTypePageState extends State with SingleTickerProv state.tabController = TabController( vsync: this, - length: state.fromType.value == 1 ? _itemTabs.length : _fromCheckInTypeItemTabs.length, + length: state.fromType.value == 1 + ? _itemTabs.length + : _fromCheckInTypeItemTabs.length, initialIndex: 0); state.tabController.addListener(() { WidgetsBinding.instance.addPostFrameCallback((_) { @@ -54,7 +58,7 @@ class _AddFaceTypePageState extends State with SingleTickerProv backgroundColor: AppColors.mainBackgroundColor, appBar: TitleAppBar( barTitle: - "${TranslationLoader.lanKeys!.addTip!.tr}${TranslationLoader.lanKeys!.face!.tr}", + "${TranslationLoader.lanKeys!.addTip!.tr}${TranslationLoader.lanKeys!.face!.tr}", haveBack: true, backgroundColor: AppColors.mainColor), body: Column( @@ -147,20 +151,26 @@ class _AddFaceTypePageState extends State with SingleTickerProv isHaveLine: true, isHaveDirection: true, action: () async { - Pickers.showDatePicker(context, mode: DateMode.YMDHM, - onConfirm: (p) { - state.timeLimitBeginTime.value = DateTool().getYMDHNDateString(p, 1); - }); + PDuration selectDate = PDuration.parse( + DateTime.parse(state.timeLimitBeginTime.value)); + Pickers.showDatePicker(context, + selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) { + state.timeLimitBeginTime.value = + DateTool().getYMDHNDateString(p, 1); + }); })), Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.failureTime!.tr, rightTitle: state.timeLimitEndTime.value, isHaveDirection: true, action: () { - Pickers.showDatePicker(context, mode: DateMode.YMDHM, - onConfirm: (p) { - state.timeLimitEndTime.value = DateTool().getYMDHNDateString(p, 1); - }); + PDuration selectDate = + PDuration.parse(DateTime.tryParse(state.timeLimitEndTime.value)); + Pickers.showDatePicker(context, + selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) { + state.timeLimitEndTime.value = + DateTool().getYMDHNDateString(p, 1); + }); })), Container(height: 10.h), ], @@ -173,11 +183,13 @@ class _AddFaceTypePageState extends State with SingleTickerProv children: [ Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr, - rightTitle:"${state.cycleBeginTime.value}\n${state.cycleEndTime.value}", + rightTitle: + "${state.cycleBeginTime.value}\n${state.cycleEndTime.value}", isHaveDirection: true, isHaveLine: true, action: () async { - var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: { + var result = + await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: { 'validityValue': state.weekdaysList.value, 'starDate': state.cycleBeginTime.value, 'endDate': state.cycleEndTime.value, @@ -200,13 +212,14 @@ class _AddFaceTypePageState extends State with SingleTickerProv isHaveDirection: true, isHaveLine: true, action: () async { - var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: { - 'validityValue': state.weekdaysList.value, - 'starDate': state.cycleBeginTime.value, - 'endDate': state.cycleEndTime.value, - 'starTime': state.effectiveDateTime.value, - 'endTime': state.failureDateTime.value - }); + var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, + arguments: { + 'validityValue': state.weekdaysList.value, + 'starDate': state.cycleBeginTime.value, + 'endDate': state.cycleEndTime.value, + 'starTime': state.effectiveDateTime.value, + 'endTime': state.failureDateTime.value + }); if (result != null && result.isNotEmpty) { state.weekdaysList.value = result['validityValue']; state.cycleBeginTime.value = result['starDate']; @@ -219,16 +232,18 @@ class _AddFaceTypePageState extends State with SingleTickerProv visible: state.effectiveDateTime.value.isNotEmpty, child: CommonItem( leftTitel: "有效时间".tr, - rightTitle: "${state.effectiveDateTime.value}-${state.failureDateTime.value}", + rightTitle: + "${state.effectiveDateTime.value}-${state.failureDateTime.value}", isHaveDirection: true, action: () async { - var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: { - 'validityValue': state.weekdaysList.value, - 'starDate': state.cycleBeginTime.value, - 'endDate': state.cycleEndTime.value, - 'starTime': state.effectiveDateTime.value, - 'endTime': state.failureDateTime.value - }); + var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, + arguments: { + 'validityValue': state.weekdaysList.value, + 'starDate': state.cycleBeginTime.value, + 'endDate': state.cycleEndTime.value, + 'starTime': state.effectiveDateTime.value, + 'endTime': state.failureDateTime.value + }); if (result != null && result.isNotEmpty) { state.weekdaysList.value = result['validityValue']; state.cycleBeginTime.value = result['starDate']; @@ -337,13 +352,14 @@ class _AddFaceTypePageState extends State with SingleTickerProv ); } - final List _itemTabs = [ + final List _itemTabs = [ ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, selectType: "0"), ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, selectType: "1"), - ItemView(title: TranslationLoader.lanKeys!.circulation!.tr, selectType: "2"), + ItemView( + title: TranslationLoader.lanKeys!.circulation!.tr, selectType: "2"), ]; - final List _fromCheckInTypeItemTabs = [ + final List _fromCheckInTypeItemTabs = [ ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, selectType: "0"), ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, selectType: "1"), ]; @@ -354,7 +370,11 @@ class _AddFaceTypePageState extends State with SingleTickerProv onTap: (index) { FocusScope.of(context).requestFocus(FocusNode()); }, - tabs: state.fromType.value == 1 ? _itemTabs.map((ItemView item) => _tab(item)).toList() : _fromCheckInTypeItemTabs.map((ItemView item) => _tab(item)).toList(), + tabs: state.fromType.value == 1 + ? _itemTabs.map((ItemView item) => _tab(item)).toList() + : _fromCheckInTypeItemTabs + .map((ItemView item) => _tab(item)) + .toList(), isScrollable: true, indicatorColor: Colors.red, unselectedLabelColor: Colors.black, @@ -386,14 +406,16 @@ class _AddFaceTypePageState extends State with SingleTickerProv return Expanded( child: TabBarView( controller: state.tabController, - children: - state.fromType.value == 1 - ? _itemTabs.map((ItemView item) => Obx(() => indexChangeWidget())).toList() - : _fromCheckInTypeItemTabs.map((ItemView item) => Obx(() => indexChangeWidget())).toList(), + children: state.fromType.value == 1 + ? _itemTabs + .map((ItemView item) => Obx(() => indexChangeWidget())) + .toList() + : _fromCheckInTypeItemTabs + .map((ItemView item) => Obx(() => indexChangeWidget())) + .toList(), ), ); } - } class ItemView { diff --git a/star_lock/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_page.dart b/star_lock/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_page.dart index f396279c..583533c4 100644 --- a/star_lock/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_page.dart +++ b/star_lock/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_page.dart @@ -5,6 +5,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/tools/pickers/pickers.dart'; import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart'; +import 'package:star_lock/tools/pickers/time_picker/model/pduration.dart'; import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; @@ -148,7 +149,9 @@ class _AddFingerprintTypePageState extends State with Si isHaveLine: true, isHaveDirection: true, action: () async { - Pickers.showDatePicker(context, mode: DateMode.YMDHM, + PDuration selectDate = + PDuration.parse(DateTime.tryParse(state.timeLimitBeginTime.value)); + Pickers.showDatePicker(context,selectDate:selectDate, mode: DateMode.YMDHM, onConfirm: (p) { state.timeLimitBeginTime.value = DateTool().getYMDHNDateString(p, 1); }); @@ -158,7 +161,9 @@ class _AddFingerprintTypePageState extends State with Si rightTitle: state.timeLimitEndTime.value, isHaveDirection: true, action: () { - Pickers.showDatePicker(context, mode: DateMode.YMDHM, + PDuration selectDate = + PDuration.parse(DateTime.tryParse(state.timeLimitEndTime.value)); + Pickers.showDatePicker(context,selectDate:selectDate, mode: DateMode.YMDHM, onConfirm: (p) { state.timeLimitEndTime.value = DateTool().getYMDHNDateString(p, 1); }); diff --git a/star_lock/lib/main/lockDetail/iris/addIrisType/addIrisType_page.dart b/star_lock/lib/main/lockDetail/iris/addIrisType/addIrisType_page.dart index e2a04b35..0c9ab97e 100644 --- a/star_lock/lib/main/lockDetail/iris/addIrisType/addIrisType_page.dart +++ b/star_lock/lib/main/lockDetail/iris/addIrisType/addIrisType_page.dart @@ -7,6 +7,7 @@ import 'package:star_lock/main/lockDetail/iris/addIrisType/addIrisType_logic.dar import 'package:star_lock/tools/dateTool.dart'; import 'package:star_lock/tools/pickers/pickers.dart'; import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart'; +import 'package:star_lock/tools/pickers/time_picker/model/pduration.dart'; import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; @@ -142,8 +143,10 @@ class _AddIrisTypePageState extends State { isHaveLine: true, isHaveDirection: true, action: () async { - Pickers.showDatePicker(context, mode: DateMode.YMDHM, - onConfirm: (p) { + PDuration selectDate = + PDuration.parse(DateTime.tryParse(state.beginTime.value)); + Pickers.showDatePicker(context, + selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) { state.beginTime.value = DateTool().getYMDHNDateString(p, 1); }); })), @@ -152,8 +155,10 @@ class _AddIrisTypePageState extends State { rightTitle: state.endTime.value, isHaveDirection: true, action: () { - Pickers.showDatePicker(context, mode: DateMode.YMDHM, - onConfirm: (p) { + PDuration selectDate = + PDuration.parse(DateTime.tryParse(state.endTime.value)); + Pickers.showDatePicker(context, + selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) { state.endTime.value = DateTool().getYMDHNDateString(p, 1); }); })), diff --git a/star_lock/lib/main/lockDetail/lockSet/catEyeSet/videoSlot/videoSlot_page.dart b/star_lock/lib/main/lockDetail/lockSet/catEyeSet/videoSlot/videoSlot_page.dart index f1eb6ebc..d060cd80 100644 --- a/star_lock/lib/main/lockDetail/lockSet/catEyeSet/videoSlot/videoSlot_page.dart +++ b/star_lock/lib/main/lockDetail/lockSet/catEyeSet/videoSlot/videoSlot_page.dart @@ -5,6 +5,7 @@ import 'package:star_lock/main/lockDetail/lockSet/catEyeSet/videoSlot/videoSlot_ import 'package:star_lock/tools/dateTool.dart'; import 'package:star_lock/tools/pickers/pickers.dart'; import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart'; +import 'package:star_lock/tools/pickers/time_picker/model/pduration.dart'; import 'package:star_lock/translations/trans_lib.dart'; import '../../../../../app_settings/app_colors.dart'; @@ -228,7 +229,10 @@ class _VideoSlotPageState extends State { ], ), onTap: () { - Pickers.showDatePicker(context, mode: DateMode.HM, onConfirm: (p) { + PDuration selectDate = PDuration.parse(DateTime.tryParse( + isEndTime == false ? state.startDate.value : state.endDate.value)); + Pickers.showDatePicker(context, + selectDate: selectDate, mode: DateMode.HM, onConfirm: (p) { if (isEndTime == false) { state.startDate.value = DateTool().getYMDHNDateString(p, 3); } else { diff --git a/star_lock/lib/main/lockDetail/lockSet/normallyOpenMode/normallyOpenMode_page.dart b/star_lock/lib/main/lockDetail/lockSet/normallyOpenMode/normallyOpenMode_page.dart index a5b361f3..3d4af8c7 100644 --- a/star_lock/lib/main/lockDetail/lockSet/normallyOpenMode/normallyOpenMode_page.dart +++ b/star_lock/lib/main/lockDetail/lockSet/normallyOpenMode/normallyOpenMode_page.dart @@ -1,4 +1,3 @@ - import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; @@ -6,6 +5,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/tools/pickers/pickers.dart'; import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart'; +import 'package:star_lock/tools/pickers/time_picker/model/pduration.dart'; import '../../../../app_settings/app_colors.dart'; import '../../../../blue/blue_manage.dart'; @@ -23,7 +23,8 @@ class NormallyOpenModePage extends StatefulWidget { State createState() => _NormallyOpenModePageState(); } -class _NormallyOpenModePageState extends State with RouteAware{ +class _NormallyOpenModePageState extends State + with RouteAware { final logic = Get.put(NormallyOpenModeLogic()); final state = Get.find().state; @@ -112,13 +113,16 @@ class _NormallyOpenModePageState extends State with RouteA ), )), Obx(() => Container( - margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 30.h), - child: state.isJustForShow.value == true ? Container() :SubmitBtn( - btnName: TranslationLoader.lanKeys!.save!.tr, - onClick: () { - logic.sendAutoLock(); - }), - )), + margin: + EdgeInsets.only(left: 20.w, right: 20.w, top: 30.h), + child: state.isJustForShow.value == true + ? Container() + : SubmitBtn( + btnName: TranslationLoader.lanKeys!.save!.tr, + onClick: () { + logic.sendAutoLock(); + }), + )), ], ))); } @@ -186,7 +190,7 @@ class _NormallyOpenModePageState extends State with RouteA } return GestureDetector( onTap: () { - if(state.isJustForShow.value == true){ + if (state.isJustForShow.value == true) { return; } @@ -238,7 +242,7 @@ class _NormallyOpenModePageState extends State with RouteA rightWidget: GestureDetector( onTap: () { // 选择全天模式 - if(state.isJustForShow.value == true){ + if (state.isJustForShow.value == true) { return; } @@ -281,12 +285,14 @@ class _NormallyOpenModePageState extends State with RouteA isHaveDirection: true, isHaveLine: true, action: () { - if(state.isJustForShow.value == true){ + if (state.isJustForShow.value == true) { return; } - - Pickers.showDatePicker(context, mode: DateMode.HM, - onConfirm: (p) { + PDuration selectDate = PDuration.parse( + DateTime.tryParse(state.beginTime.value)); + Pickers.showDatePicker(context, + selectDate: selectDate, + mode: DateMode.HM, onConfirm: (p) { setState(() { state.beginTimeMinute.value = p.hour! * 60 + p.minute!; @@ -300,12 +306,14 @@ class _NormallyOpenModePageState extends State with RouteA rightTitle: state.endTime.value, isHaveDirection: true, action: () { - if(state.isJustForShow.value == true){ + if (state.isJustForShow.value == true) { return; } - - Pickers.showDatePicker(context, mode: DateMode.HM, - onConfirm: (p) { + PDuration selectDate = PDuration.parse( + DateTime.tryParse(state.endTime.value)); + Pickers.showDatePicker(context, + selectDate: selectDate, + mode: DateMode.HM, onConfirm: (p) { setState(() { state.endTimeMinute.value = p.hour! * 60 + p.minute!; @@ -327,11 +335,13 @@ class _NormallyOpenModePageState extends State with RouteA trackColor: CupertinoColors.systemGrey5, thumbColor: CupertinoColors.white, value: state.isOpenNormallyOpenMode.value, - onChanged: state.isJustForShow.value == true ? null : (value) { - setState(() { - state.isOpenNormallyOpenMode.value = value; - }); - }, + onChanged: state.isJustForShow.value == true + ? null + : (value) { + setState(() { + state.isOpenNormallyOpenMode.value = value; + }); + }, ); } @@ -385,5 +395,4 @@ class _NormallyOpenModePageState extends State with RouteA state.ifCurrentScreen.value = false; state.sureBtnState.value = 0; } - } diff --git a/star_lock/lib/main/lockDetail/palm/addPalmType/addPalmType_page.dart b/star_lock/lib/main/lockDetail/palm/addPalmType/addPalmType_page.dart index bd6bf110..1816a18c 100644 --- a/star_lock/lib/main/lockDetail/palm/addPalmType/addPalmType_page.dart +++ b/star_lock/lib/main/lockDetail/palm/addPalmType/addPalmType_page.dart @@ -7,6 +7,7 @@ import 'package:star_lock/main/lockDetail/palm/addPalmType/addPalmType_logic.dar import 'package:star_lock/tools/dateTool.dart'; import 'package:star_lock/tools/pickers/pickers.dart'; import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart'; +import 'package:star_lock/tools/pickers/time_picker/model/pduration.dart'; import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; @@ -142,8 +143,10 @@ class _AddPalmTypePageState extends State { isHaveLine: true, isHaveDirection: true, action: () async { - Pickers.showDatePicker(context, mode: DateMode.YMDHM, - onConfirm: (p) { + PDuration selectDate = + PDuration.parse(DateTime.tryParse(state.beginTime.value)); + Pickers.showDatePicker(context, + selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) { state.beginTime.value = DateTool().getYMDHNDateString(p, 1); }); })), @@ -152,8 +155,10 @@ class _AddPalmTypePageState extends State { rightTitle: state.endTime.value, isHaveDirection: true, action: () { - Pickers.showDatePicker(context, mode: DateMode.YMDHM, - onConfirm: (p) { + PDuration selectDate = + PDuration.parse(DateTime.tryParse(state.endTime.value)); + Pickers.showDatePicker(context, + selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) { state.endTime.value = DateTool().getYMDHNDateString(p, 1); }); })), diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyDetailChangeDate/passwordKeyDetailChangeDate_page.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyDetailChangeDate/passwordKeyDetailChangeDate_page.dart index dc9fda54..2790d7f7 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyDetailChangeDate/passwordKeyDetailChangeDate_page.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyDetailChangeDate/passwordKeyDetailChangeDate_page.dart @@ -5,6 +5,7 @@ import 'package:get/get.dart'; import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyDetailChangeDate/passwordKeyDetailChangeDate_logic.dart'; import 'package:star_lock/tools/pickers/pickers.dart'; import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart'; +import 'package:star_lock/tools/pickers/time_picker/model/pduration.dart'; import '../../../../../app_settings/app_colors.dart'; import '../../../../../tools/commonItem.dart'; @@ -21,7 +22,8 @@ class PasswordKeyDetailChangeDatePage extends StatefulWidget { _PasswordKeyDetailChangeDatePage(); } -class _PasswordKeyDetailChangeDatePage extends State with RouteAware { +class _PasswordKeyDetailChangeDatePage + extends State with RouteAware { final logic = Get.put(PasswordKeyDetailChangeDateLogic()); final state = Get.find().state; @@ -42,7 +44,7 @@ class _PasswordKeyDetailChangeDatePage extends State CommonItem( @@ -105,9 +130,14 @@ class _PasswordKeyDetailChangeDatePage extends State createState() => _PasswordKeyPerpetualPageState(); } -class _PasswordKeyPerpetualPageState extends State with RouteAware, SingleTickerProviderStateMixin{ +class _PasswordKeyPerpetualPageState extends State + with RouteAware, SingleTickerProviderStateMixin { final logic = Get.put(PasswordKeyPerpetualLogic()); final state = Get.find().state; @@ -45,10 +44,8 @@ class _PasswordKeyPerpetualPageState extends State wit // TODO: implement initState super.initState(); - state.tabController = TabController( - vsync: this, - length: _itemTabs.length, - initialIndex: 0); + state.tabController = + TabController(vsync: this, length: _itemTabs.length, initialIndex: 0); state.tabController.addListener(() { WidgetsBinding.instance.addPostFrameCallback((_) { state.widgetType.value = state.tabController.index; @@ -78,7 +75,8 @@ class _PasswordKeyPerpetualPageState extends State wit } Widget indexChangeWidget() { - if (state.isSendSuccess.value == true && state.sendSucceedType.value == state.widgetType.value) { + if (state.isSendSuccess.value == true && + state.sendSucceedType.value == state.widgetType.value) { return sendElectronicKeySucceed(); } else { switch (state.widgetType.value) { @@ -89,11 +87,13 @@ class _PasswordKeyPerpetualPageState extends State wit child: Column( children: [ perpetualKeyWidget( - false, + false, TranslationLoader.lanKeys!.name!.tr, TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, state.nameController), - keyBottomWidget("密码生成后,请在当日23:59前使用一次进行激活,否则过0点后未激活则失效。密码激活后,有效期内不限次数使用。".tr) + keyBottomWidget( + "密码生成后,请在当日23:59前使用一次进行激活,否则过0点后未激活则失效。密码激活后,有效期内不限次数使用。" + .tr) ], ), ); @@ -110,7 +110,9 @@ class _PasswordKeyPerpetualPageState extends State wit TranslationLoader.lanKeys!.name!.tr, TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, state.nameController), - keyBottomWidget("密码生成后,请在当日23:59前使用一次进行激活,否则过0点后未激活则失效。密码激活后,有效期内不限次数使用。".tr) + keyBottomWidget( + "密码生成后,请在当日23:59前使用一次进行激活,否则过0点后未激活则失效。密码激活后,有效期内不限次数使用。" + .tr) ], ), ); @@ -126,7 +128,8 @@ class _PasswordKeyPerpetualPageState extends State wit TranslationLoader.lanKeys!.name!.tr, TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, state.nameController), - keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip3!.tr) + keyBottomWidget( + TranslationLoader.lanKeys!.getPasswordTip3!.tr) ], ), ); @@ -149,10 +152,11 @@ class _PasswordKeyPerpetualPageState extends State wit perpetualKeyWidget( false, TranslationLoader.lanKeys!.password!.tr, - "请输入6-9位数字", state.pwdController - ), + "请输入6-9位数字", + state.pwdController), keyIfAdministratorWidget(), - keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip4!.tr) + keyBottomWidget( + TranslationLoader.lanKeys!.getPasswordTip4!.tr) ], ), ); @@ -169,7 +173,9 @@ class _PasswordKeyPerpetualPageState extends State wit TranslationLoader.lanKeys!.name!.tr, TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, state.nameController), - keyBottomWidget("密码生成后,请在当日23:59前使用一次进行激活,否则过0点后未激活则失效。密码激活后,有效期内不限次数使用。".tr) + keyBottomWidget( + "密码生成后,请在当日23:59前使用一次进行激活,否则过0点后未激活则失效。密码激活后,有效期内不限次数使用。" + .tr) ], ), ); @@ -181,11 +187,12 @@ class _PasswordKeyPerpetualPageState extends State wit child: Column( children: [ perpetualKeyWidget( - false, + false, TranslationLoader.lanKeys!.name!.tr, TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, state.nameController), - keyBottomWidget("密码生成后,请在当日23:59前使用,否则过0点后失效。清空码用于清空今天0点之前生成的所有密码。".tr) + keyBottomWidget( + "密码生成后,请在当日23:59前使用,否则过0点后失效。清空码用于清空今天0点之前生成的所有密码。".tr) ], ), ); @@ -197,8 +204,8 @@ class _PasswordKeyPerpetualPageState extends State wit } // 密码命名输入框 - Widget perpetualKeyWidget( - bool isTopHeight, String titleStr, String rightTitle, TextEditingController controller) { + Widget perpetualKeyWidget(bool isTopHeight, String titleStr, + String rightTitle, TextEditingController controller) { return Column( children: [ isTopHeight ? SizedBox(height: 10.h) : Container(), @@ -217,19 +224,25 @@ class _PasswordKeyPerpetualPageState extends State wit return Column( children: [ Visibility( - visible: CommonDataManage().currentKeyInfo.vendor == "XHJ" ? false : true, + visible: + CommonDataManage().currentKeyInfo.vendor == "XHJ" ? false : true, child: CommonItem( leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr, rightTitle: state.beginTime.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), + PDuration selectDate = + PDuration.parse(DateTime.tryParse(state.beginTime.value)); + Pickers.showDatePicker(context, + selectDate: selectDate, + 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) { + mode: DateMode.YMDHM, onConfirm: (p) { state.beginTime.value = DateTool().getYMDHNDateString(p, 4); }); }), @@ -239,14 +252,21 @@ class _PasswordKeyPerpetualPageState extends State wit rightTitle: state.endTime.value, isHaveDirection: true, action: () { - Pickers.showDatePicker( - context, + PDuration selectDate = + PDuration.parse(DateTime.tryParse(state.endTime.value)); + Pickers.showDatePicker(context, + selectDate: selectDate, // 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.YMDH, - onConfirm: (p) { - state.endTime.value = DateTool().getYMDHNDateString(p, 4); + 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.YMDH, onConfirm: (p) { + state.endTime.value = DateTool().getYMDHNDateString(p, 4); }); }), Container(height: 10.h), @@ -264,28 +284,32 @@ class _PasswordKeyPerpetualPageState extends State wit isHaveLine: true, isHaveDirection: true, action: () { - Pickers.showDatePicker( - context, + PDuration selectDate = PDuration.parse( + DateTime.tryParse(state.customBeginTime.value)); + Pickers.showDatePicker(context, + selectDate: selectDate, // 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); - }); + 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: () { + PDuration selectDate = + PDuration.parse(DateTime.tryParse(state.customEndTime.value)); Pickers.showDatePicker(context, + selectDate: selectDate, // 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); - }); + mode: DateMode.YMDHM, onConfirm: (p) { + state.customEndTime.value = DateTool().getYMDHNDateString(p, 1); + }); }), Container(height: 10.h), ], @@ -350,15 +374,26 @@ class _PasswordKeyPerpetualPageState extends State wit showPickerView(context, pickerDataList); }), Visibility( - visible: (CommonDataManage().currentKeyInfo.vendor == IoModelVendor.vendor_XL && (CommonDataManage().currentKeyInfo.model == IoModelVendor.model_XL_BLE || CommonDataManage().currentKeyInfo.model == IoModelVendor.model_XL_WIFI)) ? true : false, + visible: (CommonDataManage().currentKeyInfo.vendor == + IoModelVendor.vendor_XL && + (CommonDataManage().currentKeyInfo.model == + IoModelVendor.model_XL_BLE || + CommonDataManage().currentKeyInfo.model == + IoModelVendor.model_XL_WIFI)) + ? true + : false, child: CommonItem( leftTitel: '结束日期', rightTitle: state.endTime.value, isHaveLine: true, isHaveDirection: true, action: () { - Pickers.showDatePicker(context, mode: DateMode.YMDH, onConfirm: (p) { - state.endTime.value = DateTool().getYMDHNDateString(p, 4); + PDuration selectDate = + PDuration.parse(DateTime.tryParse(state.endTime.value)); + Pickers.showDatePicker(context, + selectDate: selectDate, + mode: DateMode.YMDH, onConfirm: (p) { + state.endTime.value = DateTool().getYMDHNDateString(p, 4); }); }), ), @@ -368,8 +403,12 @@ class _PasswordKeyPerpetualPageState extends State wit isHaveLine: true, isHaveDirection: true, action: () { - Pickers.showDatePicker(context, mode: DateMode.H, onConfirm: (p) { - state.loopEffectiveDate.value = DateTool().getYMDHNDateString(p, 5); + PDuration selectDate = PDuration.parse( + DateTool().dateToDateTime(state.loopEffectiveDate.value, 0)); + Pickers.showDatePicker(context, + selectDate: selectDate, mode: DateMode.H, onConfirm: (p) { + state.loopEffectiveDate.value = + DateTool().getYMDHNDateString(p, 5); state.loopStartHours.value = p.hour!; }); }), @@ -378,8 +417,12 @@ class _PasswordKeyPerpetualPageState extends State wit rightTitle: state.loopFailureDate.value, isHaveDirection: true, action: () { - Pickers.showDatePicker(context, mode: DateMode.H, onConfirm: (p) { - state.loopFailureDate.value = DateTool().getYMDHNDateString(p, 5); + PDuration selectDate = PDuration.parse( + DateTool().dateToDateTime(state.loopFailureDate.value, 0)); + Pickers.showDatePicker(context, + selectDate: selectDate, mode: DateMode.H, onConfirm: (p) { + state.loopFailureDate.value = + DateTool().getYMDHNDateString(p, 5); state.loopEndHours.value = p.hour!; }); }), @@ -423,7 +466,9 @@ class _PasswordKeyPerpetualPageState extends State wit height: 20.h, ), SubmitBtn( - btnName: state.widgetType.value == 3 ? "设置密码":TranslationLoader.lanKeys!.getPassword!.tr, + btnName: state.widgetType.value == 3 + ? "设置密码" + : TranslationLoader.lanKeys!.getPassword!.tr, onClick: () async { var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); if (isDemoMode == false) { @@ -523,10 +568,14 @@ class _PasswordKeyPerpetualPageState extends State wit maxLines: 1, inputFormatters: [ FilteringTextInputFormatter.deny('\n'), - LengthLimitingTextInputFormatter(editController == state.nameController ? 50 : 9), + LengthLimitingTextInputFormatter( + editController == state.nameController ? 50 : 9), ], - keyboardType: editController == state.nameController ? TextInputType.text: TextInputType.number, - style: TextStyle(fontSize: 22.sp, color: AppColors.darkGrayTextColor), + keyboardType: editController == state.nameController + ? TextInputType.text + : TextInputType.number, + style: TextStyle( + fontSize: 22.sp, color: AppColors.darkGrayTextColor), controller: editController, autofocus: false, textAlign: TextAlign.end, @@ -543,10 +592,18 @@ class _PasswordKeyPerpetualPageState extends State wit // contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0), hintText: tfStr, hintStyle: TextStyle(fontSize: 22.sp), - focusedBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), - disabledBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), - enabledBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), - border: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), + focusedBorder: const OutlineInputBorder( + borderSide: + BorderSide(width: 0, color: Colors.transparent)), + disabledBorder: const OutlineInputBorder( + borderSide: + BorderSide(width: 0, color: Colors.transparent)), + enabledBorder: const OutlineInputBorder( + borderSide: + BorderSide(width: 0, color: Colors.transparent)), + border: const OutlineInputBorder( + borderSide: + BorderSide(width: 0, color: Colors.transparent)), contentPadding: const EdgeInsets.symmetric(vertical: 0), ), ), @@ -629,7 +686,7 @@ class _PasswordKeyPerpetualPageState extends State wit TabBar _tabBar() { return TabBar( controller: state.tabController, - onTap: (index){ + onTap: (index) { FocusScope.of(context).requestFocus(FocusNode()); }, tabs: _itemTabs.map((ItemView item) => _tab(item)).toList(), @@ -672,7 +729,9 @@ class _PasswordKeyPerpetualPageState extends State wit return Expanded( child: TabBarView( controller: state.tabController, - children: _itemTabs.map((ItemView item) => Obx(() => indexChangeWidget())).toList(), + children: _itemTabs + .map((ItemView item) => Obx(() => indexChangeWidget())) + .toList(), ), ); } @@ -697,7 +756,8 @@ class _PasswordKeyPerpetualPageState extends State wit return widgetList; } - GestureDetector buildCenter3(String imageName, String titleStr, int itemIndex) { + GestureDetector buildCenter3( + String imageName, String titleStr, int itemIndex) { return GestureDetector( child: Container( width: 120.w, @@ -735,13 +795,13 @@ class _PasswordKeyPerpetualPageState extends State wit case 0: //微信好友 { - NativeInteractionTool().loadNativeShare(shareText:pwdShareStr); + NativeInteractionTool().loadNativeShare(shareText: pwdShareStr); } break; case 1: //短信 { - NativeInteractionTool().loadNativeShare(shareText:pwdShareStr); + NativeInteractionTool().loadNativeShare(shareText: pwdShareStr); } break; case 2: @@ -753,7 +813,7 @@ class _PasswordKeyPerpetualPageState extends State wit case 3: //更多 { - NativeInteractionTool().loadNativeShare(shareText:pwdShareStr); + NativeInteractionTool().loadNativeShare(shareText: pwdShareStr); } break; default: diff --git a/star_lock/lib/main/lockDetail/remoteControl/addRemoteControl/addRemoteControl_page.dart b/star_lock/lib/main/lockDetail/remoteControl/addRemoteControl/addRemoteControl_page.dart index 7e377b7f..9ea0ffc5 100644 --- a/star_lock/lib/main/lockDetail/remoteControl/addRemoteControl/addRemoteControl_page.dart +++ b/star_lock/lib/main/lockDetail/remoteControl/addRemoteControl/addRemoteControl_page.dart @@ -5,6 +5,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/tools/pickers/pickers.dart'; import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart'; +import 'package:star_lock/tools/pickers/time_picker/model/pduration.dart'; import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; @@ -18,14 +19,14 @@ import '../../../../translations/trans_lib.dart'; import 'addRemoteControl_logic.dart'; class AddRemoteControlPage extends StatefulWidget { - const AddRemoteControlPage({Key? key}) - : super(key: key); + const AddRemoteControlPage({Key? key}) : super(key: key); @override State createState() => _AddRemoteControlPageState(); } -class _AddRemoteControlPageState extends State with SingleTickerProviderStateMixin { +class _AddRemoteControlPageState extends State + with SingleTickerProviderStateMixin { final logic = Get.put(AddRemoteControlLoigc()); final state = Get.find().state; @@ -36,7 +37,9 @@ class _AddRemoteControlPageState extends State with Single state.tabController = TabController( vsync: this, - length: state.fromType.value == 1 ? _itemTabs.length : _fromCheckInTypeItemTabs.length, + length: state.fromType.value == 1 + ? _itemTabs.length + : _fromCheckInTypeItemTabs.length, initialIndex: 0); state.tabController.addListener(() { WidgetsBinding.instance.addPostFrameCallback((_) { @@ -55,7 +58,7 @@ class _AddRemoteControlPageState extends State with Single backgroundColor: AppColors.mainBackgroundColor, appBar: TitleAppBar( barTitle: - "${TranslationLoader.lanKeys!.addTip!.tr}${TranslationLoader.lanKeys!.fingerprint!.tr}", + "${TranslationLoader.lanKeys!.addTip!.tr}${TranslationLoader.lanKeys!.fingerprint!.tr}", haveBack: true, backgroundColor: AppColors.mainColor), body: Column( @@ -145,20 +148,26 @@ class _AddRemoteControlPageState extends State with Single isHaveLine: true, isHaveDirection: true, action: () async { - Pickers.showDatePicker(context, mode: DateMode.YMDHM, - onConfirm: (p) { - state.timeLimitBeginTime.value = DateTool().getYMDHNDateString(p, 1); - }); + PDuration selectDate = PDuration.parse( + DateTime.parse(state.timeLimitBeginTime.value)); + Pickers.showDatePicker(context, + selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) { + state.timeLimitBeginTime.value = + DateTool().getYMDHNDateString(p, 1); + }); })), Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.failureTime!.tr, rightTitle: state.timeLimitEndTime.value, isHaveDirection: true, action: () { - Pickers.showDatePicker(context, mode: DateMode.YMDHM, - onConfirm: (p) { - state.timeLimitEndTime.value = DateTool().getYMDHNDateString(p, 1); - }); + PDuration selectDate = + PDuration.parse(DateTime.tryParse(state.timeLimitEndTime.value)); + Pickers.showDatePicker(context, + selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) { + state.timeLimitEndTime.value = + DateTool().getYMDHNDateString(p, 1); + }); })), Container(height: 10.h), ], @@ -171,11 +180,13 @@ class _AddRemoteControlPageState extends State with Single children: [ Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr, - rightTitle:"${state.cycleBeginTime.value}\n${state.cycleEndTime.value}", + rightTitle: + "${state.cycleBeginTime.value}\n${state.cycleEndTime.value}", isHaveDirection: true, isHaveLine: true, action: () async { - var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: { + var result = + await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: { 'validityValue': state.weekdaysList.value, 'starDate': state.cycleBeginTime.value, 'endDate': state.cycleEndTime.value, @@ -198,13 +209,14 @@ class _AddRemoteControlPageState extends State with Single isHaveDirection: true, isHaveLine: true, action: () async { - var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: { - 'validityValue': state.weekdaysList.value, - 'starDate': state.cycleBeginTime.value, - 'endDate': state.cycleEndTime.value, - 'starTime': state.effectiveDateTime.value, - 'endTime': state.failureDateTime.value - }); + var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, + arguments: { + 'validityValue': state.weekdaysList.value, + 'starDate': state.cycleBeginTime.value, + 'endDate': state.cycleEndTime.value, + 'starTime': state.effectiveDateTime.value, + 'endTime': state.failureDateTime.value + }); if (result != null && result.isNotEmpty) { state.weekdaysList.value = result['validityValue']; state.cycleBeginTime.value = result['starDate']; @@ -217,16 +229,18 @@ class _AddRemoteControlPageState extends State with Single visible: state.effectiveDateTime.value.isNotEmpty, child: CommonItem( leftTitel: "有效时间".tr, - rightTitle: "${state.effectiveDateTime.value}-${state.failureDateTime.value}", + rightTitle: + "${state.effectiveDateTime.value}-${state.failureDateTime.value}", isHaveDirection: true, action: () async { - var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: { - 'validityValue': state.weekdaysList.value, - 'starDate': state.cycleBeginTime.value, - 'endDate': state.cycleEndTime.value, - 'starTime': state.effectiveDateTime.value, - 'endTime': state.failureDateTime.value - }); + var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, + arguments: { + 'validityValue': state.weekdaysList.value, + 'starDate': state.cycleBeginTime.value, + 'endDate': state.cycleEndTime.value, + 'starTime': state.effectiveDateTime.value, + 'endTime': state.failureDateTime.value + }); if (result != null && result.isNotEmpty) { state.weekdaysList.value = result['validityValue']; state.cycleBeginTime.value = result['starDate']; @@ -359,7 +373,8 @@ class _AddRemoteControlPageState extends State with Single FilteringTextInputFormatter.deny('\n'), LengthLimitingTextInputFormatter(18), ], - style: TextStyle(fontSize: 22.sp, color: AppColors.darkGrayTextColor), + style: TextStyle( + fontSize: 22.sp, color: AppColors.darkGrayTextColor), controller: state.nameController, autofocus: false, textAlign: TextAlign.end, @@ -368,10 +383,18 @@ class _AddRemoteControlPageState extends State with Single // contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0), hintText: tfStr, hintStyle: TextStyle(fontSize: 22.sp), - focusedBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), - disabledBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), - enabledBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), - border: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), + focusedBorder: const OutlineInputBorder( + borderSide: + BorderSide(width: 0, color: Colors.transparent)), + disabledBorder: const OutlineInputBorder( + borderSide: + BorderSide(width: 0, color: Colors.transparent)), + enabledBorder: const OutlineInputBorder( + borderSide: + BorderSide(width: 0, color: Colors.transparent)), + border: const OutlineInputBorder( + borderSide: + BorderSide(width: 0, color: Colors.transparent)), contentPadding: const EdgeInsets.symmetric(vertical: 0), ), ), @@ -399,13 +422,14 @@ class _AddRemoteControlPageState extends State with Single ); } - final List _itemTabs = [ + final List _itemTabs = [ ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, selectType: "0"), ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, selectType: "1"), - ItemView(title: TranslationLoader.lanKeys!.circulation!.tr, selectType: "2"), + ItemView( + title: TranslationLoader.lanKeys!.circulation!.tr, selectType: "2"), ]; - final List _fromCheckInTypeItemTabs = [ + final List _fromCheckInTypeItemTabs = [ ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, selectType: "0"), ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, selectType: "1"), ]; @@ -416,7 +440,11 @@ class _AddRemoteControlPageState extends State with Single onTap: (index) { FocusScope.of(context).requestFocus(FocusNode()); }, - tabs: state.fromType.value == 1 ? _itemTabs.map((ItemView item) => _tab(item)).toList() : _fromCheckInTypeItemTabs.map((ItemView item) => _tab(item)).toList(), + tabs: state.fromType.value == 1 + ? _itemTabs.map((ItemView item) => _tab(item)).toList() + : _fromCheckInTypeItemTabs + .map((ItemView item) => _tab(item)) + .toList(), isScrollable: true, indicatorColor: Colors.red, unselectedLabelColor: Colors.black, @@ -448,14 +476,16 @@ class _AddRemoteControlPageState extends State with Single return Expanded( child: TabBarView( controller: state.tabController, - children: - state.fromType.value == 1 - ? _itemTabs.map((ItemView item) => Obx(() => indexChangeWidget())).toList() - : _fromCheckInTypeItemTabs.map((ItemView item) => Obx(() => indexChangeWidget())).toList(), + children: state.fromType.value == 1 + ? _itemTabs + .map((ItemView item) => Obx(() => indexChangeWidget())) + .toList() + : _fromCheckInTypeItemTabs + .map((ItemView item) => Obx(() => indexChangeWidget())) + .toList(), ), ); } - } class ItemView { diff --git a/star_lock/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministrator_page.dart b/star_lock/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministrator_page.dart index 34b9f72f..bf4240ee 100644 --- a/star_lock/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministrator_page.dart +++ b/star_lock/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministrator_page.dart @@ -9,6 +9,7 @@ import 'package:star_lock/app_settings/app_colors.dart'; import 'package:star_lock/tools/commonItem.dart'; import 'package:star_lock/tools/pickers/pickers.dart'; import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart'; +import 'package:star_lock/tools/pickers/time_picker/model/pduration.dart'; import 'package:star_lock/tools/submitBtn.dart'; import 'package:star_lock/translations/trans_lib.dart'; @@ -19,7 +20,8 @@ import 'addAuthorizedAdministrator_logic.dart'; class AddAuthorizedAdministratorPage extends StatefulWidget { String type; - AddAuthorizedAdministratorPage({Key? key, required this.type}) : super(key: key); + AddAuthorizedAdministratorPage({Key? key, required this.type}) + : super(key: key); @override State createState() { @@ -27,20 +29,24 @@ class AddAuthorizedAdministratorPage extends StatefulWidget { } } -class _AddAuthorizedAdministratorPageState extends State with SingleTickerProviderStateMixin { +class _AddAuthorizedAdministratorPageState + extends State + with SingleTickerProviderStateMixin { final logic = Get.put(AddAuthorizedAdministratorLogic()); final state = Get.find().state; @override void initState() { super.initState(); - } @override Widget build(BuildContext context) { state.type.value = widget.type; - return Obx(() => SingleChildScrollView(child: widget.type == '0' ? _timeLimitAdministrator() : _permanentAdministrator())); + return Obx(() => SingleChildScrollView( + child: widget.type == '0' + ? _timeLimitAdministrator() + : _permanentAdministrator())); } //永久 @@ -191,7 +197,8 @@ class _AddAuthorizedAdministratorPageState extends State { isHaveLine: true, isHaveDirection: true, action: () { - Pickers.showDatePicker(context, mode: DateMode.YMDHM, - onConfirm: (p) { + PDuration selectDate = PDuration.parse(_effectiveDateTime); + Pickers.showDatePicker(context, + selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) { setState(() { _selectEffectiveDate = '${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}'; @@ -83,8 +85,9 @@ class _AdminDetailChangeDatePage extends State { rightTitle: _selectFailureDate, isHaveDirection: true, action: () { - Pickers.showDatePicker(context, mode: DateMode.YMDHM, - onConfirm: (p) { + PDuration selectDate = PDuration.parse(_failureDateTime); + Pickers.showDatePicker(context, + selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) { setState(() { _selectFailureDate = '${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}'; @@ -105,8 +108,7 @@ class _AdminDetailChangeDatePage extends State { _effectiveDateTime.millisecondsSinceEpoch.toString(), ''); if (entity.errorCode!.codeIsSuccessful) { - - EasyLoading.showToast("修改成功",duration: 2000.milliseconds); + EasyLoading.showToast("修改成功", duration: 2000.milliseconds); setState(() { Navigator.pop(context); }); diff --git a/star_lock/lib/tools/dateTool.dart b/star_lock/lib/tools/dateTool.dart index d686e324..f8500682 100644 --- a/star_lock/lib/tools/dateTool.dart +++ b/star_lock/lib/tools/dateTool.dart @@ -122,6 +122,9 @@ class DateTool { int timestamp = 0; if (type == 0) { List timeParts = dateStr.split(":"); + if (timeParts.length < 2) { + return 0; + } DateTime now = DateTime.now(); DateTime dateTime = DateTime(now.year, now.month, now.day, int.parse(timeParts[0]), int.parse(timeParts[1])); @@ -133,6 +136,17 @@ class DateTool { return timestamp; } + /// 日期转化为时间戳 + /// type 0: 12:00 1: 其他 + DateTime? dateToDateTime(String dateStr, int type) { + int timestamp = dateToTimestamp(dateStr, type); + if (timestamp == 0) { + return null; + } else { + return DateTime.fromMillisecondsSinceEpoch(timestamp); + } + } + /// 将时间戳传化为年月日 (年-月-日 时:分) String dateToYMDHNString(String? timestamp) { timestamp ??= '0'; diff --git a/star_lock/lib/tools/pickers/pickers.dart b/star_lock/lib/tools/pickers/pickers.dart index 0a2d5519..44e6691d 100644 --- a/star_lock/lib/tools/pickers/pickers.dart +++ b/star_lock/lib/tools/pickers/pickers.dart @@ -10,6 +10,7 @@ import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart'; import 'package:star_lock/tools/pickers/time_picker/model/pduration.dart'; import 'package:star_lock/tools/pickers/time_picker/model/suffix.dart'; import 'package:star_lock/tools/pickers/time_picker/route/date_picker_route.dart'; + // import 'package:flutter_pickers/address_picker/route/address_picker_route.dart'; // import 'package:flutter_pickers/more_pickers/init_data.dart'; // import 'package:flutter_pickers/more_pickers/route/multiple_link_picker_route.dart'; @@ -165,7 +166,7 @@ class Pickers { /// [Suffix] : 每列时间对应的单位 默认:中文常规 Suffix(years: '年',month: '月'); /// [selectDate] : 初始化选中时间 默认现在 /// PDuration.now(); - /// PDuration.parse(DateTime.parse('20210139')); + /// PDuration.parse(DateTime.tryParse('20210139')); /// PDuration(year: 2020,month: 2); /// [maxDate] : 最大时间 用法同上 /// tip: 当只有单列数据,该限制不产生关联 只针对单列item限制,比如 maxDate>day = 3 minDate>day = 10,那么所有的月份都只显示3-10之间 @@ -173,7 +174,7 @@ class Pickers { /// [mode] : 时间选择器所显示样式 16 种时间样式 默认:DateMode.YMD static void showDatePicker(BuildContext context, {DateMode mode: DateMode.YMD, - PDuration? selectDate, + required PDuration? selectDate, PDuration? maxDate, PDuration? minDate, Suffix? suffix, diff --git a/star_lock/lib/tools/pickers/time_picker/model/pduration.dart b/star_lock/lib/tools/pickers/time_picker/model/pduration.dart index f0f62ff0..15596825 100644 --- a/star_lock/lib/tools/pickers/time_picker/model/pduration.dart +++ b/star_lock/lib/tools/pickers/time_picker/model/pduration.dart @@ -13,7 +13,7 @@ import 'package:star_lock/tools/pickers/time_picker/model/date_type.dart'; /// AppLog.log('longer2 >>> ${m.toString()}'); /// {year: 2011, month: 0, day: 0, hour: 0, minute: 0, second: 0} /// -/// var d = PDuration.parse(DateTime.parse('20200304')); +/// var d = PDuration.parse(DateTime.tryParse('20200304')); /// AppLog.log('longer3 >>> ${d.toString()}'); /// {year: 2020, month: 3, day: 4, hour: 0, minute: 0, second: 0} @@ -42,7 +42,8 @@ class PDuration { this.second: 0}); // 注意默认会设为0 不是null - PDuration.parse(DateTime dateTime) { + PDuration.parse(DateTime? dateTime) { + dateTime ??= DateTime.now(); this.year = dateTime.year; this.month = dateTime.month; this.day = dateTime.day; diff --git a/star_lock/lib/tools/seletKeyCyclicDate/seletKeyCyclicDate_page.dart b/star_lock/lib/tools/seletKeyCyclicDate/seletKeyCyclicDate_page.dart index 161d466e..9275ad1a 100644 --- a/star_lock/lib/tools/seletKeyCyclicDate/seletKeyCyclicDate_page.dart +++ b/star_lock/lib/tools/seletKeyCyclicDate/seletKeyCyclicDate_page.dart @@ -1,8 +1,8 @@ - import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/tools/dateTool.dart'; +import 'package:star_lock/tools/pickers/time_picker/model/pduration.dart'; import '../../app_settings/app_colors.dart'; import '../../translations/trans_lib.dart'; @@ -43,19 +43,18 @@ class _SeletKeyCyclicDatePageState extends State { SizedBox(height: 10.h), bottomWidget(), Obx(() => Container( - margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 30.h), - child: SubmitBtn( - btnName: TranslationLoader.lanKeys!.save!.tr, - isDisabled: - (state.starDate.value.isNotEmpty && - state.endDate.value.isNotEmpty && - state.starTime.value.isNotEmpty && - state.endTime.value.isNotEmpty && - state.weekDay.value.isNotEmpty), - onClick: () { - logic.subBtnAction(); - }), - )), + margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 30.h), + child: SubmitBtn( + btnName: TranslationLoader.lanKeys!.save!.tr, + isDisabled: (state.starDate.value.isNotEmpty && + state.endDate.value.isNotEmpty && + state.starTime.value.isNotEmpty && + state.endTime.value.isNotEmpty && + state.weekDay.value.isNotEmpty), + onClick: () { + logic.subBtnAction(); + }), + )), ], )); } @@ -73,20 +72,27 @@ class _SeletKeyCyclicDatePageState extends State { isHaveDirection: true, isHaveLine: true, action: () { - Pickers.showDatePicker(context, mode: DateMode.YMD, - onConfirm: (p) { - state.starDate.value = DateTool().getYMDHNDateString(p, 2); - }); + PDuration selectDate = PDuration.parse( + DateTime.tryParse(state.starDate.value)); + Pickers.showDatePicker(context, + selectDate: selectDate, + mode: DateMode.YMD, onConfirm: (p) { + state.starDate.value = + DateTool().getYMDHNDateString(p, 2); + }); })), Obx(() => CommonItem( leftTitel: "失效日期".tr, rightTitle: state.endDate.value, isHaveDirection: true, action: () { - Pickers.showDatePicker(context, mode: DateMode.YMD, - onConfirm: (p) { - state.endDate.value = DateTool().getYMDHNDateString(p, 2); - }); + PDuration selectDate = + PDuration.parse(DateTime.tryParse(state.endDate.value)); + Pickers.showDatePicker(context, + selectDate: selectDate, + mode: DateMode.YMD, onConfirm: (p) { + state.endDate.value = DateTool().getYMDHNDateString(p, 2); + }); })), Container(height: 10.h), ], @@ -110,12 +116,13 @@ class _SeletKeyCyclicDatePageState extends State { padding: EdgeInsets.only(left: 30.w, top: 15.h), child: Text(TranslationLoader.lanKeys!.effectiveDay!.tr, style: - TextStyle(fontSize: 24.sp, fontWeight: FontWeight.w600))), + TextStyle(fontSize: 24.sp, fontWeight: FontWeight.w600))), Container( height: 100.h, padding: EdgeInsets.only(left: 10.w, right: 10.w, bottom: 10.h), child: GridView.builder( - gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 7, childAspectRatio: 1.0), + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 7, childAspectRatio: 1.0), itemCount: 7, physics: const NeverScrollableScrollPhysics(), itemBuilder: (context, index) { @@ -167,18 +174,18 @@ class _SeletKeyCyclicDatePageState extends State { }); }, child: Obx(() => Container( - width: 40.w, - height: 40.w, - margin: EdgeInsets.all(10.w), - decoration: BoxDecoration( - color: state.weekDay.value.contains(index) - ? AppColors.mainColor - : Colors.white, - border: Border.all(width: 1, color: AppColors.btnDisableColor), - borderRadius: BorderRadius.circular(30.w), - ), - child: Center( - child: Text( + width: 40.w, + height: 40.w, + margin: EdgeInsets.all(10.w), + decoration: BoxDecoration( + color: state.weekDay.value.contains(index) + ? AppColors.mainColor + : Colors.white, + border: Border.all(width: 1, color: AppColors.btnDisableColor), + borderRadius: BorderRadius.circular(30.w), + ), + child: Center( + child: Text( dateStr, style: TextStyle( fontSize: 20.sp, @@ -186,7 +193,7 @@ class _SeletKeyCyclicDatePageState extends State { ? Colors.white : AppColors.darkGrayTextColor), )), - )), + )), ); } @@ -203,17 +210,24 @@ class _SeletKeyCyclicDatePageState extends State { isHaveDirection: true, isHaveLine: true, action: () { - Pickers.showDatePicker(context, mode: DateMode.HM, onConfirm: (p) { - state.starTime.value = DateTool().getYMDHNDateString(p, 3); + PDuration selectDate = PDuration.parse(DateTool().dateToDateTime(state.starTime.value, 0)); + Pickers.showDatePicker(context, + selectDate: selectDate, + mode: DateMode.HM, onConfirm: (p) { + state.starTime.value = + DateTool().getYMDHNDateString(p, 3); }); })), Obx(() => CommonItem( - leftTitel:"失效时间".tr, + leftTitel: "失效时间".tr, rightTitle: state.endTime.value, isHaveDirection: true, action: () { - Pickers.showDatePicker(context, mode: DateMode.HM, onConfirm: (p) { - state.endTime.value = DateTool().getYMDHNDateString(p, 3); + PDuration selectDate = PDuration.parse(DateTool().dateToDateTime(state.endTime.value, 0)); + Pickers.showDatePicker(context, + selectDate: selectDate, + mode: DateMode.HM, onConfirm: (p) { + state.endTime.value = DateTool().getYMDHNDateString(p, 3); }); })), Container(height: 10.h),