Merge branch 'master_hyx'

This commit is contained in:
anfe 2024-05-04 13:37:21 +08:00
commit 529ada69e4
25 changed files with 870 additions and 532 deletions

View File

@ -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/pickers.dart';
import 'package:star_lock/tools/pickers/time_picker/model/date_mode.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/showTipView.dart';
import 'package:star_lock/tools/storage.dart'; import 'package:star_lock/tools/storage.dart';
@ -28,7 +29,8 @@ class AuthorizedAdminPage extends StatefulWidget {
State<AuthorizedAdminPage> createState() => _AuthorizedAdminPageState(); State<AuthorizedAdminPage> createState() => _AuthorizedAdminPageState();
} }
class _AuthorizedAdminPageState extends State<AuthorizedAdminPage> with SingleTickerProviderStateMixin { class _AuthorizedAdminPageState extends State<AuthorizedAdminPage>
with SingleTickerProviderStateMixin {
final logic = Get.put(AuthorizedAdminLogic()); final logic = Get.put(AuthorizedAdminLogic());
final state = Get.find<AuthorizedAdminLogic>().state; final state = Get.find<AuthorizedAdminLogic>().state;
@ -37,10 +39,8 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage> with SingleTi
// TODO: implement initState // TODO: implement initState
super.initState(); super.initState();
state.tabController = TabController( state.tabController =
vsync: this, TabController(vsync: this, length: _itemTabs.length, initialIndex: 0);
length: _itemTabs.length,
initialIndex: 0);
state.tabController.addListener(() { state.tabController.addListener(() {
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
state.seletType.value = state.tabController.index; state.seletType.value = state.tabController.index;
@ -96,7 +96,8 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage> with SingleTi
children: [ children: [
keyInfoWidget(), keyInfoWidget(),
keyRealNameWidget(), keyRealNameWidget(),
keyBottomWidget(TranslationLoader.lanKeys!.authorizedAdminTip!.tr) keyBottomWidget(
TranslationLoader.lanKeys!.authorizedAdminTip!.tr)
], ],
), ),
); );
@ -159,7 +160,10 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage> with SingleTi
isHaveLine: true, isHaveLine: true,
isHaveDirection: true, isHaveDirection: true,
action: () { 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(() { setState(() {
state.beginDate.value = DateTool().getYMDHNDateString(p, 1); state.beginDate.value = DateTool().getYMDHNDateString(p, 1);
}); });
@ -170,8 +174,10 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage> with SingleTi
rightTitle: state.endDate.value, rightTitle: state.endDate.value,
isHaveDirection: true, isHaveDirection: true,
action: () { action: () {
Pickers.showDatePicker(context, mode: DateMode.YMDHM, PDuration selectDate =
onConfirm: (p) { PDuration.parse(DateTime.tryParse(state.endDate.value));
Pickers.showDatePicker(context,
selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) {
setState(() { setState(() {
state.endDate.value = DateTool().getYMDHNDateString(p, 1); state.endDate.value = DateTool().getYMDHNDateString(p, 1);
}); });
@ -194,14 +200,18 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage> with SingleTi
tipsImgAction: () { tipsImgAction: () {
ShowTipView().showSureAlertDialog("授权管理员只能查看和管理自己下发的钥匙、密码等权限"); 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), Container(height: 10.h),
CommonItem( CommonItem(
leftTitel: TranslationLoader.lanKeys!.realNameAuthentication!.tr, leftTitel: TranslationLoader.lanKeys!.realNameAuthentication!.tr,
rightTitle: "", rightTitle: "",
isTipsImg: true, isTipsImg: true,
tipsImgAction: () { tipsImgAction: () {
ShowTipView().showSureAlertDialog("人脸实名认证指的是用户在使用手机APP开锁时需要先进行本人人脸验证验证通过才能开锁。"); ShowTipView().showSureAlertDialog(
"人脸实名认证指的是用户在使用手机APP开锁时需要先进行本人人脸验证验证通过才能开锁。");
}, },
isHaveRightWidget: true, isHaveRightWidget: true,
rightWidget: SizedBox(width: 60.w, height: 50.h, child: _switch()), rightWidget: SizedBox(width: 60.w, height: 50.h, child: _switch()),
@ -327,8 +337,8 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage> with SingleTi
Get.toNamed(Routers.sendEmailNotificationPage); Get.toNamed(Routers.sendEmailNotificationPage);
} else { } else {
// _openModalBottomSheet(); // _openModalBottomSheet();
NativeInteractionTool().loadNativeShare( NativeInteractionTool()
shareText: state.pwdShareStr); .loadNativeShare(shareText: state.pwdShareStr);
} }
// Get.toNamed(state.emailOrPhoneController.text.contains("@")? Routers.sendEmailNotificationPage:Routers.sendEmailNotificationPage); // Get.toNamed(state.emailOrPhoneController.text.contains("@")? Routers.sendEmailNotificationPage:Routers.sendEmailNotificationPage);
}, },
@ -340,7 +350,8 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage> with SingleTi
btnName: '微信通知', btnName: '微信通知',
onClick: () { onClick: () {
// _openModalBottomSheet(); // _openModalBottomSheet();
NativeInteractionTool().loadNativeShare(shareText: state.pwdShareStr); NativeInteractionTool()
.loadNativeShare(shareText: state.pwdShareStr);
}, },
), ),
SizedBox( SizedBox(
@ -472,7 +483,8 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage> with SingleTi
value: state.onlyManageYouCreatesUser.value, value: state.onlyManageYouCreatesUser.value,
onChanged: (value) { onChanged: (value) {
setState(() { setState(() {
state.onlyManageYouCreatesUser.value = !state.onlyManageYouCreatesUser.value; state.onlyManageYouCreatesUser.value =
!state.onlyManageYouCreatesUser.value;
}); });
}, },
); );
@ -594,7 +606,7 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage> with SingleTi
return TabBar( return TabBar(
controller: state.tabController, controller: state.tabController,
tabs: _itemTabs.map((ItemView item) => _tab(item)).toList(), tabs: _itemTabs.map((ItemView item) => _tab(item)).toList(),
onTap: (index){ onTap: (index) {
FocusScope.of(context).requestFocus(FocusNode()); FocusScope.of(context).requestFocus(FocusNode());
}, },
isScrollable: true, isScrollable: true,
@ -635,9 +647,10 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage> with SingleTi
Widget _pageWidget() { Widget _pageWidget() {
return Expanded( return Expanded(
child: TabBarView( child: TabBarView(
controller: state.tabController, controller: state.tabController,
children: _itemTabs.map((ItemView item) => Obx(() => indexChangeWidget())).toList() children: _itemTabs
), .map((ItemView item) => Obx(() => indexChangeWidget()))
.toList()),
); );
} }

View File

@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_native_contact_picker/flutter_native_contact_picker.dart'; import 'package:flutter_native_contact_picker/flutter_native_contact_picker.dart';
// import 'package:flutter_pickers/pickers.dart'; // import 'package:flutter_pickers/pickers.dart';
// import 'package:flutter_pickers/time_picker/model/date_mode.dart'; // import 'package:flutter_pickers/time_picker/model/date_mode.dart';
import 'package:flutter_screenutil/flutter_screenutil.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/baseGetXController.dart';
import 'package:star_lock/tools/pickers/pickers.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/date_mode.dart';
import 'package:star_lock/tools/pickers/time_picker/model/pduration.dart';
import '../../../../appRouters.dart'; import '../../../../appRouters.dart';
import '../../../../tools/commonItem.dart'; import '../../../../tools/commonItem.dart';
@ -169,8 +171,9 @@ class _VolumeAuthorizationLockPageState
isHaveLine: true, isHaveLine: true,
isHaveDirection: true, isHaveDirection: true,
action: () { action: () {
Pickers.showDatePicker(context, mode: DateMode.YMDHM, PDuration selectDate = PDuration.parse(_effectiveDateTime);
onConfirm: (p) { Pickers.showDatePicker(context,
selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) {
setState(() { setState(() {
_selectEffectiveDate = _selectEffectiveDate =
'${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}'; '${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}';
@ -183,8 +186,9 @@ class _VolumeAuthorizationLockPageState
rightTitle: _selectFailureDate, rightTitle: _selectFailureDate,
isHaveDirection: true, isHaveDirection: true,
action: () { action: () {
Pickers.showDatePicker(context, mode: DateMode.YMDHM, PDuration selectDate = PDuration.parse(_failureDateTime);
onConfirm: (p) { Pickers.showDatePicker(context,
selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) {
setState(() { setState(() {
_selectFailureDate = _selectFailureDate =
'${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}'; '${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), // contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0),
hintText: tfStr, hintText: tfStr,
hintStyle: TextStyle(fontSize: 22.sp), hintStyle: TextStyle(fontSize: 22.sp),
focusedBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), focusedBorder: const OutlineInputBorder(
disabledBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), borderSide:
enabledBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), BorderSide(width: 0, color: Colors.transparent)),
border: 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), contentPadding: const EdgeInsets.symmetric(vertical: 0),
), ),
// decoration: InputDecoration( // decoration: InputDecoration(
@ -333,22 +345,22 @@ class _VolumeAuthorizationLockPageState
_effectiveDateTime.millisecondsSinceEpoch.toString(); _effectiveDateTime.millisecondsSinceEpoch.toString();
} }
var entity = await ApiRepository.to.addAuthorizedAdmin( var entity = await ApiRepository.to.addAuthorizedAdmin(
createUser:_isCreateUser ? "1" : "0", createUser: _isCreateUser ? "1" : "0",
endDate:getFailureDateTime, endDate: getFailureDateTime,
isRemoteUnlock:_isRemoteUnlock == true ? '1' : '2', isRemoteUnlock: _isRemoteUnlock == true ? '1' : '2',
keyGroupIdList:[], keyGroupIdList: [],
lockIdList:_lockIdList, lockIdList: _lockIdList,
name:_keyNameController.text, name: _keyNameController.text,
startDate:getEffectiveDateTime, startDate: getEffectiveDateTime,
userid:_emailOrPhoneController.text, userid: _emailOrPhoneController.text,
countryCode:countryCode, countryCode: countryCode,
usernameType:'1', usernameType: '1',
); );
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
_isSendSuccess = true; _isSendSuccess = true;
setState(() {}); setState(() {});
} else { } else {
EasyLoading.showToast('${entity.errorMsg}',duration: 2000.milliseconds); EasyLoading.showToast('${entity.errorMsg}', duration: 2000.milliseconds);
if (entity.errorCode == 425) { if (entity.errorCode == 425) {
// //
_isCreateUser = true; _isCreateUser = true;

View File

@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
@ -6,6 +5,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:star_lock/tools/pickers/pickers.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/date_mode.dart';
import 'package:star_lock/tools/pickers/time_picker/model/pduration.dart';
import '../../../../appRouters.dart'; import '../../../../appRouters.dart';
import '../../../../app_settings/app_colors.dart'; import '../../../../app_settings/app_colors.dart';
@ -25,7 +25,8 @@ class AddCardPage extends StatefulWidget {
State<AddCardPage> createState() => _AddCardPageState(); State<AddCardPage> createState() => _AddCardPageState();
} }
class _AddCardPageState extends State<AddCardPage> with SingleTickerProviderStateMixin { class _AddCardPageState extends State<AddCardPage>
with SingleTickerProviderStateMixin {
final logic = Get.put(AddCardTypeLogic()); final logic = Get.put(AddCardTypeLogic());
final state = Get.find<AddCardTypeLogic>().state; final state = Get.find<AddCardTypeLogic>().state;
@ -36,7 +37,9 @@ class _AddCardPageState extends State<AddCardPage> with SingleTickerProviderStat
state.tabController = TabController( state.tabController = TabController(
vsync: this, vsync: this,
length: state.fromType.value == 1 ? _itemTabs.length : _fromCheckInTypeItemTabs.length, length: state.fromType.value == 1
? _itemTabs.length
: _fromCheckInTypeItemTabs.length,
initialIndex: 0); initialIndex: 0);
state.tabController.addListener(() { state.tabController.addListener(() {
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
@ -48,14 +51,14 @@ class _AddCardPageState extends State<AddCardPage> with SingleTickerProviderStat
} }
}); });
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
backgroundColor: AppColors.mainBackgroundColor, backgroundColor: AppColors.mainBackgroundColor,
appBar: TitleAppBar( appBar: TitleAppBar(
barTitle: barTitle:
"${TranslationLoader.lanKeys!.addTip!.tr}${TranslationLoader.lanKeys!.card!.tr}", "${TranslationLoader.lanKeys!.addTip!.tr}${TranslationLoader.lanKeys!.card!.tr}",
haveBack: true, haveBack: true,
backgroundColor: AppColors.mainColor), backgroundColor: AppColors.mainColor),
body: Column( body: Column(
@ -148,9 +151,12 @@ class _AddCardPageState extends State<AddCardPage> with SingleTickerProviderStat
isHaveLine: true, isHaveLine: true,
isHaveDirection: true, isHaveDirection: true,
action: () async { action: () async {
Pickers.showDatePicker(context, mode: DateMode.YMDHM, PDuration selectDate = PDuration.parse(
onConfirm: (p) { DateTime.parse(state.timeLimitBeginTime.value));
state.timeLimitBeginTime.value = DateTool().getYMDHNDateString(p, 1); Pickers.showDatePicker(context,
selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) {
state.timeLimitBeginTime.value =
DateTool().getYMDHNDateString(p, 1);
}); });
})), })),
Obx(() => CommonItem( Obx(() => CommonItem(
@ -158,9 +164,12 @@ class _AddCardPageState extends State<AddCardPage> with SingleTickerProviderStat
rightTitle: state.timeLimitEndTime.value, rightTitle: state.timeLimitEndTime.value,
isHaveDirection: true, isHaveDirection: true,
action: () { action: () {
Pickers.showDatePicker(context, mode: DateMode.YMDHM, PDuration selectDate =
onConfirm: (p) { PDuration.parse(DateTime.tryParse(state.timeLimitEndTime.value));
state.timeLimitEndTime.value = DateTool().getYMDHNDateString(p, 1); Pickers.showDatePicker(context,
selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) {
state.timeLimitEndTime.value =
DateTool().getYMDHNDateString(p, 1);
}); });
})), })),
Container(height: 10.h), Container(height: 10.h),
@ -174,11 +183,13 @@ class _AddCardPageState extends State<AddCardPage> with SingleTickerProviderStat
children: [ children: [
Obx(() => CommonItem( Obx(() => CommonItem(
leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr, leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr,
rightTitle:"${state.cycleBeginTime.value}\n${state.cycleEndTime.value}", rightTitle:
"${state.cycleBeginTime.value}\n${state.cycleEndTime.value}",
isHaveDirection: true, isHaveDirection: true,
isHaveLine: true, isHaveLine: true,
action: () async { action: () async {
var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: { var result =
await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: {
'validityValue': state.weekdaysList.value, 'validityValue': state.weekdaysList.value,
'starDate': state.cycleBeginTime.value, 'starDate': state.cycleBeginTime.value,
'endDate': state.cycleEndTime.value, 'endDate': state.cycleEndTime.value,
@ -201,13 +212,14 @@ class _AddCardPageState extends State<AddCardPage> with SingleTickerProviderStat
isHaveDirection: true, isHaveDirection: true,
isHaveLine: true, isHaveLine: true,
action: () async { action: () async {
var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: { var result = await Get.toNamed(Routers.seletKeyCyclicDatePage,
'validityValue': state.weekdaysList.value, arguments: {
'starDate': state.cycleBeginTime.value, 'validityValue': state.weekdaysList.value,
'endDate': state.cycleEndTime.value, 'starDate': state.cycleBeginTime.value,
'starTime': state.effectiveDateTime.value, 'endDate': state.cycleEndTime.value,
'endTime': state.failureDateTime.value 'starTime': state.effectiveDateTime.value,
}); 'endTime': state.failureDateTime.value
});
if (result != null && result.isNotEmpty) { if (result != null && result.isNotEmpty) {
state.weekdaysList.value = result['validityValue']; state.weekdaysList.value = result['validityValue'];
state.cycleBeginTime.value = result['starDate']; state.cycleBeginTime.value = result['starDate'];
@ -220,16 +232,18 @@ class _AddCardPageState extends State<AddCardPage> with SingleTickerProviderStat
visible: state.effectiveDateTime.value.isNotEmpty, visible: state.effectiveDateTime.value.isNotEmpty,
child: CommonItem( child: CommonItem(
leftTitel: "有效时间".tr, leftTitel: "有效时间".tr,
rightTitle: "${state.effectiveDateTime.value}-${state.failureDateTime.value}", rightTitle:
"${state.effectiveDateTime.value}-${state.failureDateTime.value}",
isHaveDirection: true, isHaveDirection: true,
action: () async { action: () async {
var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: { var result = await Get.toNamed(Routers.seletKeyCyclicDatePage,
'validityValue': state.weekdaysList.value, arguments: {
'starDate': state.cycleBeginTime.value, 'validityValue': state.weekdaysList.value,
'endDate': state.cycleEndTime.value, 'starDate': state.cycleBeginTime.value,
'starTime': state.effectiveDateTime.value, 'endDate': state.cycleEndTime.value,
'endTime': state.failureDateTime.value 'starTime': state.effectiveDateTime.value,
}); 'endTime': state.failureDateTime.value
});
if (result != null && result.isNotEmpty) { if (result != null && result.isNotEmpty) {
state.weekdaysList.value = result['validityValue']; state.weekdaysList.value = result['validityValue'];
state.cycleBeginTime.value = result['starDate']; state.cycleBeginTime.value = result['starDate'];
@ -250,7 +264,8 @@ class _AddCardPageState extends State<AddCardPage> with SingleTickerProviderStat
rightTitle: "", rightTitle: "",
isTipsImg: false, isTipsImg: false,
isHaveRightWidget: true, 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), SizedBox(height: 10.h),
Obx(() => CommonItem( Obx(() => CommonItem(
leftTitel: TranslationLoader.lanKeys!.stressCard!.tr, leftTitel: TranslationLoader.lanKeys!.stressCard!.tr,
@ -260,14 +275,13 @@ class _AddCardPageState extends State<AddCardPage> with SingleTickerProviderStat
rightWidget: SizedBox( rightWidget: SizedBox(
width: 60.w, height: 50.h, child: _isStressFingerprint()))), width: 60.w, height: 50.h, child: _isStressFingerprint()))),
Container( Container(
color: Colors.white, color: Colors.white,
padding: EdgeInsets.only(left:20.w, right: 20.w, bottom: 20.h), padding: EdgeInsets.only(left: 20.w, right: 20.w, bottom: 20.h),
child: Text( child: Text(
"${"当被胁迫要求强行开锁时,使用胁迫卡会触发报警,报警信息回推送给管理员,该功能需要锁联网。".tr}\n${"请不要将胁迫卡用于日常开锁".tr}", "${"当被胁迫要求强行开锁时,使用胁迫卡会触发报警,报警信息回推送给管理员,该功能需要锁联网。".tr}\n${"请不要将胁迫卡用于日常开锁".tr}",
style: TextStyle( style: TextStyle(
fontSize: 22.sp, color: AppColors.darkGrayTextColor), fontSize: 22.sp, color: AppColors.darkGrayTextColor),
) )),
),
SizedBox(height: 30.h), SizedBox(height: 30.h),
SubmitBtn( SubmitBtn(
btnName: TranslationLoader.lanKeys!.next!.tr, btnName: TranslationLoader.lanKeys!.next!.tr,
@ -368,13 +382,14 @@ class _AddCardPageState extends State<AddCardPage> with SingleTickerProviderStat
); );
} }
final List<ItemView> _itemTabs = <ItemView>[ final List<ItemView> _itemTabs = <ItemView>[
ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, selectType: "0"), ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, selectType: "0"),
ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, selectType: "1"), 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<ItemView> _fromCheckInTypeItemTabs = <ItemView>[ final List<ItemView> _fromCheckInTypeItemTabs = <ItemView>[
ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, selectType: "0"), ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, selectType: "0"),
ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, selectType: "1"), ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, selectType: "1"),
]; ];
@ -385,7 +400,11 @@ class _AddCardPageState extends State<AddCardPage> with SingleTickerProviderStat
onTap: (index) { onTap: (index) {
FocusScope.of(context).requestFocus(FocusNode()); 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, isScrollable: true,
indicatorColor: Colors.red, indicatorColor: Colors.red,
unselectedLabelColor: Colors.black, unselectedLabelColor: Colors.black,
@ -417,14 +436,16 @@ class _AddCardPageState extends State<AddCardPage> with SingleTickerProviderStat
return Expanded( return Expanded(
child: TabBarView( child: TabBarView(
controller: state.tabController, controller: state.tabController,
children: children: state.fromType.value == 1
state.fromType.value == 1 ? _itemTabs
? _itemTabs.map((ItemView item) => Obx(() => indexChangeWidget())).toList() .map((ItemView item) => Obx(() => indexChangeWidget()))
: _fromCheckInTypeItemTabs.map((ItemView item) => Obx(() => indexChangeWidget())).toList(), .toList()
: _fromCheckInTypeItemTabs
.map((ItemView item) => Obx(() => indexChangeWidget()))
.toList(),
), ),
); );
} }
} }
class ItemView { class ItemView {
@ -433,4 +454,3 @@ class ItemView {
final String title; final String title;
final String selectType; final String selectType;
} }

View File

@ -1,4 +1,3 @@
import 'dart:ffi'; import 'dart:ffi';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -7,6 +6,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:star_lock/tools/pickers/pickers.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/date_mode.dart';
import 'package:star_lock/tools/pickers/time_picker/model/pduration.dart';
import '../../../../app_settings/app_colors.dart'; import '../../../../app_settings/app_colors.dart';
import '../../../../tools/appRouteObserver.dart'; import '../../../../tools/appRouteObserver.dart';
@ -24,7 +24,8 @@ class OtherTypeKeyChangeDatePage extends StatefulWidget {
_OtherTypeKeyChangeDatePageState(); _OtherTypeKeyChangeDatePageState();
} }
class _OtherTypeKeyChangeDatePageState extends State<OtherTypeKeyChangeDatePage> with RouteAware { class _OtherTypeKeyChangeDatePageState extends State<OtherTypeKeyChangeDatePage>
with RouteAware {
final logic = Get.put(OtherTypeKeyChangeDateLogic()); final logic = Get.put(OtherTypeKeyChangeDateLogic());
final state = Get.find<OtherTypeKeyChangeDateLogic>().state; final state = Get.find<OtherTypeKeyChangeDateLogic>().state;
@ -44,14 +45,20 @@ class _OtherTypeKeyChangeDatePageState extends State<OtherTypeKeyChangeDatePage>
style: TextStyle(color: Colors.white, fontSize: 24.sp), style: TextStyle(color: Colors.white, fontSize: 24.sp),
), ),
onPressed: () { onPressed: () {
state.beginTimeTimestamp.value = DateTool().dateToTimestamp(state.beginTime.value, 1); state.beginTimeTimestamp.value =
state.endTimeTimestamp.value = DateTool().dateToTimestamp(state.endTime.value, 1); DateTool().dateToTimestamp(state.beginTime.value, 1);
if (state.beginTimeTimestamp.value > state.endTimeTimestamp.value || state.beginTimeTimestamp.value == state.endTimeTimestamp.value) { 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); logic.showToast("失效时间需大于生效时间".tr);
return; return;
} }
if (state.endTimeTimestamp.value < DateTime.now().millisecondsSinceEpoch) { if (state.endTimeTimestamp.value <
DateTime.now().millisecondsSinceEpoch) {
logic.showToast("生效时间需大于当前时间".tr); logic.showToast("生效时间需大于当前时间".tr);
return; return;
} }
@ -92,8 +99,10 @@ class _OtherTypeKeyChangeDatePageState extends State<OtherTypeKeyChangeDatePage>
isHaveLine: true, isHaveLine: true,
isHaveDirection: true, isHaveDirection: true,
action: () { action: () {
Pickers.showDatePicker(context, mode: DateMode.YMDHM, PDuration selectDate =
onConfirm: (p) { PDuration.parse(DateTime.tryParse(state.beginTime.value));
Pickers.showDatePicker(context,
selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) {
setState(() { setState(() {
state.beginTime.value = DateTool().getYMDHNDateString(p, 1); state.beginTime.value = DateTool().getYMDHNDateString(p, 1);
}); });
@ -104,8 +113,10 @@ class _OtherTypeKeyChangeDatePageState extends State<OtherTypeKeyChangeDatePage>
rightTitle: state.endTime.value, rightTitle: state.endTime.value,
isHaveDirection: true, isHaveDirection: true,
action: () { action: () {
Pickers.showDatePicker(context, mode: DateMode.YMDHM, PDuration selectDate =
onConfirm: (p) { PDuration.parse(DateTime.tryParse(state.endTime.value));
Pickers.showDatePicker(context,
selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) {
setState(() { setState(() {
state.endTime.value = DateTool().getYMDHNDateString(p, 1); state.endTime.value = DateTool().getYMDHNDateString(p, 1);
}); });
@ -165,5 +176,4 @@ class _OtherTypeKeyChangeDatePageState extends State<OtherTypeKeyChangeDatePage>
state.ifCurrentScreen.value = false; state.ifCurrentScreen.value = false;
state.sureBtnState.value = 0; state.sureBtnState.value = 0;
} }
} }

View File

@ -3,6 +3,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:star_lock/tools/pickers/pickers.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/date_mode.dart';
import 'package:star_lock/tools/pickers/time_picker/model/pduration.dart';
import '../../../../app_settings/app_colors.dart'; import '../../../../app_settings/app_colors.dart';
import '../../../../tools/commonItem.dart'; import '../../../../tools/commonItem.dart';
@ -20,7 +21,8 @@ class OtherTypeKeyChangeValidityDatePage extends StatefulWidget {
_OtherTypeKeyChangeValidityDatePageState(); _OtherTypeKeyChangeValidityDatePageState();
} }
class _OtherTypeKeyChangeValidityDatePageState extends State<OtherTypeKeyChangeValidityDatePage> { class _OtherTypeKeyChangeValidityDatePageState
extends State<OtherTypeKeyChangeValidityDatePage> {
final logic = Get.put(OtherTypeKeyChangeValidityDateLogic()); final logic = Get.put(OtherTypeKeyChangeValidityDateLogic());
final state = Get.find<OtherTypeKeyChangeValidityDateLogic>().state; final state = Get.find<OtherTypeKeyChangeValidityDateLogic>().state;
@ -44,17 +46,23 @@ class _OtherTypeKeyChangeValidityDatePageState extends State<OtherTypeKeyChangeV
child: SubmitBtn( child: SubmitBtn(
btnName: TranslationLoader.lanKeys!.save!.tr, btnName: TranslationLoader.lanKeys!.save!.tr,
onClick: () { onClick: () {
state.starDateTimestamp.value = DateTool().dateToTimestamp(state.starDate.value, 1); state.starDateTimestamp.value =
state.endDateTimestamp.value = DateTool().dateToTimestamp(state.endDate.value, 1); DateTool().dateToTimestamp(state.starDate.value, 1);
state.starTimeTimestamp.value = DateTool().dateToTimestamp(state.starTime.value, 0); state.endDateTimestamp.value =
state.endTimeTimestamp.value = DateTool().dateToTimestamp(state.endTime.value, 0); DateTool().dateToTimestamp(state.endDate.value, 1);
state.starTimeTimestamp.value =
DateTool().dateToTimestamp(state.starTime.value, 0);
state.endTimeTimestamp.value =
DateTool().dateToTimestamp(state.endTime.value, 0);
if (state.starDateTimestamp.value >= state.endDateTimestamp.value) { if (state.starDateTimestamp.value >=
state.endDateTimestamp.value) {
logic.showToast("失效日期要大于生效日期".tr); logic.showToast("失效日期要大于生效日期".tr);
return; return;
} }
if (state.starTimeTimestamp.value >= state.endTimeTimestamp.value) { if (state.starTimeTimestamp.value >=
state.endTimeTimestamp.value) {
logic.showToast("失效时间要大于生效时间".tr); logic.showToast("失效时间要大于生效时间".tr);
return; return;
} }
@ -98,20 +106,27 @@ class _OtherTypeKeyChangeValidityDatePageState extends State<OtherTypeKeyChangeV
isHaveDirection: true, isHaveDirection: true,
isHaveLine: true, isHaveLine: true,
action: () { action: () {
Pickers.showDatePicker(context, mode: DateMode.YMD, PDuration selectDate =
onConfirm: (p) { PDuration.parse(DateTime.tryParse(state.starDate.value));
state.starDate.value = DateTool().getYMDHNDateString(p, 2); Pickers.showDatePicker(context,
}); selectDate: selectDate,
mode: DateMode.YMD, onConfirm: (p) {
state.starDate.value =
DateTool().getYMDHNDateString(p, 2);
});
})), })),
Obx(() => CommonItem( Obx(() => CommonItem(
leftTitel: "失效日期".tr, leftTitel: "失效日期".tr,
rightTitle: state.endDate.value, rightTitle: state.endDate.value,
isHaveDirection: true, isHaveDirection: true,
action: () { action: () {
Pickers.showDatePicker(context, mode: DateMode.YMD, PDuration selectDate =
onConfirm: (p) { PDuration.parse(DateTime.tryParse(state.endDate.value));
state.endDate.value = DateTool().getYMDHNDateString(p, 2); Pickers.showDatePicker(context,
}); selectDate: selectDate,
mode: DateMode.YMD, onConfirm: (p) {
state.endDate.value = DateTool().getYMDHNDateString(p, 2);
});
})), })),
Container(height: 10.h), Container(height: 10.h),
], ],
@ -135,7 +150,7 @@ class _OtherTypeKeyChangeValidityDatePageState extends State<OtherTypeKeyChangeV
padding: EdgeInsets.only(left: 30.w, top: 15.h), padding: EdgeInsets.only(left: 30.w, top: 15.h),
child: Text(TranslationLoader.lanKeys!.effectiveDay!.tr, child: Text(TranslationLoader.lanKeys!.effectiveDay!.tr,
style: style:
TextStyle(fontSize: 24.sp, fontWeight: FontWeight.w600))), TextStyle(fontSize: 24.sp, fontWeight: FontWeight.w600))),
Container( Container(
height: 100.h, height: 100.h,
padding: EdgeInsets.only(left: 10.w, right: 10.w, bottom: 10.h), padding: EdgeInsets.only(left: 10.w, right: 10.w, bottom: 10.h),
@ -230,10 +245,13 @@ class _OtherTypeKeyChangeValidityDatePageState extends State<OtherTypeKeyChangeV
isHaveDirection: true, isHaveDirection: true,
isHaveLine: true, isHaveLine: true,
action: () { action: () {
Pickers.showDatePicker(context, mode: DateMode.HM, PDuration selectDate = PDuration.parse(DateTool().dateToDateTime(state.starTime.value, 0));
onConfirm: (p) { Pickers.showDatePicker(context,
selectDate: selectDate,
mode: DateMode.HM, onConfirm: (p) {
setState(() { setState(() {
state.starTime.value = DateTool().getYMDHNDateString(p, 3); state.starTime.value =
DateTool().getYMDHNDateString(p, 3);
}); });
}); });
})), })),
@ -243,10 +261,13 @@ class _OtherTypeKeyChangeValidityDatePageState extends State<OtherTypeKeyChangeV
rightTitle: state.endTime.value, rightTitle: state.endTime.value,
isHaveDirection: true, isHaveDirection: true,
action: () { action: () {
Pickers.showDatePicker(context, mode: DateMode.HM, PDuration selectDate = PDuration.parse(DateTool().dateToDateTime(state.endTime.value, 0));
onConfirm: (p) { Pickers.showDatePicker(context,
selectDate: selectDate,
mode: DateMode.HM, onConfirm: (p) {
setState(() { setState(() {
state.endTime.value = DateTool().getYMDHNDateString(p, 3); state.endTime.value =
DateTool().getYMDHNDateString(p, 3);
}); });
}); });
})), })),

View File

@ -4,6 +4,7 @@ import 'package:get/get.dart';
import 'package:star_lock/tools/dateTool.dart'; import 'package:star_lock/tools/dateTool.dart';
import 'package:star_lock/tools/pickers/pickers.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/date_mode.dart';
import 'package:star_lock/tools/pickers/time_picker/model/pduration.dart';
import '../../../../app_settings/app_colors.dart'; import '../../../../app_settings/app_colors.dart';
import '../../../../tools/commonItem.dart'; import '../../../../tools/commonItem.dart';
@ -46,11 +47,14 @@ class _CheckingInSetWorkTimePageState extends State<CheckingInSetWorkTimePage> {
isHaveDirection: true, isHaveDirection: true,
isHaveLine: true, isHaveLine: true,
action: () { action: () {
Pickers.showDatePicker(context, mode: DateMode.HM, PDuration selectDate = PDuration.parse(DateTool().dateToDateTime(state.beginTime.value, 0));
onConfirm: (p) { Pickers.showDatePicker(context,
selectDate: selectDate, mode: DateMode.HM, onConfirm: (p) {
setState(() { setState(() {
state.beginTime.value = DateTool().getYMDHNDateString(p, 3); 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<CheckingInSetWorkTimePage> {
rightTitle: state.endTime.value, rightTitle: state.endTime.value,
isHaveDirection: true, isHaveDirection: true,
action: () { action: () {
Pickers.showDatePicker(context, mode: DateMode.HM, PDuration selectDate = PDuration.parse(DateTool().dateToDateTime(state.endTime.value, 0));
onConfirm: (p) { Pickers.showDatePicker(context,
selectDate: selectDate, mode: DateMode.HM, onConfirm: (p) {
setState(() { setState(() {
state.endTime.value = DateTool().getYMDHNDateString(p, 3); 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<CheckingInSetWorkTimePage> {
return; 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("结束时间必须要比开始时间晚,请重新选择"); logic.showToast("结束时间必须要比开始时间晚,请重新选择");
return; return;
} }

View File

@ -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/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetailChangeDate/electronicKeyDetailChangeDate_logic.dart';
import 'package:star_lock/tools/pickers/pickers.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/date_mode.dart';
import 'package:star_lock/tools/pickers/time_picker/model/pduration.dart';
import '../../../../../app_settings/app_colors.dart'; import '../../../../../app_settings/app_colors.dart';
import '../../../../../tools/commonItem.dart'; import '../../../../../tools/commonItem.dart';
@ -59,27 +60,30 @@ class _ElectronicKeyDetailChangeDateState
isHaveLine: true, isHaveLine: true,
isHaveDirection: true, isHaveDirection: true,
action: () { action: () {
Pickers.showDatePicker(context, mode: DateMode.YMDHM, PDuration selectDate =
onConfirm: (p) { PDuration.parse(DateTime.tryParse(state.beginTime.value));
setState(() { Pickers.showDatePicker(context,
state.beginTime.value = DateTool().getYMDHNDateString(p, 1); selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) {
}); setState(() {
}); state.beginTime.value = DateTool().getYMDHNDateString(p, 1);
});
});
})), })),
Obx(() => CommonItem( Obx(() => CommonItem(
leftTitel: TranslationLoader.lanKeys!.failureTime!.tr, leftTitel: TranslationLoader.lanKeys!.failureTime!.tr,
rightTitle: state.endTime.value, rightTitle: state.endTime.value,
isHaveDirection: true, isHaveDirection: true,
action: () { action: () {
Pickers.showDatePicker(context, mode: DateMode.YMDHM, PDuration selectDate =
onConfirm: (p) { PDuration.parse(DateTime.tryParse(state.endTime.value));
setState(() { Pickers.showDatePicker(context,
state.endTime.value = DateTool().getYMDHNDateString(p, 1); selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) {
}); setState(() {
}); state.endTime.value = DateTool().getYMDHNDateString(p, 1);
});
});
})), })),
], ],
); );
} }
} }

View File

@ -3,6 +3,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:star_lock/tools/pickers/pickers.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/date_mode.dart';
import 'package:star_lock/tools/pickers/time_picker/model/pduration.dart';
import '../../../../../app_settings/app_colors.dart'; import '../../../../../app_settings/app_colors.dart';
import '../../../../../tools/commonItem.dart'; import '../../../../../tools/commonItem.dart';
@ -20,7 +21,8 @@ class ElectronicKeyPeriodValidityPage extends StatefulWidget {
_ElectronicKeyPeriodValidityPageState(); _ElectronicKeyPeriodValidityPageState();
} }
class _ElectronicKeyPeriodValidityPageState extends State<ElectronicKeyPeriodValidityPage> { class _ElectronicKeyPeriodValidityPageState
extends State<ElectronicKeyPeriodValidityPage> {
final logic = Get.put(ElectronicKeyPeriodValidityLogic()); final logic = Get.put(ElectronicKeyPeriodValidityLogic());
final state = Get.find<ElectronicKeyPeriodValidityLogic>().state; final state = Get.find<ElectronicKeyPeriodValidityLogic>().state;
@ -46,9 +48,7 @@ class _ElectronicKeyPeriodValidityPageState extends State<ElectronicKeyPeriodVal
onClick: () { onClick: () {
if (state.pushType.value == 0) { if (state.pushType.value == 0) {
logic.updateKeyDateRequest(); logic.updateKeyDateRequest();
} else if (state.pushType.value == 1) { } else if (state.pushType.value == 1) {}
}
}), }),
), ),
], ],
@ -68,20 +68,27 @@ class _ElectronicKeyPeriodValidityPageState extends State<ElectronicKeyPeriodVal
isHaveDirection: true, isHaveDirection: true,
isHaveLine: true, isHaveLine: true,
action: () { action: () {
Pickers.showDatePicker(context, mode: DateMode.YMD, PDuration selectDate =
onConfirm: (p) { PDuration.parse(DateTime.tryParse(state.endTime.value));
state.starDate.value = DateTool().getYMDHNDateString(p, 2); Pickers.showDatePicker(context,
}); selectDate: selectDate,
mode: DateMode.YMD, onConfirm: (p) {
state.starDate.value =
DateTool().getYMDHNDateString(p, 2);
});
})), })),
Obx(() => CommonItem( Obx(() => CommonItem(
leftTitel: "失效日期".tr, leftTitel: "失效日期".tr,
rightTitle: state.endDate.value, rightTitle: state.endDate.value,
isHaveDirection: true, isHaveDirection: true,
action: () { action: () {
Pickers.showDatePicker(context, mode: DateMode.YMD, PDuration selectDate =
onConfirm: (p) { PDuration.parse(DateTime.tryParse(state.endDate.value));
state.endDate.value = DateTool().getYMDHNDateString(p, 2); Pickers.showDatePicker(context,
}); selectDate: selectDate,
mode: DateMode.YMD, onConfirm: (p) {
state.endDate.value = DateTool().getYMDHNDateString(p, 2);
});
})), })),
Container(height: 10.h), Container(height: 10.h),
], ],
@ -105,7 +112,7 @@ class _ElectronicKeyPeriodValidityPageState extends State<ElectronicKeyPeriodVal
padding: EdgeInsets.only(left: 30.w, top: 15.h), padding: EdgeInsets.only(left: 30.w, top: 15.h),
child: Text(TranslationLoader.lanKeys!.effectiveDay!.tr, child: Text(TranslationLoader.lanKeys!.effectiveDay!.tr,
style: style:
TextStyle(fontSize: 24.sp, fontWeight: FontWeight.w600))), TextStyle(fontSize: 24.sp, fontWeight: FontWeight.w600))),
Container( Container(
height: 100.h, height: 100.h,
padding: EdgeInsets.only(left: 10.w, right: 10.w, bottom: 10.h), padding: EdgeInsets.only(left: 10.w, right: 10.w, bottom: 10.h),
@ -163,18 +170,18 @@ class _ElectronicKeyPeriodValidityPageState extends State<ElectronicKeyPeriodVal
}); });
}, },
child: Obx(() => Container( child: Obx(() => Container(
width: 40.w, width: 40.w,
height: 40.w, height: 40.w,
margin: EdgeInsets.all(10.w), margin: EdgeInsets.all(10.w),
decoration: BoxDecoration( decoration: BoxDecoration(
color: state.weekDay.value.contains(index) color: state.weekDay.value.contains(index)
? AppColors.mainColor ? AppColors.mainColor
: Colors.white, : Colors.white,
border: Border.all(width: 1, color: AppColors.btnDisableColor), border: Border.all(width: 1, color: AppColors.btnDisableColor),
borderRadius: BorderRadius.circular(30.w), borderRadius: BorderRadius.circular(30.w),
), ),
child: Center( child: Center(
child: Text( child: Text(
dateStr, dateStr,
style: TextStyle( style: TextStyle(
fontSize: 20.sp, fontSize: 20.sp,
@ -182,7 +189,7 @@ class _ElectronicKeyPeriodValidityPageState extends State<ElectronicKeyPeriodVal
? Colors.white ? Colors.white
: AppColors.darkGrayTextColor), : AppColors.darkGrayTextColor),
)), )),
)), )),
); );
} }
@ -195,30 +202,36 @@ class _ElectronicKeyPeriodValidityPageState extends State<ElectronicKeyPeriodVal
children: [ children: [
Obx(() => CommonItem( Obx(() => CommonItem(
leftTitel: leftTitel:
"${TranslationLoader.lanKeys!.begin!.tr}${TranslationLoader.lanKeys!.time!.tr}", "${TranslationLoader.lanKeys!.begin!.tr}${TranslationLoader.lanKeys!.time!.tr}",
rightTitle: state.starTime.value, rightTitle: state.starTime.value,
isHaveDirection: true, isHaveDirection: true,
isHaveLine: true, isHaveLine: true,
action: () { action: () {
Pickers.showDatePicker(context, mode: DateMode.HM, PDuration selectDate = PDuration.parse(DateTool().dateToDateTime(state.starTime.value, 0));
onConfirm: (p) { Pickers.showDatePicker(context,
setState(() { selectDate: selectDate,
state.starTime.value = DateTool().getYMDHNDateString(p, 3); mode: DateMode.HM, onConfirm: (p) {
}); setState(() {
}); state.starTime.value =
DateTool().getYMDHNDateString(p, 3);
});
});
})), })),
Obx(() => CommonItem( Obx(() => CommonItem(
leftTitel: leftTitel:
"${TranslationLoader.lanKeys!.end!.tr}${TranslationLoader.lanKeys!.time!.tr}", "${TranslationLoader.lanKeys!.end!.tr}${TranslationLoader.lanKeys!.time!.tr}",
rightTitle: state.endTime.value, rightTitle: state.endTime.value,
isHaveDirection: true, isHaveDirection: true,
action: () { action: () {
Pickers.showDatePicker(context, mode: DateMode.HM, PDuration selectDate = PDuration.parse(DateTool().dateToDateTime(state.endTime.value, 0));
onConfirm: (p) { Pickers.showDatePicker(context,
setState(() { selectDate: selectDate,
state.endTime.value = DateTool().getYMDHNDateString(p, 3); mode: DateMode.HM, onConfirm: (p) {
}); setState(() {
}); state.endTime.value =
DateTool().getYMDHNDateString(p, 3);
});
});
})), })),
Container(height: 10.h), Container(height: 10.h),
], ],

View File

@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.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/app_settings/app_colors.dart';
import 'package:star_lock/tools/pickers/pickers.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/date_mode.dart';
import 'package:star_lock/tools/pickers/time_picker/model/pduration.dart';
import '../../../../../../tools/commonItem.dart'; import '../../../../../../tools/commonItem.dart';
import '../../../../../../tools/submitBtn.dart'; import '../../../../../../tools/submitBtn.dart';
@ -48,7 +48,9 @@ class _MassSendElectronicKeyPageState extends State<MassSendElectronicKeyPage> {
state.type.value = widget.type; state.type.value = widget.type;
return SingleChildScrollView( return SingleChildScrollView(
child: state.isDemoMode ? indexChangeWidget() : Obx(() => indexChangeWidget()), child: state.isDemoMode
? indexChangeWidget()
: Obx(() => indexChangeWidget()),
); );
} }
@ -178,7 +180,8 @@ class _MassSendElectronicKeyPageState extends State<MassSendElectronicKeyPage> {
rightWidget: Text( rightWidget: Text(
'${state.countryName.value} +${state.countryCode.value}', '${state.countryName.value} +${state.countryCode.value}',
textAlign: TextAlign.end, textAlign: TextAlign.end,
style: TextStyle(fontSize: 22.sp, color: AppColors.darkGrayTextColor), style:
TextStyle(fontSize: 22.sp, color: AppColors.darkGrayTextColor),
), ),
action: () async { action: () async {
var result = await Navigator.pushNamed( var result = await Navigator.pushNamed(
@ -223,20 +226,24 @@ class _MassSendElectronicKeyPageState extends State<MassSendElectronicKeyPage> {
isHaveLine: true, isHaveLine: true,
isHaveDirection: true, isHaveDirection: true,
action: () { action: () {
Pickers.showDatePicker(context, mode: DateMode.YMDHM, PDuration selectDate =
onConfirm: (p) { PDuration.parse(DateTime.tryParse(state.beginTime.value));
state.beginTime.value = DateTool().getYMDHNDateString(p, 1); Pickers.showDatePicker(context,
}); selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) {
state.beginTime.value = DateTool().getYMDHNDateString(p, 1);
});
})), })),
Obx(() => CommonItem( Obx(() => CommonItem(
leftTitel: TranslationLoader.lanKeys!.failureTime!.tr, leftTitel: TranslationLoader.lanKeys!.failureTime!.tr,
rightTitle: state.endTime.value, rightTitle: state.endTime.value,
isHaveDirection: true, isHaveDirection: true,
action: () { action: () {
Pickers.showDatePicker(context, mode: DateMode.YMDHM, PDuration selectDate =
onConfirm: (p) { PDuration.parse(DateTime.tryParse(state.endTime.value));
state.endTime.value = DateTool().getYMDHNDateString(p, 1); Pickers.showDatePicker(context,
}); selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) {
state.endTime.value = DateTool().getYMDHNDateString(p, 1);
});
})), })),
Container(height: 10.h), Container(height: 10.h),
], ],
@ -268,15 +275,15 @@ class _MassSendElectronicKeyPageState extends State<MassSendElectronicKeyPage> {
isHaveDirection: true, isHaveDirection: true,
isHaveLine: true, isHaveLine: true,
action: () async { action: () async {
var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, var result =
arguments: { await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: {
'validityValue': state.weekdaysList.value, 'validityValue': state.weekdaysList.value,
'starDate': state.beginTime.value, 'starDate': state.beginTime.value,
'endDate': state.endTime.value, 'endDate': state.endTime.value,
'starTime': state.effectiveDateTime.value, 'starTime': state.effectiveDateTime.value,
'endTime': state.failureDateTime.value 'endTime': state.failureDateTime.value
}); });
if(result != null && result.isNotEmpty){ if (result != null && result.isNotEmpty) {
state.weekdaysList.value = result['validityValue']; state.weekdaysList.value = result['validityValue'];
state.beginTime.value = result['starDate']; state.beginTime.value = result['starDate'];
state.endTime.value = result['endDate']; state.endTime.value = result['endDate'];
@ -300,40 +307,41 @@ class _MassSendElectronicKeyPageState extends State<MassSendElectronicKeyPage> {
'starTime': state.effectiveDateTime.value, 'starTime': state.effectiveDateTime.value,
'endTime': state.failureDateTime.value 'endTime': state.failureDateTime.value
}); });
if(result != null && result.isNotEmpty){ if (result != null && result.isNotEmpty) {
state.weekdaysList.value = result['validityValue']; state.weekdaysList.value = result['validityValue'];
state.beginTime.value = result['starDate']; state.beginTime.value = result['starDate'];
state.endTime.value = result['endDate']; state.endTime.value = result['endDate'];
state.effectiveDateTime.value = result['starTime']; state.effectiveDateTime.value = result['starTime'];
state.failureDateTime.value = result['endTime']; state.failureDateTime.value = result['endTime'];
} }
}) }))),
)),
Obx(() => Visibility( Obx(() => Visibility(
visible: state.effectiveDateTime.value.isNotEmpty, visible: state.effectiveDateTime.value.isNotEmpty,
child: CommonItem( child: CommonItem(
leftTitel: "有效时间".tr, leftTitel: "有效时间".tr,
rightTitle: "${state.effectiveDateTime.value}-${state.failureDateTime.value}", rightTitle:
isHaveDirection: true, "${state.effectiveDateTime.value}-${state.failureDateTime.value}",
action: () async { isHaveDirection: true,
var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, action: () async {
arguments: { var result = await Get.toNamed(
'validityValue': state.weekdaysList.value, Routers.seletKeyCyclicDatePage,
'starDate': state.beginTime.value, arguments: {
'endDate': state.endTime.value, 'validityValue': state.weekdaysList.value,
'starTime': state.effectiveDateTime.value, 'starDate': state.beginTime.value,
'endTime': state.failureDateTime.value 'endDate': state.endTime.value,
}); 'starTime': state.effectiveDateTime.value,
if(result != null && result.isNotEmpty){ 'endTime': state.failureDateTime.value
state.weekdaysList.value = result['validityValue']; });
state.beginTime.value = result['starDate']; if (result != null && result.isNotEmpty) {
state.endTime.value = result['endDate']; state.weekdaysList.value = result['validityValue'];
state.effectiveDateTime.value = result['starTime']; state.beginTime.value = result['starDate'];
state.failureDateTime.value = result['endTime']; state.endTime.value = result['endDate'];
Get.back(result: result); state.effectiveDateTime.value = result['starTime'];
} state.failureDateTime.value = result['endTime'];
}), Get.back(result: result);
)), }
}),
)),
Container(height: 10.h), Container(height: 10.h),
], ],
); );
@ -364,5 +372,4 @@ class _MassSendElectronicKeyPageState extends State<MassSendElectronicKeyPage> {
}, },
); );
} }
} }

