import 'package:chicken_farm/components/vb_app_bar.dart'; import 'package:chicken_farm/pages/home/menu_buttons.dart'; import 'package:chicken_farm/stores/auth_store.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'profile.dart'; class HomePage extends ConsumerStatefulWidget { const HomePage({super.key}); @override ConsumerState createState() => _HomePageState(); } class _HomePageState extends ConsumerState { int _selectedIndex = 0; static const List _titles = ['功能菜单', '个人中心']; @override Widget build(BuildContext context) { final authState = ref.watch(authStoreProvider); return Scaffold( appBar: VberAppBar( title: _titles[_selectedIndex], showLeftButton: false, // 主页不显示返回按钮 ), body: _buildBody(_selectedIndex, authState), bottomNavigationBar: BottomNavigationBar( type: BottomNavigationBarType.fixed, currentIndex: _selectedIndex, onTap: (index) { setState(() { _selectedIndex = index; }); }, items: const [ BottomNavigationBarItem( icon: Icon(Icons.home_outlined), activeIcon: Icon(Icons.home), label: '功能菜单', ), BottomNavigationBarItem( icon: Icon(Icons.person_outline), activeIcon: Icon(Icons.person), label: '个人中心', ), ], ), ); } Widget _buildBody(int selectedIndex, AuthInfo authState) { switch (selectedIndex) { case 0: return const Center(child: MenuButtons()); case 1: return const ProfilePage(); default: return const Center(child: Text('页面不存在')); } } }