Skip to content

Commit d429c4a

Browse files
committed
feat(content): update create source page to use reactive dropdowns
Refactored the `create_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 `CreateSourceBloc` 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.
1 parent 7cefb3c commit d429c4a

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

lib/content_management/view/create_source_page.dart

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,15 @@ class _CreateSourceViewState extends State<_CreateSourceView> {
161161
.add(CreateSourceUrlChanged(value)),
162162
),
163163
const SizedBox(height: AppSpacing.lg),
164-
SearchableDropdownFormField<Language>(
164+
SearchableDropdownFormField<Language, CreateSourceBloc,
165+
CreateSourceState>(
165166
labelText: l10n.language,
166-
items: state.languages,
167+
bloc: context.read<CreateSourceBloc>(),
167168
initialValue: state.language,
168-
hasMore: state.languagesHasMore,
169-
isLoading: state.status == CreateSourceStatus.loading,
169+
itemsExtractor: (state) => state.languages,
170+
hasMoreExtractor: (state) => state.languagesHasMore,
171+
isLoadingExtractor: (state) =>
172+
state.status == CreateSourceStatus.loading,
170173
onChanged: (value) => context
171174
.read<CreateSourceBloc>()
172175
.add(CreateSourceLanguageChanged(value)),
@@ -206,12 +209,15 @@ class _CreateSourceViewState extends State<_CreateSourceView> {
206209
.add(CreateSourceTypeChanged(value)),
207210
),
208211
const SizedBox(height: AppSpacing.lg),
209-
SearchableDropdownFormField<Country>(
212+
SearchableDropdownFormField<Country, CreateSourceBloc,
213+
CreateSourceState>(
210214
labelText: l10n.headquarters,
211-
items: state.countries,
215+
bloc: context.read<CreateSourceBloc>(),
212216
initialValue: state.headquarters,
213-
hasMore: state.countriesHasMore,
214-
isLoading: state.status == CreateSourceStatus.loading,
217+
itemsExtractor: (state) => state.countries,
218+
hasMoreExtractor: (state) => state.countriesHasMore,
219+
isLoadingExtractor: (state) =>
220+
state.status == CreateSourceStatus.loading,
215221
onChanged: (value) => context
216222
.read<CreateSourceBloc>()
217223
.add(CreateSourceHeadquartersChanged(value)),

0 commit comments

Comments
 (0)