feat:更新记录UI布局

This commit is contained in:
2025-07-22 22:48:49 +08:00
parent 65958d925e
commit 5d156d3a02
11 changed files with 135 additions and 116 deletions

View File

@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:food_hub_app/layout/index.dart';
import 'package:food_hub_app/models/layout.dart';
import 'package:food_hub_app/views/moment.dart';
import 'package:food_hub_app/views/profile.dart';
import 'package:food_hub_app/views/record.dart';
@@ -15,13 +16,43 @@ class HomePage extends StatefulWidget {
class _HomePage extends State<HomePage> {
int _currentIndex = 0;
final List<Widget> _tabPages = const [
RecordPage(),
StatsPage(),
MomentPage(),
ProfilePage(),
final List<NavItem> navItems = [
NavItem(
label: "记录",
icon: Icons.home_outlined,
activeIcon: Icons.home,
page: RecordPage(),
),
NavItem(
label: "统计",
icon: Icons.pie_chart_outline,
activeIcon: Icons.pie_chart,
page: StatsPage(),
),
NavItem(
label: "朋友圈",
icon: Icons.group_outlined,
activeIcon: Icons.group,
page: MomentPage(),
),
NavItem(
label: "我的",
icon: Icons.account_circle_outlined,
activeIcon: Icons.account_circle,
page: ProfilePage(),
)
];
List<BottomNavigationBarItem> get bottomNavItems =>
navItems.map((item) => BottomNavigationBarItem(
icon: Icon(item.icon),
activeIcon: Icon(item.activeIcon),
label: item.label,
)).toList();
List<Widget> get tabPages =>
navItems.map((item) => item.page).toList();
bool isShow(int index) {
return index == 0 || index == 2;
}
@@ -43,10 +74,11 @@ class _HomePage extends State<HomePage> {
),
backgroundColor: Color(0xFFF5F5F5),
endDrawer: const SettingsDrawer(),
body: _tabPages[_currentIndex],
body: tabPages[_currentIndex],
floatingActionButton:
isShow(_currentIndex) ? addItemButton(context) : null,
bottomNavigationBar: NavBar(
navItems: bottomNavItems,
currentIndex: _currentIndex,
onTap: (index) {
setState(() {