diff --git a/lib/main/lockDetail/messageWarn/addFamily/addFamily_logic.dart b/lib/main/lockDetail/messageWarn/addFamily/addFamily_logic.dart index 8bdf205f..988ef2a0 100755 --- a/lib/main/lockDetail/messageWarn/addFamily/addFamily_logic.dart +++ b/lib/main/lockDetail/messageWarn/addFamily/addFamily_logic.dart @@ -50,16 +50,29 @@ class AddFamilyLogic extends BaseGetXController { await ApiRepository.to.updateLockNoticeSettingAccount( lockNoticeSettingAccountId: state.familyData.value.id!, settingValue: { - 'openDoorId': state.familyData.value.settingValue!.openDoorId!, - 'openDoorType': state.familyData.value.settingValue!.openDoorType!, - 'remark': state.changeNameController.text, + 'openDoorId': state.isDetail.value + ? state.lockUserKeys.value.currentOpenDoorID + : state.familyData.value.settingValue!.openDoorId!, + 'openDoorType': state.isDetail.value + ? state.lockUserKeys.value.currentKeyType + : state.familyData.value.settingValue!.openDoorType!, + 'remark': state.isDetail.value + ? state.lockUserKeys.value.currentKeyName + : state.changeNameController.text, 'noticeWay': state.familyData.value.settingValue!.noticeWayList, }, ); if (entity.errorCode!.codeIsSuccessful) { showToast('更新成功'.tr); - state.lockUserKeys.value.currentKeyName = state.changeNameController.text; - Get.back(result: true); + if (!state.isDetail.value) { + state.lockUserKeys.value.currentKeyName = + state.changeNameController.text; + state.lockUserKeys.refresh(); + + Get.back(result: true); + } else { + state.lockUserKeys.refresh(); + } } } diff --git a/lib/main/lockDetail/messageWarn/addFamily/addFamily_page.dart b/lib/main/lockDetail/messageWarn/addFamily/addFamily_page.dart index 4e7f53f3..77b0425b 100755 --- a/lib/main/lockDetail/messageWarn/addFamily/addFamily_page.dart +++ b/lib/main/lockDetail/messageWarn/addFamily/addFamily_page.dart @@ -48,11 +48,16 @@ class _AddFamilyPageState extends State { isHaveDirection: true, action: () { //锁用户 - Get.toNamed(Routers.lockUserPage, arguments: { - 'getLockId': state.getLockId.value + Get.toNamed(Routers.lockUserPage, arguments: { + 'getLockId': state.getLockId.value, + 'openDoorId': state.openDoorId.value, })?.then((val) { if (val != null) { state.lockUserKeys.value = val; + + if (state.isDetail.value) { + logic.updateLockNoticeSetting(); + } } }); })), @@ -169,7 +174,7 @@ class _AddFamilyPageState extends State { ); } -//修改家人名称弹窗 + //修改家人名称弹窗 void showCupertinoAlertDialog() { showDialog( context: context, @@ -179,6 +184,10 @@ class _AddFamilyPageState extends State { '${TranslationLoader.lanKeys!.amend!.tr}${TranslationLoader.lanKeys!.name!.tr}', tipTitle: '请输入'.tr, controller: state.changeNameController, + inputFormatters: [ + FilteringTextInputFormatter.deny('\n'), + LengthLimitingTextInputFormatter(50), + ], sureClick: () { //发送编辑钥匙名称请求 if (state.changeNameController.text.isNotEmpty) { diff --git a/lib/main/lockDetail/messageWarn/addFamily/addFamily_state.dart b/lib/main/lockDetail/messageWarn/addFamily/addFamily_state.dart index 63380b14..55a359fd 100755 --- a/lib/main/lockDetail/messageWarn/addFamily/addFamily_state.dart +++ b/lib/main/lockDetail/messageWarn/addFamily/addFamily_state.dart @@ -4,21 +4,8 @@ import 'package:star_lock/main/lockDetail/messageWarn/lockUser/lockUser_entity.d import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/openDoorNotify/openDoorNotify_entity.dart'; class AddFamilyState { - final TextEditingController changeNameController = TextEditingController(); - RxInt getLockId = 0.obs; - Rx lockUserKeys = LockUserListKeys().obs; - RxList emailReceiverList = [].obs; - var phoneReceiverList = [].obs; - var emailListStr = ''.obs; - var phontListStr = ''.obs; - - var openDoorId = 0.obs; - var openDoorType = 0.obs; - var familyData = DataList().obs; - var isDetail = false.obs; - AddFamilyState() { - Map map = Get.arguments; + final Map map = Get.arguments; if (map['lockId'] != null) { getLockId.value = map['lockId']; } @@ -31,6 +18,19 @@ class AddFamilyState { familyData.value = map['itemData']; lockUserKeys.value.currentKeyName = familyData.value.settingValue!.remark!; + openDoorId.value = familyData.value.settingValue!.openDoorId!; } } + final TextEditingController changeNameController = TextEditingController(); + RxInt getLockId = 0.obs; + Rx lockUserKeys = LockUserListKeys().obs; + RxList emailReceiverList = [].obs; + RxList phoneReceiverList = [].obs; + RxString emailListStr = ''.obs; + RxString phontListStr = ''.obs; + + RxInt openDoorId = 0.obs; + RxInt openDoorType = 0.obs; + Rx familyData = DataList().obs; + RxBool isDetail = false.obs; } diff --git a/lib/main/lockDetail/messageWarn/lockUser/lockUser_logic.dart b/lib/main/lockDetail/messageWarn/lockUser/lockUser_logic.dart index e577367b..54060f5d 100755 --- a/lib/main/lockDetail/messageWarn/lockUser/lockUser_logic.dart +++ b/lib/main/lockDetail/messageWarn/lockUser/lockUser_logic.dart @@ -2,6 +2,7 @@ import 'package:get/get.dart'; import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart'; import 'package:star_lock/main/lockDetail/messageWarn/lockUser/lockUser_entity.dart'; import 'package:star_lock/main/lockDetail/messageWarn/lockUser/lockUser_state.dart'; +import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/msgNotification/msgNotification_entity.dart'; import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/dateTool.dart'; @@ -73,6 +74,17 @@ class LockUserLogic extends BaseGetXController { state.lockUserList.addAll(data5.lockUserList!); state.lockUserList.refresh(); + + if (state.selectedOpenDoorId.value != null) { + for (int i = 0; i < state.lockUserList.length; i++) { + if (state.lockUserList[i].currentOpenDoorID == + state.selectedOpenDoorId.value) { + state.isSelectIndex.value = i; + state.isSelectIndex.refresh(); + break; + } + } + } } } diff --git a/lib/main/lockDetail/messageWarn/lockUser/lockUser_page.dart b/lib/main/lockDetail/messageWarn/lockUser/lockUser_page.dart index 33dc6ba4..b86eaa89 100755 --- a/lib/main/lockDetail/messageWarn/lockUser/lockUser_page.dart +++ b/lib/main/lockDetail/messageWarn/lockUser/lockUser_page.dart @@ -21,7 +21,7 @@ class _LockUserPageState extends State { final LockUserState state = Get.find().state; @override - initState() { + void initState() { super.initState(); logic.getLockKeysList(); @@ -86,7 +86,7 @@ class _LockUserPageState extends State { if (selectIndex == i) { item.isCurrentSelect = true; } else { - item.isCurrentSelect = true; + item.isCurrentSelect = false; } } setState(() { @@ -144,13 +144,13 @@ class _LockUserPageState extends State { ], ), ), - Image.asset( - state.isSelectIndex.value == selectIndex - ? 'images/icon_round_select.png' - : 'images/icon_round_unSelect.png', - width: 30.w, - height: 30.w, - ), + Obx(() => Image.asset( + state.isSelectIndex.value == selectIndex + ? 'images/icon_round_select.png' + : 'images/icon_round_unSelect.png', + width: 30.w, + height: 30.w, + )), SizedBox(width: 20.h), ], ), diff --git a/lib/main/lockDetail/messageWarn/lockUser/lockUser_state.dart b/lib/main/lockDetail/messageWarn/lockUser/lockUser_state.dart index 1efc82ee..f045b415 100755 --- a/lib/main/lockDetail/messageWarn/lockUser/lockUser_state.dart +++ b/lib/main/lockDetail/messageWarn/lockUser/lockUser_state.dart @@ -3,17 +3,21 @@ import 'package:get/get.dart'; import 'package:star_lock/main/lockDetail/messageWarn/lockUser/lockUser_entity.dart'; class LockUserState { - TextEditingController searchController = TextEditingController(); //邮箱/手机号输入框 - var isSelectUser = false.obs; - var isSelectIndex = 0.obs; - - var getLockId = 0.obs; - var lockUserList = [].obs; //锁所有用户列表 + //锁所有用户列表 LockUserState() { - Map map = Get.arguments; + final Map map = Get.arguments; if (map['getLockId'] != null) { getLockId.value = map['getLockId']; } + + selectedOpenDoorId.value = map['openDoorId']; } + TextEditingController searchController = TextEditingController(); //邮箱/手机号输入框 + RxBool isSelectUser = false.obs; + RxInt selectedOpenDoorId = 0.obs; + RxInt isSelectIndex = 0.obs; + + RxInt getLockId = 0.obs; + RxList lockUserList = [].obs; } diff --git a/lib/main/lockDetail/messageWarn/msgNotification/openDoorNotify/openDoorNotify_page.dart b/lib/main/lockDetail/messageWarn/msgNotification/openDoorNotify/openDoorNotify_page.dart index 009619ad..33c653c1 100755 --- a/lib/main/lockDetail/messageWarn/msgNotification/openDoorNotify/openDoorNotify_page.dart +++ b/lib/main/lockDetail/messageWarn/msgNotification/openDoorNotify/openDoorNotify_page.dart @@ -24,57 +24,60 @@ class _OpenDoorNotifyPageState extends State { @override void initState() { super.initState(); - logic.lockNoticeSettingAccountList(); } @override Widget build(BuildContext context) { return Scaffold( - backgroundColor: AppColors.mainBackgroundColor, - appBar: TitleAppBar( - barTitle: '家人到家'.tr, - haveBack: true, - backgroundColor: AppColors.mainColor, - ), - body: Column( - children: [ - _topTipsWidget(), - SizedBox( - height: 20.h, + backgroundColor: AppColors.mainBackgroundColor, + appBar: TitleAppBar( + barTitle: '家人到家'.tr, + haveBack: true, + backgroundColor: AppColors.mainColor, + ), + body: Column( + children: [ + _topTipsWidget(), + SizedBox(height: 20.h), + Expanded( + child: Obx( + () => state.openDoorNotifyList.value.isNotEmpty + ? _buildMainUI() + : NoData(), ), - Expanded( - child: Obx(() => state.openDoorNotifyList.value.isNotEmpty - ? _buildMainUI() - : NoData())), - AddBottomWhiteBtn( - btnName: '添加家人'.tr, - onClick: () { - Get.toNamed(Routers.addFamilyPage, arguments: { - 'lockId': state.getLockId.value, - 'isDetail': false - })?.then((value) { - if (value != null) { - logic.lockNoticeSettingAccountList(); - } - }); - }, - ), - SizedBox( - height: 64.h, - ) - ], - )); + ), + AddBottomWhiteBtn( + btnName: '添加家人'.tr, + onClick: () { + Get.toNamed(Routers.addFamilyPage, arguments: { + 'lockId': state.getLockId.value, + 'isDetail': false, + })?.then((value) { + if (value != null) { + logic.lockNoticeSettingAccountList(); + } + }); + }, + ), + SizedBox(height: 64.h), + ], + ), + ); } Widget _topTipsWidget() { return Container( - alignment: Alignment.centerLeft, - margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w), - child: Text( - '若锁没有联网,除电子钥匙外,密码、卡、指纹等开门提醒无法及时发送,请根据你的实际情况选择。'.tr, - style: TextStyle(color: AppColors.darkGrayTextColor, fontSize: 20.sp), - )); + alignment: Alignment.centerLeft, + margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w), + child: Text( + '若锁没有联网,除电子钥匙外,密码、卡、指纹等开门提醒无法及时发送,请根据你的实际情况选择。'.tr, + style: TextStyle( + color: AppColors.darkGrayTextColor, + fontSize: 20.sp, + ), + ), + ); } Widget _buildMainUI() { @@ -99,11 +102,9 @@ class _OpenDoorNotifyPageState extends State { Get.toNamed(Routers.addFamilyPage, arguments: { 'itemData': itemData, 'lockId': state.getLockId.value, - 'isDetail': true + 'isDetail': true, })?.then((value) { - if (value != null) { - logic.lockNoticeSettingAccountList(); - } + logic.lockNoticeSettingAccountList(); }); }, child: Container( @@ -111,33 +112,30 @@ class _OpenDoorNotifyPageState extends State { height: 90.h, child: Row( children: [ - SizedBox( - width: 30.w, - ), + SizedBox(width: 30.w), Image.asset( 'images/controls_user.png', width: 60.w, height: 60.w, ), - SizedBox( - width: 20.w, - ), + SizedBox(width: 20.w), Expanded( child: Column( mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( children: [ - Text( - itemData.settingValue!.remark ?? '', - style: TextStyle( - fontSize: 24.sp, color: AppColors.blackColor), - ), - SizedBox(width: 10.w), Expanded( - child: SizedBox( - width: 20.w, - )) + child: Text( + itemData.settingValue!.remark ?? '', + style: TextStyle( + fontSize: 24.sp, + color: AppColors.blackColor, + ), + overflow: TextOverflow.ellipsis, + ), + ), ], ), SizedBox(height: 10.h), @@ -147,8 +145,9 @@ class _OpenDoorNotifyPageState extends State { Text( logic.getKeyTypeStr(itemData), style: TextStyle( - fontSize: 18.sp, - color: AppColors.placeholderTextColor), + fontSize: 18.sp, + color: AppColors.placeholderTextColor, + ), ), ], ),