|
|
|
@ -46,39 +46,52 @@ class PermissionsView extends GetView<PermissionsController> { |
|
|
|
|
|
|
|
return RefreshIndicator( |
|
|
|
onRefresh: controller.checkAllPermissions, |
|
|
|
child: ListView( |
|
|
|
child: SingleChildScrollView( |
|
|
|
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 16.h), |
|
|
|
children: _buildPermissionGroups(isDarkMode), |
|
|
|
child: _buildPermissionGroups(isDarkMode), |
|
|
|
), |
|
|
|
); |
|
|
|
}), |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
List<Widget> _buildPermissionGroups(bool isDarkMode) { |
|
|
|
final groups = PermissionGroup.getPlatformGroups(); |
|
|
|
final List<Widget> widgets = []; |
|
|
|
|
|
|
|
for (int i = 0; i < groups.length; i++) { |
|
|
|
final group = groups[i]; |
|
|
|
|
|
|
|
// 过滤平台特定权限 |
|
|
|
if (_shouldShowGroup(group)) { |
|
|
|
widgets.add(_buildPermissionSection( |
|
|
|
group.titleKey, |
|
|
|
group.icon, |
|
|
|
group.permissions, |
|
|
|
controller.permissionStatuses, |
|
|
|
isDarkMode, |
|
|
|
)); |
|
|
|
Widget _buildPermissionGroups(bool isDarkMode) { |
|
|
|
return FutureBuilder<List<PermissionGroup>>( |
|
|
|
future: PermissionGroup.getPlatformGroups(), |
|
|
|
builder: (context, snapshot) { |
|
|
|
if (snapshot.connectionState == ConnectionState.waiting) { |
|
|
|
return const Center(child: CircularProgressIndicator()); |
|
|
|
} |
|
|
|
|
|
|
|
if (i < groups.length - 1) { |
|
|
|
widgets.add(SizedBox(height: 20.h)); |
|
|
|
if (snapshot.hasError) { |
|
|
|
return Center(child: Text('加载权限组失败: ${snapshot.error}')); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
final groups = snapshot.data ?? []; |
|
|
|
final List<Widget> widgets = []; |
|
|
|
|
|
|
|
return widgets; |
|
|
|
for (int i = 0; i < groups.length; i++) { |
|
|
|
final group = groups[i]; |
|
|
|
|
|
|
|
// 过滤平台特定权限 |
|
|
|
if (_shouldShowGroup(group)) { |
|
|
|
widgets.add(_buildPermissionSection( |
|
|
|
group.titleKey, |
|
|
|
group.icon, |
|
|
|
group.permissions, |
|
|
|
controller.permissionStatuses, |
|
|
|
isDarkMode, |
|
|
|
)); |
|
|
|
|
|
|
|
if (i < groups.length - 1) { |
|
|
|
widgets.add(SizedBox(height: 20.h)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return Column(children: widgets); |
|
|
|
}, |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
bool _shouldShowGroup(PermissionGroup group) { |
|
|
|
|