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 { const CheckingInSetHolidaysPage({Key? key}) : super(key: key); @override State createState() => _CheckingInSetHolidaysPageState(); } class _CheckingInSetHolidaysPageState extends State { @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, ), ], ), body: ListView.builder( itemCount: 10, itemBuilder: (c, index) { return _checkingInListItem('images/icon_lock.png', "张三", "2023.6.21 11.15", "2023.6.21 11.15", () { // Navigator.pushNamed(context, Routers.electronicKeyDetailPage); }); })); } Widget _checkingInListItem(String lockTypeIcon, String lockTypeTitle, String beginTime, String endTime, Function() action) { return GestureDetector( onTap: action, child: Container( height: 140.h, margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(10.w), ), child: Row( children: [ Container( color: const Color(0xFFAFB5D7), 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, ), Expanded( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Container( // color: Colors.red, child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( lockTypeTitle, style: TextStyle(fontSize: 24.sp), ), ], ), ), SizedBox(height: 10.h), 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), ), ], ), ), SizedBox(height: 5.h), Container( child: Row( mainAxisAlignment: MainAxisAlignment.start, children: [ Text( "${TranslationLoader.lanKeys!.coverDate!.tr}:2023.6.21 11.15", style: TextStyle(fontSize: 20.sp), ), ], ), ), ], ), ), SizedBox(width: 20.h), ], ), ), ); } Widget titleWidget() { return GestureDetector( onTap: () { 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, ) ], ), ); } void showListType() { Pickers.showDatePicker( context, // 模式,详见下方 mode: DateMode.Y, // 后缀 默认Suffix.normal(),为空的话Suffix() suffix: Suffix(years: ' 年'), // 样式 详见下方样式 pickerStyle: PickerStyle( cancelButton: GestureDetector( onTap: () {}, 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)), ), ), commitButton: GestureDetector( onTap: () {}, child: Container( alignment: Alignment.center, padding: const EdgeInsets.only(left: 22, right: 12), child: Text(TranslationLoader.lanKeys!.sure!.tr, 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) { // // } // ); } }