import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/appRouters.dart'; import 'package:star_lock/main/lockDetail/messageWarn/addFamily/addFamily_logic.dart'; import 'package:star_lock/tools/commonItem.dart'; import 'package:star_lock/tools/submitBtn.dart'; import '../../../../../app_settings/app_colors.dart'; import '../../../../../tools/titleAppBar.dart'; class AddFamilyPage extends StatefulWidget { const AddFamilyPage({Key? key}) : super(key: key); @override State createState() => _AddFamilyPageState(); } class _AddFamilyPageState extends State { final logic = Get.put(AddFamilyLogic()); final state = Get.find().state; @override Widget build(BuildContext context) { return Scaffold( backgroundColor: AppColors.mainBackgroundColor, appBar: TitleAppBar( barTitle: state.isDetail.value ? '家人详情'.tr : '添加家人'.tr, haveBack: true, backgroundColor: AppColors.mainColor), body: Container( padding: EdgeInsets.all(30.w), child: Column( children: [ Obx(() => CommonItem( leftTitel: '开门方式'.tr, rightTitle: state.isDetail.value ? logic.getKeyTypeStr() : state.lockUserKeys.value.currentKeyTypeStr ?? '请选择'.tr, isHaveLine: true, isHaveDirection: true, action: () { //锁用户 Get.toNamed(Routers.lockUserPage, arguments: {'getLockId': state.getLockId.value}) ?.then((val) { if (val != null) { state.lockUserKeys.value = val; } }); })), Obx(() => CommonItem( leftTitel: '家人'.tr, rightTitle: state.isDetail.value ? state.familyData.value.settingValue?.remark : state.lockUserKeys.value.currentKeyName, isHaveLine: true, isHaveRightWidget: state.lockUserKeys.value.currentKeyName == null ? true : false, isHaveDirection: false, rightWidget: getFamilyWidget('请输入'.tr), )), SizedBox( height: 20.h, ), Container( color: Colors.white, margin: EdgeInsets.only(bottom: 10.h), child: Column( children: [ CommonItem( leftTitel: '提醒方式'.tr, rightTitle: "", isHaveLine: false, isHaveRightWidget: false, isHaveDirection: true, action: () { Get.toNamed(Routers.notificationModePage)?.then((val) { if (val != null) { state.emailListStr.value = logic.getEmailListStr(val); state.phontListStr.value = logic.getPhoneListStr(val); print( 'emailListStr:${state.emailListStr.value},phontListStr:${state.phontListStr.value}'); } }); }, ), _buildNotifyContain('APP推送'.tr, '管理员'.tr), Obx(() => state.emailListStr.value.isNotEmpty ? _buildNotifyContain('邮件提醒'.tr, state.emailListStr.value) : Container()), Obx(() => state.phontListStr.value.isNotEmpty ? _buildNotifyContain('短信提醒'.tr, state.phontListStr.value) : Container()), ], ), ), Expanded( child: SizedBox( height: 40.h, )), Obx(() => SubmitBtn( btnName: state.isDetail.value == true ? '删除'.tr : '保存'.tr, isDisabled: state.isDetail.value == true ? true : logic.checkBtnDisable(), isDelete: state.isDetail.value, onClick: () { if (state.isDetail.value) { logic.deleteLockNoticeSetting(); } else { logic.addLockNoticeSetting(); } }, )), SizedBox( height: 60.h, ) ], ), ), ); } Widget _buildNotifyContain(String notifyTitle, String notifyContent) { return Container( padding: EdgeInsets.only(left: 10.w, right: 10.w, top: 12.h, bottom: 12.h), margin: EdgeInsets.only(bottom: 20.h, top: 10.h, left: 20.w, right: 20.w), decoration: BoxDecoration( color: AppColors.mainBackgroundColor, borderRadius: BorderRadius.circular(6.0.w), ), child: Row( children: [ Text( notifyTitle, style: TextStyle(color: Colors.black, fontSize: 20.sp), ), Expanded( child: SizedBox( width: 20.w, )), Text(notifyContent, textAlign: TextAlign.end, style: TextStyle( color: AppColors.placeholderTextColor, fontSize: 20.sp)), ], ), ); } // 接受者邮箱输入框 Widget getFamilyWidget(String tfStr) { TextEditingController emailController = TextEditingController(); if (state.isDetail.value) { emailController.text = state.familyData.value.settingValue?.remark ?? ''; } return SizedBox( height: 50.h, width: 360.w, child: Row( children: [ Expanded( child: TextField( controller: emailController, //输入框一行 maxLines: 1, autofocus: false, textAlign: TextAlign.end, style: TextStyle(fontSize: 22.sp), decoration: InputDecoration( //输入里面输入文字内边距设置 contentPadding: const EdgeInsets.only(top: -12.0, bottom: 0.0), hintText: tfStr, hintStyle: TextStyle(fontSize: 22.sp), //不需要输入框下划线 border: InputBorder.none, ), ), ), ], ), ); } }