From b7cb6b247bf79ec8f103c25ff3f2794ae57f1475 Mon Sep 17 00:00:00 2001 From: vipg Date: Sat, 15 Nov 2025 16:38:13 +0800 Subject: [PATCH] add --- frontend/asset_assistant/lib/main.dart | 2 +- .../asset_assistant/lib/pages/home_page.dart | 73 +++++++++++++++++-- 2 files changed, 67 insertions(+), 8 deletions(-) diff --git a/frontend/asset_assistant/lib/main.dart b/frontend/asset_assistant/lib/main.dart index 9aefd0f..589cb75 100644 --- a/frontend/asset_assistant/lib/main.dart +++ b/frontend/asset_assistant/lib/main.dart @@ -30,7 +30,7 @@ class MyApp extends StatelessWidget { brightness: Brightness.dark, colorScheme: ColorScheme.dark( primary: const Color(0xFF0070F3), // 主色调:深蓝色 - secondary: const Color(0xFF64FFDA), // 辅助色:亮青色 + secondary: const Color(0xFF38B2AC), // 沉稳的绿松石色 // 将 background 替换为 surface surface: const Color(0xFF0F172A), // 背景色:深灰蓝 // 使用 surfaceContainerHighest 替代 deprecated 的 surfaceVariant diff --git a/frontend/asset_assistant/lib/pages/home_page.dart b/frontend/asset_assistant/lib/pages/home_page.dart index 557fa16..5568b90 100644 --- a/frontend/asset_assistant/lib/pages/home_page.dart +++ b/frontend/asset_assistant/lib/pages/home_page.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; // 如需退出应用可能需要 class HomePage extends StatelessWidget { // 功能列表数据 @@ -15,23 +16,77 @@ class HomePage extends StatelessWidget { HomePage({super.key}); + // 退出登录方法 + void _logout(BuildContext context) async { + // 显示确认对话框 + final result = await showDialog( + context: context, + builder: (context) => AlertDialog( + title: const Text('退出登录'), + content: const Text('确定要退出当前账号吗?'), + actions: [ + TextButton( + onPressed: () => Navigator.pop(context, false), + child: const Text('取消'), + ), + TextButton( + onPressed: () => Navigator.pop(context, true), + child: const Text('确定'), + ), + ], + ), + ); + + // 如果用户确认退出 + if (result == true) { + // 这里可以添加清除用户登录状态的逻辑 + // 例如清除本地存储的token等 + + // 返回登录页面(假设登录页路由为'/login') + // 替换当前导航栈,避免返回时回到主页 + Navigator.pushReplacementNamed(context, '/login'); + + // 如果需要完全退出应用,可以使用: + // SystemNavigator.pop(); + } + } + @override Widget build(BuildContext context) { final theme = Theme.of(context); return Scaffold( + // 适配主题的AppBar appBar: AppBar( title: const Text('功能列表'), centerTitle: true, elevation: 4, shadowColor: Colors.black12, + backgroundColor: theme.colorScheme.surfaceContainerHighest, + // 移除左上角返回按钮 + automaticallyImplyLeading: false, + // 右上角添加退出登录按钮 + actions: [ + TextButton( + onPressed: () => _logout(context), + child: Text( + '退出登录', + style: TextStyle( + color: theme.colorScheme.onSurface, + fontSize: 16, + ), + ), + ), + const SizedBox(width: 8), // 右侧间距 + ], ), + // 使用主题背景色 body: Container( - color: theme.scaffoldBackgroundColor, + color: theme.colorScheme.surface, child: ListView.separated( padding: const EdgeInsets.symmetric(vertical: 8), itemCount: features.length, - // 添加分割线 + // 分割线样式优化,使用主题中的分割色 separatorBuilder: (context, index) => Divider( height: 1, thickness: 1, @@ -66,31 +121,35 @@ class HomePage extends StatelessWidget { // 可以添加点击事件 }, borderRadius: BorderRadius.circular(8), + // 点击水波纹颜色使用主题主色的透明版本 + splashColor: theme.colorScheme.primary.withOpacity(0.1), + highlightColor: theme.colorScheme.primary.withOpacity(0.05), child: Container( height: 64, padding: const EdgeInsets.symmetric(horizontal: 16), child: Row( children: [ - // 图标容器 + // 图标容器 - 使用主题中的表面容器色 Container( width: 40, height: 40, decoration: BoxDecoration( - color: theme.primaryColor.withOpacity(0.1), + color: theme.colorScheme.surfaceContainerHighest, borderRadius: BorderRadius.circular(8), ), - child: Icon(icon, size: 24, color: theme.primaryColor), + child: Icon(icon, size: 24, color: theme.colorScheme.secondary), ), const SizedBox(width: 16), - // 标题 + // 标题 - 使用主题文本样式 Text( title, style: theme.textTheme.titleMedium?.copyWith( fontWeight: FontWeight.w500, + color: theme.colorScheme.onSurface, ), ), const Spacer(), - // 箭头图标,指示可点击 + // 箭头图标 - 使用主题提示色 Icon(Icons.arrow_forward_ios, size: 18, color: theme.hintColor), ], ),