diff --git a/lib/core/utils/permission_util.dart b/lib/core/utils/permission_util.dart index bcc264029..5b7268b04 100644 --- a/lib/core/utils/permission_util.dart +++ b/lib/core/utils/permission_util.dart @@ -164,6 +164,12 @@ class PermissionUtil { required String permissionName, required String explanationText, }) { + // 获取当前主题模式 + final context = Get.context; + final isDarkMode = context != null + ? Theme.of(context).brightness == Brightness.dark + : false; + Get.dialog( Stack( children: [ @@ -174,7 +180,7 @@ class PermissionUtil { child: Material( borderRadius: BorderRadius.circular(12), elevation: 8, - color: Colors.grey[300], + color: isDarkMode ? const Color(0xFF2D2D2D) : Colors.grey[300], shadowColor: Colors.black.withValues(alpha: 0.3), child: Padding( padding: const EdgeInsets.all(16), @@ -186,15 +192,19 @@ class PermissionUtil { 'permissionUtilNeed'.tr + permissionName + 'permissionUtilPermission'.tr, - style: const TextStyle( + style: TextStyle( fontWeight: FontWeight.bold, fontSize: 16, + color: isDarkMode ? Colors.white : Colors.black87, ), ), const SizedBox(height: 8), Text( explanationText, - style: const TextStyle(fontSize: 14), + style: TextStyle( + fontSize: 14, + color: isDarkMode ? Colors.white70 : Colors.black54, + ), ), ], ), @@ -227,18 +237,38 @@ class PermissionUtil { }) async { Logger.i('PermissionUtil', '显示永久拒绝对话框 ($permissionName)'); + // 获取当前主题模式 + final context = Get.context; + final isDarkMode = context != null + ? Theme.of(context).brightness == Brightness.dark + : false; + bool? userChoice = await Get.dialog( AlertDialog( - title: Text('permissionUtilNeed'.tr + - permissionName + - 'permissionUtilPermission'.tr), - content: Text(permanentDenialText), + backgroundColor: isDarkMode ? const Color(0xFF2D2D2D) : Colors.white, + title: Text( + 'permissionUtilNeed'.tr + + permissionName + + 'permissionUtilPermission'.tr, + style: TextStyle( + color: isDarkMode ? Colors.white : Colors.black87, + ), + ), + content: Text( + permanentDenialText, + style: TextStyle( + color: isDarkMode ? Colors.white70 : Colors.black54, + ), + ), actions: [ TextButton( onPressed: () { Logger.d('PermissionUtil', '用户取消设置 ($permissionName)'); Get.back(result: false); }, + style: TextButton.styleFrom( + foregroundColor: isDarkMode ? Colors.white70 : Colors.grey[700], + ), child: Text(cancelButtonText), ), ElevatedButton( @@ -246,6 +276,11 @@ class PermissionUtil { Logger.d('PermissionUtil', '用户同意前往设置 ($permissionName)'); Get.back(result: true); }, + style: ElevatedButton.styleFrom( + backgroundColor: + isDarkMode ? const Color(0xFF0066CC) : Colors.blue, + foregroundColor: Colors.white, + ), child: Text(settingsButtonText), ), ],