1
+ import 'package:appetizer/app_theme.dart' ;
2
+ import 'package:appetizer/data/core/theme/dimensional/dimensional.dart' ;
3
+ import 'package:appetizer/domain/repositories/user/user_repository.dart' ;
4
+ import 'package:appetizer/presentation/app/bloc/app_bloc.dart' ;
5
+ import 'package:appetizer/presentation/components/loading_indicator.dart' ;
1
6
import 'package:appetizer/presentation/components/no_data_found_container.dart' ;
7
+ import 'package:appetizer/presentation/no_internet/bloc/no_internet_bloc.dart' ;
2
8
import 'package:appetizer/presentation/no_internet/components/no_internet_banner.dart' ;
3
9
import 'package:auto_route/auto_route.dart' ;
4
10
import 'package:flutter/material.dart' ;
11
+ import 'package:flutter_bloc/flutter_bloc.dart' ;
5
12
6
13
@RoutePage ()
7
14
class NoInternetWrapper extends StatelessWidget {
@@ -19,14 +26,79 @@ class NoInternetScreen extends StatelessWidget {
19
26
20
27
@override
21
28
Widget build (BuildContext context) {
22
- return Container (
23
- color: Colors .white,
24
- child: const Column (
25
- children: [
26
- NoInternetBanner (),
27
- NoDataFoundContainer (title: "No Internet Connection" ),
28
- ],
29
- ),
30
- );
29
+ return BlocProvider (
30
+ create: (context) =>
31
+ NoInternetBloc (repo: context.read <UserRepository >()),
32
+ child: Container (
33
+ color: Colors .white,
34
+ child: Column (
35
+ mainAxisAlignment: MainAxisAlignment .spaceBetween,
36
+ children: [
37
+ const NoInternetBanner (),
38
+ BlocBuilder <NoInternetBloc , NoInternetState >(
39
+ builder: (context, state) {
40
+ if (state is ReloadSuccess ) {
41
+ context.read <AppBloc >().add (const GetUser ());
42
+ }
43
+ if (state is NoInternetInitial ) {
44
+ return Column (
45
+ children: [
46
+ const NoDataFoundContainer (
47
+ title: "No Internet Connectivity!" ),
48
+ SizedBox (
49
+ height: 20. toAutoScaledHeight,
50
+ ),
51
+ GestureDetector (
52
+ onTap: () => context
53
+ .read <NoInternetBloc >()
54
+ .add (const ReloadPressed ()),
55
+ child: Container (
56
+ height: 24. toAutoScaledHeight,
57
+ width: 72. toAutoScaledWidth,
58
+ padding: EdgeInsets .symmetric (
59
+ horizontal: 8. toAutoScaledWidth,
60
+ ),
61
+ decoration: ShapeDecoration (
62
+ color: AppTheme .primary,
63
+ shape: RoundedRectangleBorder (
64
+ borderRadius: BorderRadius .circular (6 )),
65
+ ),
66
+ child: Center (
67
+ child: Text (
68
+ 'Reload' ,
69
+ style: AppTheme .bodyText1.copyWith (
70
+ color: AppTheme .white,
71
+ fontSize: 14. toAutoScaledFont,
72
+ fontWeight: FontWeight .w600,
73
+ decoration: TextDecoration .none),
74
+ ),
75
+ ),
76
+ )),
77
+ ],
78
+ );
79
+ }
80
+ return SizedBox (
81
+ height: 200. toAutoScaledHeight,
82
+ child: const Align (
83
+ alignment: Alignment .bottomCenter,
84
+ child: LoadingIndicator (),
85
+ ),
86
+ );
87
+ }),
88
+ SizedBox (
89
+ height: 100. toAutoScaledHeight,
90
+ )
91
+ ],
92
+ ),
93
+ ));
31
94
}
32
95
}
96
+ // Container(
97
+ // color: Colors.white,
98
+ // child: const Column(
99
+ // children: [
100
+ // NoInternetBanner(),
101
+ // NoDataFoundContainer(title: "No Internet Connection"),
102
+ // ],
103
+ // ),
104
+ // ),
0 commit comments