View File

@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.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/baseGetXController.dart';
import 'package:star_lock/tools/pickers/pickers.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/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/showTipView.dart';
import 'package:star_lock/tools/storage.dart'; import 'package:star_lock/tools/storage.dart';
@ -31,7 +31,8 @@ class SendElectronicKeyPage extends StatefulWidget {
State<SendElectronicKeyPage> createState() => _SendElectronicKeyPageState(); State<SendElectronicKeyPage> createState() => _SendElectronicKeyPageState();
} }
class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> with SingleTickerProviderStateMixin { class _SendElectronicKeyPageState extends State<SendElectronicKeyPage>
with SingleTickerProviderStateMixin {
final logic = Get.put(SendElectronicKeyLogic()); final logic = Get.put(SendElectronicKeyLogic());
final state = Get.find<SendElectronicKeyLogic>().state; final state = Get.find<SendElectronicKeyLogic>().state;
@ -46,10 +47,8 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> with Sing
getDemoMode(); getDemoMode();
state.tabController = TabController( state.tabController =
vsync: this, TabController(vsync: this, length: _itemTabs.length, initialIndex: 0);
length: _itemTabs.length,
initialIndex: 0);
state.tabController.addListener(() { state.tabController.addListener(() {
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
state.seletType.value = state.tabController.index; state.seletType.value = state.tabController.index;
@ -203,9 +202,12 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> with Sing
isHaveLine: true, isHaveLine: true,
isHaveDirection: true, isHaveDirection: true,
action: () { action: () {
Pickers.showDatePicker(context, mode: DateMode.YMDHM, PDuration selectDate = PDuration.parse(
onConfirm: (p) { DateTime.parse(state.timeLimitBeginTime.value));
state.timeLimitBeginTime.value = DateTool().getYMDHNDateString(p, 1); Pickers.showDatePicker(context,
selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) {
state.timeLimitBeginTime.value =
DateTool().getYMDHNDateString(p, 1);
}); });
})), })),
Obx(() => CommonItem( Obx(() => CommonItem(
@ -213,9 +215,12 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> with Sing
rightTitle: state.timeLimitEndTime.value, rightTitle: state.timeLimitEndTime.value,
isHaveDirection: true, isHaveDirection: true,
action: () { action: () {
Pickers.showDatePicker(context, mode: DateMode.YMDHM, PDuration selectDate =
onConfirm: (p) { PDuration.parse(DateTime.tryParse(state.timeLimitEndTime.value));
state.timeLimitEndTime.value = DateTool().getYMDHNDateString(p, 1); Pickers.showDatePicker(context,
selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) {
state.timeLimitEndTime.value =
DateTool().getYMDHNDateString(p, 1);
}); });
})), })),
Container(height: 10.h), Container(height: 10.h),
@ -232,7 +237,8 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> with Sing
rightTitle: "", rightTitle: "",
isTipsImg: true, isTipsImg: true,
tipsImgAction: () { tipsImgAction: () {
ShowTipView().showSureAlertDialog("人脸实名认证指的是用户在使用手机APP开锁时需要先进行本人人脸验证验证通过才能开锁。".tr); ShowTipView().showSureAlertDialog(
"人脸实名认证指的是用户在使用手机APP开锁时需要先进行本人人脸验证验证通过才能开锁。".tr);
}, },
isHaveRightWidget: true, isHaveRightWidget: true,
rightWidget: SizedBox( rightWidget: SizedBox(
@ -250,19 +256,20 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> with Sing
children: [ children: [
Obx(() => CommonItem( Obx(() => CommonItem(
leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr, leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr,
rightTitle: "${state.cycleBeginTime.value}\n${state.cycleEndTime.value}", rightTitle:
"${state.cycleBeginTime.value}\n${state.cycleEndTime.value}",
isHaveDirection: true, isHaveDirection: true,
isHaveLine: true, isHaveLine: true,
action: () async { action: () async {
var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, var result =
arguments: { await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: {
'validityValue': state.weekdaysList.value, 'validityValue': state.weekdaysList.value,
'starDate': state.cycleBeginTime.value, 'starDate': state.cycleBeginTime.value,
'endDate': state.cycleEndTime.value, 'endDate': state.cycleEndTime.value,
'starTime': state.effectiveDateTime.value, 'starTime': state.effectiveDateTime.value,
'endTime': state.failureDateTime.value 'endTime': state.failureDateTime.value
}); });
if(result != null && result.isNotEmpty){ if (result != null && result.isNotEmpty) {
state.weekdaysList.value = result['validityValue']; state.weekdaysList.value = result['validityValue'];
state.cycleBeginTime.value = result['starDate']; state.cycleBeginTime.value = result['starDate'];
state.cycleEndTime.value = result['endDate']; state.cycleEndTime.value = result['endDate'];
@ -286,20 +293,20 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> with Sing
'starTime': state.effectiveDateTime.value, 'starTime': state.effectiveDateTime.value,
'endTime': state.failureDateTime.value 'endTime': state.failureDateTime.value
}); });
if(result != null && result.isNotEmpty){ if (result != null && result.isNotEmpty) {
state.weekdaysList.value = result['validityValue']; state.weekdaysList.value = result['validityValue'];
state.cycleBeginTime.value = result['starDate']; state.cycleBeginTime.value = result['starDate'];
state.cycleEndTime.value = result['endDate']; state.cycleEndTime.value = result['endDate'];
state.effectiveDateTime.value = result['starTime']; state.effectiveDateTime.value = result['starTime'];
state.failureDateTime.value = result['endTime']; state.failureDateTime.value = result['endTime'];
} }
}) }))),
)),
Obx(() => Visibility( Obx(() => Visibility(
visible: state.effectiveDateTime.value.isNotEmpty, visible: state.effectiveDateTime.value.isNotEmpty,
child: CommonItem( child: CommonItem(
leftTitel: "有效时间".tr, leftTitel: "有效时间".tr,
rightTitle: "${state.effectiveDateTime.value}-${state.failureDateTime.value}", rightTitle:
"${state.effectiveDateTime.value}-${state.failureDateTime.value}",
isHaveDirection: true, isHaveDirection: true,
action: () async { action: () async {
var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, var result = await Get.toNamed(Routers.seletKeyCyclicDatePage,
@ -310,15 +317,14 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> with Sing
'starTime': state.effectiveDateTime.value, 'starTime': state.effectiveDateTime.value,
'endTime': state.failureDateTime.value 'endTime': state.failureDateTime.value
}); });
if(result != null && result.isNotEmpty){ if (result != null && result.isNotEmpty) {
state.weekdaysList.value = result['validityValue']; state.weekdaysList.value = result['validityValue'];
state.cycleBeginTime.value = result['starDate']; state.cycleBeginTime.value = result['starDate'];
state.cycleEndTime.value = result['endDate']; state.cycleEndTime.value = result['endDate'];
state.effectiveDateTime.value = result['starTime']; state.effectiveDateTime.value = result['starTime'];
state.failureDateTime.value = result['endTime']; state.failureDateTime.value = result['endTime'];
} }
}) }))),
)),
], ],
); );
} }
@ -568,7 +574,9 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> with Sing
return Visibility( return Visibility(
visible: state.isDemoMode visible: state.isDemoMode
? false ? false
: (CommonDataManage().currentKeyInfo.lockSetting!.remoteUnlock == 1 ? true : false), : (CommonDataManage().currentKeyInfo.lockSetting!.remoteUnlock == 1
? true
: false),
child: Column( child: Column(
children: [ children: [
CommonItem( CommonItem(
@ -647,7 +655,7 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> with Sing
TabBar _tabBar() { TabBar _tabBar() {
return TabBar( return TabBar(
controller: state.tabController, controller: state.tabController,
onTap: (index){ onTap: (index) {
FocusScope.of(context).requestFocus(FocusNode()); FocusScope.of(context).requestFocus(FocusNode());
}, },
tabs: _itemTabs.map((ItemView item) => _tab(item)).toList(), tabs: _itemTabs.map((ItemView item) => _tab(item)).toList(),
@ -689,10 +697,10 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> with Sing
Widget _pageWidget() { Widget _pageWidget() {
return Expanded( return Expanded(
child: TabBarView( child: TabBarView(
controller: state.tabController, controller: state.tabController,
children: _itemTabs children: _itemTabs
.map((ItemView item) => Obx(() => indexChangeWidget())).toList() .map((ItemView item) => Obx(() => indexChangeWidget()))
), .toList()),
); );
} }

View File

@ -6,6 +6,7 @@ import 'package:get/get.dart';
import 'package:star_lock/tools/dateTool.dart'; import 'package:star_lock/tools/dateTool.dart';
import 'package:star_lock/tools/pickers/pickers.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/date_mode.dart';
import 'package:star_lock/tools/pickers/time_picker/model/pduration.dart';
import '../../../../appRouters.dart'; import '../../../../appRouters.dart';
import '../../../../app_settings/app_colors.dart'; import '../../../../app_settings/app_colors.dart';
@ -24,7 +25,8 @@ class AddFaceTypePage extends StatefulWidget {
State<AddFaceTypePage> createState() => _AddFaceTypePageState(); State<AddFaceTypePage> createState() => _AddFaceTypePageState();
} }
class _AddFaceTypePageState extends State<AddFaceTypePage> with SingleTickerProviderStateMixin { class _AddFaceTypePageState extends State<AddFaceTypePage>
with SingleTickerProviderStateMixin {
final logic = Get.put(AddFaceTypeLogic()); final logic = Get.put(AddFaceTypeLogic());
final state = Get.find<AddFaceTypeLogic>().state; final state = Get.find<AddFaceTypeLogic>().state;
@ -35,7 +37,9 @@ class _AddFaceTypePageState extends State<AddFaceTypePage> with SingleTickerProv
state.tabController = TabController( state.tabController = TabController(
vsync: this, vsync: this,
length: state.fromType.value == 1 ? _itemTabs.length : _fromCheckInTypeItemTabs.length, length: state.fromType.value == 1
? _itemTabs.length
: _fromCheckInTypeItemTabs.length,
initialIndex: 0); initialIndex: 0);
state.tabController.addListener(() { state.tabController.addListener(() {
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
@ -54,7 +58,7 @@ class _AddFaceTypePageState extends State<AddFaceTypePage> with SingleTickerProv
backgroundColor: AppColors.mainBackgroundColor, backgroundColor: AppColors.mainBackgroundColor,
appBar: TitleAppBar( appBar: TitleAppBar(
barTitle: barTitle:
"${TranslationLoader.lanKeys!.addTip!.tr}${TranslationLoader.lanKeys!.face!.tr}", "${TranslationLoader.lanKeys!.addTip!.tr}${TranslationLoader.lanKeys!.face!.tr}",
haveBack: true, haveBack: true,
backgroundColor: AppColors.mainColor), backgroundColor: AppColors.mainColor),
body: Column( body: Column(
@ -147,20 +151,26 @@ class _AddFaceTypePageState extends State<AddFaceTypePage> with SingleTickerProv
isHaveLine: true, isHaveLine: true,
isHaveDirection: true, isHaveDirection: true,
action: () async { action: () async {
Pickers.showDatePicker(context, mode: DateMode.YMDHM, PDuration selectDate = PDuration.parse(
onConfirm: (p) { DateTime.parse(state.timeLimitBeginTime.value));
state.timeLimitBeginTime.value = DateTool().getYMDHNDateString(p, 1); Pickers.showDatePicker(context,
}); selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) {
state.timeLimitBeginTime.value =
DateTool().getYMDHNDateString(p, 1);
});
})), })),
Obx(() => CommonItem( Obx(() => CommonItem(
leftTitel: TranslationLoader.lanKeys!.failureTime!.tr, leftTitel: TranslationLoader.lanKeys!.failureTime!.tr,
rightTitle: state.timeLimitEndTime.value, rightTitle: state.timeLimitEndTime.value,
isHaveDirection: true, isHaveDirection: true,
action: () { action: () {
Pickers.showDatePicker(context, mode: DateMode.YMDHM, PDuration selectDate =
onConfirm: (p) { PDuration.parse(DateTime.tryParse(state.timeLimitEndTime.value));
state.timeLimitEndTime.value = DateTool().getYMDHNDateString(p, 1); Pickers.showDatePicker(context,
}); selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) {
state.timeLimitEndTime.value =
DateTool().getYMDHNDateString(p, 1);
});
})), })),
Container(height: 10.h), Container(height: 10.h),
], ],
@ -173,11 +183,13 @@ class _AddFaceTypePageState extends State<AddFaceTypePage> with SingleTickerProv
children: [ children: [
Obx(() => CommonItem( Obx(() => CommonItem(
leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr, leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr,
rightTitle:"${state.cycleBeginTime.value}\n${state.cycleEndTime.value}", rightTitle:
"${state.cycleBeginTime.value}\n${state.cycleEndTime.value}",
isHaveDirection: true, isHaveDirection: true,
isHaveLine: true, isHaveLine: true,
action: () async { action: () async {
var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: { var result =
await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: {
'validityValue': state.weekdaysList.value, 'validityValue': state.weekdaysList.value,
'starDate': state.cycleBeginTime.value, 'starDate': state.cycleBeginTime.value,
'endDate': state.cycleEndTime.value, 'endDate': state.cycleEndTime.value,
@ -200,13 +212,14 @@ class _AddFaceTypePageState extends State<AddFaceTypePage> with SingleTickerProv
isHaveDirection: true, isHaveDirection: true,
isHaveLine: true, isHaveLine: true,
action: () async { action: () async {
var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: { var result = await Get.toNamed(Routers.seletKeyCyclicDatePage,
'validityValue': state.weekdaysList.value, arguments: {
'starDate': state.cycleBeginTime.value, 'validityValue': state.weekdaysList.value,
'endDate': state.cycleEndTime.value, 'starDate': state.cycleBeginTime.value,
'starTime': state.effectiveDateTime.value, 'endDate': state.cycleEndTime.value,
'endTime': state.failureDateTime.value 'starTime': state.effectiveDateTime.value,
}); 'endTime': state.failureDateTime.value
});
if (result != null && result.isNotEmpty) { if (result != null && result.isNotEmpty) {
state.weekdaysList.value = result['validityValue']; state.weekdaysList.value = result['validityValue'];
state.cycleBeginTime.value = result['starDate']; state.cycleBeginTime.value = result['starDate'];
@ -219,16 +232,18 @@ class _AddFaceTypePageState extends State<AddFaceTypePage> with SingleTickerProv
visible: state.effectiveDateTime.value.isNotEmpty, visible: state.effectiveDateTime.value.isNotEmpty,
child: CommonItem( child: CommonItem(
leftTitel: "有效时间".tr, leftTitel: "有效时间".tr,
rightTitle: "${state.effectiveDateTime.value}-${state.failureDateTime.value}", rightTitle:
"${state.effectiveDateTime.value}-${state.failureDateTime.value}",
isHaveDirection: true, isHaveDirection: true,
action: () async { action: () async {
var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: { var result = await Get.toNamed(Routers.seletKeyCyclicDatePage,
'validityValue': state.weekdaysList.value, arguments: {
'starDate': state.cycleBeginTime.value, 'validityValue': state.weekdaysList.value,
'endDate': state.cycleEndTime.value, 'starDate': state.cycleBeginTime.value,
'starTime': state.effectiveDateTime.value, 'endDate': state.cycleEndTime.value,
'endTime': state.failureDateTime.value 'starTime': state.effectiveDateTime.value,
}); 'endTime': state.failureDateTime.value
});
if (result != null && result.isNotEmpty) { if (result != null && result.isNotEmpty) {
state.weekdaysList.value = result['validityValue']; state.weekdaysList.value = result['validityValue'];
state.cycleBeginTime.value = result['starDate']; state.cycleBeginTime.value = result['starDate'];
@ -337,13 +352,14 @@ class _AddFaceTypePageState extends State<AddFaceTypePage> with SingleTickerProv
); );
} }
final List<ItemView> _itemTabs = <ItemView>[ final List<ItemView> _itemTabs = <ItemView>[
ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, selectType: "0"), ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, selectType: "0"),
ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, selectType: "1"), 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<ItemView> _fromCheckInTypeItemTabs = <ItemView>[ final List<ItemView> _fromCheckInTypeItemTabs = <ItemView>[
ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, selectType: "0"), ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, selectType: "0"),
ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, selectType: "1"), ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, selectType: "1"),
]; ];
@ -354,7 +370,11 @@ class _AddFaceTypePageState extends State<AddFaceTypePage> with SingleTickerProv
onTap: (index) { onTap: (index) {
FocusScope.of(context).requestFocus(FocusNode()); 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, isScrollable: true,
indicatorColor: Colors.red, indicatorColor: Colors.red,
unselectedLabelColor: Colors.black, unselectedLabelColor: Colors.black,
@ -386,14 +406,16 @@ class _AddFaceTypePageState extends State<AddFaceTypePage> with SingleTickerProv
return Expanded( return Expanded(
child: TabBarView( child: TabBarView(
controller: state.tabController, controller: state.tabController,
children: children: state.fromType.value == 1
state.fromType.value == 1 ? _itemTabs
? _itemTabs.map((ItemView item) => Obx(() => indexChangeWidget())).toList() .map((ItemView item) => Obx(() => indexChangeWidget()))
: _fromCheckInTypeItemTabs.map((ItemView item) => Obx(() => indexChangeWidget())).toList(), .toList()
: _fromCheckInTypeItemTabs
.map((ItemView item) => Obx(() => indexChangeWidget()))
.toList(),
), ),
); );
} }
} }
class ItemView { class ItemView {

View File

@ -5,6 +5,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:star_lock/tools/pickers/pickers.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/date_mode.dart';
import 'package:star_lock/tools/pickers/time_picker/model/pduration.dart';
import '../../../../appRouters.dart'; import '../../../../appRouters.dart';
import '../../../../app_settings/app_colors.dart'; import '../../../../app_settings/app_colors.dart';
@ -148,7 +149,9 @@ class _AddFingerprintTypePageState extends State<AddFingerprintTypePage> with Si
isHaveLine: true, isHaveLine: true,
isHaveDirection: true, isHaveDirection: true,
action: () async { 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) { onConfirm: (p) {
state.timeLimitBeginTime.value = DateTool().getYMDHNDateString(p, 1); state.timeLimitBeginTime.value = DateTool().getYMDHNDateString(p, 1);
}); });
@ -158,7 +161,9 @@ class _AddFingerprintTypePageState extends State<AddFingerprintTypePage> with Si
rightTitle: state.timeLimitEndTime.value, rightTitle: state.timeLimitEndTime.value,
isHaveDirection: true, isHaveDirection: true,
action: () { 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) { onConfirm: (p) {
state.timeLimitEndTime.value = DateTool().getYMDHNDateString(p, 1); state.timeLimitEndTime.value = DateTool().getYMDHNDateString(p, 1);
}); });

View File

@ -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/dateTool.dart';
import 'package:star_lock/tools/pickers/pickers.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/date_mode.dart';
import 'package:star_lock/tools/pickers/time_picker/model/pduration.dart';
import '../../../../appRouters.dart'; import '../../../../appRouters.dart';
import '../../../../app_settings/app_colors.dart'; import '../../../../app_settings/app_colors.dart';
@ -142,8 +143,10 @@ class _AddIrisTypePageState extends State<AddIrisTypePage> {
isHaveLine: true, isHaveLine: true,
isHaveDirection: true, isHaveDirection: true,
action: () async { action: () async {
Pickers.showDatePicker(context, mode: DateMode.YMDHM, PDuration selectDate =
onConfirm: (p) { PDuration.parse(DateTime.tryParse(state.beginTime.value));
Pickers.showDatePicker(context,
selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) {
state.beginTime.value = DateTool().getYMDHNDateString(p, 1); state.beginTime.value = DateTool().getYMDHNDateString(p, 1);
}); });
})), })),
@ -152,8 +155,10 @@ class _AddIrisTypePageState extends State<AddIrisTypePage> {
rightTitle: state.endTime.value, rightTitle: state.endTime.value,
isHaveDirection: true, isHaveDirection: true,
action: () { action: () {
Pickers.showDatePicker(context, mode: DateMode.YMDHM, PDuration selectDate =
onConfirm: (p) { PDuration.parse(DateTime.tryParse(state.endTime.value));
Pickers.showDatePicker(context,
selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) {
state.endTime.value = DateTool().getYMDHNDateString(p, 1); state.endTime.value = DateTool().getYMDHNDateString(p, 1);
}); });
})), })),

View File

@ -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/dateTool.dart';
import 'package:star_lock/tools/pickers/pickers.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/date_mode.dart';
import 'package:star_lock/tools/pickers/time_picker/model/pduration.dart';
import 'package:star_lock/translations/trans_lib.dart'; import 'package:star_lock/translations/trans_lib.dart';
import '../../../../../app_settings/app_colors.dart'; import '../../../../../app_settings/app_colors.dart';
@ -228,7 +229,10 @@ class _VideoSlotPageState extends State<VideoSlotPage> {
], ],
), ),
onTap: () { 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) { if (isEndTime == false) {
state.startDate.value = DateTool().getYMDHNDateString(p, 3); state.startDate.value = DateTool().getYMDHNDateString(p, 3);
} else { } else {

View File

@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.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:get/get.dart';
import 'package:star_lock/tools/pickers/pickers.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/date_mode.dart';
import 'package:star_lock/tools/pickers/time_picker/model/pduration.dart';
import '../../../../app_settings/app_colors.dart'; import '../../../../app_settings/app_colors.dart';
import '../../../../blue/blue_manage.dart'; import '../../../../blue/blue_manage.dart';
@ -23,7 +23,8 @@ class NormallyOpenModePage extends StatefulWidget {
State<NormallyOpenModePage> createState() => _NormallyOpenModePageState(); State<NormallyOpenModePage> createState() => _NormallyOpenModePageState();
} }
class _NormallyOpenModePageState extends State<NormallyOpenModePage> with RouteAware{ class _NormallyOpenModePageState extends State<NormallyOpenModePage>
with RouteAware {
final logic = Get.put(NormallyOpenModeLogic()); final logic = Get.put(NormallyOpenModeLogic());
final state = Get.find<NormallyOpenModeLogic>().state; final state = Get.find<NormallyOpenModeLogic>().state;
@ -112,13 +113,16 @@ class _NormallyOpenModePageState extends State<NormallyOpenModePage> with RouteA
), ),
)), )),
Obx(() => Container( Obx(() => Container(
margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 30.h), margin:
child: state.isJustForShow.value == true ? Container() :SubmitBtn( EdgeInsets.only(left: 20.w, right: 20.w, top: 30.h),
btnName: TranslationLoader.lanKeys!.save!.tr, child: state.isJustForShow.value == true
onClick: () { ? Container()
logic.sendAutoLock(); : SubmitBtn(
}), btnName: TranslationLoader.lanKeys!.save!.tr,
)), onClick: () {
logic.sendAutoLock();
}),
)),
], ],
))); )));
} }
@ -186,7 +190,7 @@ class _NormallyOpenModePageState extends State<NormallyOpenModePage> with RouteA
} }
return GestureDetector( return GestureDetector(
onTap: () { onTap: () {
if(state.isJustForShow.value == true){ if (state.isJustForShow.value == true) {
return; return;
} }
@ -238,7 +242,7 @@ class _NormallyOpenModePageState extends State<NormallyOpenModePage> with RouteA
rightWidget: GestureDetector( rightWidget: GestureDetector(
onTap: () { onTap: () {
// //
if(state.isJustForShow.value == true){ if (state.isJustForShow.value == true) {
return; return;
} }
@ -281,12 +285,14 @@ class _NormallyOpenModePageState extends State<NormallyOpenModePage> with RouteA
isHaveDirection: true, isHaveDirection: true,
isHaveLine: true, isHaveLine: true,
action: () { action: () {
if(state.isJustForShow.value == true){ if (state.isJustForShow.value == true) {
return; return;
} }
PDuration selectDate = PDuration.parse(
Pickers.showDatePicker(context, mode: DateMode.HM, DateTime.tryParse(state.beginTime.value));
onConfirm: (p) { Pickers.showDatePicker(context,
selectDate: selectDate,
mode: DateMode.HM, onConfirm: (p) {
setState(() { setState(() {
state.beginTimeMinute.value = state.beginTimeMinute.value =
p.hour! * 60 + p.minute!; p.hour! * 60 + p.minute!;
@ -300,12 +306,14 @@ class _NormallyOpenModePageState extends State<NormallyOpenModePage> with RouteA
rightTitle: state.endTime.value, rightTitle: state.endTime.value,
isHaveDirection: true, isHaveDirection: true,
action: () { action: () {
if(state.isJustForShow.value == true){ if (state.isJustForShow.value == true) {
return; return;
} }
PDuration selectDate = PDuration.parse(
Pickers.showDatePicker(context, mode: DateMode.HM, DateTime.tryParse(state.endTime.value));
onConfirm: (p) { Pickers.showDatePicker(context,
selectDate: selectDate,
mode: DateMode.HM, onConfirm: (p) {
setState(() { setState(() {
state.endTimeMinute.value = state.endTimeMinute.value =
p.hour! * 60 + p.minute!; p.hour! * 60 + p.minute!;
@ -327,11 +335,13 @@ class _NormallyOpenModePageState extends State<NormallyOpenModePage> with RouteA
trackColor: CupertinoColors.systemGrey5, trackColor: CupertinoColors.systemGrey5,
thumbColor: CupertinoColors.white, thumbColor: CupertinoColors.white,
value: state.isOpenNormallyOpenMode.value, value: state.isOpenNormallyOpenMode.value,
onChanged: state.isJustForShow.value == true ? null : (value) { onChanged: state.isJustForShow.value == true
setState(() { ? null
state.isOpenNormallyOpenMode.value = value; : (value) {
}); setState(() {
}, state.isOpenNormallyOpenMode.value = value;
});
},
); );
} }
@ -385,5 +395,4 @@ class _NormallyOpenModePageState extends State<NormallyOpenModePage> with RouteA
state.ifCurrentScreen.value = false; state.ifCurrentScreen.value = false;
state.sureBtnState.value = 0; state.sureBtnState.value = 0;
} }
} }

View File

@ -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/dateTool.dart';
import 'package:star_lock/tools/pickers/pickers.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/date_mode.dart';
import 'package:star_lock/tools/pickers/time_picker/model/pduration.dart';
import '../../../../appRouters.dart'; import '../../../../appRouters.dart';
import '../../../../app_settings/app_colors.dart'; import '../../../../app_settings/app_colors.dart';
@ -142,8 +143,10 @@ class _AddPalmTypePageState extends State<AddPalmTypePage> {
isHaveLine: true, isHaveLine: true,
isHaveDirection: true, isHaveDirection: true,
action: () async { action: () async {
Pickers.showDatePicker(context, mode: DateMode.YMDHM, PDuration selectDate =
onConfirm: (p) { PDuration.parse(DateTime.tryParse(state.beginTime.value));
Pickers.showDatePicker(context,
selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) {
state.beginTime.value = DateTool().getYMDHNDateString(p, 1); state.beginTime.value = DateTool().getYMDHNDateString(p, 1);
}); });
})), })),
@ -152,8 +155,10 @@ class _AddPalmTypePageState extends State<AddPalmTypePage> {
rightTitle: state.endTime.value, rightTitle: state.endTime.value,
isHaveDirection: true, isHaveDirection: true,
action: () { action: () {
Pickers.showDatePicker(context, mode: DateMode.YMDHM, PDuration selectDate =
onConfirm: (p) { PDuration.parse(DateTime.tryParse(state.endTime.value));
Pickers.showDatePicker(context,
selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) {
state.endTime.value = DateTool().getYMDHNDateString(p, 1); state.endTime.value = DateTool().getYMDHNDateString(p, 1);
}); });
})), })),

View File

@ -5,6 +5,7 @@ import 'package:get/get.dart';
import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyDetailChangeDate/passwordKeyDetailChangeDate_logic.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/pickers.dart';
import 'package:star_lock/tools/pickers/time_picker/model/date_mode.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 '../../../../../app_settings/app_colors.dart';
import '../../../../../tools/commonItem.dart'; import '../../../../../tools/commonItem.dart';
@ -21,7 +22,8 @@ class PasswordKeyDetailChangeDatePage extends StatefulWidget {
_PasswordKeyDetailChangeDatePage(); _PasswordKeyDetailChangeDatePage();
} }
class _PasswordKeyDetailChangeDatePage extends State<PasswordKeyDetailChangeDatePage> with RouteAware { class _PasswordKeyDetailChangeDatePage
extends State<PasswordKeyDetailChangeDatePage> with RouteAware {
final logic = Get.put(PasswordKeyDetailChangeDateLogic()); final logic = Get.put(PasswordKeyDetailChangeDateLogic());
final state = Get.find<PasswordKeyDetailChangeDateLogic>().state; final state = Get.find<PasswordKeyDetailChangeDateLogic>().state;
@ -42,7 +44,7 @@ class _PasswordKeyDetailChangeDatePage extends State<PasswordKeyDetailChangeDate
), ),
onPressed: () { onPressed: () {
// if (state.lockId.value != 0 && state.pwdId.value.isNotEmpty) { // if (state.lockId.value != 0 && state.pwdId.value.isNotEmpty) {
logic.senderCustomPasswords(); logic.senderCustomPasswords();
// } // }
}, },
), ),
@ -59,27 +61,45 @@ class _PasswordKeyDetailChangeDatePage extends State<PasswordKeyDetailChangeDate
DateTime startDateStr = DateTime startDateStr =
DateTime.fromMillisecondsSinceEpoch(state.itemData.value.startDate!); DateTime.fromMillisecondsSinceEpoch(state.itemData.value.startDate!);
getStartDate = startDateStr.toLocal().toString().substring(0, 16); getStartDate = startDateStr.toLocal().toString().substring(0, 16);
}else{ } else {
// DateTime startDateStr = // DateTime startDateStr =
// DateTime.fromMillisecondsSinceEpoch(DateTime.now().millisecondsSinceEpoch); // DateTime.fromMillisecondsSinceEpoch(DateTime.now().millisecondsSinceEpoch);
// getStartDate = startDateStr.toLocal().toString().substring(0, 16); // getStartDate = startDateStr.toLocal().toString().substring(0, 16);
getStartDate = "${formatDate(DateTime.now(), [yyyy,'-',mm,'-', dd, ' ', HH,])}:00"; // getStartDate = "${formatDate(DateTime.now(), [
yyyy,
'-',
mm,
'-',
dd,
' ',
HH,
])}:00"; //生效时间
// state.selectEffectiveDate.value = getStartDate; // state.selectEffectiveDate.value = getStartDate;
state.itemData.value.startDate = DateTime.parse(getStartDate).millisecondsSinceEpoch; state.itemData.value.startDate =
DateTime.parse(getStartDate).millisecondsSinceEpoch;
} }
if (state.itemData.value.endDate != 0) { if (state.itemData.value.endDate != 0) {
DateTime endDateStr = DateTime endDateStr =
DateTime.fromMillisecondsSinceEpoch(state.itemData.value.endDate!); DateTime.fromMillisecondsSinceEpoch(state.itemData.value.endDate!);
getEndDate = endDateStr.toLocal().toString().substring(0, 16); getEndDate = endDateStr.toLocal().toString().substring(0, 16);
}else{ } else {
// DateTime endDateStr = // DateTime endDateStr =
// DateTime.fromMillisecondsSinceEpoch(DateTime.now().millisecondsSinceEpoch); // DateTime.fromMillisecondsSinceEpoch(DateTime.now().millisecondsSinceEpoch);
// getEndDate = endDateStr.toLocal().toString().substring(0, 16); // getEndDate = endDateStr.toLocal().toString().substring(0, 16);
getEndDate = "${formatDate(DateTime.now(), [yyyy, '-', mm, '-', dd, ' ', HH,])}:00"; // getEndDate = "${formatDate(DateTime.now(), [
state.itemData.value.endDate = DateTime.parse(getEndDate).millisecondsSinceEpoch; yyyy,
'-',
mm,
'-',
dd,
' ',
HH,
])}:00"; //失效时间
state.itemData.value.endDate =
DateTime.parse(getEndDate).millisecondsSinceEpoch;
} }
return Column( return Column(
@ -92,10 +112,15 @@ class _PasswordKeyDetailChangeDatePage extends State<PasswordKeyDetailChangeDate
isHaveLine: true, isHaveLine: true,
isHaveDirection: true, isHaveDirection: true,
action: () { action: () {
Pickers.showDatePicker(context, mode: DateMode.YMDH, onConfirm: (p) { PDuration selectDate = PDuration.parse(
state.selectEffectiveDate.value = DateTool().getYMDHNDateString(p, 1); DateTime.parse(state.selectEffectiveDate.value));
Pickers.showDatePicker(context,
selectDate: selectDate, mode: DateMode.YMDH, onConfirm: (p) {
state.selectEffectiveDate.value =
DateTool().getYMDHNDateString(p, 1);
// state.effectiveDateTime = DateTime.parse(state.selectEffectiveDate.value); // state.effectiveDateTime = DateTime.parse(state.selectEffectiveDate.value);
state.itemData.value.startDate = DateTool().dateToTimestamp(state.selectEffectiveDate.value, 1); // state.itemData.value.startDate = DateTool().dateToTimestamp(
state.selectEffectiveDate.value, 1); //
}); });
})), })),
Obx(() => CommonItem( Obx(() => CommonItem(
@ -105,9 +130,14 @@ class _PasswordKeyDetailChangeDatePage extends State<PasswordKeyDetailChangeDate
: getEndDate, : getEndDate,
isHaveDirection: true, isHaveDirection: true,
action: () { action: () {
Pickers.showDatePicker(context, mode: DateMode.YMDH, onConfirm: (p) { PDuration selectDate = PDuration.parse(
state.selectFailureDate.value = DateTool().getYMDHNDateString(p, 1); DateTime.parse(state.selectFailureDate.value));
state.itemData.value.endDate = DateTool().dateToTimestamp(state.selectFailureDate.value, 1); // Pickers.showDatePicker(context,
selectDate: selectDate, mode: DateMode.YMDH, onConfirm: (p) {
state.selectFailureDate.value =
DateTool().getYMDHNDateString(p, 1);
state.itemData.value.endDate = DateTool()
.dateToTimestamp(state.selectFailureDate.value, 1); //
}); });
})), })),
], ],

