- pubspec.yaml: dio/provider/shared_preferences/flutter_map/geolocator - main.dart: Provider 状态管理 + 登录守卫 - AuthService: Token 管理 + Dio HTTP + SharedPreferences 持久化 - LoginPage: Material Design 登录页 - HomePage: 三合一 BottomTab 导航(供水/巡检/营收) - 预留依赖: flutter_local_notifications/image_picker/permission_handler
36 lines
1.3 KiB
Dart
36 lines
1.3 KiB
Dart
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<HomePage> createState() => _HomePageState();
|
|
}
|
|
|
|
class _HomePageState extends State<HomePage> {
|
|
int _tabIndex = 0;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final auth = context.read<AuthService>();
|
|
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: '营收'),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|