Skip to content

Commit 35e8663

Browse files
authored
Merge pull request #49 from flutter-news-app-full-source-code/enhance-data-fetching-mechanism
Enhance data fetching mechanism
2 parents f8cca99 + 421dc9c commit 35e8663

File tree

8 files changed

+61
-16
lines changed

8 files changed

+61
-16
lines changed

lib/content_management/view/create_source_page.dart

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ class _CreateSourceViewState extends State<_CreateSourceView> {
166166
decoration: InputDecoration(
167167
labelText: l10n.language,
168168
border: const OutlineInputBorder(),
169+
helperText: state.languagesIsLoadingMore
170+
? l10n.loadingFullList
171+
: null,
169172
),
170173
items: [
171174
DropdownMenuItem(value: null, child: Text(l10n.none)),
@@ -176,9 +179,11 @@ class _CreateSourceViewState extends State<_CreateSourceView> {
176179
),
177180
),
178181
],
179-
onChanged: (value) => context
180-
.read<CreateSourceBloc>()
181-
.add(CreateSourceLanguageChanged(value)),
182+
onChanged: state.languagesIsLoadingMore
183+
? null
184+
: (value) => context
185+
.read<CreateSourceBloc>()
186+
.add(CreateSourceLanguageChanged(value)),
182187
),
183188
const SizedBox(height: AppSpacing.lg),
184189
DropdownButtonFormField<SourceType?>(
@@ -206,6 +211,9 @@ class _CreateSourceViewState extends State<_CreateSourceView> {
206211
decoration: InputDecoration(
207212
labelText: l10n.headquarters,
208213
border: const OutlineInputBorder(),
214+
helperText: state.countriesIsLoadingMore
215+
? l10n.loadingFullList
216+
: null,
209217
),
210218
items: [
211219
DropdownMenuItem(value: null, child: Text(l10n.none)),
@@ -232,9 +240,11 @@ class _CreateSourceViewState extends State<_CreateSourceView> {
232240
),
233241
),
234242
],
235-
onChanged: (value) => context
236-
.read<CreateSourceBloc>()
237-
.add(CreateSourceHeadquartersChanged(value)),
243+
onChanged: state.countriesIsLoadingMore
244+
? null
245+
: (value) => context
246+
.read<CreateSourceBloc>()
247+
.add(CreateSourceHeadquartersChanged(value)),
238248
),
239249
const SizedBox(height: AppSpacing.lg),
240250
DropdownButtonFormField<ContentStatus>(

lib/content_management/view/edit_headline_page.dart

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,9 @@ class _EditHeadlineViewState extends State<_EditHeadlineView> {
287287
decoration: InputDecoration(
288288
labelText: l10n.countryName,
289289
border: const OutlineInputBorder(),
290+
helperText: state.countriesIsLoadingMore
291+
? l10n.loadingFullList
292+
: null,
290293
),
291294
items: [
292295
DropdownMenuItem(value: null, child: Text(l10n.none)),
@@ -313,9 +316,11 @@ class _EditHeadlineViewState extends State<_EditHeadlineView> {
313316
),
314317
),
315318
],
316-
onChanged: (value) => context
317-
.read<EditHeadlineBloc>()
318-
.add(EditHeadlineCountryChanged(value)),
319+
onChanged: state.countriesIsLoadingMore
320+
? null
321+
: (value) => context
322+
.read<EditHeadlineBloc>()
323+
.add(EditHeadlineCountryChanged(value)),
319324
),
320325
const SizedBox(height: AppSpacing.lg),
321326
DropdownButtonFormField<ContentStatus>(

lib/content_management/view/edit_source_page.dart

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,9 @@ class _EditSourceViewState extends State<_EditSourceView> {
196196
decoration: InputDecoration(
197197
labelText: l10n.language,
198198
border: const OutlineInputBorder(),
199+
helperText: state.languagesIsLoadingMore
200+
? l10n.loadingFullList
201+
: null,
199202
),
200203
items: [
201204
DropdownMenuItem(value: null, child: Text(l10n.none)),
@@ -206,9 +209,11 @@ class _EditSourceViewState extends State<_EditSourceView> {
206209
),
207210
),
208211
],
209-
onChanged: (value) => context
210-
.read<EditSourceBloc>()
211-
.add(EditSourceLanguageChanged(value)),
212+
onChanged: state.languagesIsLoadingMore
213+
? null
214+
: (value) => context
215+
.read<EditSourceBloc>()
216+
.add(EditSourceLanguageChanged(value)),
212217
),
213218
const SizedBox(height: AppSpacing.lg),
214219
DropdownButtonFormField<SourceType?>(
@@ -236,6 +241,9 @@ class _EditSourceViewState extends State<_EditSourceView> {
236241
decoration: InputDecoration(
237242
labelText: l10n.headquarters,
238243
border: const OutlineInputBorder(),
244+
helperText: state.countriesIsLoadingMore
245+
? l10n.loadingFullList
246+
: null,
239247
),
240248
items: [
241249
DropdownMenuItem(value: null, child: Text(l10n.none)),
@@ -262,9 +270,11 @@ class _EditSourceViewState extends State<_EditSourceView> {
262270
),
263271
),
264272
],
265-
onChanged: (value) => context
266-
.read<EditSourceBloc>()
267-
.add(EditSourceHeadquartersChanged(value)),
273+
onChanged: state.countriesIsLoadingMore
274+
? null
275+
: (value) => context
276+
.read<EditSourceBloc>()
277+
.add(EditSourceHeadquartersChanged(value)),
268278
),
269279
const SizedBox(height: AppSpacing.lg),
270280
DropdownButtonFormField<ContentStatus>(

lib/l10n/app_localizations.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,6 +1328,12 @@ abstract class AppLocalizations {
13281328
/// **'Loading data...'**
13291329
String get loadingData;
13301330

1331+
/// Message displayed in a dropdown when its full list of items is being loaded in the background.
1332+
///
1333+
/// In en, this message translates to:
1334+
/// **'Loading full list...'**
1335+
String get loadingFullList;
1336+
13311337
/// Title for the Create Source page
13321338
///
13331339
/// In en, this message translates to:

lib/l10n/app_localizations_ar.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,9 @@ class AppLocalizationsAr extends AppLocalizations {
696696
@override
697697
String get loadingData => 'جاري تحميل البيانات...';
698698

699+
@override
700+
String get loadingFullList => 'جاري تحميل القائمة الكاملة...';
701+
699702
@override
700703
String get createSource => 'إنشاء مصدر';
701704

lib/l10n/app_localizations_en.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,9 @@ class AppLocalizationsEn extends AppLocalizations {
695695
@override
696696
String get loadingData => 'Loading data...';
697697

698+
@override
699+
String get loadingFullList => 'Loading full list...';
700+
698701
@override
699702
String get createSource => 'Create Source';
700703

lib/l10n/arb/app_ar.arb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -854,6 +854,10 @@
854854
"@loadingData": {
855855
"description": "رسالة عامة تُعرض أثناء تحميل البيانات لنموذج"
856856
},
857+
"loadingFullList": "جاري تحميل القائمة الكاملة...",
858+
"@loadingFullList": {
859+
"description": "رسالة تُعرض في قائمة منسدلة عند تحميل قائمتها الكاملة من العناصر في الخلفية."
860+
},
857861
"createSource": "إنشاء مصدر",
858862
"@createSource": {
859863
"description": "عنوان صفحة إنشاء مصدر"
@@ -1090,4 +1094,4 @@
10901094
"@countryPickerSelectCountryLabel": {
10911095
"description": "التسمية المعروضة عند عدم اختيار أي دولة في حقل نموذج منتقي البلد"
10921096
}
1093-
}
1097+
}

lib/l10n/arb/app_en.arb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -854,6 +854,10 @@
854854
"@loadingData": {
855855
"description": "Generic message displayed while loading data for a form"
856856
},
857+
"loadingFullList": "Loading full list...",
858+
"@loadingFullList": {
859+
"description": "Message displayed in a dropdown when its full list of items is being loaded in the background."
860+
},
857861
"createSource": "Create Source",
858862
"@createSource": {
859863
"description": "Title for the Create Source page"

0 commit comments

Comments
 (0)