1,完善循环逻辑处理

2,新增操作记录列表接口API
This commit is contained in:
Daisy 2023-08-28 10:14:14 +08:00
parent 43d79320a5
commit f6ef117fe7
2 changed files with 74 additions and 13 deletions

View File

@ -2,6 +2,7 @@ import 'package:date_format/date_format.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_pickers/pickers.dart'; import 'package:flutter_pickers/pickers.dart';
import 'package:flutter_pickers/style/default_style.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';
import 'package:get/get.dart'; import 'package:get/get.dart';
@ -27,11 +28,15 @@ class PasswordKeyPerpetualPage extends StatefulWidget {
class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> { class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
final TextEditingController _controller = TextEditingController(); final TextEditingController _controller = TextEditingController();
late bool _isSendSuccess; late bool _isSendSuccess;
late bool _isPermanent;
late String _getPwdStr; late String _getPwdStr;
String _selectEffectiveDate = ''; // String _selectEffectiveDate = ''; //
String _selectFailureDate = ''; // String _selectFailureDate = ''; //
late DateTime _effectiveDateTime; late DateTime _effectiveDateTime;
late DateTime _failureDateTime; late DateTime _failureDateTime;
late String cyclicModeStr;
late String effectiveHourStr;
late String failureHourStr;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -43,13 +48,21 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
super.initState(); super.initState();
_isSendSuccess = false; _isSendSuccess = false;
_isPermanent = false;
DateTime dateTime = DateTime.now(); DateTime dateTime = DateTime.now();
_effectiveDateTime = dateTime; _effectiveDateTime = dateTime;
_failureDateTime = dateTime; _failureDateTime = dateTime;
_selectEffectiveDate = formatDate( if (int.parse(widget.type) == 4) {
dateTime, [yyyy, '-', mm, '-', dd, ' ', HH, ':', nn]); // cyclicModeStr = '周末';
_selectFailureDate = formatDate(
dateTime, [yyyy, '-', mm, '-', dd, ' ', HH, ':', nn]); // _selectEffectiveDate = formatDate(dateTime, [HH, ':', nn]); //
_selectFailureDate = formatDate(dateTime, [HH, ':', nn]); //
} else {
_selectEffectiveDate = formatDate(
dateTime, [yyyy, '-', mm, '-', dd, ' ', HH, ':', nn]); //
_selectFailureDate = formatDate(
dateTime, [yyyy, '-', mm, '-', dd, ' ', HH, ':', nn]); //
}
} }
Widget indexChangeWidget() { Widget indexChangeWidget() {
@ -103,6 +116,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
return Column( return Column(
children: [ children: [
keyIfPerpetualWidget(), keyIfPerpetualWidget(),
_isPermanent == false ? keyTimeLimitWidget() : Container(),
perpetualKeyWidget( perpetualKeyWidget(
TranslationLoader.lanKeys!.name!.tr, TranslationLoader.lanKeys!.name!.tr,
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
@ -221,7 +235,9 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
rightWidget: rightWidget:
SizedBox(width: 60.w, height: 50.h, child: _switch()), SizedBox(width: 60.w, height: 50.h, child: _switch()),
action: () {}), action: () {}),
Container(height: 10.h), _isPermanent == true
? Container(height: 10.h)
: Container(height: 1.h),
], ],
), ),
); );
@ -238,23 +254,68 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
rightTitle: "周末", rightTitle: "周末",
isHaveLine: true, isHaveLine: true,
isHaveDirection: true, isHaveDirection: true,
action: () {}), action: () {
List<String> pickerDataList = [
'周末',
'每日',
'工作日',
'星期一',
'星期二',
'星期三',
'星期四',
'星期五',
'星期六',
'星期日'
];
showPickerView(context, pickerDataList);
}),
CommonItem( CommonItem(
leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr, leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr,
rightTitle: "10:00", rightTitle: _selectEffectiveDate,
isHaveLine: true, isHaveLine: true,
isHaveDirection: true, isHaveDirection: true,
action: () {}), action: () {
Pickers.showDatePicker(context, mode: DateMode.HM,
onConfirm: (p) {
setState(() {
_effectiveDateTime = DateTime.parse(
'${intToStr(p.hour!)}:${intToStr(p.minute!)}');
_selectEffectiveDate =
formatDate(_effectiveDateTime, [HH, ':', nn]);
});
});
}),
CommonItem( CommonItem(
leftTitel: TranslationLoader.lanKeys!.failureTime!.tr, leftTitel: TranslationLoader.lanKeys!.failureTime!.tr,
rightTitle: "11:00", rightTitle: _selectFailureDate,
isHaveDirection: true, isHaveDirection: true,
action: () {}), action: () {
Pickers.showDatePicker(context, mode: DateMode.HM,
onConfirm: (p) {
setState(() {
_failureDateTime = DateTime.parse(
'${intToStr(p.hour!)}:${intToStr(p.minute!)}');
_selectFailureDate =
formatDate(_effectiveDateTime, [HH, ':', nn]);
});
});
}),
], ],
), ),
); );
} }
//pickerView
showPickerView(BuildContext context, List dataList) {
Pickers.showSinglePicker(context,
data: dataList,
pickerStyle: DefaultPickerStyle(), onConfirm: (p, position) {
setState(() {});
}, onChanged: (p, position) {
setState(() {});
});
}
Widget keyBottomWidget(String tipStr) { Widget keyBottomWidget(String tipStr) {
return Column( return Column(
children: [ children: [
@ -453,15 +514,14 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
} }
CupertinoSwitch _switch() { CupertinoSwitch _switch() {
bool _isOn = false;
return CupertinoSwitch( return CupertinoSwitch(
activeColor: CupertinoColors.activeBlue, activeColor: CupertinoColors.activeBlue,
trackColor: CupertinoColors.systemGrey5, trackColor: CupertinoColors.systemGrey5,
thumbColor: CupertinoColors.white, thumbColor: CupertinoColors.white,
value: _isOn, value: _isPermanent,
onChanged: (value) { onChanged: (value) {
setState(() { setState(() {
_isOn = value; _isPermanent = value;
}); });
}, },
); );

View File

@ -26,4 +26,5 @@ abstract class Api {
final String passwordKeyListURL = '/keyboardPwd/listSendRecords'; // final String passwordKeyListURL = '/keyboardPwd/listSendRecords'; //
final String passwordKeyResetURL = '/keyboardPwd/reset'; // final String passwordKeyResetURL = '/keyboardPwd/reset'; //
final String passwordKeyGetURL = '/keyboardPwd/get'; // final String passwordKeyGetURL = '/keyboardPwd/get'; //
final String lockRecordsListURL = '/lockRecords/list'; //
} }