智慧水务管理系统 - 精河县供水工程综合管理平台

home_page.dart 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import 'package:flutter/material.dart';
  2. import 'package:provider/provider.dart';
  3. import '../../services/auth_service.dart';
  4. import '../profile/profile_page.dart';
  5. import 'tabs/water_supply_tab.dart';
  6. import 'tabs/inspection_tab.dart';
  7. import 'tabs/revenue_tab.dart';
  8. /// 首页 —— 底部三 Tab (供水 / 巡检 / 营收) + 个人中心入口
  9. class HomePage extends StatefulWidget {
  10. const HomePage({super.key});
  11. @override
  12. State<HomePage> createState() => _HomePageState();
  13. }
  14. class _HomePageState extends State<HomePage> {
  15. int _tabIndex = 0;
  16. final List<Widget> _tabs = const [
  17. WaterSupplyTab(),
  18. InspectionTab(),
  19. RevenueTab(),
  20. ];
  21. final List<String> _titles = const ['供水管理', '巡检管理', '营业收费'];
  22. @override
  23. Widget build(BuildContext context) {
  24. return Scaffold(
  25. appBar: AppBar(
  26. title: Text(_titles[_tabIndex]),
  27. centerTitle: true,
  28. actions: [
  29. IconButton(
  30. icon: const Icon(Icons.person_outline),
  31. tooltip: '个人中心',
  32. onPressed: () {
  33. Navigator.push(
  34. context,
  35. MaterialPageRoute(builder: (_) => const ProfilePage()),
  36. );
  37. },
  38. ),
  39. ],
  40. ),
  41. body: IndexedStack(index: _tabIndex, children: _tabs),
  42. bottomNavigationBar: NavigationBar(
  43. selectedIndex: _tabIndex,
  44. onDestinationSelected: (i) => setState(() => _tabIndex = i),
  45. destinations: const [
  46. NavigationDestination(
  47. icon: Icon(Icons.water_drop_outlined),
  48. selectedIcon: Icon(Icons.water_drop),
  49. label: '供水',
  50. ),
  51. NavigationDestination(
  52. icon: Icon(Icons.search),
  53. selectedIcon: Icon(Icons.search),
  54. label: '巡检',
  55. ),
  56. NavigationDestination(
  57. icon: Icon(Icons.receipt_long_outlined),
  58. selectedIcon: Icon(Icons.receipt_long),
  59. label: '营收',
  60. ),
  61. ],
  62. ),
  63. );
  64. }
  65. }