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/app_settings/app_colors.dart'; import 'package:star_lock/app_settings/app_settings.dart'; import 'package:star_lock/main/lockDetail/checkingIn/checkingInSet/checkingInSet_state.dart'; import '../../../../appRouters.dart'; import '../../../../tools/commonItem.dart'; import '../../../../tools/showTFView.dart'; import '../../../../tools/showTipView.dart'; import '../../../../tools/submitBtn.dart'; import '../../../../tools/titleAppBar.dart'; import '../../../../translations/trans_lib.dart'; import 'checkingInSet_logic.dart'; class CheckingInSetPage extends StatefulWidget { const CheckingInSetPage({Key? key}) : super(key: key); @override State createState() => _CheckingInSetPageState(); } class _CheckingInSetPageState extends State { final CheckingInSetLogic logic = Get.put(CheckingInSetLogic()); final CheckingInSetState state = Get.find().state; @override Widget build(BuildContext context) { return Scaffold( backgroundColor: AppColors.mainBackgroundColor, appBar: TitleAppBar( barTitle: '${TranslationLoader.lanKeys!.checkingIn!.tr}${TranslationLoader.lanKeys!.set!.tr}', haveBack: true, backgroundColor: AppColors.mainColor), body: Column( children: [ Obx(() => CommonItem( leftTitel: '公司名称'.tr, rightTitle: state.companyName.value ?? '', // isHaveRightWidget: true, // rightWidget: getTFWidget(), isHaveLine: true, isHaveDirection: true, action: () { showCupertinoAlertDialog(context); })), Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.staff!.tr, rightTitle: state.staffNumber.value, isHaveLine: true, isHaveDirection: true, action: () { Get.toNamed(Routers.checkingInStaffManagePage, arguments: { 'getKeyInfosData': state.getKeyInfosData.value, 'companyId': state.companyId.value }); })), Obx(() => CommonItem( leftTitel: '${TranslationLoader.lanKeys!.work!.tr}${TranslationLoader.lanKeys!.time!.tr}', rightTitle: (state.beginTime.value.isNotEmpty) ? '${state.beginTime.value} - ${state.endTime.value}' : '', isHaveLine: true, isHaveDirection: true, action: () async { var data = await Get.toNamed(Routers.checkingInSetWorkTimePage, arguments: { // "getKeyInfosData": state.getKeyInfosData.value, 'companyId': state.companyId.value, 'pushType': '2', 'checkingInSetInfo': state.checkingInSetInfo.value, }); if(data != null) { setState(logic.getCheckInSetInfoData); } })), Obx(() => CommonItem( leftTitel: '${TranslationLoader.lanKeys!.workday!.tr}${TranslationLoader.lanKeys!.set!.tr}', rightTitle: state.isCustom.value == true ? state.weekDaysStr.value : (state.weekDays.value.length == 6 ? '单休' : '双休'), isHaveLine: true, isHaveDirection: true, action: () async { var data = await Get.toNamed(Routers.checkingInSetWorkdaySet, arguments: { 'getKeyInfosData': state.getKeyInfosData.value, 'companyId': state.companyId.value, 'pushType': '2', 'checkingInSetInfo': state.checkingInSetInfo.value, }); if(data != null) { state.isCustom.value = data['attendanceType']; state.weekDays.value = data['weekDays']; state.weekDaysStr.value = state.weekDays.join(','); AppLog.log('state.weekDays.value:${state.weekDays.value} state.weekDaysStr.value:${state.weekDaysStr.value}'); setState(() {}); } })), CommonItem( leftTitel: TranslationLoader.lanKeys!.holidays!.tr, rightTitle: '', isHaveLine: false, isHaveDirection: true, action: () { Get.toNamed(Routers.checkingInSetHolidaysPage, arguments: { 'companyId': state.companyId.value }); }), SizedBox( height: 30.h, ), Visibility( visible: state.getKeyInfosData.value.isLockOwner == 1, child: SubmitBtn( btnName: '${TranslationLoader.lanKeys!.delete!.tr} ${TranslationLoader.lanKeys!.company!.tr}', borderRadius: 20.w, fontSize: 32.sp, isDelete: true, margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 20.w), padding: EdgeInsets.only(top: 20.w, bottom: 20.w), onClick: () { ShowTipView().showIosTipWithContentDialog('是否删除?'.tr, logic.deletCompanyData); // showDeletCompanyAlertDialog(context); }), ), ], ), ); } void showCupertinoAlertDialog(BuildContext context) { showDialog( context: context, builder: (BuildContext context) { return ShowTFView( title: '修改公司名字'.tr, tipTitle: '', controller: state.changeNameController, inputFormatters: [ LengthLimitingTextInputFormatter(30), ], sureClick: () { if(state.changeNameController.text.isEmpty){ logic.showToast('请输入公司名字'.tr); return; } if(state.changeNameController.text.length <6){ logic.showToast('公司名字长度不能小于 6 '.tr); return; } Get.back(); logic.editCheckInSetInfoData(); }, cancelClick: () { Get.back(); },); }); } // 接受者信息输入框 Widget getTFWidget() { state.nameController.text = state.companyName.value ?? ''; return Container( // color: Colors.red, height: 65.h, width: 300.w, padding: EdgeInsets.only(top: 5.h), child: Row( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: [ Expanded( child: TextField( //输入框一行 maxLines: 1, inputFormatters: [ FilteringTextInputFormatter.deny('\n'), LengthLimitingTextInputFormatter(30), ], style: TextStyle(fontSize: 22.sp, color: AppColors.darkGrayTextColor), controller: state.nameController, autofocus: false, enabled: false, textAlign: TextAlign.end, decoration: InputDecoration( //输入里面输入文字内边距设置 // contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0), // hintText: state.companyName.value ?? "", hintStyle: TextStyle(fontSize: 22.sp), focusedBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), disabledBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), enabledBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), border: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)), contentPadding: const EdgeInsets.symmetric(vertical: 0), ), ), ), SizedBox( width: 10.w, ), ], ), ); } }