fix: align settings page style with other pages using Card containers

设置页改为与 Dashboard/Alerts 等页面一致的卡片分组风格:
每个设置分区用 Card 容器包裹,内部 ListTile 用 Divider(height:1) 分隔,
统一使用 AppColors.surface 卡片背景色,外边距 padding: 16。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-02-23 01:51:42 -08:00
parent d1993a1175
commit b76b5246cc
1 changed files with 139 additions and 90 deletions

View File

@ -1,6 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
import '../../../../core/theme/app_colors.dart';
import '../../../auth/data/providers/auth_provider.dart'; import '../../../auth/data/providers/auth_provider.dart';
import '../providers/settings_providers.dart'; import '../providers/settings_providers.dart';
@ -25,14 +26,22 @@ class _SettingsPageState extends ConsumerState<SettingsPage> {
final settings = ref.watch(settingsProvider); final settings = ref.watch(settingsProvider);
final profile = ref.watch(accountProfileProvider); final profile = ref.watch(accountProfileProvider);
final theme = Theme.of(context); final theme = Theme.of(context);
final cardColor = theme.cardTheme.color ?? AppColors.surface;
return Scaffold( return Scaffold(
appBar: AppBar(title: const Text('设置')), appBar: AppBar(
title: const Text('设置'),
),
body: ListView( body: ListView(
padding: const EdgeInsets.symmetric(vertical: 8), padding: const EdgeInsets.all(16),
children: [ children: [
// --- Profile Section --- // --- Profile Section ---
_SectionHeader(title: '个人信息'), _SectionHeader(title: '个人信息'),
const SizedBox(height: 8),
Card(
color: cardColor,
child: Column(
children: [
ListTile( ListTile(
leading: CircleAvatar( leading: CircleAvatar(
backgroundColor: theme.colorScheme.primary, backgroundColor: theme.colorScheme.primary,
@ -45,7 +54,9 @@ class _SettingsPageState extends ConsumerState<SettingsPage> {
), ),
), ),
title: Text( title: Text(
profile.displayName.isNotEmpty ? profile.displayName : '加载中...', profile.displayName.isNotEmpty
? profile.displayName
: '加载中...',
), ),
subtitle: Text(profile.email), subtitle: Text(profile.email),
trailing: IconButton( trailing: IconButton(
@ -53,18 +64,25 @@ class _SettingsPageState extends ConsumerState<SettingsPage> {
onPressed: () => _showEditNameDialog(profile.displayName), onPressed: () => _showEditNameDialog(profile.displayName),
), ),
), ),
const Divider(height: 1),
ListTile( ListTile(
leading: const Icon(Icons.lock_outline), leading: const Icon(Icons.lock_outline),
title: const Text('修改密码'), title: const Text('修改密码'),
trailing: const Icon(Icons.chevron_right), trailing: const Icon(Icons.chevron_right),
onTap: _showChangePasswordSheet, onTap: _showChangePasswordSheet,
), ),
const Divider(), ],
),
),
const SizedBox(height: 20),
// --- Appearance Section --- // --- Appearance Section ---
_SectionHeader(title: '外观'), _SectionHeader(title: '外观'),
Padding( const SizedBox(height: 8),
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), Card(
color: cardColor,
child: Padding(
padding: const EdgeInsets.all(16),
child: SegmentedButton<ThemeMode>( child: SegmentedButton<ThemeMode>(
segments: const [ segments: const [
ButtonSegment( ButtonSegment(
@ -82,63 +100,94 @@ class _SettingsPageState extends ConsumerState<SettingsPage> {
], ],
selected: {settings.themeMode}, selected: {settings.themeMode},
onSelectionChanged: (modes) { onSelectionChanged: (modes) {
ref.read(settingsProvider.notifier).setThemeMode(modes.first); ref
.read(settingsProvider.notifier)
.setThemeMode(modes.first);
}, },
), ),
), ),
const Divider(), ),
const SizedBox(height: 20),
// --- Notifications Section --- // --- Notifications Section ---
_SectionHeader(title: '通知'), _SectionHeader(title: '通知'),
const SizedBox(height: 8),
Card(
color: cardColor,
child: Column(
children: [
SwitchListTile( SwitchListTile(
secondary: const Icon(Icons.notifications_outlined), secondary: const Icon(Icons.notifications_outlined),
title: const Text('推送通知'), title: const Text('推送通知'),
value: settings.notificationsEnabled, value: settings.notificationsEnabled,
onChanged: (v) { onChanged: (v) {
ref.read(settingsProvider.notifier).setNotificationsEnabled(v); ref
.read(settingsProvider.notifier)
.setNotificationsEnabled(v);
}, },
), ),
const Divider(height: 1),
SwitchListTile( SwitchListTile(
secondary: const Icon(Icons.volume_up_outlined), secondary: const Icon(Icons.volume_up_outlined),
title: const Text('提示音'), title: const Text('提示音'),
value: settings.soundEnabled, value: settings.soundEnabled,
onChanged: settings.notificationsEnabled onChanged: settings.notificationsEnabled
? (v) => ref.read(settingsProvider.notifier).setSoundEnabled(v) ? (v) => ref
.read(settingsProvider.notifier)
.setSoundEnabled(v)
: null, : null,
), ),
const Divider(height: 1),
SwitchListTile( SwitchListTile(
secondary: const Icon(Icons.vibration), secondary: const Icon(Icons.vibration),
title: const Text('震动反馈'), title: const Text('震动反馈'),
value: settings.hapticFeedback, value: settings.hapticFeedback,
onChanged: settings.notificationsEnabled onChanged: settings.notificationsEnabled
? (v) => ? (v) => ref
ref.read(settingsProvider.notifier).setHapticFeedback(v) .read(settingsProvider.notifier)
.setHapticFeedback(v)
: null, : null,
), ),
const Divider(), ],
),
),
const SizedBox(height: 20),
// --- About Section --- // --- About Section ---
_SectionHeader(title: '关于'), _SectionHeader(title: '关于'),
const SizedBox(height: 8),
Card(
color: cardColor,
child: Column(
children: [
const ListTile( const ListTile(
leading: Icon(Icons.info_outline), leading: Icon(Icons.info_outline),
title: Text('应用版本'), title: Text('应用版本'),
subtitle: Text('iAgent v1.0.0'), subtitle: Text('iAgent v1.0.0'),
), ),
if (settings.selectedTenantName != null) if (settings.selectedTenantName != null) ...[
const Divider(height: 1),
ListTile( ListTile(
leading: const Icon(Icons.business), leading: const Icon(Icons.business),
title: const Text('租户'), title: const Text('租户'),
subtitle: Text(settings.selectedTenantName!), subtitle: Text(settings.selectedTenantName!),
), ),
const Divider(), ],
],
),
),
const SizedBox(height: 20),
// --- Logout --- // --- Logout ---
ListTile( Card(
color: cardColor,
child: ListTile(
leading: const Icon(Icons.logout, color: Colors.red), leading: const Icon(Icons.logout, color: Colors.red),
title: title: const Text('退出登录',
const Text('退出登录', style: TextStyle(color: Colors.red)), style: TextStyle(color: Colors.red)),
onTap: () => _confirmLogout(), onTap: () => _confirmLogout(),
), ),
),
const SizedBox(height: 32), const SizedBox(height: 32),
], ],
), ),