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 fallbackLocale;
} }
return _getMatchedLocale(systemLocale); return getMatchedLocale(systemLocale);
} }
/// 智能匹配系统语言到支持的语言 /// 智能匹配系统语言到支持的语言
static Locale _getMatchedLocale(Locale systemLocale) { static Locale getMatchedLocale(Locale systemLocale) {
String languageCode = systemLocale.languageCode.toLowerCase(); String languageCode = systemLocale.languageCode.toLowerCase();
String? countryCode = systemLocale.countryCode?.toUpperCase(); String? countryCode = systemLocale.countryCode?.toUpperCase();
String? scriptCode = systemLocale.scriptCode; String? scriptCode = systemLocale.scriptCode;

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

@ -184,7 +184,7 @@ class PermissionsController extends GetxController {
); );
if (hasPermission) { if (hasPermission) {
_showSuccessMessage(); // _showSuccessMessage();
if (Platform.isIOS && permission == Permission.calendarFullAccess) { if (Platform.isIOS && permission == Permission.calendarFullAccess) {
if (_isCalendarFullAccess == null) { if (_isCalendarFullAccess == null) {
_storage.write('record_permission_calendar', true); _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 { Future<void> setLanguage(LanguageModel data) async {
try { try {
Locale? targetLocale; Locale? targetLocale;
// print('lxm--设置语言: ${data.value}');
if (data.value != 'system') { if (data.value != 'system') {
// 用户手动选择的语言 // 用户手动选择的语言
@ -311,7 +313,11 @@ class SettingsController extends GetxController {
targetLocale = Locale(languageList[0], languageList[1]); targetLocale = Locale(languageList[0], languageList[1]);
} else { } else {
// 跟随系统语言,使用智能匹配 // 跟随系统语言,使用智能匹配
targetLocale = AppTranslations.deviceLocale(); targetLocale = Get.deviceLocale;
if (targetLocale != null) {
// 智能匹配系统语言到支持的语言
targetLocale = AppTranslations.getMatchedLocale(targetLocale);
}
} }
if (targetLocale != null) { if (targetLocale != null) {

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

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

Loading…
Cancel
Save