|
|
|
@ -10,9 +10,11 @@ import 'googleLogin.dart'; |
|
|
|
import 'weixinLogin.dart'; |
|
|
|
import '../../../data/services/network/api.dart'; |
|
|
|
import '../../../../data/models/user_Info.dart'; |
|
|
|
import '../../common/webview_page.dart'; |
|
|
|
//import 'package:shared_preferences/shared_preferences.dart'; |
|
|
|
import 'package:get_storage/get_storage.dart'; |
|
|
|
import 'package:device_info_plus/device_info_plus.dart'; |
|
|
|
import 'dart:io'; |
|
|
|
|
|
|
|
enum LoginViewState { |
|
|
|
welcome, // 欢迎页面 |
|
|
|
@ -175,6 +177,12 @@ class LoginController extends GetxController { |
|
|
|
void onInit() { |
|
|
|
super.onInit(); |
|
|
|
_viewState.value = LoginViewState.welcome; |
|
|
|
|
|
|
|
// 使用addPostFrameCallback确保在构建完成后显示对话框 |
|
|
|
// WidgetsBinding.instance.addPostFrameCallback((_) { |
|
|
|
// _showPrivacyDialog(); |
|
|
|
// }); |
|
|
|
|
|
|
|
_initDeviceInfo(); |
|
|
|
} |
|
|
|
|
|
|
|
@ -185,6 +193,128 @@ class LoginController extends GetxController { |
|
|
|
super.onClose(); |
|
|
|
} |
|
|
|
|
|
|
|
// 显示隐私政策弹窗 |
|
|
|
void _showPrivacyDialog() { |
|
|
|
Get.dialog( |
|
|
|
WillPopScope( |
|
|
|
onWillPop: () async => false, // 禁止通过返回键关闭弹窗 |
|
|
|
child: Dialog( |
|
|
|
shape: RoundedRectangleBorder( |
|
|
|
borderRadius: BorderRadius.circular(16), |
|
|
|
), |
|
|
|
child: Container( |
|
|
|
padding: const EdgeInsets.all(20), |
|
|
|
child: Column( |
|
|
|
mainAxisSize: MainAxisSize.min, |
|
|
|
children: [ |
|
|
|
const Text( |
|
|
|
'DeapSound 声明', |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 18, |
|
|
|
fontWeight: FontWeight.bold, |
|
|
|
), |
|
|
|
), |
|
|
|
const SizedBox(height: 16), |
|
|
|
Padding( |
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 20), |
|
|
|
child: Text.rich( |
|
|
|
TextSpan( |
|
|
|
children: [ |
|
|
|
const TextSpan( |
|
|
|
text: '欢迎使用DeapSound,请先阅读', |
|
|
|
style: TextStyle(fontSize: 14), |
|
|
|
), |
|
|
|
WidgetSpan( |
|
|
|
child: GestureDetector( |
|
|
|
onTap: () { |
|
|
|
String url = 'https://www.deepsoud.com/ysxy.html'; |
|
|
|
if (Get.locale?.toString() != 'zh_CN') { |
|
|
|
url = 'https://www.deepsoud.com/ysxy_en.html'; |
|
|
|
} |
|
|
|
Get.to(() => WebViewPage( |
|
|
|
url: url, |
|
|
|
title: 'privacyPolicy'.tr, |
|
|
|
)); |
|
|
|
}, |
|
|
|
child: Text( |
|
|
|
'《隐私政策》', |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 14, |
|
|
|
color: const Color(0xFF3B82F6), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
const TextSpan( |
|
|
|
text: '和', |
|
|
|
style: TextStyle(fontSize: 14), |
|
|
|
), |
|
|
|
WidgetSpan( |
|
|
|
child: GestureDetector( |
|
|
|
onTap: () { |
|
|
|
String url = 'https://www.deepsoud.com/yhxy.html'; |
|
|
|
if (Get.locale?.toString() != 'zh_CN') { |
|
|
|
url = 'https://www.deepsoud.com/yhxy_en.html'; |
|
|
|
} |
|
|
|
Get.to(() => WebViewPage( |
|
|
|
url: url, |
|
|
|
title: 'userAgreement'.tr, |
|
|
|
)); |
|
|
|
}, |
|
|
|
child: Text( |
|
|
|
'《用户协议》', |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 14, |
|
|
|
color: const Color(0xFF3B82F6), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
textAlign: TextAlign.center, |
|
|
|
), |
|
|
|
), |
|
|
|
const SizedBox(height: 20), |
|
|
|
Row( |
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly, |
|
|
|
children: [ |
|
|
|
TextButton( |
|
|
|
onPressed: () { |
|
|
|
// 用户不同意,退出应用 |
|
|
|
exit(0); |
|
|
|
}, |
|
|
|
style: TextButton.styleFrom( |
|
|
|
foregroundColor: Colors.black54, |
|
|
|
), |
|
|
|
child: const Text('取消'), |
|
|
|
), |
|
|
|
ElevatedButton( |
|
|
|
onPressed: () { |
|
|
|
// 用户同意,关闭弹窗并继续 |
|
|
|
_hasAcceptedPrivacy.value = true; |
|
|
|
Get.back(); |
|
|
|
}, |
|
|
|
style: ElevatedButton.styleFrom( |
|
|
|
backgroundColor: const Color(0xFF0066CC), |
|
|
|
foregroundColor: Colors.white, |
|
|
|
shape: RoundedRectangleBorder( |
|
|
|
borderRadius: BorderRadius.circular(8), |
|
|
|
), |
|
|
|
), |
|
|
|
child: const Text('同意并进入'), |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
barrierDismissible: false, // 禁止点击外部关闭弹窗 |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
// 初始化设备信息 |
|
|
|
Future<void> _initDeviceInfo() async { |
|
|
|
try { |
|
|
|
@ -462,13 +592,14 @@ class LoginController extends GetxController { |
|
|
|
|
|
|
|
//验证隐私协议勾选状态 |
|
|
|
if (!_hasAcceptedPrivacy.value) { |
|
|
|
Get.snackbar( |
|
|
|
'tip'.tr, |
|
|
|
'pleaseAcceptPrivacyPolicy'.tr, |
|
|
|
snackPosition: SnackPosition.TOP, |
|
|
|
backgroundColor: Colors.red.withOpacity(0.1), |
|
|
|
colorText: Colors.red, |
|
|
|
); |
|
|
|
// Get.snackbar( |
|
|
|
// 'tip'.tr, |
|
|
|
// 'pleaseAcceptPrivacyPolicy'.tr, |
|
|
|
// snackPosition: SnackPosition.TOP, |
|
|
|
// backgroundColor: Colors.red.withOpacity(0.1), |
|
|
|
// colorText: Colors.red, |
|
|
|
// ); |
|
|
|
_showPrivacyDialog(); |
|
|
|
return; |
|
|
|
} |
|
|
|
_isLoading.value = true; |
|
|
|
|