完善细类
This commit is contained in:
@@ -23,14 +23,16 @@ class _AppFunSettingsPageState extends State<AppFunSettingsPage> {
|
||||
bool _debugInfoEnabled = false;
|
||||
bool _soundEnabled = false; // 默认关闭
|
||||
bool _vibrationEnabled = true;
|
||||
bool _darkModeEnabled = false;
|
||||
bool _preloadEnabled = true;
|
||||
bool _globalTipsEnabled = true; // 添加全局Tips开关状态
|
||||
bool _hideSecondaryButtons = false; // 隐藏次要按钮
|
||||
|
||||
static const String _autoRefreshKey = 'auto_refresh_enabled';
|
||||
static const String _debugInfoKey = 'debug_info_enabled';
|
||||
static const String _globalTipsKey = 'global_tips_enabled'; // 添加全局Tips开关key
|
||||
static const String _soundEnabledKey = 'sound_enabled'; // 声音反馈开关key
|
||||
static const String _hideSecondaryButtonsKey =
|
||||
'hide_secondary_buttons'; // 隐藏次要按钮key
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -48,6 +50,8 @@ class _AppFunSettingsPageState extends State<AppFunSettingsPage> {
|
||||
prefs.getBool(_globalTipsKey) ?? true; // 加载全局Tips开关状态
|
||||
_preloadEnabled = prefs.getBool('preload_enabled') ?? true;
|
||||
_soundEnabled = prefs.getBool(_soundEnabledKey) ?? false; // 加载声音反馈状态
|
||||
_hideSecondaryButtons =
|
||||
prefs.getBool(_hideSecondaryButtonsKey) ?? false; // 加载隐藏次要按钮状态
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -96,6 +100,65 @@ class _AppFunSettingsPageState extends State<AppFunSettingsPage> {
|
||||
}
|
||||
}
|
||||
|
||||
// 设置震动反馈
|
||||
Future<void> _setVibrationEnabled(bool value) async {
|
||||
if (value && !_vibrationEnabled) {
|
||||
// 从关闭到开启,显示提示对话框
|
||||
_showVibrationDialog();
|
||||
} else {
|
||||
// 从开启到关闭,直接设置
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_vibrationEnabled = value;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 显示震动提示对话框
|
||||
void _showVibrationDialog() {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text('震动反馈'),
|
||||
content: const Text('默认场景调用震动,未对软件震动做出优化,待收集建议改进'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: const Text('取消'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_vibrationEnabled = true;
|
||||
});
|
||||
}
|
||||
},
|
||||
child: Text(
|
||||
'确定',
|
||||
style: TextStyle(color: AppConstants.primaryColor),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// 设置隐藏次要按钮
|
||||
Future<void> _setHideSecondaryButtons(bool value) async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setBool(_hideSecondaryButtonsKey, value);
|
||||
// 更新管理器状态
|
||||
await SecondaryButtonsManager().setHidden(value);
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_hideSecondaryButtons = value;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@@ -145,14 +208,21 @@ class _AppFunSettingsPageState extends State<AppFunSettingsPage> {
|
||||
),
|
||||
]),
|
||||
const SizedBox(height: 16),
|
||||
_buildSettingsGroup('显示设置', [
|
||||
_buildSwitchItem(
|
||||
_buildSettingsGroup('主页显示设置', [
|
||||
_buildDevelopmentItem(
|
||||
'Tap沉浸光感',
|
||||
'开启后底栏显示类iOS26 风格\nbeta实验功能',
|
||||
'开启后底栏显示类iOS26 风格',
|
||||
Icons.dark_mode,
|
||||
_darkModeEnabled,
|
||||
(value) => setState(() => _darkModeEnabled = value),
|
||||
),
|
||||
|
||||
_buildSwitchItem(
|
||||
'隐藏次要按钮',
|
||||
'开启后隐藏上一条和分享按钮',
|
||||
Icons.share,
|
||||
_hideSecondaryButtons,
|
||||
_setHideSecondaryButtons,
|
||||
),
|
||||
|
||||
_buildFontSliderItem(),
|
||||
]),
|
||||
const SizedBox(height: 16),
|
||||
@@ -184,30 +254,30 @@ class _AppFunSettingsPageState extends State<AppFunSettingsPage> {
|
||||
'操作时震动提示',
|
||||
Icons.vibration,
|
||||
_vibrationEnabled,
|
||||
(value) => setState(() => _vibrationEnabled = value),
|
||||
(value) => _setVibrationEnabled(value),
|
||||
),
|
||||
]),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
_buildSettingsGroup('高级设置', [
|
||||
_buildActionItem(
|
||||
'Beta开关 关闭软件',
|
||||
'开发者选项',
|
||||
Icons.developer_mode,
|
||||
() => _showSnackBar('调试模式开发中'),
|
||||
),
|
||||
// _buildActionItem(
|
||||
// 'Beta开关 关闭软件',
|
||||
// '开发者选项',
|
||||
// Icons.developer_mode,
|
||||
// () => _showSnackBar('调试模式开发中'),
|
||||
// ),
|
||||
_buildActionItem(
|
||||
'重置设置',
|
||||
'恢复默认设置',
|
||||
Icons.restore,
|
||||
() => _showResetDialog(),
|
||||
),
|
||||
_buildActionItem(
|
||||
'调试模式',
|
||||
'开发者选项',
|
||||
Icons.developer_mode,
|
||||
() => _showSnackBar('调试模式开发中'),
|
||||
),
|
||||
// _buildActionItem(
|
||||
// '调试模式',
|
||||
// '开发者选项',
|
||||
// Icons.developer_mode,
|
||||
// () => _showSnackBar('调试模式开发中'),
|
||||
// ),
|
||||
]),
|
||||
const SizedBox(height: 32),
|
||||
_buildVersionInfo(),
|
||||
@@ -337,6 +407,46 @@ class _AppFunSettingsPageState extends State<AppFunSettingsPage> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDevelopmentItem(String title, String subtitle, IconData icon) {
|
||||
return ListTile(
|
||||
leading: Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey.withValues(alpha: 0.1),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Icon(icon, color: Colors.grey, size: 20),
|
||||
),
|
||||
title: Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.grey[600],
|
||||
),
|
||||
),
|
||||
subtitle: Text(
|
||||
subtitle,
|
||||
style: TextStyle(fontSize: 12, color: Colors.grey[400]),
|
||||
),
|
||||
trailing: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey.withValues(alpha: 0.2),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Text(
|
||||
'开发中',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Colors.grey[600],
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildVersionInfo() {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(20),
|
||||
@@ -399,7 +509,6 @@ class _AppFunSettingsPageState extends State<AppFunSettingsPage> {
|
||||
_soundEnabled = true;
|
||||
_vibrationEnabled = true;
|
||||
_globalTipsEnabled = true; // 重置全局Tips开关为开启
|
||||
_darkModeEnabled = false;
|
||||
});
|
||||
_showSnackBar('已恢复默认设置');
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user