添加考勤选择月份弹窗,修复修改密码名字报红问题,添加密码列表未生效状态

This commit is contained in:
魏少阳 2024-06-07 15:14:52 +08:00
parent 8f63629e4a
commit 37480a1a02
4 changed files with 50 additions and 17 deletions

View File

@ -2,19 +2,24 @@
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/app_settings/app_settings.dart';
typedef SelectDateCallback(DateTime dateTime);
class CheckingInListSeletMonthPage extends StatefulWidget { class CheckingInListSeletMonthPage extends StatefulWidget {
const CheckingInListSeletMonthPage({Key? key}) : super(key: key); int selectYear;
int selectMonth;
SelectDateCallback? selectAction;
CheckingInListSeletMonthPage({required this.selectYear, required this.selectMonth, required this.selectAction, Key? key}) : super(key: key);
@override @override
State<CheckingInListSeletMonthPage> createState() => _CheckingInListSeletMonthPageState(); State<CheckingInListSeletMonthPage> createState() => _CheckingInListSeletMonthPageState();
} }
class _CheckingInListSeletMonthPageState extends State<CheckingInListSeletMonthPage> { class _CheckingInListSeletMonthPageState extends State<CheckingInListSeletMonthPage> {
var _selectMonth = 1;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
AppLog.log('selectYear:${widget.selectYear} selectMonth:${widget.selectMonth}');
return Dialog( return Dialog(
// insetPadding: EdgeInsets.all(10), // // insetPadding: EdgeInsets.all(10), //
shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(10.w))), // shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(10.w))), //
@ -35,16 +40,20 @@ class _CheckingInListSeletMonthPageState extends State<CheckingInListSeletMonthP
children: <Widget>[ children: <Widget>[
GestureDetector( GestureDetector(
onTap:(){ onTap:(){
setState(() {
widget.selectYear--;
});
}, },
child: Image(width: 50.w, height: 40.w, image: const AssetImage('images/icon_left_black.png'),), child: Image(width: 50.w, height: 40.w, image: const AssetImage('images/icon_left_black.png'),),
), ),
SizedBox(width: 50.w,), SizedBox(width: 50.w,),
Text('2024', style: TextStyle(fontSize: 30.sp, color: Colors.black, fontWeight: FontWeight.w500)), Text('${widget.selectYear}', style: TextStyle(fontSize: 30.sp, color: Colors.black, fontWeight: FontWeight.w500)),
SizedBox(width: 50.w), SizedBox(width: 50.w),
GestureDetector( GestureDetector(
onTap: (){ onTap: (){
setState(() {
widget.selectYear++;
});
}, },
child: Image(width: 50.w, height: 40.w, image: const AssetImage('images/icon_right_black.png')), child: Image(width: 50.w, height: 40.w, image: const AssetImage('images/icon_right_black.png')),
), ),
@ -67,10 +76,12 @@ class _CheckingInListSeletMonthPageState extends State<CheckingInListSeletMonthP
itemCount: 12, itemCount: 12,
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
return GestureDetector( return GestureDetector(
onTap: (){ onTap: isFutureMonth(widget.selectYear, index + 1) ? null : (){
setState(() { setState(() {
Get.back(); Get.back();
_selectMonth = index + 1; widget.selectMonth = index + 1;
final DateTime selectedDate = DateTime(widget.selectYear, widget.selectMonth, 1);
widget.selectAction!(selectedDate);
}); });
}, },
child: Container( child: Container(
@ -78,13 +89,13 @@ class _CheckingInListSeletMonthPageState extends State<CheckingInListSeletMonthP
height: 60.w, height: 60.w,
alignment: Alignment.center, alignment: Alignment.center,
decoration: BoxDecoration( decoration: BoxDecoration(
color: index+1 == _selectMonth ? Colors.blue : null, color: index+1 == widget.selectMonth ? Colors.blue : null,
// color: Colors.blue, // color: Colors.blue,
borderRadius: BorderRadius.circular(40.w), borderRadius: BorderRadius.circular(40.w),
), ),
child: Text('${index + 1}', style: TextStyle(fontSize: 24.sp, color: index+1 == _selectMonth ? Colors.white : Colors.black)), child: Text('${index + 1}', style: TextStyle(fontSize: 24.sp, color: isFutureMonth(widget.selectYear, index + 1) ? Colors.grey : (index+1 == widget.selectMonth ? Colors.white : Colors.black)),
), ),
); ));
}, },
), ),
), ),
@ -95,4 +106,11 @@ class _CheckingInListSeletMonthPageState extends State<CheckingInListSeletMonthP
); );
} }
bool isFutureMonth(int year, int month) {
final DateTime now = DateTime.now();
if (year > now.year || (year == now.year && month > now.month)) {
return true;
}
return false;
}
} }

View File

