diff --git a/lib/modules/login/controllers/login_controller.dart b/lib/modules/login/controllers/login_controller.dart index 951885884..c5561a250 100644 --- a/lib/modules/login/controllers/login_controller.dart +++ b/lib/modules/login/controllers/login_controller.dart @@ -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 _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; diff --git a/lib/modules/pairing/controllers/pairing_controller.dart b/lib/modules/pairing/controllers/pairing_controller.dart index 686db7ba8..585cc30d3 100644 --- a/lib/modules/pairing/controllers/pairing_controller.dart +++ b/lib/modules/pairing/controllers/pairing_controller.dart @@ -79,7 +79,7 @@ class PairingController extends GetxController { super.onClose(); } - /// 初始化流程 + /// 初始化流程:检查权限-如果通过,设置监听-检查蓝牙是否开启-如果开启,刷新设备连接-检查配对状态 Future _initialize() async { try { isLoading.value = true; diff --git a/pubspec.yaml b/pubspec.yaml index f32b631d5..fd7ad853a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -25,7 +25,7 @@ dependencies: web_socket_channel: ^3.0.2 flutter_dotenv: ^5.1.0 synchronized: ^3.1.0 - intl: ^0.20.2 + intl: ^0.19.0 crypto: ^3.0.3 flutter_tts: ^4.2.2 logger: ^2.0.2+1