diff --git a/it0_app/lib/features/settings/presentation/pages/settings_page.dart b/it0_app/lib/features/settings/presentation/pages/settings_page.dart index 4298384..cb701d5 100644 --- a/it0_app/lib/features/settings/presentation/pages/settings_page.dart +++ b/it0_app/lib/features/settings/presentation/pages/settings_page.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:go_router/go_router.dart'; +import '../../../../core/theme/app_colors.dart'; import '../../../auth/data/providers/auth_provider.dart'; import '../providers/settings_providers.dart'; @@ -25,119 +26,167 @@ class _SettingsPageState extends ConsumerState { final settings = ref.watch(settingsProvider); final profile = ref.watch(accountProfileProvider); final theme = Theme.of(context); + final cardColor = theme.cardTheme.color ?? AppColors.surface; return Scaffold( - appBar: AppBar(title: const Text('设置')), + appBar: AppBar( + title: const Text('设置'), + ), body: ListView( - padding: const EdgeInsets.symmetric(vertical: 8), + padding: const EdgeInsets.all(16), children: [ // --- Profile Section --- _SectionHeader(title: '个人信息'), - ListTile( - leading: CircleAvatar( - backgroundColor: theme.colorScheme.primary, - child: Text( - profile.displayName.isNotEmpty - ? profile.displayName[0].toUpperCase() - : '?', - style: const TextStyle( - color: Colors.white, fontWeight: FontWeight.bold), - ), - ), - title: Text( - profile.displayName.isNotEmpty ? profile.displayName : '加载中...', - ), - subtitle: Text(profile.email), - trailing: IconButton( - icon: const Icon(Icons.edit), - onPressed: () => _showEditNameDialog(profile.displayName), + const SizedBox(height: 8), + Card( + color: cardColor, + child: Column( + children: [ + ListTile( + leading: CircleAvatar( + backgroundColor: theme.colorScheme.primary, + child: Text( + profile.displayName.isNotEmpty + ? profile.displayName[0].toUpperCase() + : '?', + style: const TextStyle( + color: Colors.white, fontWeight: FontWeight.bold), + ), + ), + title: Text( + profile.displayName.isNotEmpty + ? profile.displayName + : '加载中...', + ), + subtitle: Text(profile.email), + trailing: IconButton( + icon: const Icon(Icons.edit), + onPressed: () => _showEditNameDialog(profile.displayName), + ), + ), + const Divider(height: 1), + ListTile( + leading: const Icon(Icons.lock_outline), + title: const Text('修改密码'), + trailing: const Icon(Icons.chevron_right), + onTap: _showChangePasswordSheet, + ), + ], ), ), - ListTile( - leading: const Icon(Icons.lock_outline), - title: const Text('修改密码'), - trailing: const Icon(Icons.chevron_right), - onTap: _showChangePasswordSheet, - ), - const Divider(), + const SizedBox(height: 20), // --- Appearance Section --- _SectionHeader(title: '外观'), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), - child: SegmentedButton( - segments: const [ - ButtonSegment( - value: ThemeMode.dark, - label: Text('深色'), - icon: Icon(Icons.dark_mode)), - ButtonSegment( - value: ThemeMode.light, - label: Text('浅色'), - icon: Icon(Icons.light_mode)), - ButtonSegment( - value: ThemeMode.system, - label: Text('跟随系统'), - icon: Icon(Icons.settings_brightness)), - ], - selected: {settings.themeMode}, - onSelectionChanged: (modes) { - ref.read(settingsProvider.notifier).setThemeMode(modes.first); - }, + const SizedBox(height: 8), + Card( + color: cardColor, + child: Padding( + padding: const EdgeInsets.all(16), + child: SegmentedButton( + segments: const [ + ButtonSegment( + value: ThemeMode.dark, + label: Text('深色'), + icon: Icon(Icons.dark_mode)), + ButtonSegment( + value: ThemeMode.light, + label: Text('浅色'), + icon: Icon(Icons.light_mode)), + ButtonSegment( + value: ThemeMode.system, + label: Text('跟随系统'), + icon: Icon(Icons.settings_brightness)), + ], + selected: {settings.themeMode}, + onSelectionChanged: (modes) { + ref + .read(settingsProvider.notifier) + .setThemeMode(modes.first); + }, + ), ), ), - const Divider(), + const SizedBox(height: 20), // --- Notifications Section --- _SectionHeader(title: '通知'), - SwitchListTile( - secondary: const Icon(Icons.notifications_outlined), - title: const Text('推送通知'), - value: settings.notificationsEnabled, - onChanged: (v) { - ref.read(settingsProvider.notifier).setNotificationsEnabled(v); - }, + const SizedBox(height: 8), + Card( + color: cardColor, + child: Column( + children: [ + SwitchListTile( + secondary: const Icon(Icons.notifications_outlined), + title: const Text('推送通知'), + value: settings.notificationsEnabled, + onChanged: (v) { + ref + .read(settingsProvider.notifier) + .setNotificationsEnabled(v); + }, + ), + const Divider(height: 1), + SwitchListTile( + secondary: const Icon(Icons.volume_up_outlined), + title: const Text('提示音'), + value: settings.soundEnabled, + onChanged: settings.notificationsEnabled + ? (v) => ref + .read(settingsProvider.notifier) + .setSoundEnabled(v) + : null, + ), + const Divider(height: 1), + SwitchListTile( + secondary: const Icon(Icons.vibration), + title: const Text('震动反馈'), + value: settings.hapticFeedback, + onChanged: settings.notificationsEnabled + ? (v) => ref + .read(settingsProvider.notifier) + .setHapticFeedback(v) + : null, + ), + ], + ), ), - SwitchListTile( - secondary: const Icon(Icons.volume_up_outlined), - title: const Text('提示音'), - value: settings.soundEnabled, - onChanged: settings.notificationsEnabled - ? (v) => ref.read(settingsProvider.notifier).setSoundEnabled(v) - : null, - ), - SwitchListTile( - secondary: const Icon(Icons.vibration), - title: const Text('震动反馈'), - value: settings.hapticFeedback, - onChanged: settings.notificationsEnabled - ? (v) => - ref.read(settingsProvider.notifier).setHapticFeedback(v) - : null, - ), - const Divider(), + const SizedBox(height: 20), // --- About Section --- _SectionHeader(title: '关于'), - const ListTile( - leading: Icon(Icons.info_outline), - title: Text('应用版本'), - subtitle: Text('iAgent v1.0.0'), - ), - if (settings.selectedTenantName != null) - ListTile( - leading: const Icon(Icons.business), - title: const Text('租户'), - subtitle: Text(settings.selectedTenantName!), + const SizedBox(height: 8), + Card( + color: cardColor, + child: Column( + children: [ + const ListTile( + leading: Icon(Icons.info_outline), + title: Text('应用版本'), + subtitle: Text('iAgent v1.0.0'), + ), + if (settings.selectedTenantName != null) ...[ + const Divider(height: 1), + ListTile( + leading: const Icon(Icons.business), + title: const Text('租户'), + subtitle: Text(settings.selectedTenantName!), + ), + ], + ], ), - const Divider(), + ), + const SizedBox(height: 20), // --- Logout --- - ListTile( - leading: const Icon(Icons.logout, color: Colors.red), - title: - const Text('退出登录', style: TextStyle(color: Colors.red)), - onTap: () => _confirmLogout(), + Card( + color: cardColor, + child: ListTile( + leading: const Icon(Icons.logout, color: Colors.red), + title: const Text('退出登录', + style: TextStyle(color: Colors.red)), + onTap: () => _confirmLogout(), + ), ), const SizedBox(height: 32), ],