|
|
|
@ -4,6 +4,8 @@ import 'package:permission_handler/permission_handler.dart'; |
|
|
|
import '../controllers/settings_controller.dart'; |
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
|
|
import 'dart:ui'; |
|
|
|
import 'dart:io' show Platform; |
|
|
|
|
|
|
|
import '../../../core/utils/permission_util.dart'; // 引入PermissionUtil |
|
|
|
|
|
|
|
class PermissionsView extends GetView<SettingsController> { |
|
|
|
@ -37,7 +39,7 @@ class PermissionsView extends GetView<SettingsController> { |
|
|
|
centerTitle: true, |
|
|
|
), |
|
|
|
body: FutureBuilder<Map<Permission, PermissionStatus>>( |
|
|
|
future: controller.checkAllPermissions(), |
|
|
|
future: controller.checkAllPermissions(), //检查权限当前状态 |
|
|
|
builder: (context, snapshot) { |
|
|
|
if (snapshot.connectionState == ConnectionState.waiting) { |
|
|
|
return const Center(child: CircularProgressIndicator()); |
|
|
|
@ -45,8 +47,8 @@ class PermissionsView extends GetView<SettingsController> { |
|
|
|
|
|
|
|
if (snapshot.hasError) { |
|
|
|
return Center( |
|
|
|
child: Text('getPermissionStatusFailed'.tr + |
|
|
|
': ${snapshot.error}')); // 获取权限状态失败 |
|
|
|
child: Text( |
|
|
|
'${'getPermissionStatusFailed'.tr}: ${snapshot.error}')); // 获取权限状态失败 |
|
|
|
} |
|
|
|
|
|
|
|
final permissionStatuses = snapshot.data ?? {}; |
|
|
|
@ -54,15 +56,27 @@ class PermissionsView extends GetView<SettingsController> { |
|
|
|
return ListView( |
|
|
|
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 16.h), |
|
|
|
children: [ |
|
|
|
// 通讯权限组 |
|
|
|
_buildPermissionSection( |
|
|
|
'communicationPermissions'.tr, // 通讯权限 |
|
|
|
Icons.phone_android, |
|
|
|
[Permission.phone, Permission.sms], |
|
|
|
// 通讯权限组- iOS平台没有通讯权限 |
|
|
|
if (Platform.isAndroid) ...[ |
|
|
|
_buildPermissionSection( |
|
|
|
'communicationPermissions'.tr, // 通讯权限 |
|
|
|
Icons.phone_android, |
|
|
|
[Permission.phone, Permission.sms], |
|
|
|
permissionStatuses, |
|
|
|
isDarkMode), |
|
|
|
SizedBox(height: 20.h), |
|
|
|
], |
|
|
|
// 闹钟权限组 |
|
|
|
if (Platform.isAndroid) ...[ |
|
|
|
_buildPermissionSection( |
|
|
|
'alarmPermissions'.tr, // 闹钟权限 |
|
|
|
Icons.alarm, |
|
|
|
[Permission.scheduleExactAlarm], |
|
|
|
permissionStatuses, |
|
|
|
isDarkMode), |
|
|
|
|
|
|
|
SizedBox(height: 20.h), |
|
|
|
isDarkMode, |
|
|
|
), |
|
|
|
SizedBox(height: 20.h), |
|
|
|
], |
|
|
|
|
|
|
|
// 日历权限组 |
|
|
|
_buildPermissionSection( |
|
|
|
@ -162,6 +176,8 @@ class PermissionsView extends GetView<SettingsController> { |
|
|
|
return 'calendarFullAccess'.tr; // 日历完整访问 |
|
|
|
case Permission.location: |
|
|
|
return 'locationInfo'.tr; // 位置信息 |
|
|
|
case Permission.scheduleExactAlarm: |
|
|
|
return 'alarm'.tr; // 闹钟 |
|
|
|
default: |
|
|
|
return permission.toString(); |
|
|
|
} |
|
|
|
@ -180,6 +196,8 @@ class PermissionsView extends GetView<SettingsController> { |
|
|
|
return 'calendarFullAccessPermissionDesc'.tr; // 用于读取和管理日历事件及提醒 |
|
|
|
case Permission.location: |
|
|
|
return 'locationPermissionDesc'.tr; // 用于获取当前位置信息 |
|
|
|
case Permission.scheduleExactAlarm: |
|
|
|
return 'alarmPermissionDesc'.tr; // 设置精确闹钟需要此权限 |
|
|
|
default: |
|
|
|
return 'appFunctionNeeds'.tr; // 应用功能需要 |
|
|
|
} |
|
|
|
@ -355,6 +373,8 @@ class PermissionsView extends GetView<SettingsController> { |
|
|
|
return 'calendarFullAccess'.tr; // 日历完整访问 |
|
|
|
case Permission.location: |
|
|
|
return 'locationInfo'.tr; // 位置信息 |
|
|
|
case Permission.scheduleExactAlarm: |
|
|
|
return 'alarm'.tr; // 闹钟 |
|
|
|
default: |
|
|
|
return permission.toString(); |
|
|
|
} |
|
|
|
@ -373,6 +393,8 @@ class PermissionsView extends GetView<SettingsController> { |
|
|
|
return 'calendarFullAccessPermissionDetailDesc'.tr; // 管理日历事件需要完整日历权限 |
|
|
|
case Permission.location: |
|
|
|
return 'locationPermissionDetailDesc'.tr; // 获取位置信息需要位置权限 |
|
|
|
case Permission.scheduleExactAlarm: |
|
|
|
return 'alarmPermissionDetailDesc'.tr; // 设置精确闹钟需要此权限 |
|
|
|
default: |
|
|
|
return 'appNeedsPermissionForFullFunction'.tr; // 应用需要此权限以提供完整功能 |
|
|
|
} |
|
|
|
|