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,119 +26,167 @@ 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: '个人信息'),
ListTile( const SizedBox(height: 8),
leading: CircleAvatar( Card(
backgroundColor: theme.colorScheme.primary, color: cardColor,
child: Text( child: Column(
profile.displayName.isNotEmpty children: [
? profile.displayName[0].toUpperCase() ListTile(
: '?', leading: CircleAvatar(
style: const TextStyle( backgroundColor: theme.colorScheme.primary,
color: Colors.white, fontWeight: FontWeight.bold), child: Text(
), profile.displayName.isNotEmpty
), ? profile.displayName[0].toUpperCase()
title: Text( : '?',
profile.displayName.isNotEmpty ? profile.displayName : '加载中...', style: const TextStyle(
), color: Colors.white, fontWeight: FontWeight.bold),
subtitle: Text(profile.email), ),
trailing: IconButton( ),
icon: const Icon(Icons.edit), title: Text(
onPressed: () => _showEditNameDialog(profile.displayName), 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( const SizedBox(height: 20),
leading: const Icon(Icons.lock_outline),
title: const Text('修改密码'),
trailing: const Icon(Icons.chevron_right),
onTap: _showChangePasswordSheet,
),
const Divider(),
// --- Appearance Section --- // --- Appearance Section ---
_SectionHeader(title: '外观'), _SectionHeader(title: '外观'),
Padding( const SizedBox(height: 8),
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), Card(
child: SegmentedButton<ThemeMode>( color: cardColor,
segments: const [ child: Padding(
ButtonSegment( padding: const EdgeInsets.all(16),
value: ThemeMode.dark, child: SegmentedButton<ThemeMode>(
label: Text('深色'), segments: const [
icon: Icon(Icons.dark_mode)), ButtonSegment(
ButtonSegment( value: ThemeMode.dark,
value: ThemeMode.light, label: Text('深色'),
label: Text('浅色'), icon: Icon(Icons.dark_mode)),
icon: Icon(Icons.light_mode)), ButtonSegment(
ButtonSegment( value: ThemeMode.light,
value: ThemeMode.system, label: Text('浅色'),
label: Text('跟随系统'), icon: Icon(Icons.light_mode)),
icon: Icon(Icons.settings_brightness)), ButtonSegment(
], value: ThemeMode.system,
selected: {settings.themeMode}, label: Text('跟随系统'),
onSelectionChanged: (modes) { icon: Icon(Icons.settings_brightness)),
ref.read(settingsProvider.notifier).setThemeMode(modes.first); ],
}, selected: {settings.themeMode},
onSelectionChanged: (modes) {
ref
.read(settingsProvider.notifier)
.setThemeMode(modes.first);
},
),
), ),
), ),
const Divider(), const SizedBox(height: 20),
// --- Notifications Section --- // --- Notifications Section ---
_SectionHeader(title: '通知'), _SectionHeader(title: '通知'),
SwitchListTile( const SizedBox(height: 8),
secondary: const Icon(Icons.notifications_outlined), Card(
title: const Text('推送通知'), color: cardColor,
value: settings.notificationsEnabled, child: Column(
onChanged: (v) { children: [
ref.read(settingsProvider.notifier).setNotificationsEnabled(v); 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( const SizedBox(height: 20),
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(),
// --- About Section --- // --- About Section ---
_SectionHeader(title: '关于'), _SectionHeader(title: '关于'),
const ListTile( const SizedBox(height: 8),
leading: Icon(Icons.info_outline), Card(
title: Text('应用版本'), color: cardColor,
subtitle: Text('iAgent v1.0.0'), child: Column(
), children: [
if (settings.selectedTenantName != null) const ListTile(
ListTile( leading: Icon(Icons.info_outline),
leading: const Icon(Icons.business), title: Text('应用版本'),
title: const Text('租户'), subtitle: Text('iAgent v1.0.0'),
subtitle: Text(settings.selectedTenantName!), ),
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 --- // --- Logout ---
ListTile( Card(
leading: const Icon(Icons.logout, color: Colors.red), color: cardColor,
title: child: ListTile(
const Text('退出登录', style: TextStyle(color: Colors.red)), leading: const Icon(Icons.logout, color: Colors.red),
onTap: () => _confirmLogout(), title: const Text('退出登录',
style: TextStyle(color: Colors.red)),
onTap: () => _confirmLogout(),
),
), ),
const SizedBox(height: 32), const SizedBox(height: 32),
], ],