From c5b63f6398ba8d940ce91a4e06ae93765152928e Mon Sep 17 00:00:00 2001 From: lxm <1274844347@qq.com> Date: Wed, 18 Jun 2025 17:05:40 +0800 Subject: [PATCH] =?UTF-8?q?style(login):=20=E4=BC=98=E5=8C=96=E6=9A=97?= =?UTF-8?q?=E9=BB=91=E6=A8=A1=E5=BC=8F=E4=B8=8B=E7=9A=84UI=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 调整登录视图的背景色、边框和阴影效果 - 优化隐私政策弹窗的暗黑模式适配 - 统一按钮样式和文字颜色 --- .../login/controllers/login_controller.dart | 55 ++++++++++++++----- lib/modules/login/views/login_view.dart | 54 +++++++++++++----- 2 files changed, 82 insertions(+), 27 deletions(-) diff --git a/lib/modules/login/controllers/login_controller.dart b/lib/modules/login/controllers/login_controller.dart index c512d1eb7..d6cc76ca1 100644 --- a/lib/modules/login/controllers/login_controller.dart +++ b/lib/modules/login/controllers/login_controller.dart @@ -201,6 +201,9 @@ class LoginController extends GetxController { // 显示隐私政策弹窗 void _showPrivacyDialog() { + // 获取当前主题模式 + final bool isDarkMode = Get.theme.brightness == Brightness.dark; + Get.dialog( WillPopScope( onWillPop: () async => false, // 禁止通过返回键关闭弹窗 @@ -208,16 +211,20 @@ class LoginController extends GetxController { 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: [ - const Text( + Text( 'DeapSound 声明', style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, + color: + isDarkMode ? Colors.white : Colors.black, // 暗黑模式使用白色文字 ), ), const SizedBox(height: 16), @@ -226,9 +233,14 @@ class LoginController extends GetxController { child: Text.rich( TextSpan( children: [ - const TextSpan( + TextSpan( text: '欢迎使用DeapSound,请充分阅读', - style: TextStyle(fontSize: 14), + style: TextStyle( + fontSize: 14, + color: isDarkMode + ? Colors.white70 + : Colors.black87, // 暗黑模式使用浅白色 + ), ), WidgetSpan( alignment: PlaceholderAlignment.middle, @@ -244,18 +256,21 @@ class LoginController extends GetxController { title: 'privacyPolicy'.tr, )); }, - child: Text( + child: const Text( '《隐私政策》', style: TextStyle( fontSize: 14, - color: const Color(0xFF3B82F6), + color: Color(0xFF3B82F6), ), ), ), ), - const TextSpan( + TextSpan( text: '和', - style: TextStyle(fontSize: 14), + style: TextStyle( + fontSize: 14, + color: isDarkMode ? Colors.white70 : Colors.black87, + ), ), WidgetSpan( alignment: PlaceholderAlignment.middle, @@ -271,18 +286,21 @@ class LoginController extends GetxController { title: 'userAgreement'.tr, )); }, - child: Text( + child: const Text( '《用户协议》', style: TextStyle( fontSize: 14, - color: const Color(0xFF3B82F6), + color: Color(0xFF3B82F6), ), ), ), ), - const TextSpan( + TextSpan( text: ',点击“同意并进入”表示您已充分阅读并同意上述协议。点击“不同意”将退出应用。', - style: TextStyle(fontSize: 14), + style: TextStyle( + fontSize: 14, + color: isDarkMode ? Colors.white70 : Colors.black87, + ), ), ], ), @@ -299,9 +317,17 @@ class LoginController extends GetxController { exit(0); }, style: TextButton.styleFrom( - foregroundColor: Colors.black54, + foregroundColor: isDarkMode + ? Colors.grey[400] + : Colors.black54, // 暗黑模式使用浅灰色 + ), + child: Text( + '不同意', + style: TextStyle( + color: isDarkMode ? Colors.grey[400] : Colors.black54, + ), ), - child: const Text('不同意'), + //child: const Text('不同意'), ), ElevatedButton( onPressed: () { @@ -317,6 +343,9 @@ class LoginController extends GetxController { shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(8), ), + elevation: isDarkMode ? 4 : 2, // 暗黑模式下增加阴影效果提高辨识度 + padding: const EdgeInsets.symmetric( + horizontal: 16, vertical: 10), // 统一的内边距 ), child: const Text('同意并进入'), ), diff --git a/lib/modules/login/views/login_view.dart b/lib/modules/login/views/login_view.dart index 98cdfae0f..deb838681 100644 --- a/lib/modules/login/views/login_view.dart +++ b/lib/modules/login/views/login_view.dart @@ -177,9 +177,23 @@ class LoginView extends GetView { return Container( decoration: BoxDecoration( color: isDarkMode - ? Colors.grey[900]!.withOpacity(0.4) + ? Colors.grey[850]!.withOpacity(0.6) // 更深的背景色,增加不透明度 : Colors.grey.withOpacity(0.1), borderRadius: BorderRadius.circular(16.r), + border: Border.all( + color: + isDarkMode ? Colors.grey[700]! : Colors.transparent, // 暗黑模式添加边框 + width: 1, + ), + boxShadow: isDarkMode + ? [ + BoxShadow( + color: Colors.black.withOpacity(0.2), + blurRadius: 4, + offset: const Offset(0, 2), + ) + ] + : [], // 暗黑模式添加阴影 ), child: Padding( padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 4.h), @@ -213,32 +227,27 @@ class LoginView extends GetView { Container( height: 20.h, width: 1, - color: isDarkMode ? Colors.grey[800] : Colors.grey[300], + color: + isDarkMode ? Colors.grey[600] : Colors.grey[300], // 调整分隔线颜色 margin: EdgeInsets.symmetric(horizontal: 8.w), ), - // Icon( - // Icons.person_outline, - // color: isDarkMode ? Colors.grey[400] : Colors.black54, - // size: 20.sp, - // ), - //SizedBox(width: 12.w), Expanded( child: TextField( controller: controller.contactController, - // keyboardType: controller.selectedCountryFlag == '✉️' - // ? TextInputType.emailAddress - // : TextInputType.phone, decoration: InputDecoration( hintText: controller.selectedCountryFlag == '✉️' ? 'email'.tr // 需要在翻译文件中添加 : 'phoneNumber'.tr, // 需要在翻译文件中添加 hintStyle: TextStyle( fontSize: 14.sp, - color: isDarkMode ? Colors.grey[600] : Colors.black38, + color: isDarkMode + ? Colors.grey[500] + : Colors.black38, // 调整提示文字颜色 ), border: InputBorder.none, fillColor: Colors.transparent, filled: true, + focusedBorder: InputBorder.none, ), style: TextStyle( fontSize: 14.sp, @@ -322,9 +331,23 @@ class LoginView extends GetView { return Container( decoration: BoxDecoration( color: isDarkMode - ? Colors.grey[900]!.withOpacity(0.4) + ? Colors.grey[850]!.withOpacity(0.6) // 更深的背景色,增加不透明度 : Colors.grey.withOpacity(0.1), borderRadius: BorderRadius.circular(16.r), + border: Border.all( + color: + isDarkMode ? Colors.grey[700]! : Colors.transparent, // 暗黑模式添加边框 + width: 1, + ), + boxShadow: isDarkMode + ? [ + BoxShadow( + color: Colors.black.withOpacity(0.2), + blurRadius: 4, + offset: const Offset(0, 2), + ) + ] + : [], // 暗黑模式添加阴影 ), child: Padding( padding: EdgeInsets.only(left: 16.w, right: 4.w, top: 4.h, bottom: 4.h), @@ -345,12 +368,15 @@ class LoginView extends GetView { hintText: 'verificationCode'.tr, // 验证码 hintStyle: TextStyle( fontSize: 14.sp, - color: isDarkMode ? Colors.grey[600] : Colors.black38, + color: isDarkMode + ? Colors.grey[500] + : Colors.black38, // 调整提示文字颜色 ), border: InputBorder.none, counterText: '', fillColor: Colors.transparent, filled: true, + focusedBorder: InputBorder.none, ), style: TextStyle( fontSize: 14.sp,