import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'HomePage/presentation/home_page.dart'; import 'HospitalPage/presentation/hospital_page.dart'; import 'MallPage/presentation/mall_page.dart'; import 'MinePage/presentation/mine_page.dart'; class MainTabPage extends ConsumerStatefulWidget{ const MainTabPage({super.key}); @override ConsumerState createState() => _MainTabPageState(); } class _MainTabPageState extends ConsumerState with SingleTickerProviderStateMixin { int _currentIndex = 0; final List _pages = const [ HomePage(), HospitalPage(), MallPage(), MinePage(), ]; @override Widget build(BuildContext context) { return Scaffold( body: IndexedStack( index: _currentIndex, children: _pages, ), bottomNavigationBar: BottomNavigationBar( currentIndex: _currentIndex, type: BottomNavigationBarType.fixed, onTap: (index) { setState(() { _currentIndex = index; }); }, items: const [ BottomNavigationBarItem( icon: Icon(Icons.home_outlined), activeIcon: Icon(Icons.home), label: '首页', ), BottomNavigationBarItem( icon: Icon(Icons.local_hospital_outlined), activeIcon: Icon(Icons.local_hospital), label: '医院', ), BottomNavigationBarItem( icon: Icon(Icons.shopping_cart_outlined), activeIcon: Icon(Icons.shopping_cart), label: '商城', ), BottomNavigationBarItem( icon: Icon(Icons.person_outlined), activeIcon: Icon(Icons.person), label: '我的', ), ] ), ); } }