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