@@ -42,119 +42,126 @@ class _SearchPageState extends State<SearchPage> {
42
42
@override
43
43
Widget build (BuildContext context) {
44
44
ScreenUtil .init (context);
45
- var mediaQueryData = MediaQuery .of (context);
46
- var paddingTop = mediaQueryData.padding.top;
47
- var paddingBottom = mediaQueryData.padding.bottom;
48
45
return Scaffold (
49
46
body: BlocProvider <TopHeadlinesNewsBloc >(
50
47
create: (context) => topHeadlinesNewsBloc,
51
- child: Container (
52
- color: Color (0xFFEFF5F5 ),
53
- width: double .infinity,
54
- padding: EdgeInsets .symmetric (
55
- horizontal: 48. w,
56
- vertical: 24. h,
57
- ),
58
- child: Column (
59
- children: < Widget > [
60
- SizedBox (height: paddingTop),
61
- Row (
62
- children: < Widget > [
63
- GestureDetector (
64
- onTap: () {
65
- Navigator .pop (context);
66
- },
67
- child: Icon (
68
- Platform .isIOS ? Icons .arrow_back_ios : Icons .arrow_back,
69
- ),
70
- ),
71
- SizedBox (width: 24. w),
72
- Expanded (
73
- child: Container (
74
- decoration: BoxDecoration (
75
- border: Border .all (color: Colors .grey),
76
- borderRadius: BorderRadius .circular (99.0 ),
77
- ),
78
- padding: EdgeInsets .symmetric (horizontal: 36. w),
79
- child: Row (
80
- children: < Widget > [
81
- Expanded (
82
- child: TextField (
83
- controller: controllerKeyword,
84
- decoration: InputDecoration (
85
- isDense: true ,
86
- hintText: 'Searching something?' ,
87
- hintStyle: TextStyle (
88
- fontSize: 36. sp,
89
- color: Colors .grey,
90
- ),
91
- enabledBorder: InputBorder .none,
92
- focusedBorder: InputBorder .none,
93
- ),
94
- style: TextStyle (
95
- fontSize: 36. sp,
96
- ),
97
- ),
48
+ child: Stack (
49
+ children: [
50
+ Container (
51
+ width: double .infinity,
52
+ height: double .infinity,
53
+ color: Color (0xFFEFF5F5 ),
54
+ ),
55
+ SafeArea (
56
+ child: Container (
57
+ color: Color (0xFFEFF5F5 ),
58
+ width: double .infinity,
59
+ padding: EdgeInsets .symmetric (
60
+ vertical: 24. h,
61
+ horizontal: 48. w,
62
+ ),
63
+ child: Column (
64
+ children: < Widget > [
65
+ Row (
66
+ children: < Widget > [
67
+ GestureDetector (
68
+ onTap: () {
69
+ Navigator .pop (context);
70
+ },
71
+ child: Icon (
72
+ Platform .isIOS ? Icons .arrow_back_ios : Icons .arrow_back,
98
73
),
99
- Hero (
100
- tag: 'iconSearch' ,
101
- child: Focus (
102
- focusNode: focusNodeIconSearch,
103
- child: Icon (
104
- Icons .search,
105
- size: 48. w,
106
- ),
74
+ ),
75
+ SizedBox (width: 24. w),
76
+ Expanded (
77
+ child: Container (
78
+ decoration: BoxDecoration (
79
+ border: Border .all (color: Colors .grey),
80
+ borderRadius: BorderRadius .circular (99.0 ),
81
+ ),
82
+ padding: EdgeInsets .symmetric (horizontal: 36. w),
83
+ child: Row (
84
+ children: < Widget > [
85
+ Expanded (
86
+ child: TextField (
87
+ controller: controllerKeyword,
88
+ decoration: InputDecoration (
89
+ isDense: true ,
90
+ hintText: 'Searching something?' ,
91
+ hintStyle: TextStyle (
92
+ fontSize: 36. sp,
93
+ color: Colors .grey,
94
+ ),
95
+ enabledBorder: InputBorder .none,
96
+ focusedBorder: InputBorder .none,
97
+ ),
98
+ style: TextStyle (
99
+ fontSize: 36. sp,
100
+ ),
101
+ ),
102
+ ),
103
+ Hero (
104
+ tag: 'iconSearch' ,
105
+ child: Focus (
106
+ focusNode: focusNodeIconSearch,
107
+ child: Icon (
108
+ Icons .search,
109
+ size: 48. w,
110
+ ),
111
+ ),
112
+ ),
113
+ ],
107
114
),
108
115
),
109
- ] ,
110
- ) ,
116
+ ) ,
117
+ ] ,
111
118
),
112
- ),
113
- ],
114
- ),
115
- SizedBox (height: 16. h),
116
- Expanded (
117
- child: BlocBuilder <TopHeadlinesNewsBloc , TopHeadlinesNewsState >(
118
- builder: (context, state) {
119
- if (state is LoadingTopHeadlinesNewsState ) {
120
- return Center (
121
- child: Platform .isIOS ? CupertinoActivityIndicator () : CircularProgressIndicator (),
122
- );
123
- } else if (state is FailureTopHeadlinesNewsState ) {
124
- return WidgetFailureMessage ();
125
- } else if (state is SearchSuccessTopHeadlinesNewsState ) {
126
- var listArticles = state.listArticles;
127
- if (listArticles.isEmpty) {
128
- return WidgetFailureMessage (
129
- errorTitle: 'Data not found' ,
130
- errorSubtitle: 'Hm, we couldn\' t find what you were looking for.' ,
131
- );
132
- } else {
133
- return ListView .builder (
134
- padding: EdgeInsets .only (bottom: paddingBottom),
135
- itemBuilder: (context, index) {
136
- var itemArticle = listArticles[index];
137
- var dateTimePublishedAt =
138
- DateFormat ('yyy-MM-ddTHH:mm:ssZ' ).parse (itemArticle.publishedAt, true );
139
- var strPublishedAt = DateFormat ('MMM dd, yyyy HH:mm' ).format (dateTimePublishedAt);
140
- return Padding (
141
- padding: EdgeInsets .symmetric (vertical: 16. h),
142
- child: WidgetItemNews (
143
- itemArticle: itemArticle,
144
- strPublishedAt: strPublishedAt,
145
- ),
119
+ SizedBox (height: 16. h),
120
+ Expanded (
121
+ child: BlocBuilder <TopHeadlinesNewsBloc , TopHeadlinesNewsState >(
122
+ builder: (context, state) {
123
+ if (state is LoadingTopHeadlinesNewsState ) {
124
+ return Center (
125
+ child: Platform .isIOS ? CupertinoActivityIndicator () : CircularProgressIndicator (),
146
126
);
147
- },
148
- itemCount: listArticles.length,
149
- );
150
- }
151
- }
152
- return Container ();
153
- },
127
+ } else if (state is FailureTopHeadlinesNewsState ) {
128
+ return WidgetFailureMessage ();
129
+ } else if (state is SearchSuccessTopHeadlinesNewsState ) {
130
+ var listArticles = state.listArticles;
131
+ if (listArticles.isEmpty) {
132
+ return WidgetFailureMessage (
133
+ errorTitle: 'Data not found' ,
134
+ errorSubtitle: 'Hm, we couldn\' t find what you were looking for.' ,
135
+ );
136
+ } else {
137
+ return ListView .builder (
138
+ padding: EdgeInsets .zero,
139
+ itemBuilder: (context, index) {
140
+ var itemArticle = listArticles[index];
141
+ var dateTimePublishedAt =
142
+ DateFormat ('yyy-MM-ddTHH:mm:ssZ' ).parse (itemArticle.publishedAt, true );
143
+ var strPublishedAt = DateFormat ('MMM dd, yyyy HH:mm' ).format (dateTimePublishedAt);
144
+ return Padding (
145
+ padding: EdgeInsets .symmetric (vertical: 16. h),
146
+ child: WidgetItemNews (
147
+ itemArticle: itemArticle,
148
+ strPublishedAt: strPublishedAt,
149
+ ),
150
+ );
151
+ },
152
+ itemCount: listArticles.length,
153
+ );
154
+ }
155
+ }
156
+ return Container ();
157
+ },
158
+ ),
159
+ ),
160
+ ],
154
161
),
155
162
),
156
- ] ,
157
- ) ,
163
+ ) ,
164
+ ] ,
158
165
),
159
166
),
160
167
);
0 commit comments