Aidra Driver 1.3.5+68
Aidra Driver - Your path to green energy
Loading...
Searching...
No Matches
home_screen.dart
Go to the documentation of this file.
1import 'package:easy_localization/easy_localization.dart';
2import 'package:fluentui_system_icons/fluentui_system_icons.dart';
3import 'package:flutter_screenutil/flutter_screenutil.dart';
4import 'package:flutter_bloc/flutter_bloc.dart';
5import 'package:flutter/material.dart';
6import 'package:posthog_flutter/posthog_flutter.dart';
7import '../../../../core/services/location_service.dart';
8import '../../../../core/services/user_info_service.dart';
9import '../../../auth/presentation/bloc/authentication_bloc/authentication_bloc.dart';
10import '../../../../core/ui/theme/color_palette.dart';
11import '../../../../core/router/routes.dart';
12import 'widgets/dashboard_card.dart';
13import 'widgets/banner_slider.dart';
14import 'widgets/home_header.dart';
15import 'widgets/dashboard_grid.dart';
16
17class HomeScreen extends StatefulWidget {
18 const HomeScreen({super.key});
19
20 @override
21 State<HomeScreen> createState() => _HomeScreenState();
22}
23
24class _HomeScreenState extends State<HomeScreen> {
26
27 List<DashboardItem> get items => [
29 title: 'home.today_schedule'.tr(),
30 icon: FluentIcons.calendar_12_regular,
32 path: Routes.todayScheduleScreen.route,
33 ),
35 title: 'home.transactions'.tr(),
36 icon: FluentIcons.arrow_swap_16_regular,
38 path: Routes.transactionsHistoryScreen.route,
39 ),
41 title: 'home.unloading'.tr(),
42 icon: FluentIcons.vehicle_truck_profile_16_regular,
43 color: Colors.teal,
44 path: Routes.unloadingScreen.route,
45 ),
47 title: 'home.wallet'.tr(),
48 icon: FluentIcons.wallet_16_regular,
49 color: Colors.green,
50 path: Routes.wallet.route,
51 ),
52 ];
53
54
55 @override
56 void initState() {
57 super.initState();
58 final authBloc = context.read<AuthenticationBloc>();
59 final authState = authBloc.state;
60 if (authState is AuthenticatedState) {
61 UserInfoService.instance.fetchAndSaveUserInfo(authState.session.uid ?? 0);
62 WidgetsBinding.instance.addPostFrameCallback((_) async {
63 await Posthog().identify(
64 userId: authState.session.uid?.toString() ?? 'N/A',
65 userProperties: {
66 "name": authState.session.name.toString(),
67 "email": authState.session.username.toString(),
68 });
69 });
70 _locationService.setDriverId(authState.session.uid ?? 0);
71 _locationService.startLocationTracking();
72 }
73 }
74
75 @override
76 void dispose() {
77 _locationService.stopLocationTracking();
78 super.dispose();
79 }
80
81 @override
82 Widget build(BuildContext context) {
83 return Scaffold(
84 backgroundColor: ColorPalette.antiFlashWhite,
85 body: SafeArea(
87 children: [
88 SizedBox(height: 20.sp),
89 const HomeHeader(),
90 SizedBox(height: 30.sp),
91 const BannerSlider(),
92 SizedBox(height: 30.sp),
93 Expanded(
94 child: DashboardGrid(items: items),
95 ),
96 ],
97 ),
98 ),
99 );
100 }
101}
override void initState()
override void dispose()
class App extends StatefulWidget build(BuildContext context)
Definition app.dart:31
AuthGuard _()
sealed class CheckInOutEvent extends Equatable userId
static const lightGreen
static const antiFlashWhite
override State< HomeScreen > createState()
const HomeScreen({super.key})
static final UserInfoService instance
Future< UserInfo?> fetchAndSaveUserInfo(int userId) async
final Widget child
final String path
String get(String locale)
final Color color
Definition failures.dart:1
List< DashboardItem > get items
class HomeScreen extends StatefulWidget _locationService
List< DashboardItem > get DashboardItem(title:'home.transactions'.tr(), icon:FluentIcons.arrow_swap_16_regular, color:ColorPalette.lightGreen, path:Routes.transactionsHistoryScreen.route,)
Routes
Definition routes.dart:30
final String title
style SizedBox(height:2.h)
style Column(crossAxisAlignment:CrossAxisAlignment.end, children:[Container(padding:EdgeInsets.symmetric(horizontal:8.w, vertical:4.h), decoration:BoxDecoration(color:ColorPalette.tiffanyBlue.withValues(alpha:0.1), borderRadius:BorderRadius.circular(12),), child:Text(collection.type ?? '', style:Theme.of(context).textTheme.bodySmall?.copyWith(color:ColorPalette.tiffanyBlue, fontWeight:FontWeight.bold,),),),],)