From f6ef117fe7ef550a934230b6aafb26121416f6af Mon Sep 17 00:00:00 2001 From: Daisy <> Date: Mon, 28 Aug 2023 10:14:14 +0800 Subject: [PATCH] =?UTF-8?q?1=EF=BC=8C=E5=AE=8C=E5=96=84=E5=BE=AA=E7=8E=AF?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E5=A4=84=E7=90=86=202=EF=BC=8C=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E6=93=8D=E4=BD=9C=E8=AE=B0=E5=BD=95=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../passwordKey_perpetual_page.dart | 86 ++++++++++++++++--- star_lock/lib/network/api.dart | 1 + 2 files changed, 74 insertions(+), 13 deletions(-) diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart index 39b817be..429e90ac 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart @@ -2,6 +2,7 @@ import 'package:date_format/date_format.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.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_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; @@ -27,11 +28,15 @@ class PasswordKeyPerpetualPage extends StatefulWidget { class _PasswordKeyPerpetualPageState extends State { final TextEditingController _controller = TextEditingController(); late bool _isSendSuccess; + late bool _isPermanent; late String _getPwdStr; String _selectEffectiveDate = ''; //生效时间 String _selectFailureDate = ''; //失效时间 late DateTime _effectiveDateTime; late DateTime _failureDateTime; + late String cyclicModeStr; + late String effectiveHourStr; + late String failureHourStr; @override Widget build(BuildContext context) { @@ -43,13 +48,21 @@ class _PasswordKeyPerpetualPageState extends State { super.initState(); _isSendSuccess = false; + _isPermanent = false; DateTime dateTime = DateTime.now(); _effectiveDateTime = dateTime; _failureDateTime = dateTime; - _selectEffectiveDate = formatDate( - dateTime, [yyyy, '-', mm, '-', dd, ' ', HH, ':', nn]); //默认为当前时间 - _selectFailureDate = formatDate( - dateTime, [yyyy, '-', mm, '-', dd, ' ', HH, ':', nn]); //默认为当前时间 + if (int.parse(widget.type) == 4) { + cyclicModeStr = '周末'; + + _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() { @@ -103,6 +116,7 @@ class _PasswordKeyPerpetualPageState extends State { return Column( children: [ keyIfPerpetualWidget(), + _isPermanent == false ? keyTimeLimitWidget() : Container(), perpetualKeyWidget( TranslationLoader.lanKeys!.name!.tr, TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, @@ -221,7 +235,9 @@ class _PasswordKeyPerpetualPageState extends State { rightWidget: SizedBox(width: 60.w, height: 50.h, child: _switch()), action: () {}), - Container(height: 10.h), + _isPermanent == true + ? Container(height: 10.h) + : Container(height: 1.h), ], ), ); @@ -238,23 +254,68 @@ class _PasswordKeyPerpetualPageState extends State { rightTitle: "周末", isHaveLine: true, isHaveDirection: true, - action: () {}), + action: () { + List pickerDataList = [ + '周末', + '每日', + '工作日', + '星期一', + '星期二', + '星期三', + '星期四', + '星期五', + '星期六', + '星期日' + ]; + showPickerView(context, pickerDataList); + }), CommonItem( leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr, - rightTitle: "10:00", + rightTitle: _selectEffectiveDate, isHaveLine: 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( leftTitel: TranslationLoader.lanKeys!.failureTime!.tr, - rightTitle: "11:00", + rightTitle: _selectFailureDate, 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) { return Column( children: [ @@ -453,15 +514,14 @@ class _PasswordKeyPerpetualPageState extends State { } CupertinoSwitch _switch() { - bool _isOn = false; return CupertinoSwitch( activeColor: CupertinoColors.activeBlue, trackColor: CupertinoColors.systemGrey5, thumbColor: CupertinoColors.white, - value: _isOn, + value: _isPermanent, onChanged: (value) { setState(() { - _isOn = value; + _isPermanent = value; }); }, ); diff --git a/star_lock/lib/network/api.dart b/star_lock/lib/network/api.dart index 4ad0b6d9..b4f924c2 100644 --- a/star_lock/lib/network/api.dart +++ b/star_lock/lib/network/api.dart @@ -26,4 +26,5 @@ abstract class Api { final String passwordKeyListURL = '/keyboardPwd/listSendRecords'; //密码钥匙列表 final String passwordKeyResetURL = '/keyboardPwd/reset'; //密码钥匙重置 final String passwordKeyGetURL = '/keyboardPwd/get'; //获取密码 + final String lockRecordsListURL = '/lockRecords/list'; //操作记录列表 }