From b79f5d0913af44c84441fce54dd779fc38dff14a Mon Sep 17 00:00:00 2001 From: liyi Date: Thu, 21 Nov 2024 18:11:11 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E9=83=A8=E5=88=86?= =?UTF-8?q?=E5=9B=BD=E9=99=85=E5=8C=96bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lockDetail/lockDetail_page.dart | 225 +++++++++--------- .../messageList/messageList_logic.dart | 31 ++- .../message/messageList/messageList_page.dart | 71 +++--- .../mineMultiLanguage_logic.dart | 9 +- lib/mine/mineSet/mineSet/mineSet_logic.dart | 13 +- lib/tools/langue/langue_tool.dart | 3 + lib/tools/titleAppBar.dart | 7 +- 7 files changed, 199 insertions(+), 160 deletions(-) diff --git a/lib/main/lockDetail/lockDetail/lockDetail_page.dart b/lib/main/lockDetail/lockDetail/lockDetail_page.dart index f9bf8c35..9872cd6f 100755 --- a/lib/main/lockDetail/lockDetail/lockDetail_page.dart +++ b/lib/main/lockDetail/lockDetail/lockDetail_page.dart @@ -1,6 +1,8 @@ import 'dart:async'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; @@ -275,6 +277,9 @@ class _LockDetailPageState extends State return Container( width: 0.9.sw, height: 0.6.sw, + constraints: BoxConstraints( + minHeight: 0.6.sw, + ), decoration: BoxDecoration( image: const DecorationImage( image: AssetImage('images/xhj_main_bg.jpg'), @@ -293,7 +298,6 @@ class _LockDetailPageState extends State child: Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ - const Spacer(), GestureDetector( onTap: () { ShowTipView().showSureAlertDialog( @@ -322,9 +326,6 @@ class _LockDetailPageState extends State SizedBox(width: 20.w), ], ), - SizedBox( - height: 15.h, - ), Visibility( visible: state .keyInfos.value.lockFeature!.isSupportBackupBattery == @@ -388,7 +389,6 @@ class _LockDetailPageState extends State spreadRadius: 0, ), ]), - margin: EdgeInsets.only(top: 0.h), child: Stack( alignment: AlignmentDirectional.center, children: [ @@ -428,31 +428,17 @@ class _LockDetailPageState extends State ), ), ), - const Spacer(), - Padding( - padding: EdgeInsets.only(left: 15.w, right: 00.w, bottom: 15.h), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Text( - '点击开锁,长按闭锁'.tr, - style: TextStyle( - color: AppColors.darkGrayTextColor, - fontSize: 20.sp, - ), - ), - SizedBox( - height: 16.h, - ), - adminInfoView(center: false, max: false), - ], - ), - ], + Expanded( + child: Text( + '点击开锁,长按闭锁'.tr, + textAlign: TextAlign.center, + style: TextStyle( + color: AppColors.darkGrayTextColor, + fontSize: 20.sp, + ), ), - ) + ), + adminInfoView(center: false, max: false), ], ), ); @@ -762,90 +748,109 @@ class _LockDetailPageState extends State Widget adminInfoView( {bool center = true, bool max = true, bool add = false}) { - return Row( - mainAxisAlignment: - center ? MainAxisAlignment.center : MainAxisAlignment.start, - mainAxisSize: max ? MainAxisSize.max : MainAxisSize.min, - children: [ - Image.asset( - 'images/icon_electronicKey_admin.png', - width: 24.w, - height: 20.w, - color: AppColors.blackColor, //应根据状态显示(当前角色为超级管理员 应显示蓝色图标) - ), - SizedBox(width: 6.w), - Text( - state.keyInfos.value.isLockOwner == 1 - ? '超级管理员'.tr - : (state.keyInfos.value.keyRight == 1 ? '授权管理员'.tr : '普通用户'.tr), - style: TextStyle(fontSize: 20.sp, color: AppColors.darkGrayTextColor), - ), - if (add) SizedBox(width: 20.w) else SizedBox(width: 40.w), - FlavorsImg( - child: Image.asset( - state.keyInfos.value.hasGateway == 1 - ? 'images/main/icon_main_remoteUnlocking.png' - : 'images/main/icon_main_remoteUnlocking_grey.png', - width: 24.w, - height: 20.w, + return Expanded( + child: Wrap( + children: [ + Row( + mainAxisSize: max ? MainAxisSize.max : MainAxisSize.min, + children: [ + Image.asset( + 'images/icon_electronicKey_admin.png', + width: 24.w, + height: 20.w, + color: AppColors.blackColor, //应根据状态显示(当前角色为超级管理员 应显示蓝色图标) + ), + SizedBox(width: 6.w), + Text( + state.keyInfos.value.isLockOwner == 1 + ? '超级管理员'.tr + : (state.keyInfos.value.keyRight == 1 + ? '授权管理员'.tr + : '普通用户'.tr), + style: TextStyle( + fontSize: 20.sp, color: AppColors.darkGrayTextColor), + ), + if (add) SizedBox(width: 20.w) else SizedBox(width: 40.w), + ], ), - ), - SizedBox(width: 6.w), - Text( - '网关设备'.tr, - style: TextStyle( - fontSize: 20.sp, - color: state.keyInfos.value.hasGateway == 1 - ? AppColors.mainColor - : AppColors.btnDisableColor), - ), - if (add) SizedBox(width: 20.w) else SizedBox(width: 20.w), - FlavorsImg( - child: Image.asset('images/main/icon_lockDetail_needNetwork.png', - width: 24.w, - height: 20.w, - color: state.isOpenLockNeedOnline.value == 1 - ? AppColors.mainColor - : AppColors.btnDisableColor), - ), - SizedBox(width: 6.w), - Text( - '手机需联网'.tr, - style: TextStyle( - fontSize: 20.sp, - color: state.isOpenLockNeedOnline.value == 1 - ? AppColors.mainColor - : AppColors.btnDisableColor), - ), - if (add) ...[ - const Spacer(), - GestureDetector( - onTap: () { - Get.toNamed(Routers.selectLockTypePage); - }, - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - FlavorsImg( - child: Image.asset( - 'images/mine/icon_mine_main_addLock.png', - width: 24.w, - height: 20.w, + Row( + mainAxisSize: max ? MainAxisSize.max : MainAxisSize.min, + children: [ + FlavorsImg( + child: Image.asset( + state.keyInfos.value.hasGateway == 1 + ? 'images/main/icon_main_remoteUnlocking.png' + : 'images/main/icon_main_remoteUnlocking_grey.png', + width: 24.w, + height: 20.w, + ), + ), + SizedBox(width: 6.w), + Text( + '网关设备'.tr, + style: TextStyle( + fontSize: 20.sp, + color: state.keyInfos.value.hasGateway == 1 + ? AppColors.mainColor + : AppColors.btnDisableColor), + ), + if (add) SizedBox(width: 20.w) else SizedBox(width: 20.w), + ], + ), + Row( + mainAxisSize: max ? MainAxisSize.max : MainAxisSize.min, + children: [ + FlavorsImg( + child: Image.asset( + 'images/main/icon_lockDetail_needNetwork.png', + width: 24.w, + height: 20.w, + color: state.isOpenLockNeedOnline.value == 1 + ? AppColors.mainColor + : AppColors.btnDisableColor), + ), + SizedBox(width: 6.w), + Text( + '手机需联网'.tr, + style: TextStyle( + fontSize: 20.sp, + color: state.isOpenLockNeedOnline.value == 1 + ? AppColors.mainColor + : AppColors.btnDisableColor), + ), + if (add) ...[ + const Spacer(), + GestureDetector( + onTap: () { + Get.toNamed(Routers.selectLockTypePage); + }, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + FlavorsImg( + child: Image.asset( + 'images/mine/icon_mine_main_addLock.png', + width: 24.w, + height: 20.w, + ), + ), + Text( + '添加设备'.tr, + style: TextStyle( + fontSize: 20.sp, + color: AppColors.darkGrayTextColor), + ) + ], ), ), - Text( - '添加设备'.tr, - style: TextStyle( - fontSize: 20.sp, color: AppColors.darkGrayTextColor), - ) - ], - ), - ), - ), - ] - ], + ), + ], + ], + ) + ], + ), ); } diff --git a/lib/mine/message/messageList/messageList_logic.dart b/lib/mine/message/messageList/messageList_logic.dart index 8541d183..6c119cee 100755 --- a/lib/mine/message/messageList/messageList_logic.dart +++ b/lib/mine/message/messageList/messageList_logic.dart @@ -1,4 +1,3 @@ - import 'dart:async'; import 'package:star_lock/tools/baseGetXController.dart'; @@ -8,14 +7,14 @@ import 'messageList_entity.dart'; import 'messageList_state.dart'; typedef BlockDeletSuccssCallback = void Function(); + class MessageListLogic extends BaseGetXController { final MessageListState state = MessageListState(); //请求消息列表 Future messageListDataRequest() async { - final MessageListEntity entity = await ApiRepository.to.messageListLoadData( - pageNo:pageNo.toString(), - pageSize:pageSize); + final MessageListEntity entity = await ApiRepository.to + .messageListLoadData(pageNo: pageNo.toString(), pageSize: pageSize); if (entity.errorCode!.codeIsSuccessful) { if (pageNo == 1) { state.itemDataList.value = entity.data!.list!; @@ -31,8 +30,10 @@ class MessageListLogic extends BaseGetXController { } // 删除消息 - Future deletMessageDataRequest(String messageId, BlockDeletSuccssCallback blockDeletSuccssCallback) async { - final MessageListEntity entity = await ApiRepository.to.deletMessageLoadData(messageId:messageId); + Future deletMessageDataRequest(String messageId, + BlockDeletSuccssCallback blockDeletSuccssCallback) async { + final MessageListEntity entity = + await ApiRepository.to.deletMessageLoadData(messageId: messageId); if (entity.errorCode!.codeIsSuccessful) { blockDeletSuccssCallback(); } @@ -40,7 +41,8 @@ class MessageListLogic extends BaseGetXController { // 清空消息 Future deletAllMessageDataRequest() async { - final MessageListEntity entity = await ApiRepository.to.deletAllMessageLoadData(); + final MessageListEntity entity = + await ApiRepository.to.deletAllMessageLoadData(); if (entity.errorCode!.codeIsSuccessful) { pageNo = 1; messageListDataRequest(); @@ -49,9 +51,11 @@ class MessageListLogic extends BaseGetXController { // 刷新消息列表 StreamSubscription? _readMessageRefreshUIEvent; + void _readMessageRefreshUIAction() { // 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus - _readMessageRefreshUIEvent = eventBus.on().listen((event) { + _readMessageRefreshUIEvent = + eventBus.on().listen((event) { pageNo = 1; messageListDataRequest(); }); @@ -63,6 +67,14 @@ class MessageListLogic extends BaseGetXController { // messageListDataRequest(); _readMessageRefreshUIAction(); + + // 收到切换语言消息,重新拉取一下列表 + eventBus + .on() + .listen((ChangeLanguageBlockLastLanguageEvent event) { + pageNo = 1; + messageListDataRequest(); + }); } @override @@ -70,5 +82,4 @@ class MessageListLogic extends BaseGetXController { super.onClose(); _readMessageRefreshUIEvent?.cancel(); } - -} \ No newline at end of file +} diff --git a/lib/mine/message/messageList/messageList_page.dart b/lib/mine/message/messageList/messageList_page.dart index cbaed343..dd0cb4ed 100755 --- a/lib/mine/message/messageList/messageList_page.dart +++ b/lib/mine/message/messageList/messageList_page.dart @@ -1,9 +1,9 @@ - import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_slidable/flutter_slidable.dart'; import 'package:get/get.dart'; import 'package:star_lock/mine/message/messageList/messageList_state.dart'; +import 'package:star_lock/tools/eventBusEventManage.dart'; import 'package:star_lock/tools/noData.dart'; import '../../../appRouters.dart'; @@ -50,24 +50,26 @@ class _MessageListPageState extends State ? TitleAppBar( barTitle: '消息'.tr, haveBack: true, - actionsList: [ - TextButton( - child: Text( - '清空'.tr, - style: TextStyle(color: Colors.white, fontSize: 24.sp), - ), - onPressed: () async { - final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); - if (isDemoMode == false) { - ShowTipView().showIosTipWithContentDialog('是否清空?'.tr, () async { - logic.deletAllMessageDataRequest(); - }); - } else { - logic.showToast('演示模式'.tr); - } - }, - ), - ], + actionsList: [ + TextButton( + child: Text( + '清空'.tr, + style: TextStyle(color: Colors.white, fontSize: 24.sp), + ), + onPressed: () async { + final bool? isDemoMode = + await Storage.getBool(ifIsDemoModeOrNot); + if (isDemoMode == false) { + ShowTipView().showIosTipWithContentDialog('是否清空?'.tr, + () async { + logic.deletAllMessageDataRequest(); + }); + } else { + logic.showToast('演示模式'.tr); + } + }, + ), + ], backgroundColor: AppColors.mainColor) : null, body: EasyRefreshTool(onRefresh: () { @@ -106,9 +108,10 @@ class _MessageListPageState extends State ], ), child: _messageListItem(messageItemEntity, () { - Get.toNamed(Routers.messageDetailPage, arguments: { - 'messageItemEntity': messageItemEntity - }); + Get.toNamed(Routers.messageDetailPage, + arguments: { + 'messageItemEntity': messageItemEntity + }); }), ); }), @@ -137,15 +140,21 @@ class _MessageListPageState extends State children: [ Row( children: [ - if (messageItemEntity.readAt! == 0) Container( - width: 10.w, - height: 10.w, - decoration: BoxDecoration( - color: Colors.red, - borderRadius: BorderRadius.circular(5.w), - ), - ) else Container(), - if (messageItemEntity.readAt! == 0) SizedBox(width: 5.w) else Container(), + if (messageItemEntity.readAt! == 0) + Container( + width: 10.w, + height: 10.w, + decoration: BoxDecoration( + color: Colors.red, + borderRadius: BorderRadius.circular(5.w), + ), + ) + else + Container(), + if (messageItemEntity.readAt! == 0) + SizedBox(width: 5.w) + else + Container(), Flexible( child: Text( messageItemEntity.data!, diff --git a/lib/mine/mineMultiLanguage/mineMultiLanguage_logic.dart b/lib/mine/mineMultiLanguage/mineMultiLanguage_logic.dart index cbfeed66..0c1ee11c 100755 --- a/lib/mine/mineMultiLanguage/mineMultiLanguage_logic.dart +++ b/lib/mine/mineMultiLanguage/mineMultiLanguage_logic.dart @@ -1,4 +1,3 @@ - import 'dart:ui'; import 'package:get/get.dart'; import 'package:star_lock/app_settings/app_settings.dart'; @@ -16,16 +15,18 @@ class MineMultiLanguageLogic extends GetxController { // AppLog.log('lanTypeTitle: $lanTypeTitle'); final String lang = l.toLanguageTag(); - final PasswordKeyListEntity entity = await ApiRepository.to.updateUserLangInfo(lang: lang); + final PasswordKeyListEntity entity = + await ApiRepository.to.updateUserLangInfo(lang: lang); if (entity.errorCode!.codeIsSuccessful) { await changeLanguage(l); eventBus.fire(ChangeLanguageBlockLastLanguageEvent()); + print('发送语言变化事件'); } } Future changeLanguage(Locale l) async { - if(l == Get.locale)return; + if (l == Get.locale) return; await Get.updateLocale(l); state.resetLan(); } -} \ No newline at end of file +} diff --git a/lib/mine/mineSet/mineSet/mineSet_logic.dart b/lib/mine/mineSet/mineSet/mineSet_logic.dart index 29eacf09..fd0dc965 100755 --- a/lib/mine/mineSet/mineSet/mineSet_logic.dart +++ b/lib/mine/mineSet/mineSet/mineSet_logic.dart @@ -1,4 +1,3 @@ - import 'dart:async'; import 'package:flutter/material.dart'; @@ -25,6 +24,7 @@ import '../../../translations/app_dept.dart'; class MineSetLogic extends BaseGetXController { final MineSetState state = MineSetState(); + //用户信息 Future userSettingsInfoRequest() async { final UserSettingInfoEntity entity = @@ -108,7 +108,8 @@ class MineSetLogic extends BaseGetXController { getPushDeviceID = value; } }); - final LoginEntity entity = await ApiRepository.to.userLogout(deviceld: getPushDeviceID); + final LoginEntity entity = + await ApiRepository.to.userLogout(deviceld: getPushDeviceID); if (entity.errorCode!.codeIsSuccessful) { UdpHelp().closeUDP(); logOut(); @@ -148,10 +149,14 @@ class MineSetLogic extends BaseGetXController { String _getCurrentLanguage() { String? languageCode = StoreService.to.getLanguageCode(); - if(languageCode!.isEmpty){ + if (languageCode!.isEmpty) { languageCode = Get.deviceLocale!.languageCode; } - final String currentLanguage = ExtensionLanguageType.fromLocale(appDept.deptSupportedLocales.where((Locale element) => element.languageCode == languageCode).first).lanTitle; + final String currentLanguage = ExtensionLanguageType.fromLocale(appDept + .deptSupportedLocales + .where((Locale element) => element.languageCode == languageCode) + .first) + .lanTitle; return currentLanguage; } diff --git a/lib/tools/langue/langue_tool.dart b/lib/tools/langue/langue_tool.dart index b8013d7a..36715085 100644 --- a/lib/tools/langue/langue_tool.dart +++ b/lib/tools/langue/langue_tool.dart @@ -10,4 +10,7 @@ class LanguageTool { String get currentLanguage => Get.locale?.languageCode ?? 'zh'; bool get isChinese => currentLanguage == 'zh'; + + bool get isArabic => currentLanguage == 'ar'; + bool get isHebrew => currentLanguage == 'he'; } diff --git a/lib/tools/titleAppBar.dart b/lib/tools/titleAppBar.dart index bffe2184..adf5c792 100755 --- a/lib/tools/titleAppBar.dart +++ b/lib/tools/titleAppBar.dart @@ -3,6 +3,7 @@ import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:star_lock/app_settings/app_colors.dart'; import 'package:star_lock/flavors.dart'; +import 'package:star_lock/tools/langue/langue_tool.dart'; class TitleAppBar extends AppBar { @override @@ -40,13 +41,17 @@ class TitleAppBar extends AppBar { class _TitleAppBarState extends State { @override Widget build(BuildContext context) { + bool isRTL = + LanguageTool.instance.isArabic || LanguageTool.instance.isHebrew; + return AppBar( elevation: 0, leading: widget.haveOtherLeftWidget! ? widget.leftWidget : (widget.haveBack ?? false ? IconButton( - icon: Icon(Icons.arrow_back_ios, + icon: Icon( + isRTL ? Icons.arrow_forward_ios : Icons.arrow_back_ios, color: widget.iconColor ?? Colors.white), onPressed: () { if (widget.backAction != null) {