219 lines
7.2 KiB
Dart
Raw Normal View History

2023-07-13 14:13:44 +08:00
import 'package:flutter/material.dart';
import 'package:flutter_pickers/pickers.dart';
import 'package:flutter_pickers/style/default_style.dart';
import 'package:flutter_pickers/style/picker_style.dart';
import 'package:flutter_pickers/time_picker/model/date_mode.dart';
import 'package:flutter_pickers/time_picker/model/pduration.dart';
import 'package:flutter_pickers/time_picker/model/suffix.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import '../../../../appRouters.dart';
import '../../../../app_settings/app_colors.dart';
import '../../../../tools/showBottomSheetTool.dart';
import '../../../../tools/titleAppBar.dart';
import '../../../../translations/trans_lib.dart';
class CheckingInSetHolidaysPage extends StatefulWidget {
2023-07-15 15:11:28 +08:00
const CheckingInSetHolidaysPage({Key? key}) : super(key: key);
2023-07-13 14:13:44 +08:00
@override
State<CheckingInSetHolidaysPage> createState() =>
_CheckingInSetHolidaysPageState();
2023-07-13 14:13:44 +08:00
}
class _CheckingInSetHolidaysPageState extends State<CheckingInSetHolidaysPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColors.mainBackgroundColor,
appBar: TitleAppBar(
haveTitleWidget: true,
titleWidget: titleWidget(),
haveBack: true,
backgroundColor: AppColors.mainColor,
actionsList: [
GestureDetector(
onTap: () {
Navigator.pushNamed(
context, Routers.checkingInAddHolidaysPage);
},
child: Image.asset(
'images/icon_add_white.png',
width: 36.w,
height: 36.w,
)),
SizedBox(
width: 30.w,
),
],
2023-07-13 14:13:44 +08:00
),
body: ListView.builder(
itemCount: 10,
itemBuilder: (c, index) {
return _checkingInListItem('images/icon_lock.png', "张三",
"2023.6.21 11.15", "2023.6.21 11.15", () {
2023-07-13 14:13:44 +08:00
// Navigator.pushNamed(context, Routers.electronicKeyDetailPage);
});
}));
2023-07-13 14:13:44 +08:00
}
Widget _checkingInListItem(String lockTypeIcon, String lockTypeTitle,
String beginTime, String endTime, Function() action) {
2023-07-13 14:13:44 +08:00
return GestureDetector(
onTap: action,
child: Container(
height: 140.h,
margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w),
decoration: BoxDecoration(
2023-07-13 14:13:44 +08:00
color: Colors.white,
borderRadius: BorderRadius.circular(10.w),
),
child: Row(
children: [
Container(
color: const Color(0xFFAFB5D7),
2023-07-13 14:13:44 +08:00
width: 100.w,
height: 140.h,
child: Center(
child: Text(
"7\n${TranslationLoader.lanKeys!.month!.tr}",
textAlign: TextAlign.center,
style: TextStyle(fontSize: 28.sp, color: Colors.white),
))),
SizedBox(
width: 20.w,
2023-07-13 14:13:44 +08:00
),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
// color: Colors.red,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
lockTypeTitle,
style: TextStyle(fontSize: 24.sp),
),
2023-07-13 14:13:44 +08:00
],
),
),
SizedBox(height: 10.h),
2023-07-13 14:13:44 +08:00
Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
"${TranslationLoader.lanKeys!.libertyDay!.tr}:2023.6.21 11.15-2023.6.21 11.15",
style: TextStyle(fontSize: 20.sp),
),
2023-07-13 14:13:44 +08:00
],
),
),
SizedBox(height: 5.h),
2023-07-13 14:13:44 +08:00
Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
"${TranslationLoader.lanKeys!.coverDate!.tr}:2023.6.21 11.15",
style: TextStyle(fontSize: 20.sp),
),
2023-07-13 14:13:44 +08:00
],
),
),
],
),
),
SizedBox(width: 20.h),
2023-07-13 14:13:44 +08:00
],
),
),
);
}
Widget titleWidget() {
2023-07-13 14:13:44 +08:00
return GestureDetector(
onTap: () {
2023-07-13 14:13:44 +08:00
showListType();
},
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"${DateTime.now().year}${TranslationLoader.lanKeys!.year!.tr}",
style: TextStyle(color: Colors.white, fontSize: 26.sp),
),
SizedBox(
width: 5.w,
),
Image.asset(
'images/main/icon_lockDetail_checkIn_topTitle.png',
width: 22.w,
height: 16.w,
)
2023-07-13 14:13:44 +08:00
],
),
);
}
void showListType() {
2023-07-13 14:13:44 +08:00
Pickers.showDatePicker(
context,
// 模式,详见下方
mode: DateMode.Y,
// 后缀 默认Suffix.normal()为空的话Suffix()
suffix: Suffix(years: ''),
// 样式 详见下方样式
pickerStyle: PickerStyle(
cancelButton: GestureDetector(
onTap: () {},
2023-07-13 14:13:44 +08:00
child: Container(
alignment: Alignment.center,
padding: const EdgeInsets.only(left: 22, right: 12),
child: Text(TranslationLoader.lanKeys!.cancel!.tr,
style: const TextStyle(color: Colors.black, fontSize: 16.0)),
2023-07-13 14:13:44 +08:00
),
),
commitButton: GestureDetector(
onTap: () {},
2023-07-13 14:13:44 +08:00
child: Container(
alignment: Alignment.center,
padding: const EdgeInsets.only(left: 22, right: 12),
2023-07-15 15:11:28 +08:00
child: Text(TranslationLoader.lanKeys!.sure!.tr,
2023-07-13 14:13:44 +08:00
style: const TextStyle(color: Colors.black, fontSize: 16.0)),
),
),
),
// 默认选中
selectDate: PDuration(year: 2023),
minDate: PDuration(year: 1900),
maxDate: PDuration(year: 2100),
onConfirm: (p) {
print('longer >>> 返回数据:$p');
},
// onChanged: (p) => print(p),
);
// var list = [TranslationLoader.lanKeys.earlyArrivalList.tr, TranslationLoader.lanKeys.lateList.tr, TranslationLoader.lanKeys.hardWorkingList.tr];
// ShowBottomSheetTool().showSingleRowPicker(
// //上下文
// context,
// //默认的索引
// normalIndex: 0,
// title: "",
// cancelTitle: TranslationLoader.lanKeys.cancel.tr,
// sureTitle: TranslationLoader.lanKeys.sure.tr,
// //要显示的列表
// //可自定义数据适配器
// //adapter: PickerAdapter(),
// data: list,
// //选择事件的回调
// clickCallBack: (int index, var str) {
//
// }
// );
}
}