fix:修复部分国际化bug
This commit is contained in:
parent
178353895e
commit
b79f5d0913
@ -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<LockDetailPage>
|
||||
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<LockDetailPage>
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
const Spacer(),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
ShowTipView().showSureAlertDialog(
|
||||
@ -322,9 +326,6 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
SizedBox(width: 20.w),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 15.h,
|
||||
),
|
||||
Visibility(
|
||||
visible: state
|
||||
.keyInfos.value.lockFeature!.isSupportBackupBattery ==
|
||||
@ -388,7 +389,6 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
spreadRadius: 0,
|
||||
),
|
||||
]),
|
||||
margin: EdgeInsets.only(top: 0.h),
|
||||
child: Stack(
|
||||
alignment: AlignmentDirectional.center,
|
||||
children: <Widget>[
|
||||
@ -428,31 +428,17 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
),
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: 15.w, right: 00.w, bottom: 15.h),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
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<LockDetailPage>
|
||||
|
||||
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: <Widget>[
|
||||
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: <Widget>[
|
||||
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) ...<Widget>[
|
||||
const Spacer(),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
Get.toNamed(Routers.selectLockTypePage);
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
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) ...<Widget>[
|
||||
const Spacer(),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
Get.toNamed(Routers.selectLockTypePage);
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
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),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
]
|
||||
],
|
||||
),
|
||||
],
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -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<MessageListEntity> 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<void> deletMessageDataRequest(String messageId, BlockDeletSuccssCallback blockDeletSuccssCallback) async {
|
||||
final MessageListEntity entity = await ApiRepository.to.deletMessageLoadData(messageId:messageId);
|
||||
Future<void> 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<void> 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<ReadMessageRefreshUI>().listen((event) {
|
||||
_readMessageRefreshUIEvent =
|
||||
eventBus.on<ReadMessageRefreshUI>().listen((event) {
|
||||
pageNo = 1;
|
||||
messageListDataRequest();
|
||||
});
|
||||
@ -63,6 +67,14 @@ class MessageListLogic extends BaseGetXController {
|
||||
// messageListDataRequest();
|
||||
|
||||
_readMessageRefreshUIAction();
|
||||
|
||||
// 收到切换语言消息,重新拉取一下列表
|
||||
eventBus
|
||||
.on<ChangeLanguageBlockLastLanguageEvent>()
|
||||
.listen((ChangeLanguageBlockLastLanguageEvent event) {
|
||||
pageNo = 1;
|
||||
messageListDataRequest();
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
@ -70,5 +82,4 @@ class MessageListLogic extends BaseGetXController {
|
||||
super.onClose();
|
||||
_readMessageRefreshUIEvent?.cancel();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -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<MessageListPage>
|
||||
? TitleAppBar(
|
||||
barTitle: '消息'.tr,
|
||||
haveBack: true,
|
||||
actionsList: <Widget>[
|
||||
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: <Widget>[
|
||||
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<MessageListPage>
|
||||
],
|
||||
),
|
||||
child: _messageListItem(messageItemEntity, () {
|
||||
Get.toNamed(Routers.messageDetailPage, arguments: <String, MessageItemEntity>{
|
||||
'messageItemEntity': messageItemEntity
|
||||
});
|
||||
Get.toNamed(Routers.messageDetailPage,
|
||||
arguments: <String, MessageItemEntity>{
|
||||
'messageItemEntity': messageItemEntity
|
||||
});
|
||||
}),
|
||||
);
|
||||
}),
|
||||
@ -137,15 +140,21 @@ class _MessageListPageState extends State<MessageListPage>
|
||||
children: <Widget>[
|
||||
Row(
|
||||
children: <Widget>[
|
||||
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!,
|
||||
|
||||
@ -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<void> changeLanguage(Locale l) async {
|
||||
if(l == Get.locale)return;
|
||||
if (l == Get.locale) return;
|
||||
await Get.updateLocale(l);
|
||||
state.resetLan();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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<void> 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;
|
||||
}
|
||||
|
||||
|
||||
@ -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';
|
||||
}
|
||||
|
||||
@ -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<TitleAppBar> {
|
||||
@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) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user