| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- import 'package:flutter/material.dart';
- import 'package:provider/provider.dart';
- import '../../services/auth_service.dart';
- import '../profile/profile_page.dart';
- import 'tabs/water_supply_tab.dart';
- import 'tabs/inspection_tab.dart';
- import 'tabs/revenue_tab.dart';
-
- /// 首页 —— 底部三 Tab (供水 / 巡检 / 营收) + 个人中心入口
- class HomePage extends StatefulWidget {
- const HomePage({super.key});
- @override
- State<HomePage> createState() => _HomePageState();
- }
-
- class _HomePageState extends State<HomePage> {
- int _tabIndex = 0;
-
- final List<Widget> _tabs = const [
- WaterSupplyTab(),
- InspectionTab(),
- RevenueTab(),
- ];
-
- final List<String> _titles = const ['供水管理', '巡检管理', '营业收费'];
-
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: AppBar(
- title: Text(_titles[_tabIndex]),
- centerTitle: true,
- actions: [
- IconButton(
- icon: const Icon(Icons.person_outline),
- tooltip: '个人中心',
- onPressed: () {
- Navigator.push(
- context,
- MaterialPageRoute(builder: (_) => const ProfilePage()),
- );
- },
- ),
- ],
- ),
- body: IndexedStack(index: _tabIndex, children: _tabs),
- bottomNavigationBar: NavigationBar(
- selectedIndex: _tabIndex,
- onDestinationSelected: (i) => setState(() => _tabIndex = i),
- destinations: const [
- NavigationDestination(
- icon: Icon(Icons.water_drop_outlined),
- selectedIcon: Icon(Icons.water_drop),
- label: '供水',
- ),
- NavigationDestination(
- icon: Icon(Icons.search),
- selectedIcon: Icon(Icons.search),
- label: '巡检',
- ),
- NavigationDestination(
- icon: Icon(Icons.receipt_long_outlined),
- selectedIcon: Icon(Icons.receipt_long),
- label: '营收',
- ),
- ],
- ),
- );
- }
- }
|