|
|
@ -4,6 +4,8 @@ import 'package:permission_handler/permission_handler.dart'; |
|
|
import '../controllers/settings_controller.dart'; |
|
|
import '../controllers/settings_controller.dart'; |
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
|
import 'dart:ui'; |
|
|
import 'dart:ui'; |
|
|
|
|
|
import 'dart:io' show Platform; |
|
|
|
|
|
|
|
|
import '../../../core/utils/permission_util.dart'; // 引入PermissionUtil |
|
|
import '../../../core/utils/permission_util.dart'; // 引入PermissionUtil |
|
|
|
|
|
|
|
|
class PermissionsView extends GetView<SettingsController> { |
|
|
class PermissionsView extends GetView<SettingsController> { |
|
|
@ -37,7 +39,7 @@ class PermissionsView extends GetView<SettingsController> { |
|
|
centerTitle: true, |
|
|
centerTitle: true, |
|
|
), |
|
|
), |
|
|
body: FutureBuilder<Map<Permission, PermissionStatus>>( |
|
|
body: FutureBuilder<Map<Permission, PermissionStatus>>( |
|
|
future: controller.checkAllPermissions(), |
|
|
future: controller.checkAllPermissions(), //检查权限当前状态 |
|
|
builder: (context, snapshot) { |
|
|
builder: (context, snapshot) { |
|
|
if (snapshot.connectionState == ConnectionState.waiting) { |
|
|
if (snapshot.connectionState == ConnectionState.waiting) { |
|
|
return const Center(child: CircularProgressIndicator()); |
|
|
return const Center(child: CircularProgressIndicator()); |
|
|
@ -45,8 +47,8 @@ class PermissionsView extends GetView<SettingsController> { |
|
|
|
|
|
|
|
|
if (snapshot.hasError) { |
|
|
if (snapshot.hasError) { |
|
|
return Center( |
|
|
return Center( |
|
|
child: Text('getPermissionStatusFailed'.tr + |
|
|
child: Text( |
|
|
': ${snapshot.error}')); // 获取权限状态失败 |
|
|
'${'getPermissionStatusFailed'.tr}: ${snapshot.error}')); // 获取权限状态失败 |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
final permissionStatuses = snapshot.data ?? {}; |
|
|
final permissionStatuses = snapshot.data ?? {}; |
|
|
@ -54,15 +56,16 @@ class PermissionsView extends GetView<SettingsController> { |
|
|
return ListView( |
|
|
return ListView( |
|
|
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 16.h), |
|
|
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 16.h), |
|
|
children: [ |
|
|
children: [ |
|
|
// 通讯权限组 |
|
|
// 通讯权限组- iOS平台没有通讯权限 |
|
|
_buildPermissionSection( |
|
|
if (Platform.isAndroid) ...[ |
|
|
'communicationPermissions'.tr, // 通讯权限 |
|
|
_buildPermissionSection( |
|
|
Icons.phone_android, |
|
|
'communicationPermissions'.tr, // 通讯权限 |
|
|
[Permission.phone, Permission.sms], |
|
|
Icons.phone_android, |
|
|
permissionStatuses, |
|
|
[Permission.phone, Permission.sms], |
|
|
isDarkMode), |
|
|
permissionStatuses, |
|
|
|
|
|
isDarkMode), |
|
|
SizedBox(height: 20.h), |
|
|
SizedBox(height: 20.h), |
|
|
|
|
|
], |
|
|
|
|
|
|
|
|
// 日历权限组 |
|
|
// 日历权限组 |
|
|
_buildPermissionSection( |
|
|
_buildPermissionSection( |
|
|
|