From f5a3255df81e3b0ce87352cf9d85c50501bae386 Mon Sep 17 00:00:00 2001 From: vipg Date: Thu, 13 Nov 2025 18:28:02 +0800 Subject: [PATCH] add --- .../asset_assistant/lib/pages/home_page.dart | 97 ++++++++++--------- 1 file changed, 51 insertions(+), 46 deletions(-) diff --git a/frontend/asset_assistant/lib/pages/home_page.dart b/frontend/asset_assistant/lib/pages/home_page.dart index 06aa62b..c2def9a 100644 --- a/frontend/asset_assistant/lib/pages/home_page.dart +++ b/frontend/asset_assistant/lib/pages/home_page.dart @@ -74,23 +74,7 @@ class _HomePageState extends State { return Scaffold( backgroundColor: Theme.of(context).colorScheme.surface, - appBar: AppBar( - leading: IconButton( - icon: const Icon(Icons.settings), - onPressed: () { - Navigator.pushNamed(context, '/setting_list'); - }, - ), - title: const Text(''), - backgroundColor: Theme.of(context).colorScheme.surface, - elevation: 4, - actions: [ - IconButton( - icon: const Icon(Icons.logout), - onPressed: () => _logout(context), - ), - ], - ), + // 移除顶部导航栏 body: Row( children: [ // 左侧功能导航栏 @@ -98,7 +82,6 @@ class _HomePageState extends State { width: 180, decoration: BoxDecoration( color: Theme.of(context).colorScheme.surfaceContainerHighest, - // 使用withValues替换withOpacity border: Border( right: BorderSide( color: Theme.of( @@ -107,35 +90,57 @@ class _HomePageState extends State { ), ), ), - child: ListView.builder( - itemCount: _functions.length, - itemBuilder: (context, index) { - final function = _functions[index]; - return ListTile( - title: Text( - function.name, - style: TextStyle( - color: _selectedFunctionIndex == index - ? Theme.of(context).colorScheme.secondary - : Theme.of(context).colorScheme.onSurface, - fontWeight: _selectedFunctionIndex == index - ? FontWeight.bold - : FontWeight.normal, - ), + child: Column( + children: [ + // 功能列表 + Expanded( + child: ListView.builder( + itemCount: _functions.length, + itemBuilder: (context, index) { + final function = _functions[index]; + return ListTile( + title: Text( + function.name, + style: TextStyle( + color: _selectedFunctionIndex == index + ? Theme.of(context).colorScheme.secondary + : Theme.of(context).colorScheme.onSurface, + fontWeight: _selectedFunctionIndex == index + ? FontWeight.bold + : FontWeight.normal, + ), + ), + selected: _selectedFunctionIndex == index, + selectedTileColor: Theme.of( + context, + ).colorScheme.primary.withValues(alpha: 0.1), + onTap: () { + setState(() { + _selectedFunctionIndex = index; + _selectedSubFunctionIndex = 0; // 切换功能时默认选中第一个子功能 + }); + }, + ); + }, ), - selected: _selectedFunctionIndex == index, - // 使用withValues替换withOpacity - selectedTileColor: Theme.of( + ), + // 底部退出登录功能 + const Divider(height: 1), // 分隔线 + ListTile( + title: const Text( + '退出登录', + textAlign: TextAlign.center, // 文案居中展示 + ), + // 设置文本颜色为灰白色 + textColor: Theme.of(context).colorScheme.onSurfaceVariant, + onTap: () => _logout(context), + tileColor: Theme.of( context, - ).colorScheme.primary.withValues(alpha: 0.1), - onTap: () { - setState(() { - _selectedFunctionIndex = index; - _selectedSubFunctionIndex = 0; // 切换功能时默认选中第一个子功能 - }); - }, - ); - }, + ).colorScheme.surfaceContainerHighest, + // 移除默认内边距,使居中更美观 + contentPadding: EdgeInsets.zero, + ), + ], ), ), @@ -150,7 +155,6 @@ class _HomePageState extends State { color: Theme.of( context, ).colorScheme.surfaceContainerHighest, - // 使用withValues替换withOpacity border: Border( bottom: BorderSide( color: Theme.of( @@ -204,6 +208,7 @@ class _HomePageState extends State { // 子功能操作页面区域 Expanded(child: currentSubFunction.page), + Expanded(child: currentSubFunction.page), ], ), ),