View File

@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
@ -28,15 +27,15 @@ import '../../../../translations/trans_lib.dart';
import '../../../lockMian/entity/lockListInfo_entity.dart'; import '../../../lockMian/entity/lockListInfo_entity.dart';
class PasswordKeyPerpetualPage extends StatefulWidget { class PasswordKeyPerpetualPage extends StatefulWidget {
const PasswordKeyPerpetualPage( const PasswordKeyPerpetualPage({Key? key}) : super(key: key);
{Key? key}) : super(key: key);
@override @override
State<PasswordKeyPerpetualPage> createState() => State<PasswordKeyPerpetualPage> createState() =>
_PasswordKeyPerpetualPageState(); _PasswordKeyPerpetualPageState();
} }
class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> with RouteAware, SingleTickerProviderStateMixin{ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage>
with RouteAware, SingleTickerProviderStateMixin {
final logic = Get.put(PasswordKeyPerpetualLogic()); final logic = Get.put(PasswordKeyPerpetualLogic());
final state = Get.find<PasswordKeyPerpetualLogic>().state; final state = Get.find<PasswordKeyPerpetualLogic>().state;
@ -45,10 +44,8 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> wit
// TODO: implement initState // TODO: implement initState
super.initState(); super.initState();
state.tabController = TabController( state.tabController =
vsync: this, TabController(vsync: this, length: _itemTabs.length, initialIndex: 0);
length: _itemTabs.length,
initialIndex: 0);
state.tabController.addListener(() { state.tabController.addListener(() {
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
state.widgetType.value = state.tabController.index; state.widgetType.value = state.tabController.index;
@ -78,7 +75,8 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> wit
} }
Widget indexChangeWidget() { 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(); return sendElectronicKeySucceed();
} else { } else {
switch (state.widgetType.value) { switch (state.widgetType.value) {
@ -89,11 +87,13 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> wit
child: Column( child: Column(
children: [ children: [
perpetualKeyWidget( perpetualKeyWidget(
false, false,
TranslationLoader.lanKeys!.name!.tr, TranslationLoader.lanKeys!.name!.tr,
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
state.nameController), state.nameController),
keyBottomWidget("密码生成后请在当日2359前使用一次进行激活否则过0点后未激活则失效。密码激活后有效期内不限次数使用。".tr) keyBottomWidget(
"密码生成后请在当日2359前使用一次进行激活否则过0点后未激活则失效。密码激活后有效期内不限次数使用。"
.tr)
], ],
), ),
); );
@ -110,7 +110,9 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> wit
TranslationLoader.lanKeys!.name!.tr, TranslationLoader.lanKeys!.name!.tr,
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
state.nameController), state.nameController),
keyBottomWidget("密码生成后请在当日2359前使用一次进行激活否则过0点后未激活则失效。密码激活后有效期内不限次数使用。".tr) keyBottomWidget(
"密码生成后请在当日2359前使用一次进行激活否则过0点后未激活则失效。密码激活后有效期内不限次数使用。"
.tr)
], ],
), ),
); );
@ -126,7 +128,8 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> wit
TranslationLoader.lanKeys!.name!.tr, TranslationLoader.lanKeys!.name!.tr,
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
state.nameController), state.nameController),
keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip3!.tr) keyBottomWidget(
TranslationLoader.lanKeys!.getPasswordTip3!.tr)
], ],
), ),
); );
@ -149,10 +152,11 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> wit
perpetualKeyWidget( perpetualKeyWidget(
false, false,
TranslationLoader.lanKeys!.password!.tr, TranslationLoader.lanKeys!.password!.tr,
"请输入6-9位数字", state.pwdController "请输入6-9位数字",
), state.pwdController),
keyIfAdministratorWidget(), keyIfAdministratorWidget(),
keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip4!.tr) keyBottomWidget(
TranslationLoader.lanKeys!.getPasswordTip4!.tr)
], ],
), ),
); );
@ -169,7 +173,9 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> wit
TranslationLoader.lanKeys!.name!.tr, TranslationLoader.lanKeys!.name!.tr,
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
state.nameController), state.nameController),
keyBottomWidget("密码生成后请在当日2359前使用一次进行激活否则过0点后未激活则失效。密码激活后有效期内不限次数使用。".tr) keyBottomWidget(
"密码生成后请在当日2359前使用一次进行激活否则过0点后未激活则失效。密码激活后有效期内不限次数使用。"
.tr)
], ],
), ),
); );
@ -181,11 +187,12 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> wit
child: Column( child: Column(
children: [ children: [
perpetualKeyWidget( perpetualKeyWidget(
false, false,
TranslationLoader.lanKeys!.name!.tr, TranslationLoader.lanKeys!.name!.tr,
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
state.nameController), state.nameController),
keyBottomWidget("密码生成后请在当日2359前使用否则过0点后失效。清空码用于清空今天0点之前生成的所有密码。".tr) keyBottomWidget(
"密码生成后请在当日2359前使用否则过0点后失效。清空码用于清空今天0点之前生成的所有密码。".tr)
], ],
), ),
); );
@ -197,8 +204,8 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> wit
} }
// //
Widget perpetualKeyWidget( Widget perpetualKeyWidget(bool isTopHeight, String titleStr,
bool isTopHeight, String titleStr, String rightTitle, TextEditingController controller) { String rightTitle, TextEditingController controller) {
return Column( return Column(
children: [ children: [
isTopHeight ? SizedBox(height: 10.h) : Container(), isTopHeight ? SizedBox(height: 10.h) : Container(),
@ -217,19 +224,25 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> wit
return Column( return Column(
children: [ children: [
Visibility( Visibility(
visible: CommonDataManage().currentKeyInfo.vendor == "XHJ" ? false : true, visible:
CommonDataManage().currentKeyInfo.vendor == "XHJ" ? false : true,
child: CommonItem( child: CommonItem(
leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr, leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr,
rightTitle: state.beginTime.value, rightTitle: state.beginTime.value,
isHaveLine: true, isHaveLine: true,
isHaveDirection: true, isHaveDirection: true,
action: () { action: () {
Pickers.showDatePicker( PDuration selectDate =
context, PDuration.parse(DateTime.tryParse(state.beginTime.value));
maxDate: PDuration(year: DateTime.now().year + 3, month: DateTime.now().month, day: DateTime.now().day, hour: 24), 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(), // minDate: PDuration.now(),
mode: DateMode.YMDHM, mode: DateMode.YMDHM, onConfirm: (p) {
onConfirm: (p) {
state.beginTime.value = DateTool().getYMDHNDateString(p, 4); state.beginTime.value = DateTool().getYMDHNDateString(p, 4);
}); });
}), }),
@ -239,14 +252,21 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> wit
rightTitle: state.endTime.value, rightTitle: state.endTime.value,
isHaveDirection: true, isHaveDirection: true,
action: () { action: () {
Pickers.showDatePicker( PDuration selectDate =
context, PDuration.parse(DateTime.tryParse(state.endTime.value));
Pickers.showDatePicker(context,
selectDate: selectDate,
// maxDate传入三年以后得今天的时间 // maxDate传入三年以后得今天的时间
maxDate: PDuration(year: DateTime.now().year + 3, month: DateTime.now().month, day: DateTime.now().day), maxDate: PDuration(
minDate: PDuration(year: DateTime.now().year, month: DateTime.now().month, day: DateTime.now().day), year: DateTime.now().year + 3,
mode: DateMode.YMDH, month: DateTime.now().month,
onConfirm: (p) { day: DateTime.now().day),
state.endTime.value = DateTool().getYMDHNDateString(p, 4); 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), Container(height: 10.h),
@ -264,28 +284,32 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> wit
isHaveLine: true, isHaveLine: true,
isHaveDirection: true, isHaveDirection: true,
action: () { action: () {
Pickers.showDatePicker( PDuration selectDate = PDuration.parse(
context, 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), // maxDate: PDuration(year: DateTime.now().year + 3, month: DateTime.now().month, day: DateTime.now().day, hour: 24),
// minDate: PDuration.now(), // minDate: PDuration.now(),
mode: DateMode.YMDHM, mode: DateMode.YMDHM, onConfirm: (p) {
onConfirm: (p) { state.customBeginTime.value =
state.customBeginTime.value = DateTool().getYMDHNDateString(p, 1); DateTool().getYMDHNDateString(p, 1);
}); });
}), }),
CommonItem( CommonItem(
leftTitel: TranslationLoader.lanKeys!.failureTime!.tr, leftTitel: TranslationLoader.lanKeys!.failureTime!.tr,
rightTitle: state.customEndTime.value, rightTitle: state.customEndTime.value,
isHaveDirection: true, isHaveDirection: true,
action: () { action: () {
PDuration selectDate =
PDuration.parse(DateTime.tryParse(state.customEndTime.value));
Pickers.showDatePicker(context, Pickers.showDatePicker(context,
selectDate: selectDate,
// maxDate传入三年以后得今天的时间 // maxDate传入三年以后得今天的时间
// maxDate: PDuration(year: DateTime.now().year + 3, month: DateTime.now().month, day: DateTime.now().day), // 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), // minDate: PDuration(year: DateTime.now().year, month: DateTime.now().month, day: DateTime.now().day),
mode: DateMode.YMDHM, mode: DateMode.YMDHM, onConfirm: (p) {
onConfirm: (p) { state.customEndTime.value = DateTool().getYMDHNDateString(p, 1);
state.customEndTime.value = DateTool().getYMDHNDateString(p, 1); });
});
}), }),
Container(height: 10.h), Container(height: 10.h),
], ],
@ -350,15 +374,26 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> wit
showPickerView(context, pickerDataList); showPickerView(context, pickerDataList);
}), }),
Visibility( 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( child: CommonItem(
leftTitel: '结束日期', leftTitel: '结束日期',
rightTitle: state.endTime.value, rightTitle: state.endTime.value,
isHaveLine: true, isHaveLine: true,
isHaveDirection: true, isHaveDirection: true,
action: () { action: () {
Pickers.showDatePicker(context, mode: DateMode.YMDH, onConfirm: (p) { PDuration selectDate =
state.endTime.value = DateTool().getYMDHNDateString(p, 4); 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<PasswordKeyPerpetualPage> wit
isHaveLine: true, isHaveLine: true,
isHaveDirection: true, isHaveDirection: true,
action: () { action: () {
Pickers.showDatePicker(context, mode: DateMode.H, onConfirm: (p) { PDuration selectDate = PDuration.parse(
state.loopEffectiveDate.value = DateTool().getYMDHNDateString(p, 5); 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!; state.loopStartHours.value = p.hour!;
}); });
}), }),
@ -378,8 +417,12 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> wit
rightTitle: state.loopFailureDate.value, rightTitle: state.loopFailureDate.value,
isHaveDirection: true, isHaveDirection: true,
action: () { action: () {
Pickers.showDatePicker(context, mode: DateMode.H, onConfirm: (p) { PDuration selectDate = PDuration.parse(
state.loopFailureDate.value = DateTool().getYMDHNDateString(p, 5); 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!; state.loopEndHours.value = p.hour!;
}); });
}), }),
@ -423,7 +466,9 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> wit
height: 20.h, height: 20.h,
), ),
SubmitBtn( SubmitBtn(
btnName: state.widgetType.value == 3 ? "设置密码":TranslationLoader.lanKeys!.getPassword!.tr, btnName: state.widgetType.value == 3
? "设置密码"
: TranslationLoader.lanKeys!.getPassword!.tr,
onClick: () async { onClick: () async {
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
if (isDemoMode == false) { if (isDemoMode == false) {
@ -523,10 +568,14 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> wit
maxLines: 1, maxLines: 1,
inputFormatters: <TextInputFormatter>[ inputFormatters: <TextInputFormatter>[
FilteringTextInputFormatter.deny('\n'), FilteringTextInputFormatter.deny('\n'),
LengthLimitingTextInputFormatter(editController == state.nameController ? 50 : 9), LengthLimitingTextInputFormatter(
editController == state.nameController ? 50 : 9),
], ],
keyboardType: editController == state.nameController ? TextInputType.text: TextInputType.number, keyboardType: editController == state.nameController
style: TextStyle(fontSize: 22.sp, color: AppColors.darkGrayTextColor), ? TextInputType.text
: TextInputType.number,
style: TextStyle(
fontSize: 22.sp, color: AppColors.darkGrayTextColor),
controller: editController, controller: editController,
autofocus: false, autofocus: false,
textAlign: TextAlign.end, textAlign: TextAlign.end,
@ -543,10 +592,18 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> wit
// contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0), // contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0),
hintText: tfStr, hintText: tfStr,
hintStyle: TextStyle(fontSize: 22.sp), hintStyle: TextStyle(fontSize: 22.sp),
focusedBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), focusedBorder: const OutlineInputBorder(
disabledBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), borderSide:
enabledBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), BorderSide(width: 0, color: Colors.transparent)),
border: 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), contentPadding: const EdgeInsets.symmetric(vertical: 0),
), ),
), ),
@ -629,7 +686,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> wit
TabBar _tabBar() { TabBar _tabBar() {
return TabBar( return TabBar(
controller: state.tabController, controller: state.tabController,
onTap: (index){ onTap: (index) {
FocusScope.of(context).requestFocus(FocusNode()); FocusScope.of(context).requestFocus(FocusNode());
}, },
tabs: _itemTabs.map((ItemView item) => _tab(item)).toList(), tabs: _itemTabs.map((ItemView item) => _tab(item)).toList(),
@ -672,7 +729,9 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> wit
return Expanded( return Expanded(
child: TabBarView( child: TabBarView(
controller: state.tabController, 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<PasswordKeyPerpetualPage> wit
return widgetList; return widgetList;
} }
GestureDetector buildCenter3(String imageName, String titleStr, int itemIndex) { GestureDetector buildCenter3(
String imageName, String titleStr, int itemIndex) {
return GestureDetector( return GestureDetector(
child: Container( child: Container(
width: 120.w, width: 120.w,
@ -735,13 +795,13 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> wit
case 0: case 0:
// //
{ {
NativeInteractionTool().loadNativeShare(shareText:pwdShareStr); NativeInteractionTool().loadNativeShare(shareText: pwdShareStr);
} }
break; break;
case 1: case 1:
// //
{ {
NativeInteractionTool().loadNativeShare(shareText:pwdShareStr); NativeInteractionTool().loadNativeShare(shareText: pwdShareStr);
} }
break; break;
case 2: case 2:
@ -753,7 +813,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> wit
case 3: case 3:
// //
{ {
NativeInteractionTool().loadNativeShare(shareText:pwdShareStr); NativeInteractionTool().loadNativeShare(shareText: pwdShareStr);
} }
break; break;
default: default:

View File

@ -5,6 +5,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:star_lock/tools/pickers/pickers.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/date_mode.dart';
import 'package:star_lock/tools/pickers/time_picker/model/pduration.dart';
import '../../../../appRouters.dart'; import '../../../../appRouters.dart';
import '../../../../app_settings/app_colors.dart'; import '../../../../app_settings/app_colors.dart';
@ -18,14 +19,14 @@ import '../../../../translations/trans_lib.dart';
import 'addRemoteControl_logic.dart'; import 'addRemoteControl_logic.dart';
class AddRemoteControlPage extends StatefulWidget { class AddRemoteControlPage extends StatefulWidget {
const AddRemoteControlPage({Key? key}) const AddRemoteControlPage({Key? key}) : super(key: key);
: super(key: key);
@override @override
State<AddRemoteControlPage> createState() => _AddRemoteControlPageState(); State<AddRemoteControlPage> createState() => _AddRemoteControlPageState();
} }
class _AddRemoteControlPageState extends State<AddRemoteControlPage> with SingleTickerProviderStateMixin { class _AddRemoteControlPageState extends State<AddRemoteControlPage>
with SingleTickerProviderStateMixin {
final logic = Get.put(AddRemoteControlLoigc()); final logic = Get.put(AddRemoteControlLoigc());
final state = Get.find<AddRemoteControlLoigc>().state; final state = Get.find<AddRemoteControlLoigc>().state;
@ -36,7 +37,9 @@ class _AddRemoteControlPageState extends State<AddRemoteControlPage> with Single
state.tabController = TabController( state.tabController = TabController(
vsync: this, vsync: this,
length: state.fromType.value == 1 ? _itemTabs.length : _fromCheckInTypeItemTabs.length, length: state.fromType.value == 1
? _itemTabs.length
: _fromCheckInTypeItemTabs.length,
initialIndex: 0); initialIndex: 0);
state.tabController.addListener(() { state.tabController.addListener(() {
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
@ -55,7 +58,7 @@ class _AddRemoteControlPageState extends State<AddRemoteControlPage> with Single
backgroundColor: AppColors.mainBackgroundColor, backgroundColor: AppColors.mainBackgroundColor,
appBar: TitleAppBar( appBar: TitleAppBar(
barTitle: barTitle:
"${TranslationLoader.lanKeys!.addTip!.tr}${TranslationLoader.lanKeys!.fingerprint!.tr}", "${TranslationLoader.lanKeys!.addTip!.tr}${TranslationLoader.lanKeys!.fingerprint!.tr}",
haveBack: true, haveBack: true,
backgroundColor: AppColors.mainColor), backgroundColor: AppColors.mainColor),
body: Column( body: Column(
@ -145,20 +148,26 @@ class _AddRemoteControlPageState extends State<AddRemoteControlPage> with Single
isHaveLine: true, isHaveLine: true,
isHaveDirection: true, isHaveDirection: true,
action: () async { action: () async {
Pickers.showDatePicker(context, mode: DateMode.YMDHM, PDuration selectDate = PDuration.parse(
onConfirm: (p) { DateTime.parse(state.timeLimitBeginTime.value));
state.timeLimitBeginTime.value = DateTool().getYMDHNDateString(p, 1); Pickers.showDatePicker(context,
}); selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) {
state.timeLimitBeginTime.value =
DateTool().getYMDHNDateString(p, 1);
});
})), })),
Obx(() => CommonItem( Obx(() => CommonItem(
leftTitel: TranslationLoader.lanKeys!.failureTime!.tr, leftTitel: TranslationLoader.lanKeys!.failureTime!.tr,
rightTitle: state.timeLimitEndTime.value, rightTitle: state.timeLimitEndTime.value,
isHaveDirection: true, isHaveDirection: true,
action: () { action: () {
Pickers.showDatePicker(context, mode: DateMode.YMDHM, PDuration selectDate =
onConfirm: (p) { PDuration.parse(DateTime.tryParse(state.timeLimitEndTime.value));
state.timeLimitEndTime.value = DateTool().getYMDHNDateString(p, 1); Pickers.showDatePicker(context,
}); selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) {
state.timeLimitEndTime.value =
DateTool().getYMDHNDateString(p, 1);
});
})), })),
Container(height: 10.h), Container(height: 10.h),
], ],
@ -171,11 +180,13 @@ class _AddRemoteControlPageState extends State<AddRemoteControlPage> with Single
children: [ children: [
Obx(() => CommonItem( Obx(() => CommonItem(
leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr, leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr,
rightTitle:"${state.cycleBeginTime.value}\n${state.cycleEndTime.value}", rightTitle:
"${state.cycleBeginTime.value}\n${state.cycleEndTime.value}",
isHaveDirection: true, isHaveDirection: true,
isHaveLine: true, isHaveLine: true,
action: () async { action: () async {
var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: { var result =
await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: {
'validityValue': state.weekdaysList.value, 'validityValue': state.weekdaysList.value,
'starDate': state.cycleBeginTime.value, 'starDate': state.cycleBeginTime.value,
'endDate': state.cycleEndTime.value, 'endDate': state.cycleEndTime.value,
@ -198,13 +209,14 @@ class _AddRemoteControlPageState extends State<AddRemoteControlPage> with Single
isHaveDirection: true, isHaveDirection: true,
isHaveLine: true, isHaveLine: true,
action: () async { action: () async {
var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: { var result = await Get.toNamed(Routers.seletKeyCyclicDatePage,
'validityValue': state.weekdaysList.value, arguments: {
'starDate': state.cycleBeginTime.value, 'validityValue': state.weekdaysList.value,
'endDate': state.cycleEndTime.value, 'starDate': state.cycleBeginTime.value,
'starTime': state.effectiveDateTime.value, 'endDate': state.cycleEndTime.value,
'endTime': state.failureDateTime.value 'starTime': state.effectiveDateTime.value,
}); 'endTime': state.failureDateTime.value
});
if (result != null && result.isNotEmpty) { if (result != null && result.isNotEmpty) {
state.weekdaysList.value = result['validityValue']; state.weekdaysList.value = result['validityValue'];
state.cycleBeginTime.value = result['starDate']; state.cycleBeginTime.value = result['starDate'];
@ -217,16 +229,18 @@ class _AddRemoteControlPageState extends State<AddRemoteControlPage> with Single
visible: state.effectiveDateTime.value.isNotEmpty, visible: state.effectiveDateTime.value.isNotEmpty,
child: CommonItem( child: CommonItem(
leftTitel: "有效时间".tr, leftTitel: "有效时间".tr,
rightTitle: "${state.effectiveDateTime.value}-${state.failureDateTime.value}", rightTitle:
"${state.effectiveDateTime.value}-${state.failureDateTime.value}",
isHaveDirection: true, isHaveDirection: true,
action: () async { action: () async {
var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: { var result = await Get.toNamed(Routers.seletKeyCyclicDatePage,
'validityValue': state.weekdaysList.value, arguments: {
'starDate': state.cycleBeginTime.value, 'validityValue': state.weekdaysList.value,
'endDate': state.cycleEndTime.value, 'starDate': state.cycleBeginTime.value,
'starTime': state.effectiveDateTime.value, 'endDate': state.cycleEndTime.value,
'endTime': state.failureDateTime.value 'starTime': state.effectiveDateTime.value,
}); 'endTime': state.failureDateTime.value
});
if (result != null && result.isNotEmpty) { if (result != null && result.isNotEmpty) {
state.weekdaysList.value = result['validityValue']; state.weekdaysList.value = result['validityValue'];
state.cycleBeginTime.value = result['starDate']; state.cycleBeginTime.value = result['starDate'];
@ -359,7 +373,8 @@ class _AddRemoteControlPageState extends State<AddRemoteControlPage> with Single
FilteringTextInputFormatter.deny('\n'), FilteringTextInputFormatter.deny('\n'),
LengthLimitingTextInputFormatter(18), LengthLimitingTextInputFormatter(18),
], ],
style: TextStyle(fontSize: 22.sp, color: AppColors.darkGrayTextColor), style: TextStyle(
fontSize: 22.sp, color: AppColors.darkGrayTextColor),
controller: state.nameController, controller: state.nameController,
autofocus: false, autofocus: false,
textAlign: TextAlign.end, textAlign: TextAlign.end,
@ -368,10 +383,18 @@ class _AddRemoteControlPageState extends State<AddRemoteControlPage> with Single
// contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0), // contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0),
hintText: tfStr, hintText: tfStr,
hintStyle: TextStyle(fontSize: 22.sp), hintStyle: TextStyle(fontSize: 22.sp),
focusedBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), focusedBorder: const OutlineInputBorder(
disabledBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), borderSide:
enabledBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), BorderSide(width: 0, color: Colors.transparent)),
border: 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), contentPadding: const EdgeInsets.symmetric(vertical: 0),
), ),
), ),
@ -399,13 +422,14 @@ class _AddRemoteControlPageState extends State<AddRemoteControlPage> with Single
); );
} }
final List<ItemView> _itemTabs = <ItemView>[ final List<ItemView> _itemTabs = <ItemView>[
ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, selectType: "0"), ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, selectType: "0"),
ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, selectType: "1"), 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<ItemView> _fromCheckInTypeItemTabs = <ItemView>[ final List<ItemView> _fromCheckInTypeItemTabs = <ItemView>[
ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, selectType: "0"), ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, selectType: "0"),
ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, selectType: "1"), ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, selectType: "1"),
]; ];
@ -416,7 +440,11 @@ class _AddRemoteControlPageState extends State<AddRemoteControlPage> with Single
onTap: (index) { onTap: (index) {
FocusScope.of(context).requestFocus(FocusNode()); 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, isScrollable: true,
indicatorColor: Colors.red, indicatorColor: Colors.red,
unselectedLabelColor: Colors.black, unselectedLabelColor: Colors.black,
@ -448,14 +476,16 @@ class _AddRemoteControlPageState extends State<AddRemoteControlPage> with Single
return Expanded( return Expanded(
child: TabBarView( child: TabBarView(
controller: state.tabController, controller: state.tabController,
children: children: state.fromType.value == 1
state.fromType.value == 1 ? _itemTabs
? _itemTabs.map((ItemView item) => Obx(() => indexChangeWidget())).toList() .map((ItemView item) => Obx(() => indexChangeWidget()))
: _fromCheckInTypeItemTabs.map((ItemView item) => Obx(() => indexChangeWidget())).toList(), .toList()
: _fromCheckInTypeItemTabs
.map((ItemView item) => Obx(() => indexChangeWidget()))
.toList(),
), ),
); );
} }
} }
class ItemView { class ItemView {

View File

@ -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/commonItem.dart';
import 'package:star_lock/tools/pickers/pickers.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/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/tools/submitBtn.dart';
import 'package:star_lock/translations/trans_lib.dart'; import 'package:star_lock/translations/trans_lib.dart';
@ -19,7 +20,8 @@ import 'addAuthorizedAdministrator_logic.dart';
class AddAuthorizedAdministratorPage extends StatefulWidget { class AddAuthorizedAdministratorPage extends StatefulWidget {
String type; String type;
AddAuthorizedAdministratorPage({Key? key, required this.type}) : super(key: key); AddAuthorizedAdministratorPage({Key? key, required this.type})
: super(key: key);
@override @override
State<StatefulWidget> createState() { State<StatefulWidget> createState() {
@ -27,20 +29,24 @@ class AddAuthorizedAdministratorPage extends StatefulWidget {
} }
} }
class _AddAuthorizedAdministratorPageState extends State<AddAuthorizedAdministratorPage> with SingleTickerProviderStateMixin { class _AddAuthorizedAdministratorPageState
extends State<AddAuthorizedAdministratorPage>
with SingleTickerProviderStateMixin {
final logic = Get.put(AddAuthorizedAdministratorLogic()); final logic = Get.put(AddAuthorizedAdministratorLogic());
final state = Get.find<AddAuthorizedAdministratorLogic>().state; final state = Get.find<AddAuthorizedAdministratorLogic>().state;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
state.type.value = widget.type; 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<AddAuthorizedAdministra
FilteringTextInputFormatter.deny('\n'), FilteringTextInputFormatter.deny('\n'),
LengthLimitingTextInputFormatter(18), LengthLimitingTextInputFormatter(18),
], ],
style: TextStyle(fontSize: 22.sp, color: AppColors.darkGrayTextColor), style: TextStyle(
fontSize: 22.sp, color: AppColors.darkGrayTextColor),
controller: editController, controller: editController,
// autofocus: false, // autofocus: false,
textAlign: TextAlign.end, textAlign: TextAlign.end,
@ -200,10 +207,18 @@ class _AddAuthorizedAdministratorPageState extends State<AddAuthorizedAdministra
// contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0), // contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0),
hintText: tfStr, hintText: tfStr,
hintStyle: TextStyle(fontSize: 22.sp), hintStyle: TextStyle(fontSize: 22.sp),
focusedBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), focusedBorder: const OutlineInputBorder(
disabledBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), borderSide:
enabledBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), BorderSide(width: 0, color: Colors.transparent)),
border: 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), contentPadding: const EdgeInsets.symmetric(vertical: 0),
), ),
), ),
@ -268,7 +283,10 @@ class _AddAuthorizedAdministratorPageState extends State<AddAuthorizedAdministra
isHaveLine: true, isHaveLine: true,
isHaveDirection: true, isHaveDirection: true,
action: () { 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(() { setState(() {
state.beginDate.value = DateTool().getYMDHNDateString(p, 1); state.beginDate.value = DateTool().getYMDHNDateString(p, 1);
}); });
@ -279,8 +297,10 @@ class _AddAuthorizedAdministratorPageState extends State<AddAuthorizedAdministra
rightTitle: state.endDate.value, rightTitle: state.endDate.value,
isHaveDirection: true, isHaveDirection: true,
action: () { action: () {
Pickers.showDatePicker(context, mode: DateMode.YMDHM, PDuration selectDate =
onConfirm: (p) { PDuration.parse(DateTime.tryParse(state.endDate.value));
Pickers.showDatePicker(context,
selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) {
setState(() { setState(() {
state.endDate.value = DateTool().getYMDHNDateString(p, 1); state.endDate.value = DateTool().getYMDHNDateString(p, 1);
}); });
@ -409,14 +429,14 @@ class _AddAuthorizedAdministratorPageState extends State<AddAuthorizedAdministra
), ),
OutLineBtn( OutLineBtn(
btnName: btnName:
state.emailOrPhoneController.text.contains("@") ? '邮件通知' : "短信通知", state.emailOrPhoneController.text.contains("@") ? '邮件通知' : "短信通知",
onClick: () { onClick: () {
if (state.emailOrPhoneController.text.contains("@")) { if (state.emailOrPhoneController.text.contains("@")) {
Get.toNamed(Routers.sendEmailNotificationPage); Get.toNamed(Routers.sendEmailNotificationPage);
} else { } else {
// _openModalBottomSheet(); // _openModalBottomSheet();
NativeInteractionTool().loadNativeShare( NativeInteractionTool()
shareText: state.pwdShareStr); .loadNativeShare(shareText: state.pwdShareStr);
} }
// Get.toNamed(state.emailOrPhoneController.text.contains("@")? Routers.sendEmailNotificationPage:Routers.sendEmailNotificationPage); // Get.toNamed(state.emailOrPhoneController.text.contains("@")? Routers.sendEmailNotificationPage:Routers.sendEmailNotificationPage);
}, },
@ -428,7 +448,8 @@ class _AddAuthorizedAdministratorPageState extends State<AddAuthorizedAdministra
btnName: '微信通知', btnName: '微信通知',
onClick: () { onClick: () {
// _openModalBottomSheet(); // _openModalBottomSheet();
NativeInteractionTool().loadNativeShare(shareText: state.pwdShareStr); NativeInteractionTool()
.loadNativeShare(shareText: state.pwdShareStr);
}, },
), ),
SizedBox( SizedBox(
@ -462,7 +483,7 @@ class _AddAuthorizedAdministratorPageState extends State<AddAuthorizedAdministra
width: 120.w, width: 120.w,
// height: 64.h, // height: 64.h,
margin: margin:
EdgeInsets.only(top: 20.w, bottom: 20.w, left: 10.w, right: 10.w), EdgeInsets.only(top: 20.w, bottom: 20.w, left: 10.w, right: 10.w),
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
@ -491,25 +512,25 @@ class _AddAuthorizedAdministratorPageState extends State<AddAuthorizedAdministra
Get.back(); Get.back();
switch (itemIndex) { switch (itemIndex) {
case 0: case 0:
// //
{ {
NativeInteractionTool().loadNativeShare(shareText: state.pwdShareStr); NativeInteractionTool().loadNativeShare(shareText: state.pwdShareStr);
} }
break; break;
case 1: case 1:
// //
{ {
NativeInteractionTool().loadNativeShare(shareText: state.pwdShareStr); NativeInteractionTool().loadNativeShare(shareText: state.pwdShareStr);
} }
break; break;
case 2: case 2:
// //
{ {
Navigator.pushNamed(context, Routers.sendEmailNotificationPage); Navigator.pushNamed(context, Routers.sendEmailNotificationPage);
} }
break; break;
case 3: case 3:
// //
{ {
NativeInteractionTool().loadNativeShare(shareText: state.pwdShareStr); NativeInteractionTool().loadNativeShare(shareText: state.pwdShareStr);
} }
@ -517,5 +538,4 @@ class _AddAuthorizedAdministratorPageState extends State<AddAuthorizedAdministra
default: default:
} }
} }
} }

View File

@ -8,6 +8,7 @@ import 'package:star_lock/network/api_repository.dart';
import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/baseGetXController.dart';
import 'package:star_lock/tools/pickers/pickers.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/date_mode.dart';
import 'package:star_lock/tools/pickers/time_picker/model/pduration.dart';
import '../../../../../app_settings/app_colors.dart'; import '../../../../../app_settings/app_colors.dart';
import '../../../../../tools/commonItem.dart'; import '../../../../../tools/commonItem.dart';
@ -69,8 +70,9 @@ class _AdminDetailChangeDatePage extends State<AdminDetailChangeDatePage> {
isHaveLine: true, isHaveLine: true,
isHaveDirection: true, isHaveDirection: true,
action: () { action: () {
Pickers.showDatePicker(context, mode: DateMode.YMDHM, PDuration selectDate = PDuration.parse(_effectiveDateTime);
onConfirm: (p) { Pickers.showDatePicker(context,
selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) {
setState(() { setState(() {
_selectEffectiveDate = _selectEffectiveDate =
'${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}'; '${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}';
@ -83,8 +85,9 @@ class _AdminDetailChangeDatePage extends State<AdminDetailChangeDatePage> {
rightTitle: _selectFailureDate, rightTitle: _selectFailureDate,
isHaveDirection: true, isHaveDirection: true,
action: () { action: () {
Pickers.showDatePicker(context, mode: DateMode.YMDHM, PDuration selectDate = PDuration.parse(_failureDateTime);
onConfirm: (p) { Pickers.showDatePicker(context,
selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) {
setState(() { setState(() {
_selectFailureDate = _selectFailureDate =
'${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}'; '${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}';
@ -105,8 +108,7 @@ class _AdminDetailChangeDatePage extends State<AdminDetailChangeDatePage> {
_effectiveDateTime.millisecondsSinceEpoch.toString(), _effectiveDateTime.millisecondsSinceEpoch.toString(),
''); '');
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
EasyLoading.showToast("修改成功", duration: 2000.milliseconds);
EasyLoading.showToast("修改成功",duration: 2000.milliseconds);
setState(() { setState(() {
Navigator.pop(context); Navigator.pop(context);
}); });

View File

@ -122,6 +122,9 @@ class DateTool {
int timestamp = 0; int timestamp = 0;
if (type == 0) { if (type == 0) {
List<String> timeParts = dateStr.split(":"); List<String> timeParts = dateStr.split(":");
if (timeParts.length < 2) {
return 0;
}
DateTime now = DateTime.now(); DateTime now = DateTime.now();
DateTime dateTime = DateTime(now.year, now.month, now.day, DateTime dateTime = DateTime(now.year, now.month, now.day,
int.parse(timeParts[0]), int.parse(timeParts[1])); int.parse(timeParts[0]), int.parse(timeParts[1]));
@ -133,6 +136,17 @@ class DateTool {
return timestamp; 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) { String dateToYMDHNString(String? timestamp) {
timestamp ??= '0'; timestamp ??= '0';

View File

@ -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/pduration.dart';
import 'package:star_lock/tools/pickers/time_picker/model/suffix.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: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/address_picker/route/address_picker_route.dart';
// import 'package:flutter_pickers/more_pickers/init_data.dart'; // import 'package:flutter_pickers/more_pickers/init_data.dart';
// import 'package:flutter_pickers/more_pickers/route/multiple_link_picker_route.dart'; // import 'package:flutter_pickers/more_pickers/route/multiple_link_picker_route.dart';
@ -165,7 +166,7 @@ class Pickers {
/// [Suffix] : Suffix(years: '',month: ''); /// [Suffix] : Suffix(years: '',month: '');
/// [selectDate] : /// [selectDate] :
/// PDuration.now(); /// PDuration.now();
/// PDuration.parse(DateTime.parse('20210139')); /// PDuration.parse(DateTime.tryParse('20210139'));
/// PDuration(year: 2020,month: 2); /// PDuration(year: 2020,month: 2);
/// [maxDate] : /// [maxDate] :
/// tip: item限制 maxDate>day = 3 minDate>day = 10,3-10 /// tip: item限制 maxDate>day = 3 minDate>day = 10,3-10
@ -173,7 +174,7 @@ class Pickers {
/// [mode] : 16 DateMode.YMD /// [mode] : 16 DateMode.YMD
static void showDatePicker(BuildContext context, static void showDatePicker(BuildContext context,
{DateMode mode: DateMode.YMD, {DateMode mode: DateMode.YMD,
PDuration? selectDate, required PDuration? selectDate,
PDuration? maxDate, PDuration? maxDate,
PDuration? minDate, PDuration? minDate,
Suffix? suffix, Suffix? suffix,

View File

@ -13,7 +13,7 @@ import 'package:star_lock/tools/pickers/time_picker/model/date_type.dart';
/// AppLog.log('longer2 >>> ${m.toString()}'); /// AppLog.log('longer2 >>> ${m.toString()}');
/// {year: 2011, month: 0, day: 0, hour: 0, minute: 0, second: 0} /// {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()}'); /// AppLog.log('longer3 >>> ${d.toString()}');
/// {year: 2020, month: 3, day: 4, hour: 0, minute: 0, second: 0} /// {year: 2020, month: 3, day: 4, hour: 0, minute: 0, second: 0}
@ -42,7 +42,8 @@ class PDuration {
this.second: 0}); this.second: 0});
// 0 null // 0 null
PDuration.parse(DateTime dateTime) { PDuration.parse(DateTime? dateTime) {
dateTime ??= DateTime.now();
this.year = dateTime.year; this.year = dateTime.year;
this.month = dateTime.month; this.month = dateTime.month;
this.day = dateTime.day; this.day = dateTime.day;

View File

@ -1,8 +1,8 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:star_lock/tools/dateTool.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 '../../app_settings/app_colors.dart';
import '../../translations/trans_lib.dart'; import '../../translations/trans_lib.dart';
@ -43,19 +43,18 @@ class _SeletKeyCyclicDatePageState extends State<SeletKeyCyclicDatePage> {
SizedBox(height: 10.h), SizedBox(height: 10.h),
bottomWidget(), bottomWidget(),
Obx(() => Container( Obx(() => Container(
margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 30.h), margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 30.h),
child: SubmitBtn( child: SubmitBtn(
btnName: TranslationLoader.lanKeys!.save!.tr, btnName: TranslationLoader.lanKeys!.save!.tr,
isDisabled: isDisabled: (state.starDate.value.isNotEmpty &&
(state.starDate.value.isNotEmpty && state.endDate.value.isNotEmpty &&
state.endDate.value.isNotEmpty && state.starTime.value.isNotEmpty &&
state.starTime.value.isNotEmpty && state.endTime.value.isNotEmpty &&
state.endTime.value.isNotEmpty && state.weekDay.value.isNotEmpty),
state.weekDay.value.isNotEmpty), onClick: () {
onClick: () { logic.subBtnAction();
logic.subBtnAction(); }),
}), )),
)),
], ],
)); ));
} }
@ -73,20 +72,27 @@ class _SeletKeyCyclicDatePageState extends State<SeletKeyCyclicDatePage> {
isHaveDirection: true, isHaveDirection: true,
isHaveLine: true, isHaveLine: true,
action: () { action: () {
Pickers.showDatePicker(context, mode: DateMode.YMD, PDuration selectDate = PDuration.parse(
onConfirm: (p) { DateTime.tryParse(state.starDate.value));
state.starDate.value = DateTool().getYMDHNDateString(p, 2); Pickers.showDatePicker(context,
}); selectDate: selectDate,
mode: DateMode.YMD, onConfirm: (p) {
state.starDate.value =
DateTool().getYMDHNDateString(p, 2);
});
})), })),
Obx(() => CommonItem( Obx(() => CommonItem(
leftTitel: "失效日期".tr, leftTitel: "失效日期".tr,
rightTitle: state.endDate.value, rightTitle: state.endDate.value,
isHaveDirection: true, isHaveDirection: true,
action: () { action: () {
Pickers.showDatePicker(context, mode: DateMode.YMD, PDuration selectDate =
onConfirm: (p) { PDuration.parse(DateTime.tryParse(state.endDate.value));
state.endDate.value = DateTool().getYMDHNDateString(p, 2); Pickers.showDatePicker(context,
}); selectDate: selectDate,
mode: DateMode.YMD, onConfirm: (p) {
state.endDate.value = DateTool().getYMDHNDateString(p, 2);
});
})), })),
Container(height: 10.h), Container(height: 10.h),
], ],
@ -110,12 +116,13 @@ class _SeletKeyCyclicDatePageState extends State<SeletKeyCyclicDatePage> {
padding: EdgeInsets.only(left: 30.w, top: 15.h), padding: EdgeInsets.only(left: 30.w, top: 15.h),
child: Text(TranslationLoader.lanKeys!.effectiveDay!.tr, child: Text(TranslationLoader.lanKeys!.effectiveDay!.tr,
style: style:
TextStyle(fontSize: 24.sp, fontWeight: FontWeight.w600))), TextStyle(fontSize: 24.sp, fontWeight: FontWeight.w600))),
Container( Container(
height: 100.h, height: 100.h,
padding: EdgeInsets.only(left: 10.w, right: 10.w, bottom: 10.h), padding: EdgeInsets.only(left: 10.w, right: 10.w, bottom: 10.h),
child: GridView.builder( child: GridView.builder(
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 7, childAspectRatio: 1.0), gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 7, childAspectRatio: 1.0),
itemCount: 7, itemCount: 7,
physics: const NeverScrollableScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
itemBuilder: (context, index) { itemBuilder: (context, index) {
@ -167,18 +174,18 @@ class _SeletKeyCyclicDatePageState extends State<SeletKeyCyclicDatePage> {
}); });
}, },
child: Obx(() => Container( child: Obx(() => Container(
width: 40.w, width: 40.w,
height: 40.w, height: 40.w,
margin: EdgeInsets.all(10.w), margin: EdgeInsets.all(10.w),
decoration: BoxDecoration( decoration: BoxDecoration(
color: state.weekDay.value.contains(index) color: state.weekDay.value.contains(index)
? AppColors.mainColor ? AppColors.mainColor
: Colors.white, : Colors.white,
border: Border.all(width: 1, color: AppColors.btnDisableColor), border: Border.all(width: 1, color: AppColors.btnDisableColor),
borderRadius: BorderRadius.circular(30.w), borderRadius: BorderRadius.circular(30.w),
), ),
child: Center( child: Center(
child: Text( child: Text(
dateStr, dateStr,
style: TextStyle( style: TextStyle(
fontSize: 20.sp, fontSize: 20.sp,
@ -186,7 +193,7 @@ class _SeletKeyCyclicDatePageState extends State<SeletKeyCyclicDatePage> {
? Colors.white ? Colors.white
: AppColors.darkGrayTextColor), : AppColors.darkGrayTextColor),
)), )),
)), )),
); );
} }
@ -203,17 +210,24 @@ class _SeletKeyCyclicDatePageState extends State<SeletKeyCyclicDatePage> {
isHaveDirection: true, isHaveDirection: true,
isHaveLine: true, isHaveLine: true,
action: () { action: () {
Pickers.showDatePicker(context, mode: DateMode.HM, onConfirm: (p) { PDuration selectDate = PDuration.parse(DateTool().dateToDateTime(state.starTime.value, 0));
state.starTime.value = DateTool().getYMDHNDateString(p, 3); Pickers.showDatePicker(context,
selectDate: selectDate,
mode: DateMode.HM, onConfirm: (p) {
state.starTime.value =
DateTool().getYMDHNDateString(p, 3);
}); });
})), })),
Obx(() => CommonItem( Obx(() => CommonItem(
leftTitel:"失效时间".tr, leftTitel: "失效时间".tr,
rightTitle: state.endTime.value, rightTitle: state.endTime.value,
isHaveDirection: true, isHaveDirection: true,
action: () { action: () {
Pickers.showDatePicker(context, mode: DateMode.HM, onConfirm: (p) { PDuration selectDate = PDuration.parse(DateTool().dateToDateTime(state.endTime.value, 0));
state.endTime.value = DateTool().getYMDHNDateString(p, 3); Pickers.showDatePicker(context,
selectDate: selectDate,
mode: DateMode.HM, onConfirm: (p) {
state.endTime.value = DateTool().getYMDHNDateString(p, 3);
}); });
})), })),
Container(height: 10.h), Container(height: 10.h),