Aidra Connect 10.0.2+16
Aidra Connect Mobile Application
Loading...
Searching...
No Matches
dashboard_screen.dart
Go to the documentation of this file.
1import 'package:connect/core/localization/app_localizations.dart';
2import 'package:flutter/material.dart';
3import 'package:flutter_bloc/flutter_bloc.dart';
4
5import '../../../../core/ui/screens/views/faild_to_fetch_data_view.dart';
6import '../../../../core/ui/widgets/custom_scaffold.dart';
7import '../../../authentication/presentation/logic/authentication_bloc/authentication_bloc.dart';
8import '../logic/dashboard_cubit/dashboard_cubit.dart';
9import 'views/dashboard_data_loaded_view.dart';
10
12 const DashboardScreen({super.key});
13
14 @override
15 State<DashboardScreen> createState() => _DashboardScreenState();
16}
17
18class _DashboardScreenState extends State<DashboardScreen> {
20 final authenticationState = context.read<AuthenticationBloc>().state;
21 if (authenticationState is AuthenticatedState) {
22 String? partnerId = authenticationState.session.partnerId;
23 if (partnerId != null) {
24 context.read<DashboardCubit>().loadDashboard(partnerId);
25 }
26 }
27 }
28
29 @override
30 void initState() {
32 super.initState();
33 }
34
35 @override
36 Widget build(BuildContext context) {
37 return BlocBuilder<DashboardCubit, DashboardState>(
38 builder: (context, state) {
39 return CustomScaffold(
40 title: AppLocalizations.of(context).translate('DASHBOARD'),
41 isLeadingVisible: false,
42 isLoading: state is DashboardLoadingState,
44 body: SafeArea(
46 ),
47 );
48 },
49 );
50 }
51
53 if (state is DashboardLoadedState) {
54 return DashboardDataLoadedView(
55 entity: state.entity,
56 );
57 } else if (state is DashboardFailureState) {
58 return FailedToFetchDataView(
59 failureMessage: state.failure?.message,
60 onRetry: () {
61 _triggerDashboardLoaderEvent();
62 },
63 );
64 } else {
65 return const SizedBox();
66 }
67 }
68}
String translate(String key)
static AppLocalizations of(BuildContext context)
final DashboardEntity entity
override State< DashboardScreen > createState()
const DashboardScreen({super.key})
final num partnerId
final Widget child
override void initState()
_adaptViewToState(DashboardState state)
const DashboardScreen({super.key})
class DashboardScreen extends StatefulWidget _triggerDashboardLoaderEvent()
const DashboardFailureState({required this.failure})
override Widget build(BuildContext context)
final String title