| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- 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<MainTabPage> createState() => _MainTabPageState();
- }
- class _MainTabPageState extends ConsumerState<MainTabPage>
- with SingleTickerProviderStateMixin {
- int _currentIndex = 0;
- final List<Widget> _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: '我的',
- ),
- ]
- ),
- );
- }
- }
|