|
|
@ -1,4 +1,5 @@ |
|
|
import 'dart:async'; |
|
|
import 'dart:async'; |
|
|
|
|
|
import 'dart:io'; |
|
|
import '../../../data/models/appconfig.dart'; |
|
|
import '../../../data/models/appconfig.dart'; |
|
|
import '../../../data/models/appconfig_model.dart'; |
|
|
import '../../../data/models/appconfig_model.dart'; |
|
|
import 'package:flutter/material.dart'; |
|
|
import 'package:flutter/material.dart'; |
|
|
@ -10,6 +11,7 @@ import '../../../core/themes/theme_service.dart'; |
|
|
import '../../../data/services/network/api.dart'; |
|
|
import '../../../data/services/network/api.dart'; |
|
|
import '../../../data/services/version_update_service.dart'; |
|
|
import '../../../data/services/version_update_service.dart'; |
|
|
import '../../../modules/common/widgets/version_update_dialog.dart'; |
|
|
import '../../../modules/common/widgets/version_update_dialog.dart'; |
|
|
|
|
|
import '../../common/webview_page.dart'; |
|
|
|
|
|
|
|
|
class SplashController extends GetxController { |
|
|
class SplashController extends GetxController { |
|
|
final GetStorage _storage = GetStorage(); |
|
|
final GetStorage _storage = GetStorage(); |
|
|
@ -21,6 +23,8 @@ class SplashController extends GetxController { |
|
|
final _isResourceLoaded = false.obs; |
|
|
final _isResourceLoaded = false.obs; |
|
|
bool get isResourceLoaded => _isResourceLoaded.value; |
|
|
bool get isResourceLoaded => _isResourceLoaded.value; |
|
|
|
|
|
|
|
|
|
|
|
final _hasAcceptedPrivacy = false.obs; //是否同意隐私政策 |
|
|
|
|
|
|
|
|
// 版本号 |
|
|
// 版本号 |
|
|
//final String version = 'V1.0.0'; |
|
|
//final String version = 'V1.0.0'; |
|
|
|
|
|
|
|
|
@ -30,13 +34,200 @@ class SplashController extends GetxController { |
|
|
@override |
|
|
@override |
|
|
void onInit() { |
|
|
void onInit() { |
|
|
super.onInit(); |
|
|
super.onInit(); |
|
|
|
|
|
|
|
|
|
|
|
// 首先检查隐私政策状态 |
|
|
|
|
|
final hasAcceptedPrivacy = _storage.read('hasAcceptedPrivacy') ?? false; |
|
|
WidgetsBinding.instance.addPostFrameCallback((_) { |
|
|
WidgetsBinding.instance.addPostFrameCallback((_) { |
|
|
_startLoadingAnimation(); |
|
|
if (!hasAcceptedPrivacy) { |
|
|
_loadAppResources(); |
|
|
// 优先显示隐私政策弹窗,暂停其他初始化 |
|
|
// _initMapSDK(); |
|
|
_showPrivacyDialog(); |
|
|
|
|
|
} else { |
|
|
|
|
|
// 已同意隐私政策,正常启动流程 |
|
|
|
|
|
_startNormalFlow(); |
|
|
|
|
|
} |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void _startNormalFlow() { |
|
|
|
|
|
_startLoadingAnimation(); |
|
|
|
|
|
_loadAppResources(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void _onPrivacyAccepted() { |
|
|
|
|
|
_storage.write('hasAcceptedPrivacy', true); |
|
|
|
|
|
Get.back(); // 关闭弹窗 |
|
|
|
|
|
_startNormalFlow(); // 开始正常流程 |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void _onPrivacyRejected() { |
|
|
|
|
|
exit(0); // 退出应用 |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 显示隐私政策弹窗 |
|
|
|
|
|
void _showPrivacyDialog() { |
|
|
|
|
|
// 获取当前主题模式 |
|
|
|
|
|
final bool isDarkMode = Get.theme.brightness == Brightness.dark; |
|
|
|
|
|
|
|
|
|
|
|
Get.dialog( |
|
|
|
|
|
WillPopScope( |
|
|
|
|
|
onWillPop: () async => false, // 禁止通过返回键关闭弹窗 |
|
|
|
|
|
child: Dialog( |
|
|
|
|
|
shape: RoundedRectangleBorder( |
|
|
|
|
|
borderRadius: BorderRadius.circular(16), |
|
|
|
|
|
), |
|
|
|
|
|
backgroundColor: |
|
|
|
|
|
isDarkMode ? Colors.grey[800] : Colors.white, // 暗黑模式使用深灰色背景 |
|
|
|
|
|
child: Container( |
|
|
|
|
|
padding: const EdgeInsets.all(20), |
|
|
|
|
|
child: Column( |
|
|
|
|
|
mainAxisSize: MainAxisSize.min, |
|
|
|
|
|
children: [ |
|
|
|
|
|
Text( |
|
|
|
|
|
'loginDeclaration'.tr, //APP 声明 |
|
|
|
|
|
style: TextStyle( |
|
|
|
|
|
fontSize: 18, |
|
|
|
|
|
fontWeight: FontWeight.bold, |
|
|
|
|
|
color: |
|
|
|
|
|
isDarkMode ? Colors.white : Colors.black, // 暗黑模式使用白色文字 |
|
|
|
|
|
), |
|
|
|
|
|
), |
|
|
|
|
|
const SizedBox(height: 16), |
|
|
|
|
|
Padding( |
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 20), |
|
|
|
|
|
child: Text.rich( |
|
|
|
|
|
TextSpan( |
|
|
|
|
|
children: [ |
|
|
|
|
|
TextSpan( |
|
|
|
|
|
text: 'welcomeToThisApp'.tr, //欢迎使用本APP,请充分阅读 |
|
|
|
|
|
style: TextStyle( |
|
|
|
|
|
fontSize: 14, |
|
|
|
|
|
color: isDarkMode |
|
|
|
|
|
? Colors.white70 |
|
|
|
|
|
: Colors.black87, // 暗黑模式使用浅白色 |
|
|
|
|
|
), |
|
|
|
|
|
), |
|
|
|
|
|
WidgetSpan( |
|
|
|
|
|
alignment: PlaceholderAlignment.middle, |
|
|
|
|
|
child: GestureDetector( |
|
|
|
|
|
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'; // 隐私政策英文链接 |
|
|
|
|
|
} |
|
|
|
|
|
Get.to(() => WebViewPage( |
|
|
|
|
|
url: url, |
|
|
|
|
|
title: 'privacyPolicy'.tr, |
|
|
|
|
|
)); |
|
|
|
|
|
}, |
|
|
|
|
|
child: Text( |
|
|
|
|
|
'privacyPolicy'.tr, //隐私政策 |
|
|
|
|
|
style: const TextStyle( |
|
|
|
|
|
fontSize: 14, |
|
|
|
|
|
color: Color(0xFF3B82F6), |
|
|
|
|
|
), |
|
|
|
|
|
), |
|
|
|
|
|
), |
|
|
|
|
|
), |
|
|
|
|
|
TextSpan( |
|
|
|
|
|
text: 'and'.tr, //和 |
|
|
|
|
|
style: TextStyle( |
|
|
|
|
|
fontSize: 14, |
|
|
|
|
|
color: isDarkMode ? Colors.white70 : Colors.black87, |
|
|
|
|
|
), |
|
|
|
|
|
), |
|
|
|
|
|
WidgetSpan( |
|
|
|
|
|
alignment: PlaceholderAlignment.middle, |
|
|
|
|
|
child: 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, //用户协议 |
|
|
|
|
|
)); |
|
|
|
|
|
}, |
|
|
|
|
|
child: Text( |
|
|
|
|
|
'userAgreement'.tr, //用户协议 |
|
|
|
|
|
style: const TextStyle( |
|
|
|
|
|
fontSize: 14, |
|
|
|
|
|
color: Color(0xFF3B82F6), |
|
|
|
|
|
), |
|
|
|
|
|
), |
|
|
|
|
|
), |
|
|
|
|
|
), |
|
|
|
|
|
TextSpan( |
|
|
|
|
|
text: 'privacyPolicyText' |
|
|
|
|
|
.tr, //',点击“同意并进入”表示您已充分阅读并同意上述协议。点击“不同意”将退出应用。', |
|
|
|
|
|
style: TextStyle( |
|
|
|
|
|
fontSize: 14, |
|
|
|
|
|
color: isDarkMode ? Colors.white70 : Colors.black87, |
|
|
|
|
|
), |
|
|
|
|
|
), |
|
|
|
|
|
], |
|
|
|
|
|
), |
|
|
|
|
|
textAlign: TextAlign.center, |
|
|
|
|
|
), |
|
|
|
|
|
), |
|
|
|
|
|
const SizedBox(height: 20), |
|
|
|
|
|
Row( |
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly, |
|
|
|
|
|
children: [ |
|
|
|
|
|
TextButton( |
|
|
|
|
|
onPressed: () { |
|
|
|
|
|
// 用户不同意,退出应用 |
|
|
|
|
|
_onPrivacyRejected(); |
|
|
|
|
|
}, |
|
|
|
|
|
style: TextButton.styleFrom( |
|
|
|
|
|
foregroundColor: isDarkMode |
|
|
|
|
|
? Colors.grey[400] |
|
|
|
|
|
: Colors.black54, // 暗黑模式使用浅灰色 |
|
|
|
|
|
), |
|
|
|
|
|
child: Text( |
|
|
|
|
|
'disagree'.tr, //不同意 |
|
|
|
|
|
style: TextStyle( |
|
|
|
|
|
color: isDarkMode ? Colors.grey[400] : Colors.black54, |
|
|
|
|
|
), |
|
|
|
|
|
), |
|
|
|
|
|
//child: const Text('不同意'), |
|
|
|
|
|
), |
|
|
|
|
|
ElevatedButton( |
|
|
|
|
|
onPressed: () { |
|
|
|
|
|
_onPrivacyAccepted(); |
|
|
|
|
|
// 用户同意,关闭弹窗并继续 |
|
|
|
|
|
_hasAcceptedPrivacy.value = true; |
|
|
|
|
|
//Get.back(); |
|
|
|
|
|
}, |
|
|
|
|
|
style: ElevatedButton.styleFrom( |
|
|
|
|
|
backgroundColor: const Color(0xFF0066CC), |
|
|
|
|
|
foregroundColor: Colors.white, |
|
|
|
|
|
shape: RoundedRectangleBorder( |
|
|
|
|
|
borderRadius: BorderRadius.circular(8), |
|
|
|
|
|
), |
|
|
|
|
|
elevation: isDarkMode ? 4 : 2, // 暗黑模式下增加阴影效果提高辨识度 |
|
|
|
|
|
padding: const EdgeInsets.symmetric( |
|
|
|
|
|
horizontal: 16, vertical: 10), // 统一的内边距 |
|
|
|
|
|
), |
|
|
|
|
|
child: Text('agreeAndEnter'.tr), |
|
|
|
|
|
), |
|
|
|
|
|
], |
|
|
|
|
|
), |
|
|
|
|
|
], |
|
|
|
|
|
), |
|
|
|
|
|
), |
|
|
|
|
|
), |
|
|
|
|
|
), |
|
|
|
|
|
barrierDismissible: false, // 禁止点击外部关闭弹窗 |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 初始化地图SDK |
|
|
// 初始化地图SDK |
|
|
// void _initMapSDK() { |
|
|
// void _initMapSDK() { |
|
|
// try { |
|
|
// try { |
|
|
|