Browse Source

refactor(settings): 优化语言设置逻辑,直接使用Get.deviceLocale,修复

fix(permissions): 移除权限成功时的消息显示

chore(splash): 注释掉隐私协议和用户协议的点击事件
weicu
lxm 1 year ago
parent
commit
8c8b3f9809
  1. 4
      lib/core/translations/app_translations.dart
  2. 2
      lib/modules/permissions/controllers/permissions_controller.dart
  3. 8
      lib/modules/settings/controllers/settings_controller.dart
  4. 46
      lib/modules/splash/views/splash_view.dart

4
lib/core/translations/app_translations.dart

@ -186,11 +186,11 @@ class AppTranslations extends Translations {
return fallbackLocale;
}
return _getMatchedLocale(systemLocale);
return getMatchedLocale(systemLocale);
}
/// 智能匹配系统语言到支持的语言
static Locale _getMatchedLocale(Locale systemLocale) {
static Locale getMatchedLocale(Locale systemLocale) {
String languageCode = systemLocale.languageCode.toLowerCase();
String? countryCode = systemLocale.countryCode?.toUpperCase();
String? scriptCode = systemLocale.scriptCode;

2
lib/modules/permissions/controllers/permissions_controller.dart

@ -184,7 +184,7 @@ class PermissionsController extends GetxController {
);
if (hasPermission) {
_showSuccessMessage();
// _showSuccessMessage();
if (Platform.isIOS && permission == Permission.calendarFullAccess) {
if (_isCalendarFullAccess == null) {
_storage.write('record_permission_calendar', true);

8
lib/modules/settings/controllers/settings_controller.dart

@ -301,9 +301,11 @@ class SettingsController extends GetxController {
}
}
/// 设置语言
Future<void> setLanguage(LanguageModel data) async {
try {
Locale? targetLocale;
// print('lxm--设置语言: ${data.value}');
if (data.value != 'system') {
// 用户手动选择的语言
@ -311,7 +313,11 @@ class SettingsController extends GetxController {
targetLocale = Locale(languageList[0], languageList[1]);
} else {
// 跟随系统语言,使用智能匹配
targetLocale = AppTranslations.deviceLocale();
targetLocale = Get.deviceLocale;
if (targetLocale != null) {
// 智能匹配系统语言到支持的语言
targetLocale = AppTranslations.getMatchedLocale(targetLocale);
}
}
if (targetLocale != null) {

46
lib/modules/splash/views/splash_view.dart

@ -225,7 +225,7 @@ class SplashView extends GetView<SplashController> {
children: [
// 将勾选框和文本包装在 GestureDetector 中
GestureDetector(
onTap: () => controller.togglePrivacyAcceptance(),
//onTap: () => controller.togglePrivacyAcceptance(),
behavior: HitTestBehavior.opaque, // 确保透明区域也能响应点击
child: Row(
children: [
@ -267,17 +267,17 @@ class SplashView extends GetView<SplashController> {
mainAxisAlignment: MainAxisAlignment.center,
children: [
GestureDetector(
onTap: () {
String url = 'https://www.voitrans.net/doc/yhxy.html'; // 用户协议链接
if (Get.locale?.languageCode != 'zh' ||
Get.locale?.countryCode != 'CN') {
url = 'https://www.voitrans.net/doc/yhxy_en.html'; // 用户协议英文链接
}
Get.to(() => WebViewPage(
url: url,
title: 'userAgreement'.tr,
));
},
// onTap: () {
// String url = 'https://www.voitrans.net/doc/yhxy.html'; // 用户协议链接
// if (Get.locale?.languageCode != 'zh' ||
// Get.locale?.countryCode != 'CN') {
// url = 'https://www.voitrans.net/doc/yhxy_en.html'; // 用户协议英文链接
// }
// Get.to(() => WebViewPage(
// url: url,
// title: 'userAgreement'.tr,
// ));
// },
child: Text(
'userAgreement'.tr, // 《用户协议》
style: TextStyle(
@ -294,19 +294,19 @@ class SplashView extends GetView<SplashController> {
),
),
GestureDetector(
onTap: () {
String url = 'https://www.voitrans.net/doc/ysxy.html'; // 隐私政策链接
// onTap: () {
// String url = 'https://www.voitrans.net/doc/ysxy.html'; // 隐私政策链接
if (Get.locale?.languageCode != 'zh' ||
Get.locale?.countryCode != 'CN') {
url = 'https://www.voitrans.net/doc/ysxy_en.html'; // 隐私政策英文链接
}
// if (Get.locale?.languageCode != 'zh' ||
// Get.locale?.countryCode != 'CN') {
// url = 'https://www.voitrans.net/doc/ysxy_en.html'; // 隐私政策英文链接
// }
Get.to(() => WebViewPage(
url: url,
title: 'privacyPolicy'.tr,
));
},
// Get.to(() => WebViewPage(
// url: url,
// title: 'privacyPolicy'.tr,
// ));
// },
child: Text(
'privacyPolicy'.tr, // 《隐私政策》
style: TextStyle(

Loading…
Cancel
Save