深色模式、首页设置页面和功能优化
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import '../../../constants/app_constants.dart';
|
||||
import '../../../services/get/theme_controller.dart';
|
||||
|
||||
/// 时间: 2026-03-27
|
||||
/// 功能: 权限管理页面
|
||||
@@ -15,6 +17,7 @@ class PermissionPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _PermissionPageState extends State<PermissionPage> {
|
||||
final ThemeController _themeController = Get.find<ThemeController>();
|
||||
bool _vibrationEnabled = true;
|
||||
bool _networkEnabled = true;
|
||||
bool _clipboardEnabled = true;
|
||||
@@ -36,98 +39,114 @@ class _PermissionPageState extends State<PermissionPage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: const Color(0xFFF5F5F5),
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
'权限管理',
|
||||
style: TextStyle(
|
||||
color: AppConstants.primaryColor,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
backgroundColor: Colors.white,
|
||||
elevation: 0,
|
||||
centerTitle: true,
|
||||
leading: IconButton(
|
||||
icon: Icon(Icons.arrow_back, color: AppConstants.primaryColor),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: Icon(Icons.info_outline, color: AppConstants.primaryColor),
|
||||
onPressed: _showPermissionInfoDialog,
|
||||
),
|
||||
],
|
||||
),
|
||||
body: ListView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
children: [
|
||||
_buildPermissionGroup('权限列表', [
|
||||
_buildPermissionItem(
|
||||
'网络访问',
|
||||
'访问网络获取诗词内容和数据',
|
||||
Icons.wifi,
|
||||
_networkEnabled,
|
||||
null,
|
||||
return Obx(() {
|
||||
final isDark = _themeController.isDarkMode;
|
||||
return Scaffold(
|
||||
backgroundColor: isDark
|
||||
? const Color(0xFF1A1A1A)
|
||||
: const Color(0xFFF5F5F5),
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
'权限管理',
|
||||
style: TextStyle(
|
||||
color: isDark ? Colors.white : AppConstants.primaryColor,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
_buildPermissionItem(
|
||||
'震动反馈',
|
||||
'操作时的震动反馈,提升交互体验',
|
||||
Icons.vibration,
|
||||
_vibrationEnabled,
|
||||
null,
|
||||
),
|
||||
backgroundColor: isDark ? const Color(0xFF2A2A2A) : Colors.white,
|
||||
elevation: 0,
|
||||
centerTitle: true,
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.arrow_back,
|
||||
color: isDark ? Colors.white : AppConstants.primaryColor,
|
||||
),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: Icon(
|
||||
Icons.info_outline,
|
||||
color: isDark ? Colors.white : AppConstants.primaryColor,
|
||||
),
|
||||
onPressed: _showPermissionInfoDialog,
|
||||
),
|
||||
],
|
||||
),
|
||||
body: ListView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
children: [
|
||||
_buildPermissionGroup('权限列表', [
|
||||
_buildPermissionItem(
|
||||
'网络访问',
|
||||
'访问网络获取诗词内容和数据',
|
||||
Icons.wifi,
|
||||
_networkEnabled,
|
||||
null,
|
||||
isDark,
|
||||
),
|
||||
_buildPermissionItem(
|
||||
'震动反馈',
|
||||
'操作时的震动反馈,提升交互体验',
|
||||
Icons.vibration,
|
||||
_vibrationEnabled,
|
||||
null,
|
||||
isDark,
|
||||
),
|
||||
|
||||
_buildPermissionItem(
|
||||
'剪切板',
|
||||
'复制诗词内容到剪切板',
|
||||
Icons.content_copy,
|
||||
_clipboardEnabled,
|
||||
null,
|
||||
),
|
||||
_buildPermissionItem(
|
||||
'播放声音',
|
||||
'播放内置提示音',
|
||||
Icons.audio_file,
|
||||
_clipboardEnabled,
|
||||
null,
|
||||
),
|
||||
_buildPermissionItem(
|
||||
'分享能力',
|
||||
'调用系统分享接口',
|
||||
Icons.share,
|
||||
_clipboardEnabled,
|
||||
null,
|
||||
),
|
||||
]),
|
||||
const SizedBox(height: 16),
|
||||
_buildPermissionGroup('权限说明', [
|
||||
_buildInfoItem('震动反馈', '用于点赞、收藏等操作的触觉反馈,提升用户体验。'),
|
||||
_buildInfoItem('网络访问', '用于获取诗词内容、排行榜数据、用户信息等。'),
|
||||
_buildInfoItem('剪切板', '用于复制诗词内容,方便用户分享和记录。'),
|
||||
_buildInfoItem('播放声音', '用于主页点击提示音,提升用户体验。'),
|
||||
_buildInfoItem('分享能力', '用于分享诗词内容到社交媒体平台。'),
|
||||
]),
|
||||
const SizedBox(height: 16),
|
||||
_buildSandboxInfoCard(),
|
||||
const SizedBox(height: 16),
|
||||
_buildProjectSupplement(),
|
||||
const SizedBox(height: 24),
|
||||
_buildBottomTip(),
|
||||
],
|
||||
),
|
||||
);
|
||||
_buildPermissionItem(
|
||||
'剪切板',
|
||||
'复制诗词内容到剪切板',
|
||||
Icons.content_copy,
|
||||
_clipboardEnabled,
|
||||
null,
|
||||
isDark,
|
||||
),
|
||||
_buildPermissionItem(
|
||||
'播放声音',
|
||||
'播放内置提示音',
|
||||
Icons.audio_file,
|
||||
_clipboardEnabled,
|
||||
null,
|
||||
isDark,
|
||||
),
|
||||
_buildPermissionItem(
|
||||
'分享能力',
|
||||
'调用系统分享接口',
|
||||
Icons.share,
|
||||
_clipboardEnabled,
|
||||
null,
|
||||
isDark,
|
||||
),
|
||||
], isDark),
|
||||
const SizedBox(height: 16),
|
||||
_buildPermissionGroup('权限说明', [
|
||||
_buildInfoItem('震动反馈', '用于点赞、收藏等操作的触觉反馈,提升用户体验。', isDark),
|
||||
_buildInfoItem('网络访问', '用于获取诗词内容、排行榜数据、用户信息等。', isDark),
|
||||
_buildInfoItem('剪切板', '用于复制诗词内容,方便用户分享和记录。', isDark),
|
||||
_buildInfoItem('播放声音', '用于主页点击提示音,提升用户体验。', isDark),
|
||||
_buildInfoItem('分享能力', '用于分享诗词内容到社交媒体平台。', isDark),
|
||||
], isDark),
|
||||
const SizedBox(height: 16),
|
||||
_buildSandboxInfoCard(isDark),
|
||||
const SizedBox(height: 16),
|
||||
_buildProjectSupplement(isDark),
|
||||
const SizedBox(height: 24),
|
||||
_buildBottomTip(isDark),
|
||||
],
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Widget _buildPermissionGroup(String title, List<Widget> items) {
|
||||
Widget _buildPermissionGroup(String title, List<Widget> items, bool isDark) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
color: isDark ? const Color(0xFF2A2A2A) : Colors.white,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withValues(alpha: 0.05),
|
||||
color: Colors.black.withValues(alpha: isDark ? 0.3 : 0.05),
|
||||
blurRadius: 10,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
@@ -157,7 +176,7 @@ class _PermissionPageState extends State<PermissionPage> {
|
||||
],
|
||||
),
|
||||
),
|
||||
const Divider(height: 1),
|
||||
Divider(height: 1, color: isDark ? Colors.grey[700] : null),
|
||||
...items,
|
||||
],
|
||||
),
|
||||
@@ -170,6 +189,7 @@ class _PermissionPageState extends State<PermissionPage> {
|
||||
IconData icon,
|
||||
bool enabled,
|
||||
Function(bool)? onToggle,
|
||||
bool isDark,
|
||||
) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
@@ -193,9 +213,10 @@ class _PermissionPageState extends State<PermissionPage> {
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: isDark ? Colors.white : Colors.black87,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
@@ -205,12 +226,15 @@ class _PermissionPageState extends State<PermissionPage> {
|
||||
vertical: 2,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[200],
|
||||
color: isDark ? Colors.grey[700] : Colors.grey[200],
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Text(
|
||||
'已开启',
|
||||
style: TextStyle(fontSize: 10, color: Colors.grey[600]),
|
||||
style: TextStyle(
|
||||
fontSize: 10,
|
||||
color: isDark ? Colors.grey[300] : Colors.grey[600],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -218,18 +242,25 @@ class _PermissionPageState extends State<PermissionPage> {
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
description,
|
||||
style: TextStyle(fontSize: 12, color: Colors.grey[600]),
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: isDark ? Colors.grey[400] : Colors.grey[600],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Icon(Icons.lock, color: Colors.grey[400], size: 20),
|
||||
Icon(
|
||||
Icons.lock,
|
||||
color: isDark ? Colors.grey[500] : Colors.grey[400],
|
||||
size: 20,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildInfoItem(String title, String description) {
|
||||
Widget _buildInfoItem(String title, String description, bool isDark) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
child: Row(
|
||||
@@ -251,9 +282,10 @@ class _PermissionPageState extends State<PermissionPage> {
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: isDark ? Colors.white : Colors.black87,
|
||||
),
|
||||
),
|
||||
// const SizedBox(height: 4),
|
||||
@@ -261,7 +293,7 @@ class _PermissionPageState extends State<PermissionPage> {
|
||||
description,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Colors.grey[600],
|
||||
color: isDark ? Colors.grey[400] : Colors.grey[600],
|
||||
height: 1.5,
|
||||
),
|
||||
),
|
||||
@@ -273,14 +305,14 @@ class _PermissionPageState extends State<PermissionPage> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildProjectSupplement() {
|
||||
Widget _buildProjectSupplement(bool isDark) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
color: isDark ? const Color(0xFF2A2A2A) : Colors.white,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withValues(alpha: 0.05),
|
||||
color: Colors.black.withValues(alpha: isDark ? 0.3 : 0.05),
|
||||
blurRadius: 10,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
@@ -306,30 +338,34 @@ class _PermissionPageState extends State<PermissionPage> {
|
||||
],
|
||||
),
|
||||
),
|
||||
const Divider(height: 1),
|
||||
Divider(height: 1, color: isDark ? Colors.grey[700] : null),
|
||||
_buildSupplementItem(
|
||||
'用户反馈',
|
||||
'帮助我们改进产品',
|
||||
Icons.feedback,
|
||||
() => _showFeedbackDialog(),
|
||||
isDark,
|
||||
),
|
||||
_buildSupplementItem(
|
||||
'功能建议',
|
||||
'提出您希望的功能',
|
||||
Icons.lightbulb,
|
||||
() => _showSuggestionDialog(),
|
||||
isDark,
|
||||
),
|
||||
// _buildSupplementItem(
|
||||
// 'Bug报告',
|
||||
// '报告遇到的问题',
|
||||
// Icons.bug_report,
|
||||
// () => _showBugReportDialog(),
|
||||
// isDark,
|
||||
// ),
|
||||
// _buildSupplementItem(
|
||||
// '参与开发',
|
||||
// '成为贡献者',
|
||||
// Icons.code,
|
||||
// () => _showContributionDialog(),
|
||||
// isDark,
|
||||
// ),
|
||||
],
|
||||
),
|
||||
@@ -341,6 +377,7 @@ class _PermissionPageState extends State<PermissionPage> {
|
||||
String description,
|
||||
IconData icon,
|
||||
VoidCallback onTap,
|
||||
bool isDark,
|
||||
) {
|
||||
return InkWell(
|
||||
onTap: onTap,
|
||||
@@ -364,20 +401,27 @@ class _PermissionPageState extends State<PermissionPage> {
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: isDark ? Colors.white : Colors.black87,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
description,
|
||||
style: TextStyle(fontSize: 12, color: Colors.grey[600]),
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: isDark ? Colors.grey[400] : Colors.grey[600],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Icon(Icons.chevron_right, color: Colors.grey[400]),
|
||||
Icon(
|
||||
Icons.chevron_right,
|
||||
color: isDark ? Colors.grey[500] : Colors.grey[400],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -533,15 +577,15 @@ class _PermissionPageState extends State<PermissionPage> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSandboxInfoCard() {
|
||||
Widget _buildSandboxInfoCard(bool isDark) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
color: isDark ? const Color(0xFF2A2A2A) : Colors.white,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withValues(alpha: 0.05),
|
||||
color: Colors.black.withValues(alpha: isDark ? 0.3 : 0.05),
|
||||
blurRadius: 10,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
@@ -576,30 +620,34 @@ class _PermissionPageState extends State<PermissionPage> {
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
const Divider(height: 1),
|
||||
Divider(height: 1, color: isDark ? Colors.grey[700] : null),
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
'本软件严格遵循移动平台沙盒机制运行,确保您的数据安全:',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.grey[800],
|
||||
color: isDark ? Colors.grey[300] : Colors.grey[800],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
_buildSandboxItem('📱 沙盒隔离', '软件在独立沙盒环境中运行,无法访问系统其他应用数据'),
|
||||
_buildSandboxItem('📱 沙盒隔离', '软件在独立沙盒环境中运行,无法访问系统其他应用数据', isDark),
|
||||
const SizedBox(height: 8),
|
||||
_buildSandboxItem('📄 无文件创建', '不会在设备上创建额外文件,所有数据通过网络获取'),
|
||||
_buildSandboxItem('📄 无文件创建', '不会在设备上创建额外文件,所有数据通过网络获取', isDark),
|
||||
const SizedBox(height: 8),
|
||||
_buildSandboxItem('🔒 权限透明', '仅使用必要权限,此类权限均为基础权限'),
|
||||
_buildSandboxItem('🔒 权限透明', '仅使用必要权限,此类权限均为基础权限', isDark),
|
||||
const SizedBox(height: 8),
|
||||
_buildSandboxItem('💾 本地存储', '仅使用 SharedPreferences 存储少量用户偏好设置'),
|
||||
_buildSandboxItem(
|
||||
'💾 本地存储',
|
||||
'仅使用 SharedPreferences 存储少量用户偏好设置',
|
||||
isDark,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSandboxItem(String title, String description) {
|
||||
Widget _buildSandboxItem(String title, String description, bool isDark) {
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
@@ -622,7 +670,7 @@ class _PermissionPageState extends State<PermissionPage> {
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.grey[800],
|
||||
color: isDark ? Colors.white : Colors.grey[800],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
@@ -630,7 +678,7 @@ class _PermissionPageState extends State<PermissionPage> {
|
||||
description,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Colors.grey[600],
|
||||
color: isDark ? Colors.grey[400] : Colors.grey[600],
|
||||
height: 1.5,
|
||||
),
|
||||
),
|
||||
@@ -641,7 +689,7 @@ class _PermissionPageState extends State<PermissionPage> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildBottomTip() {
|
||||
Widget _buildBottomTip(bool isDark) {
|
||||
return Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(bottom: 32),
|
||||
@@ -649,7 +697,7 @@ class _PermissionPageState extends State<PermissionPage> {
|
||||
'到底了',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Colors.grey[400],
|
||||
color: isDark ? Colors.grey[500] : Colors.grey[400],
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user