This commit is contained in:
vipg
2025-11-13 18:28:02 +08:00
parent e85f38ac81
commit f5a3255df8

View File

@@ -74,23 +74,7 @@ class _HomePageState extends State<HomePage> {
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<HomePage> {
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<HomePage> {
),
),
),
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<HomePage> {
color: Theme.of(
context,
).colorScheme.surfaceContainerHighest,
// 使用withValues替换withOpacity
border: Border(
bottom: BorderSide(
color: Theme.of(
@@ -204,6 +208,7 @@ class _HomePageState extends State<HomePage> {
// 子功能操作页面区域
Expanded(child: currentSubFunction.page),
Expanded(child: currentSubFunction.page),
],
),
),