244 lines
8.3 KiB
Dart
Executable File
244 lines
8.3 KiB
Dart
Executable File
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:star_lock/tools/pickers/pickers.dart';
|
|
import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart';
|
|
import 'package:star_lock/tools/pickers/time_picker/model/pduration.dart';
|
|
|
|
import '../../../../../app_settings/app_colors.dart';
|
|
import '../../../../../tools/commonItem.dart';
|
|
import '../../../../../tools/dateTool.dart';
|
|
import '../../../../../tools/submitBtn.dart';
|
|
import '../../../../../tools/titleAppBar.dart';
|
|
import '../../../../../translations/trans_lib.dart';
|
|
import 'electronicKeyPeriodValidity_logic.dart';
|
|
|
|
class ElectronicKeyPeriodValidityPage extends StatefulWidget {
|
|
const ElectronicKeyPeriodValidityPage({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<ElectronicKeyPeriodValidityPage> createState() =>
|
|
_ElectronicKeyPeriodValidityPageState();
|
|
}
|
|
|
|
class _ElectronicKeyPeriodValidityPageState
|
|
extends State<ElectronicKeyPeriodValidityPage> {
|
|
final logic = Get.put(ElectronicKeyPeriodValidityLogic());
|
|
final state = Get.find<ElectronicKeyPeriodValidityLogic>().state;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: AppColors.mainBackgroundColor,
|
|
appBar: TitleAppBar(
|
|
barTitle: "修改有效期".tr,
|
|
haveBack: true,
|
|
backgroundColor: AppColors.mainColor),
|
|
body: ListView(
|
|
children: [
|
|
topWidget(),
|
|
SizedBox(height: 10.h),
|
|
middleWidget(),
|
|
SizedBox(height: 10.h),
|
|
bottomWidget(),
|
|
Container(
|
|
margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 30.h),
|
|
child: SubmitBtn(
|
|
btnName: TranslationLoader.lanKeys!.save!.tr,
|
|
onClick: () {
|
|
if (state.pushType.value == 0) {
|
|
logic.updateKeyDateRequest();
|
|
} else if (state.pushType.value == 1) {}
|
|
}),
|
|
),
|
|
],
|
|
));
|
|
}
|
|
|
|
Widget topWidget() {
|
|
return Column(
|
|
children: [
|
|
Container(
|
|
color: Colors.white,
|
|
child: Column(
|
|
children: [
|
|
Obx(() => CommonItem(
|
|
leftTitel: "生效日期".tr,
|
|
rightTitle: state.starDate.value,
|
|
isHaveDirection: true,
|
|
isHaveLine: true,
|
|
action: () {
|
|
PDuration selectDate =
|
|
PDuration.parse(DateTime.tryParse(state.endTime.value));
|
|
Pickers.showDatePicker(context,
|
|
selectDate: selectDate,
|
|
mode: DateMode.YMD, onConfirm: (p) {
|
|
state.starDate.value =
|
|
DateTool().getYMDHNDateString(p, 2);
|
|
});
|
|
})),
|
|
Obx(() => CommonItem(
|
|
leftTitel: "失效日期".tr,
|
|
rightTitle: state.endDate.value,
|
|
isHaveDirection: true,
|
|
action: () {
|
|
PDuration selectDate =
|
|
PDuration.parse(DateTime.tryParse(state.endDate.value));
|
|
Pickers.showDatePicker(context,
|
|
selectDate: selectDate,
|
|
mode: DateMode.YMD, onConfirm: (p) {
|
|
state.endDate.value = DateTool().getYMDHNDateString(p, 2);
|
|
});
|
|
})),
|
|
Container(height: 10.h),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget middleWidget() {
|
|
return Container(
|
|
height: 160.h,
|
|
width: 1.sw,
|
|
color: Colors.white,
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Container(
|
|
height: 60.h,
|
|
// color: Colors.red,
|
|
padding: EdgeInsets.only(left: 30.w, top: 15.h),
|
|
child: Text(TranslationLoader.lanKeys!.effectiveDay!.tr,
|
|
style:
|
|
TextStyle(fontSize: 24.sp, fontWeight: FontWeight.w600))),
|
|
Container(
|
|
height: 100.h,
|
|
padding: EdgeInsets.only(left: 10.w, right: 10.w, bottom: 10.h),
|
|
child: GridView.builder(
|
|
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
|
crossAxisCount: 7, childAspectRatio: 1.0),
|
|
itemCount: 7,
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
itemBuilder: (context, index) {
|
|
index += 1;
|
|
return btnItem(index);
|
|
})),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget btnItem(int index) {
|
|
String dateStr;
|
|
switch (index) {
|
|
case 1:
|
|
dateStr = TranslationLoader.lanKeys!.mondayShort!.tr;
|
|
break;
|
|
case 2:
|
|
dateStr = TranslationLoader.lanKeys!.tuesdayShort!.tr;
|
|
break;
|
|
case 3:
|
|
dateStr = TranslationLoader.lanKeys!.wednesdayShort!.tr;
|
|
break;
|
|
case 4:
|
|
dateStr = TranslationLoader.lanKeys!.thursdayShort!.tr;
|
|
break;
|
|
case 5:
|
|
dateStr = TranslationLoader.lanKeys!.fridayShort!.tr;
|
|
break;
|
|
case 6:
|
|
dateStr = TranslationLoader.lanKeys!.saturdayShort!.tr;
|
|
break;
|
|
case 7:
|
|
dateStr = TranslationLoader.lanKeys!.sundayShort!.tr;
|
|
break;
|
|
default:
|
|
dateStr = "";
|
|
break;
|
|
}
|
|
return GestureDetector(
|
|
onTap: () {
|
|
setState(() {
|
|
if (state.weekDay.value.contains(index)) {
|
|
state.weekDay.value.remove(index);
|
|
} else {
|
|
state.weekDay.value.add(index);
|
|
}
|
|
state.weekDay.value.sort();
|
|
});
|
|
},
|
|
child: Obx(() => Container(
|
|
width: 40.w,
|
|
height: 40.w,
|
|
margin: EdgeInsets.all(10.w),
|
|
decoration: BoxDecoration(
|
|
color: state.weekDay.value.contains(index)
|
|
? AppColors.mainColor
|
|
: Colors.white,
|
|
border: Border.all(width: 1, color: AppColors.btnDisableColor),
|
|
borderRadius: BorderRadius.circular(30.w),
|
|
),
|
|
child: Center(
|
|
child: Text(
|
|
dateStr,
|
|
style: TextStyle(
|
|
fontSize: 20.sp,
|
|
color: state.weekDay.value.contains(index)
|
|
? Colors.white
|
|
: AppColors.darkGrayTextColor),
|
|
)),
|
|
)),
|
|
);
|
|
}
|
|
|
|
Widget bottomWidget() {
|
|
return Column(
|
|
children: [
|
|
Container(
|
|
color: Colors.white,
|
|
child: Column(
|
|
children: [
|
|
Obx(() => CommonItem(
|
|
leftTitel:
|
|
"${TranslationLoader.lanKeys!.begin!.tr}${TranslationLoader.lanKeys!.time!.tr}",
|
|
rightTitle: state.starTime.value,
|
|
isHaveDirection: true,
|
|
isHaveLine: true,
|
|
action: () {
|
|
PDuration selectDate = PDuration.parse(DateTool().dateToDateTime(state.starTime.value, 0));
|
|
Pickers.showDatePicker(context,
|
|
selectDate: selectDate,
|
|
mode: DateMode.HM, onConfirm: (p) {
|
|
setState(() {
|
|
state.starTime.value =
|
|
DateTool().getYMDHNDateString(p, 3);
|
|
});
|
|
});
|
|
})),
|
|
Obx(() => CommonItem(
|
|
leftTitel:
|
|
"${TranslationLoader.lanKeys!.end!.tr}${TranslationLoader.lanKeys!.time!.tr}",
|
|
rightTitle: state.endTime.value,
|
|
isHaveDirection: true,
|
|
action: () {
|
|
PDuration selectDate = PDuration.parse(DateTool().dateToDateTime(state.endTime.value, 0));
|
|
Pickers.showDatePicker(context,
|
|
selectDate: selectDate,
|
|
mode: DateMode.HM, onConfirm: (p) {
|
|
setState(() {
|
|
state.endTime.value =
|
|
DateTool().getYMDHNDateString(p, 3);
|
|
});
|
|
});
|
|
})),
|
|
Container(height: 10.h),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|