import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../../services/auth_service.dart'; class HomePage extends StatefulWidget { const HomePage({super.key}); @override State createState() => _HomePageState(); } class _HomePageState extends State { int _tabIndex = 0; @override Widget build(BuildContext context) { final auth = context.read(); return Scaffold( appBar: AppBar(title: const Text('智慧水务'), actions: [ IconButton(icon: const Icon(Icons.logout), onPressed: () async { await auth.logout(); Navigator.pushReplacement(context, MaterialPageRoute(builder: (_) => const HomePage())); }) ]), body: IndexedStack(index: _tabIndex, children: const [ Center(child: Text('💧 供水管理')), Center(child: Text('🔍 巡检管理')), Center(child: Text('💰 营业收费')), ]), bottomNavigationBar: BottomNavigationBar( currentIndex: _tabIndex, onTap: (i) => setState(() => _tabIndex = i), items: const [ BottomNavigationBarItem(icon: Icon(Icons.water), label: '供水'), BottomNavigationBarItem(icon: Icon(Icons.search), label: '巡检'), BottomNavigationBarItem(icon: Icon(Icons.receipt_long), label: '营收'), ], ), ); } }