Skip to content

Enhance data fetching mechanism #49

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Aug 1, 2025
22 changes: 16 additions & 6 deletions lib/content_management/view/create_source_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ class _CreateSourceViewState extends State<_CreateSourceView> {
decoration: InputDecoration(
labelText: l10n.language,
border: const OutlineInputBorder(),
helperText: state.languagesIsLoadingMore
? l10n.loadingFullList
: null,
),
items: [
DropdownMenuItem(value: null, child: Text(l10n.none)),
Expand All @@ -176,9 +179,11 @@ class _CreateSourceViewState extends State<_CreateSourceView> {
),
),
],
onChanged: (value) => context
.read<CreateSourceBloc>()
.add(CreateSourceLanguageChanged(value)),
onChanged: state.languagesIsLoadingMore
? null
: (value) => context
.read<CreateSourceBloc>()
.add(CreateSourceLanguageChanged(value)),
),
const SizedBox(height: AppSpacing.lg),
DropdownButtonFormField<SourceType?>(
Expand Down Expand Up @@ -206,6 +211,9 @@ class _CreateSourceViewState extends State<_CreateSourceView> {
decoration: InputDecoration(
labelText: l10n.headquarters,
border: const OutlineInputBorder(),
helperText: state.countriesIsLoadingMore
? l10n.loadingFullList
: null,
),
items: [
DropdownMenuItem(value: null, child: Text(l10n.none)),
Expand All @@ -232,9 +240,11 @@ class _CreateSourceViewState extends State<_CreateSourceView> {
),
),
],
onChanged: (value) => context
.read<CreateSourceBloc>()
.add(CreateSourceHeadquartersChanged(value)),
onChanged: state.countriesIsLoadingMore
? null
: (value) => context
.read<CreateSourceBloc>()
.add(CreateSourceHeadquartersChanged(value)),
),
const SizedBox(height: AppSpacing.lg),
DropdownButtonFormField<ContentStatus>(
Expand Down
11 changes: 8 additions & 3 deletions lib/content_management/view/edit_headline_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,9 @@ class _EditHeadlineViewState extends State<_EditHeadlineView> {
decoration: InputDecoration(
labelText: l10n.countryName,
border: const OutlineInputBorder(),
helperText: state.countriesIsLoadingMore
? l10n.loadingFullList
: null,
),
items: [
DropdownMenuItem(value: null, child: Text(l10n.none)),
Expand All @@ -313,9 +316,11 @@ class _EditHeadlineViewState extends State<_EditHeadlineView> {
),
),
],
onChanged: (value) => context
.read<EditHeadlineBloc>()
.add(EditHeadlineCountryChanged(value)),
onChanged: state.countriesIsLoadingMore
? null
: (value) => context
.read<EditHeadlineBloc>()
.add(EditHeadlineCountryChanged(value)),
),
const SizedBox(height: AppSpacing.lg),
DropdownButtonFormField<ContentStatus>(
Expand Down
22 changes: 16 additions & 6 deletions lib/content_management/view/edit_source_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ class _EditSourceViewState extends State<_EditSourceView> {
decoration: InputDecoration(
labelText: l10n.language,
border: const OutlineInputBorder(),
helperText: state.languagesIsLoadingMore
? l10n.loadingFullList
: null,
),
items: [
DropdownMenuItem(value: null, child: Text(l10n.none)),
Expand All @@ -206,9 +209,11 @@ class _EditSourceViewState extends State<_EditSourceView> {
),
),
],
onChanged: (value) => context
.read<EditSourceBloc>()
.add(EditSourceLanguageChanged(value)),
onChanged: state.languagesIsLoadingMore
? null
: (value) => context
.read<EditSourceBloc>()
.add(EditSourceLanguageChanged(value)),
),
const SizedBox(height: AppSpacing.lg),
DropdownButtonFormField<SourceType?>(
Expand Down Expand Up @@ -236,6 +241,9 @@ class _EditSourceViewState extends State<_EditSourceView> {
decoration: InputDecoration(
labelText: l10n.headquarters,
border: const OutlineInputBorder(),
helperText: state.countriesIsLoadingMore
? l10n.loadingFullList
: null,
),
items: [
DropdownMenuItem(value: null, child: Text(l10n.none)),
Expand All @@ -262,9 +270,11 @@ class _EditSourceViewState extends State<_EditSourceView> {
),
),
],
onChanged: (value) => context
.read<EditSourceBloc>()
.add(EditSourceHeadquartersChanged(value)),
onChanged: state.countriesIsLoadingMore
? null
: (value) => context
.read<EditSourceBloc>()
.add(EditSourceHeadquartersChanged(value)),
),
const SizedBox(height: AppSpacing.lg),
DropdownButtonFormField<ContentStatus>(
Expand Down
6 changes: 6 additions & 0 deletions lib/l10n/app_localizations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1328,6 +1328,12 @@ abstract class AppLocalizations {
/// **'Loading data...'**
String get loadingData;

/// Message displayed in a dropdown when its full list of items is being loaded in the background.
///
/// In en, this message translates to:
/// **'Loading full list...'**
String get loadingFullList;

/// Title for the Create Source page
///
/// In en, this message translates to:
Expand Down
3 changes: 3 additions & 0 deletions lib/l10n/app_localizations_ar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,9 @@ class AppLocalizationsAr extends AppLocalizations {
@override
String get loadingData => 'جاري تحميل البيانات...';

@override
String get loadingFullList => 'جاري تحميل القائمة الكاملة...';

@override
String get createSource => 'إنشاء مصدر';

Expand Down
3 changes: 3 additions & 0 deletions lib/l10n/app_localizations_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,9 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get loadingData => 'Loading data...';

@override
String get loadingFullList => 'Loading full list...';

@override
String get createSource => 'Create Source';

Expand Down
6 changes: 5 additions & 1 deletion lib/l10n/arb/app_ar.arb
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,10 @@
"@loadingData": {
"description": "رسالة عامة تُعرض أثناء تحميل البيانات لنموذج"
},
"loadingFullList": "جاري تحميل القائمة الكاملة...",
"@loadingFullList": {
"description": "رسالة تُعرض في قائمة منسدلة عند تحميل قائمتها الكاملة من العناصر في الخلفية."
},
"createSource": "إنشاء مصدر",
"@createSource": {
"description": "عنوان صفحة إنشاء مصدر"
Expand Down Expand Up @@ -1090,4 +1094,4 @@
"@countryPickerSelectCountryLabel": {
"description": "التسمية المعروضة عند عدم اختيار أي دولة في حقل نموذج منتقي البلد"
}
}
}
4 changes: 4 additions & 0 deletions lib/l10n/arb/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,10 @@
"@loadingData": {
"description": "Generic message displayed while loading data for a form"
},
"loadingFullList": "Loading full list...",
"@loadingFullList": {
"description": "Message displayed in a dropdown when its full list of items is being loaded in the background."
},
"createSource": "Create Source",
"@createSource": {
"description": "Title for the Create Source page"
Expand Down
Loading