feat:重构模块

This commit is contained in:
2026-06-27 17:12:38 +08:00
parent a5e788eee6
commit a340ba424e
31 changed files with 919 additions and 623 deletions

View File

@@ -1,8 +1,14 @@
import 'package:flutter/material.dart';
import 'package:food_hub_app/layout/app_actions.dart';
import 'package:food_hub_app/layout/app_drawer.dart';
import 'package:food_hub_app/layout/app_navbar.dart';
import 'package:food_hub_app/layout/menu.dart';
import 'package:food_hub_app/views/profile.dart';
import 'package:food_hub_app/views/record.dart';
import 'package:food_hub_app/views/stats.dart';
import 'package:liquid_glass_widgets/liquid_glass_widgets.dart';
import 'package:liquid_glass_widgets/widgets/shared/glass_page.dart';
import 'package:liquid_glass_widgets/widgets/surfaces/glass_app_bar.dart';
import 'package:liquid_glass_widgets/widgets/surfaces/glass_bottom_bar.dart';
import 'package:liquid_glass_widgets/widgets/surfaces/glass_scaffold.dart';
import 'moment.dart';
class HomePage extends StatefulWidget {
const HomePage({super.key});
@@ -14,38 +20,52 @@ class HomePage extends StatefulWidget {
class _HomePage extends State<HomePage> {
int _currentIndex = 0;
final _pages = [
const RecordPage(),
const StatsPage(),
const MomentPage(),
const ProfilePage(),
];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
centerTitle: true,
title: Text('食光集', style: TextStyle(color: Colors.white)),
backgroundColor: Theme.of(context).colorScheme.primary,
leading: Builder(
builder: (context) {
return IconButton(
icon: const Icon(Icons.menu),
color: Colors.white,
onPressed: () => Scaffold.of(context).openDrawer(),
);
},
final colors = Theme.of(context).colorScheme;
return GlassScaffold(
statusBarStyle: GlassStatusBarStyle.auto,
bottomBar: GlassBottomBar(
settings: LiquidGlassSettings(
glassColor: colors.surface
),
actions: [AppActions(pageIndex: _currentIndex)],
),
// backgroundColor: Color(0xFFF5F5F5),
drawer: AppDrawer(),
body: Padding(
padding: EdgeInsets.all(10),
child: tabPages[_currentIndex],
),
bottomNavigationBar: AppNavbar(
currentPageIndex: _currentIndex,
onTapNavbarItem: (index) {
setState(() {
_currentIndex = index;
});
},
selectedIndex: _currentIndex,
onTabSelected: (i) => setState(() => _currentIndex = i),
indicatorColor: colors.primary,
selectedIconColor: colors.surface,
unselectedIconColor: Color(0xFF000000),
tabs: const [
GlassBottomBarTab(
icon: Icon(Icons.home_outlined),
activeIcon: Icon(Icons.home),
label: '记录',
),
GlassBottomBarTab(
icon: Icon(Icons.pie_chart_outline),
activeIcon: Icon(Icons.pie_chart),
label: '统计',
),
GlassBottomBarTab(
icon: Icon(Icons.group_outlined),
activeIcon: Icon(Icons.group),
label: '朋友圈',
),
GlassBottomBarTab(
icon: Icon(Icons.account_circle_outlined),
activeIcon: Icon(Icons.account_circle),
label: '我的',
),
],
),
body: _pages[_currentIndex],
);
}
}