Skip to content

Commit 332cce0

Browse files
committed
refactor: update edit source page to use reactive dropdowns
Refactored the `edit_source_page.dart` to use the new BLoC-aware `SearchableDropdownFormField` for both language and country selection. - Replaced the old dropdown implementations with the new generic `SearchableDropdownFormField`. - Injected the `EditSourceBloc` instance into each widget. - Provided extractor functions (`itemsExtractor`, `hasMoreExtractor`, `isLoadingExtractor`) to enable the dropdowns to reactively pull the correct data (languages or countries) from the BLoC's state. This change ensures that both the language and country lists in their respective search dialogs update automatically when more items are loaded via pagination, completing the bug fix.
1 parent d429c4a commit 332cce0

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

lib/content_management/view/edit_source_page.dart

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,15 @@ class _EditSourceViewState extends State<_EditSourceView> {
191191
),
192192
),
193193
const SizedBox(height: AppSpacing.lg),
194-
SearchableDropdownFormField<Language>(
194+
SearchableDropdownFormField<Language, EditSourceBloc,
195+
EditSourceState>(
195196
labelText: l10n.language,
196-
items: state.languages,
197+
bloc: context.read<EditSourceBloc>(),
197198
initialValue: state.language,
198-
hasMore: state.languagesHasMore,
199-
isLoading: state.status == EditSourceStatus.loading,
199+
itemsExtractor: (state) => state.languages,
200+
hasMoreExtractor: (state) => state.languagesHasMore,
201+
isLoadingExtractor: (state) =>
202+
state.status == EditSourceStatus.loading,
200203
onChanged: (value) => context
201204
.read<EditSourceBloc>()
202205
.add(EditSourceLanguageChanged(value)),
@@ -236,12 +239,15 @@ class _EditSourceViewState extends State<_EditSourceView> {
236239
),
237240
),
238241
const SizedBox(height: AppSpacing.lg),
239-
SearchableDropdownFormField<Country>(
242+
SearchableDropdownFormField<Country, EditSourceBloc,
243+
EditSourceState>(
240244
labelText: l10n.headquarters,
241-
items: state.countries,
245+
bloc: context.read<EditSourceBloc>(),
242246
initialValue: state.headquarters,
243-
hasMore: state.countriesHasMore,
244-
isLoading: state.status == EditSourceStatus.loading,
247+
itemsExtractor: (state) => state.countries,
248+
hasMoreExtractor: (state) => state.countriesHasMore,
249+
isLoadingExtractor: (state) =>
250+
state.status == EditSourceStatus.loading,
245251
onChanged: (value) => context
246252
.read<EditSourceBloc>()
247253
.add(EditSourceHeadquartersChanged(value)),

0 commit comments

Comments
 (0)