@ -6,6 +6,7 @@ import 'package:get/get.dart';
import 'package:star_lock/main/lockDetail/checkingIn/checkingInList/checkingInListMonth_entity.dart'; import 'package:star_lock/main/lockDetail/checkingIn/checkingInList/checkingInListMonth_entity.dart';
import 'package:star_lock/main/lockDetail/checkingIn/checkingInList/checkingInList_state.dart'; import 'package:star_lock/main/lockDetail/checkingIn/checkingInList/checkingInList_state.dart';
import 'package:star_lock/main/lockMian/entity/lockListInfo_entity.dart'; import 'package:star_lock/main/lockMian/entity/lockListInfo_entity.dart';
import 'package:star_lock/tools/dateTool.dart';
import '../../../../appRouters.dart'; import '../../../../appRouters.dart';
import '../../../../app_settings/app_colors.dart'; import '../../../../app_settings/app_colors.dart';
@ -211,7 +212,7 @@ class _CheckingInListPageState extends State<CheckingInListPage> {
await showDialog( await showDialog(
context: Get.context!, context: Get.context!,
builder: (BuildContext context) { builder: (BuildContext context) {
// if(state.isDay.value){ if(state.isDay.value){
return ShowCalendar( return ShowCalendar(
datePickerMode: DatePickerMode.day, datePickerMode: DatePickerMode.day,
selectAction: (DateTime dateTime) { selectAction: (DateTime dateTime) {
@ -223,9 +224,18 @@ class _CheckingInListPageState extends State<CheckingInListPage> {
Get.back(); Get.back();
}); });
}); });
// }else{ }else{
// return CheckingInListSeletMonthPage(); final int timestamp = state.checkListDateTimestamp.value;
// } final DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(timestamp);
return CheckingInListSeletMonthPage(selectYear: dateTime.year, selectMonth: int.parse(state.checkListDate.value), selectAction: (DateTime dateTime){
setState(() {
state.checkListDateTimestamp.value = dateTime.millisecondsSinceEpoch;
final String beginDate = formatDate(dateTime, state.isDay.value ? <String>[mm, '-', dd] : <String>[mm]);
state.checkListDate.value = beginDate;
logic.loadDataByType();
});
});
}
}); });
} else { } else {
// Get.toNamed(Routers.selectLockTypePage); // Get.toNamed(Routers.selectLockTypePage);

View File

@ -227,7 +227,7 @@ class _PasswordKeyListPageState extends State<PasswordKeyListPage>
Row( Row(
children: <Widget>[ children: <Widget>[
SizedBox( SizedBox(
width: passwordKeyListItem.keyboardPwdStatus == 2 width: passwordKeyListItem.keyboardPwdStatus == 2 || passwordKeyListItem.keyboardPwdStatus == 3
? 1.sw - 110.w - 100.w ? 1.sw - 110.w - 100.w
: 1.sw - 110.w - 50.w, : 1.sw - 110.w - 50.w,
child: Row(children: <Widget>[ child: Row(children: <Widget>[
@ -247,6 +247,11 @@ class _PasswordKeyListPageState extends State<PasswordKeyListPage>
'已过期'.tr, '已过期'.tr,
style: TextStyle(color: Colors.red, fontSize: 20.sp), style: TextStyle(color: Colors.red, fontSize: 20.sp),
) )
else if (passwordKeyListItem.keyboardPwdStatus == 3)
Text(
'未生效'.tr,
style: TextStyle(color: Colors.red, fontSize: 20.sp),
)
else else
Container(), Container(),
// SizedBox(width: 15.w) // SizedBox(width: 15.w)

View File

@ -60,12 +60,12 @@ class ShowTFView extends StatelessWidget {
inputFormatters: inputFormatters, inputFormatters: inputFormatters,
keyboardType: keyboardType, keyboardType: keyboardType,
decoration: InputDecoration( decoration: InputDecoration(
contentPadding: EdgeInsets.only(left: 5, top: isShowSuffixIcon! ? 0 : -8, bottom: 6), contentPadding: EdgeInsets.only(left: 5, top: isShowSuffixIcon??false ? 0 : -8, bottom: 6),
hintText: tipTitle??TranslationLoader.lanKeys!.pleaseEnter!.tr, hintText: tipTitle??TranslationLoader.lanKeys!.pleaseEnter!.tr,
hintStyle: TextStyle(fontSize: 22.sp, height: 1.0), hintStyle: TextStyle(fontSize: 22.sp, height: 1.0),
//线 //线
border: InputBorder.none, border: InputBorder.none,
suffixIcon: isShowSuffixIcon! ? IconButton( suffixIcon: isShowSuffixIcon??false ? IconButton(
onPressed: () => controller?.clear(), onPressed: () => controller?.clear(),
icon: const Icon(Icons.clear), icon: const Icon(Icons.clear),
) : null, ) : null,