Repository navigation
Expand file tree
/
Copy pathmain.dart
More file actions
63 lines (59 loc) · 1.97 KB
/
Copy pathmain.dart
File metadata and controls
63 lines (59 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:google_fonts/google_fonts.dart';
import 'features/auth/auth_provider.dart';
import 'features/auth/login_screen.dart';
import 'features/customer/customer_list_screen.dart';
import 'features/customer/customer_provider.dart';
import 'features/reading/reading_provider.dart';
import 'features/payment/bill_list_screen.dart';
void main() {
runApp(
MultiProvider(
providers: [
ChangeNotifierProvider(create: (_) => AuthProvider()..checkAuth()),
ChangeNotifierProvider(create: (_) => CustomerProvider()),
ChangeNotifierProvider(create: (_) => ReadingProvider()),
],
child: const WaterBillingApp(),
),
);
}
class WaterBillingApp extends StatelessWidget {
const WaterBillingApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Water Billing',
debugShowCheckedModeBanner: false,
theme: ThemeData(
useMaterial3: true,
colorScheme: ColorScheme.fromSeed(
seedColor: const Color(0xFF0061FF),
primary: const Color(0xFF0061FF),
secondary: const Color(0xFF60EFFF),
),
textTheme: GoogleFonts.outfitTextTheme(),
),
home: Consumer<AuthProvider>(
builder: (context, auth, _) {
if (auth.status == AuthStatus.initial) {
return const Scaffold(
body: Center(
child: CircularProgressIndicator(),
),
);
}
if (auth.status == AuthStatus.authenticated) {
// Nếu là admin hoặc worker thì vào danh sách hộ dân, ngược lại vào hóa đơn cá nhân
if (auth.username == "admin" || auth.role == "worker") {
return const CustomerListScreen();
}
return const BillListScreen();
}
return const LoginScreen();
},
),
);
}
}