import 'package:date_format/date_format.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/main/lockDetail/checkingIn/checkingInHolidays/checkingInAddHolidays/checkingInAddHolidays_state.dart'; import '../../../../../app_settings/app_colors.dart'; import '../../../../../tools/commonItem.dart'; import '../../../../../tools/showCalendar.dart'; import '../../../../../tools/submitBtn.dart'; import '../../../../../tools/titleAppBar.dart'; import '../../../../../translations/trans_lib.dart'; import 'checkingInAddHolidays_logic.dart'; class CheckingInAddHolidaysPage extends StatefulWidget { const CheckingInAddHolidaysPage({Key? key}) : super(key: key); @override State createState() => _CheckingInAddHolidaysPageState(); } class _CheckingInAddHolidaysPageState extends State { final CheckingInAddHolidaysLogic logic = Get.put(CheckingInAddHolidaysLogic()); final CheckingInAddHolidaysState state = Get.find().state; @override Widget build(BuildContext context) { return Scaffold( backgroundColor: AppColors.mainBackgroundColor, appBar: TitleAppBar( barTitle: TranslationLoader.lanKeys!.addedHoliday!.tr, haveBack: true, backgroundColor: AppColors.mainColor), body: Column( children: [ CommonItem( leftTitel: TranslationLoader.lanKeys!.name!.tr, rightTitle: '', isHaveLine: true, isHaveRightWidget: true, setHeight: false, rightWidget: getTFWidget( '(${TranslationLoader.lanKeys!.mustFillIn!.tr})', maxSize: 50)), Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.startDate!.tr, rightTitle: state.beginDate.value.isEmpty ? '(${TranslationLoader.lanKeys!.mustFillIn!.tr})' : state.beginDate.value, isHaveLine: true, isHaveDirection: false, action: () async { await showDialog( context: context, builder: (BuildContext context) { return ShowCalendar( datePickerMode: DatePickerMode.day, selectAction: (DateTime dateTime) { final String beginDate = formatDate( dateTime, [yyyy, '-', mm, '-', dd]); state.beginDate.value = beginDate; Get.back(); // Navigator.of(context).pop(true); }); }); })), Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.endDate!.tr, rightTitle: state.endDate.value.isEmpty ? '(${TranslationLoader.lanKeys!.mustFillIn!.tr})' : state.endDate.value, isHaveLine: true, isHaveDirection: false, action: () async { await showDialog( context: context, builder: (BuildContext context) { return ShowCalendar( datePickerMode: DatePickerMode.day, selectAction: (DateTime dateTime) { final String endDate = formatDate( dateTime, [yyyy, '-', mm, '-', dd]); state.endDate.value = endDate; Get.back(); }); }); })), Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.coverDate!.tr, rightTitle: state.makeUpWorkDate.value, isHaveLine: false, isHaveDirection: false, action: () async { await showDialog( context: context, builder: (BuildContext context) { return ShowCalendar( datePickerMode: DatePickerMode.day, selectAction: (DateTime dateTime) { final String makeUpWorkDate = formatDate( dateTime, [yyyy, '-', mm, '-', dd]); state.makeUpWorkDate.value = makeUpWorkDate; Get.back(); }); }); })), SizedBox( height: 50.w, ), SubmitBtn( btnName: TranslationLoader.lanKeys!.sure!.tr, borderRadius: 20.w, margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w), padding: EdgeInsets.only(top: 25.w, bottom: 25.w), onClick: () { logic.editStaffLoadData(); }), ], ), ); } Widget getTFWidget(String tfStr, {int maxSize = 30}) { return Expanded( child: TextField( //输入框一行 maxLines: 2, minLines: 1, controller: state.staffNameController, autofocus: false, textAlign: TextAlign.end, decoration: InputDecoration( //输入里面输入文字内边距设置 contentPadding: const EdgeInsets.only(bottom: 3), hintText: tfStr, hintStyle: TextStyle( fontSize: 22.sp, color: AppColors.darkGrayTextColor, height: 1), //不需要输入框下划线 border: InputBorder.none, isCollapsed: true, ), inputFormatters: [ LengthLimitingTextInputFormatter(maxSize), ], ), ); } Widget whetherTheEmployeeHasAKeyWidget(String title, Function action) { return GestureDetector( onTap: () {}, child: Row( children: [ Image.asset( 'images/icon_round_unSelect.png', width: 40.w, height: 40.w, ), SizedBox( width: 5.w, ), Text(title), ], ), ); } }