diff --git a/lib/content_management/bloc/create_headline/create_headline_bloc.dart b/lib/content_management/bloc/create_headline/create_headline_bloc.dart index 456fb6a..9c0da77 100644 --- a/lib/content_management/bloc/create_headline/create_headline_bloc.dart +++ b/lib/content_management/bloc/create_headline/create_headline_bloc.dart @@ -35,10 +35,6 @@ class CreateHeadlineBloc on(_onCountryChanged); on(_onStatusChanged); on(_onSubmitted); - on( - _onCountrySearchChanged, - transformer: droppable(), - ); on(_onLoadMoreCountriesRequested); } @@ -195,37 +191,6 @@ class CreateHeadlineBloc } } - Future _onCountrySearchChanged( - CreateHeadlineCountrySearchChanged event, - Emitter emit, - ) async { - await Future.delayed(_searchDebounceDuration); - emit(state.copyWith(countrySearchTerm: event.searchTerm)); - try { - final countriesResponse = await _countriesRepository.readAll( - filter: event.searchTerm.isNotEmpty ? {'name': event.searchTerm} : null, - sort: [const SortOption('name', SortOrder.asc)], - ); - - emit( - state.copyWith( - countries: countriesResponse.items, - countriesCursor: countriesResponse.cursor, - countriesHasMore: countriesResponse.hasMore, - ), - ); - } on HttpException catch (e) { - emit(state.copyWith(status: CreateHeadlineStatus.failure, exception: e)); - } catch (e) { - emit( - state.copyWith( - status: CreateHeadlineStatus.failure, - exception: UnknownException('An unexpected error occurred: $e'), - ), - ); - } - } - Future _onLoadMoreCountriesRequested( CreateHeadlineLoadMoreCountriesRequested event, Emitter emit, @@ -239,9 +204,6 @@ class CreateHeadlineBloc pagination: state.countriesCursor != null ? PaginationOptions(cursor: state.countriesCursor) : null, - filter: state.countrySearchTerm.isNotEmpty - ? {'name': state.countrySearchTerm} - : null, sort: [const SortOption('name', SortOrder.asc)], ); diff --git a/lib/content_management/bloc/create_headline/create_headline_event.dart b/lib/content_management/bloc/create_headline/create_headline_event.dart index b2dd90d..f93a664 100644 --- a/lib/content_management/bloc/create_headline/create_headline_event.dart +++ b/lib/content_management/bloc/create_headline/create_headline_event.dart @@ -84,14 +84,6 @@ final class CreateHeadlineSubmitted extends CreateHeadlineEvent { const CreateHeadlineSubmitted(); } -/// Event for when the country search term is changed. -final class CreateHeadlineCountrySearchChanged extends CreateHeadlineEvent { - const CreateHeadlineCountrySearchChanged(this.searchTerm); - final String searchTerm; - @override - List get props => [searchTerm]; -} - /// Event to request loading more countries. final class CreateHeadlineLoadMoreCountriesRequested extends CreateHeadlineEvent { diff --git a/lib/content_management/bloc/create_headline/create_headline_state.dart b/lib/content_management/bloc/create_headline/create_headline_state.dart index f4effd4..1fb3f0c 100644 --- a/lib/content_management/bloc/create_headline/create_headline_state.dart +++ b/lib/content_management/bloc/create_headline/create_headline_state.dart @@ -35,7 +35,6 @@ final class CreateHeadlineState extends Equatable { this.countriesHasMore = true, this.countriesIsLoadingMore = false, this.countriesCursor, - this.countrySearchTerm = '', this.contentStatus = ContentStatus.active, this.exception, this.createdHeadline, @@ -55,7 +54,6 @@ final class CreateHeadlineState extends Equatable { final bool countriesHasMore; final bool countriesIsLoadingMore; final String? countriesCursor; - final String countrySearchTerm; final ContentStatus contentStatus; final HttpException? exception; final Headline? createdHeadline; @@ -85,7 +83,6 @@ final class CreateHeadlineState extends Equatable { bool? countriesHasMore, bool? countriesIsLoadingMore, String? countriesCursor, - String? countrySearchTerm, ContentStatus? contentStatus, HttpException? exception, Headline? createdHeadline, @@ -106,7 +103,6 @@ final class CreateHeadlineState extends Equatable { countriesIsLoadingMore: countriesIsLoadingMore ?? this.countriesIsLoadingMore, countriesCursor: countriesCursor ?? this.countriesCursor, - countrySearchTerm: countrySearchTerm ?? this.countrySearchTerm, contentStatus: contentStatus ?? this.contentStatus, exception: exception, createdHeadline: createdHeadline ?? this.createdHeadline, @@ -129,7 +125,6 @@ final class CreateHeadlineState extends Equatable { countriesHasMore, countriesIsLoadingMore, countriesCursor, - countrySearchTerm, contentStatus, exception, createdHeadline, diff --git a/lib/content_management/bloc/create_source/create_source_bloc.dart b/lib/content_management/bloc/create_source/create_source_bloc.dart index dda551c..c2f2c88 100644 --- a/lib/content_management/bloc/create_source/create_source_bloc.dart +++ b/lib/content_management/bloc/create_source/create_source_bloc.dart @@ -31,17 +31,9 @@ class CreateSourceBloc extends Bloc { on(_onHeadquartersChanged); on(_onStatusChanged); on(_onSubmitted); - on( - _onCountrySearchChanged, - transformer: droppable(), - ); on( _onLoadMoreCountriesRequested, ); - on( - _onLanguageSearchChanged, - transformer: droppable(), - ); on( _onLoadMoreLanguagesRequested, ); @@ -186,37 +178,6 @@ class CreateSourceBloc extends Bloc { } } - Future _onCountrySearchChanged( - CreateSourceCountrySearchChanged event, - Emitter emit, - ) async { - await Future.delayed(_searchDebounceDuration); - emit(state.copyWith(countrySearchTerm: event.searchTerm)); - try { - final countriesResponse = await _countriesRepository.readAll( - filter: event.searchTerm.isNotEmpty ? {'name': event.searchTerm} : null, - sort: [const SortOption('name', SortOrder.asc)], - ); - - emit( - state.copyWith( - countries: countriesResponse.items, - countriesCursor: countriesResponse.cursor, - countriesHasMore: countriesResponse.hasMore, - ), - ); - } on HttpException catch (e) { - emit(state.copyWith(status: CreateSourceStatus.failure, exception: e)); - } catch (e) { - emit( - state.copyWith( - status: CreateSourceStatus.failure, - exception: UnknownException('An unexpected error occurred: $e'), - ), - ); - } - } - Future _onLoadMoreCountriesRequested( CreateSourceLoadMoreCountriesRequested event, Emitter emit, @@ -230,9 +191,6 @@ class CreateSourceBloc extends Bloc { pagination: state.countriesCursor != null ? PaginationOptions(cursor: state.countriesCursor) : null, - filter: state.countrySearchTerm.isNotEmpty - ? {'name': state.countrySearchTerm} - : null, sort: [const SortOption('name', SortOrder.asc)], ); @@ -263,37 +221,6 @@ class CreateSourceBloc extends Bloc { } } - Future _onLanguageSearchChanged( - CreateSourceLanguageSearchChanged event, - Emitter emit, - ) async { - await Future.delayed(_searchDebounceDuration); - emit(state.copyWith(languageSearchTerm: event.searchTerm)); - try { - final languagesResponse = await _languagesRepository.readAll( - filter: event.searchTerm.isNotEmpty ? {'name': event.searchTerm} : null, - sort: [const SortOption('name', SortOrder.asc)], - ); - - emit( - state.copyWith( - languages: languagesResponse.items, - languagesCursor: languagesResponse.cursor, - languagesHasMore: languagesResponse.hasMore, - ), - ); - } on HttpException catch (e) { - emit(state.copyWith(status: CreateSourceStatus.failure, exception: e)); - } catch (e) { - emit( - state.copyWith( - status: CreateSourceStatus.failure, - exception: UnknownException('An unexpected error occurred: $e'), - ), - ); - } - } - Future _onLoadMoreLanguagesRequested( CreateSourceLoadMoreLanguagesRequested event, Emitter emit, @@ -307,9 +234,6 @@ class CreateSourceBloc extends Bloc { pagination: state.languagesCursor != null ? PaginationOptions(cursor: state.languagesCursor) : null, - filter: state.languageSearchTerm.isNotEmpty - ? {'name': state.languageSearchTerm} - : null, sort: [const SortOption('name', SortOrder.asc)], ); diff --git a/lib/content_management/bloc/create_source/create_source_event.dart b/lib/content_management/bloc/create_source/create_source_event.dart index d15f2f4..739cc3f 100644 --- a/lib/content_management/bloc/create_source/create_source_event.dart +++ b/lib/content_management/bloc/create_source/create_source_event.dart @@ -76,27 +76,11 @@ final class CreateSourceSubmitted extends CreateSourceEvent { const CreateSourceSubmitted(); } -/// Event for when the country search term is changed. -final class CreateSourceCountrySearchChanged extends CreateSourceEvent { - const CreateSourceCountrySearchChanged(this.searchTerm); - final String searchTerm; - @override - List get props => [searchTerm]; -} - /// Event to request loading more countries. final class CreateSourceLoadMoreCountriesRequested extends CreateSourceEvent { const CreateSourceLoadMoreCountriesRequested(); } -/// Event for when the language search term is changed. -final class CreateSourceLanguageSearchChanged extends CreateSourceEvent { - const CreateSourceLanguageSearchChanged(this.searchTerm); - final String searchTerm; - @override - List get props => [searchTerm]; -} - /// Event to request loading more languages. final class CreateSourceLoadMoreLanguagesRequested extends CreateSourceEvent { const CreateSourceLoadMoreLanguagesRequested(); diff --git a/lib/content_management/bloc/create_source/create_source_state.dart b/lib/content_management/bloc/create_source/create_source_state.dart index cc0aef6..2d45156 100644 --- a/lib/content_management/bloc/create_source/create_source_state.dart +++ b/lib/content_management/bloc/create_source/create_source_state.dart @@ -33,12 +33,10 @@ final class CreateSourceState extends Equatable { this.countriesHasMore = true, this.countriesIsLoadingMore = false, this.countriesCursor, - this.countrySearchTerm = '', this.languages = const [], this.languagesHasMore = true, this.languagesIsLoadingMore = false, this.languagesCursor, - this.languageSearchTerm = '', this.contentStatus = ContentStatus.active, this.exception, this.createdSource, @@ -55,12 +53,10 @@ final class CreateSourceState extends Equatable { final bool countriesHasMore; final bool countriesIsLoadingMore; final String? countriesCursor; - final String countrySearchTerm; final List languages; final bool languagesHasMore; final bool languagesIsLoadingMore; final String? languagesCursor; - final String languageSearchTerm; final ContentStatus contentStatus; final HttpException? exception; final Source? createdSource; @@ -86,12 +82,10 @@ final class CreateSourceState extends Equatable { bool? countriesHasMore, bool? countriesIsLoadingMore, String? countriesCursor, - String? countrySearchTerm, List? languages, bool? languagesHasMore, bool? languagesIsLoadingMore, String? languagesCursor, - String? languageSearchTerm, ContentStatus? contentStatus, HttpException? exception, Source? createdSource, @@ -109,13 +103,11 @@ final class CreateSourceState extends Equatable { countriesIsLoadingMore: countriesIsLoadingMore ?? this.countriesIsLoadingMore, countriesCursor: countriesCursor ?? this.countriesCursor, - countrySearchTerm: countrySearchTerm ?? this.countrySearchTerm, languages: languages ?? this.languages, languagesHasMore: languagesHasMore ?? this.languagesHasMore, languagesIsLoadingMore: languagesIsLoadingMore ?? this.languagesIsLoadingMore, languagesCursor: languagesCursor ?? this.languagesCursor, - languageSearchTerm: languageSearchTerm ?? this.languageSearchTerm, contentStatus: contentStatus ?? this.contentStatus, exception: exception, createdSource: createdSource ?? this.createdSource, @@ -133,16 +125,14 @@ final class CreateSourceState extends Equatable { headquarters, countries, countriesHasMore, - countriesIsLoadingMore, - countriesCursor, - countrySearchTerm, - languages, - languagesHasMore, - languagesIsLoadingMore, - languagesCursor, - languageSearchTerm, - contentStatus, - exception, + countriesIsLoadingMore, + countriesCursor, + languages, + languagesHasMore, + languagesIsLoadingMore, + languagesCursor, + contentStatus, + exception, createdSource, ]; } diff --git a/lib/content_management/bloc/edit_headline/edit_headline_bloc.dart b/lib/content_management/bloc/edit_headline/edit_headline_bloc.dart index c1129e0..f280c48 100644 --- a/lib/content_management/bloc/edit_headline/edit_headline_bloc.dart +++ b/lib/content_management/bloc/edit_headline/edit_headline_bloc.dart @@ -35,10 +35,6 @@ class EditHeadlineBloc extends Bloc { on(_onCountryChanged); on(_onStatusChanged); on(_onSubmitted); - on( - _onCountrySearchChanged, - transformer: droppable(), - ); on( _onLoadMoreCountriesRequested, ); @@ -245,37 +241,6 @@ class EditHeadlineBloc extends Bloc { } } - Future _onCountrySearchChanged( - EditHeadlineCountrySearchChanged event, - Emitter emit, - ) async { - await Future.delayed(_searchDebounceDuration); - emit(state.copyWith(countrySearchTerm: event.searchTerm)); - try { - final countriesResponse = await _countriesRepository.readAll( - filter: event.searchTerm.isNotEmpty ? {'name': event.searchTerm} : null, - sort: [const SortOption('name', SortOrder.asc)], - ); - - emit( - state.copyWith( - countries: countriesResponse.items, - countriesCursor: countriesResponse.cursor, - countriesHasMore: countriesResponse.hasMore, - ), - ); - } on HttpException catch (e) { - emit(state.copyWith(status: EditHeadlineStatus.failure, exception: e)); - } catch (e) { - emit( - state.copyWith( - status: EditHeadlineStatus.failure, - exception: UnknownException('An unexpected error occurred: $e'), - ), - ); - } - } - Future _onLoadMoreCountriesRequested( EditHeadlineLoadMoreCountriesRequested event, Emitter emit, @@ -289,9 +254,6 @@ class EditHeadlineBloc extends Bloc { pagination: state.countriesCursor != null ? PaginationOptions(cursor: state.countriesCursor) : null, - filter: state.countrySearchTerm.isNotEmpty - ? {'name': state.countrySearchTerm} - : null, sort: [const SortOption('name', SortOrder.asc)], ); diff --git a/lib/content_management/bloc/edit_headline/edit_headline_event.dart b/lib/content_management/bloc/edit_headline/edit_headline_event.dart index f07256d..31de495 100644 --- a/lib/content_management/bloc/edit_headline/edit_headline_event.dart +++ b/lib/content_management/bloc/edit_headline/edit_headline_event.dart @@ -84,14 +84,6 @@ final class EditHeadlineSubmitted extends EditHeadlineEvent { const EditHeadlineSubmitted(); } -/// Event for when the country search term is changed. -final class EditHeadlineCountrySearchChanged extends EditHeadlineEvent { - const EditHeadlineCountrySearchChanged(this.searchTerm); - final String searchTerm; - @override - List get props => [searchTerm]; -} - /// Event to request loading more countries. final class EditHeadlineLoadMoreCountriesRequested extends EditHeadlineEvent { const EditHeadlineLoadMoreCountriesRequested(); diff --git a/lib/content_management/bloc/edit_headline/edit_headline_state.dart b/lib/content_management/bloc/edit_headline/edit_headline_state.dart index 804e639..30688de 100644 --- a/lib/content_management/bloc/edit_headline/edit_headline_state.dart +++ b/lib/content_management/bloc/edit_headline/edit_headline_state.dart @@ -36,7 +36,6 @@ final class EditHeadlineState extends Equatable { this.countriesHasMore = true, this.countriesIsLoadingMore = false, this.countriesCursor, - this.countrySearchTerm = '', this.contentStatus = ContentStatus.active, this.exception, this.updatedHeadline, @@ -57,7 +56,6 @@ final class EditHeadlineState extends Equatable { final bool countriesHasMore; final bool countriesIsLoadingMore; final String? countriesCursor; - final String countrySearchTerm; final ContentStatus contentStatus; final HttpException? exception; final Headline? updatedHeadline; @@ -88,7 +86,6 @@ final class EditHeadlineState extends Equatable { bool? countriesHasMore, bool? countriesIsLoadingMore, String? countriesCursor, - String? countrySearchTerm, ContentStatus? contentStatus, HttpException? exception, Headline? updatedHeadline, @@ -110,7 +107,6 @@ final class EditHeadlineState extends Equatable { countriesIsLoadingMore: countriesIsLoadingMore ?? this.countriesIsLoadingMore, countriesCursor: countriesCursor ?? this.countriesCursor, - countrySearchTerm: countrySearchTerm ?? this.countrySearchTerm, contentStatus: contentStatus ?? this.contentStatus, exception: exception, updatedHeadline: updatedHeadline ?? this.updatedHeadline, @@ -134,7 +130,6 @@ final class EditHeadlineState extends Equatable { countriesHasMore, countriesIsLoadingMore, countriesCursor, - countrySearchTerm, contentStatus, exception, updatedHeadline, diff --git a/lib/content_management/bloc/edit_source/edit_source_bloc.dart b/lib/content_management/bloc/edit_source/edit_source_bloc.dart index 5f886a0..a503235 100644 --- a/lib/content_management/bloc/edit_source/edit_source_bloc.dart +++ b/lib/content_management/bloc/edit_source/edit_source_bloc.dart @@ -32,17 +32,9 @@ class EditSourceBloc extends Bloc { on(_onHeadquartersChanged); on(_onStatusChanged); on(_onSubmitted); - on( - _onCountrySearchChanged, - transformer: droppable(), - ); on( _onLoadMoreCountriesRequested, ); - on( - _onLanguageSearchChanged, - transformer: droppable(), - ); on( _onLoadMoreLanguagesRequested, ); @@ -240,37 +232,6 @@ class EditSourceBloc extends Bloc { } } - Future _onCountrySearchChanged( - EditSourceCountrySearchChanged event, - Emitter emit, - ) async { - await Future.delayed(_searchDebounceDuration); - emit(state.copyWith(countrySearchTerm: event.searchTerm)); - try { - final countriesResponse = await _countriesRepository.readAll( - filter: event.searchTerm.isNotEmpty ? {'name': event.searchTerm} : null, - sort: [const SortOption('name', SortOrder.asc)], - ); - - emit( - state.copyWith( - countries: countriesResponse.items, - countriesCursor: countriesResponse.cursor, - countriesHasMore: countriesResponse.hasMore, - ), - ); - } on HttpException catch (e) { - emit(state.copyWith(status: EditSourceStatus.failure, exception: e)); - } catch (e) { - emit( - state.copyWith( - status: EditSourceStatus.failure, - exception: UnknownException('An unexpected error occurred: $e'), - ), - ); - } - } - Future _onLoadMoreCountriesRequested( EditSourceLoadMoreCountriesRequested event, Emitter emit, @@ -284,9 +245,6 @@ class EditSourceBloc extends Bloc { pagination: state.countriesCursor != null ? PaginationOptions(cursor: state.countriesCursor) : null, - filter: state.countrySearchTerm.isNotEmpty - ? {'name': state.countrySearchTerm} - : null, sort: [const SortOption('name', SortOrder.asc)], ); @@ -317,37 +275,6 @@ class EditSourceBloc extends Bloc { } } - Future _onLanguageSearchChanged( - EditSourceLanguageSearchChanged event, - Emitter emit, - ) async { - await Future.delayed(_searchDebounceDuration); - emit(state.copyWith(languageSearchTerm: event.searchTerm)); - try { - final languagesResponse = await _languagesRepository.readAll( - filter: event.searchTerm.isNotEmpty ? {'name': event.searchTerm} : null, - sort: [const SortOption('name', SortOrder.asc)], - ); - - emit( - state.copyWith( - languages: languagesResponse.items, - languagesCursor: languagesResponse.cursor, - languagesHasMore: languagesResponse.hasMore, - ), - ); - } on HttpException catch (e) { - emit(state.copyWith(status: EditSourceStatus.failure, exception: e)); - } catch (e) { - emit( - state.copyWith( - status: EditSourceStatus.failure, - exception: UnknownException('An unexpected error occurred: $e'), - ), - ); - } - } - Future _onLoadMoreLanguagesRequested( EditSourceLoadMoreLanguagesRequested event, Emitter emit, @@ -361,9 +288,6 @@ class EditSourceBloc extends Bloc { pagination: state.languagesCursor != null ? PaginationOptions(cursor: state.languagesCursor) : null, - filter: state.languageSearchTerm.isNotEmpty - ? {'name': state.languageSearchTerm} - : null, sort: [const SortOption('name', SortOrder.asc)], ); diff --git a/lib/content_management/bloc/edit_source/edit_source_event.dart b/lib/content_management/bloc/edit_source/edit_source_event.dart index b68ec43..ce57667 100644 --- a/lib/content_management/bloc/edit_source/edit_source_event.dart +++ b/lib/content_management/bloc/edit_source/edit_source_event.dart @@ -87,27 +87,11 @@ final class EditSourceSubmitted extends EditSourceEvent { const EditSourceSubmitted(); } -/// Event for when the country search term is changed. -final class EditSourceCountrySearchChanged extends EditSourceEvent { - const EditSourceCountrySearchChanged(this.searchTerm); - final String searchTerm; - @override - List get props => [searchTerm]; -} - /// Event to request loading more countries. final class EditSourceLoadMoreCountriesRequested extends EditSourceEvent { const EditSourceLoadMoreCountriesRequested(); } -/// Event for when the language search term is changed. -final class EditSourceLanguageSearchChanged extends EditSourceEvent { - const EditSourceLanguageSearchChanged(this.searchTerm); - final String searchTerm; - @override - List get props => [searchTerm]; -} - /// Event to request loading more languages. final class EditSourceLoadMoreLanguagesRequested extends EditSourceEvent { const EditSourceLoadMoreLanguagesRequested(); diff --git a/lib/content_management/bloc/edit_source/edit_source_state.dart b/lib/content_management/bloc/edit_source/edit_source_state.dart index 82dda1c..c40b167 100644 --- a/lib/content_management/bloc/edit_source/edit_source_state.dart +++ b/lib/content_management/bloc/edit_source/edit_source_state.dart @@ -33,12 +33,10 @@ final class EditSourceState extends Equatable { this.countriesHasMore = true, this.countriesIsLoadingMore = false, this.countriesCursor, - this.countrySearchTerm = '', this.languages = const [], this.languagesHasMore = true, this.languagesIsLoadingMore = false, this.languagesCursor, - this.languageSearchTerm = '', this.contentStatus = ContentStatus.active, this.exception, this.updatedSource, @@ -56,12 +54,10 @@ final class EditSourceState extends Equatable { final bool countriesHasMore; final bool countriesIsLoadingMore; final String? countriesCursor; - final String countrySearchTerm; final List languages; final bool languagesHasMore; final bool languagesIsLoadingMore; final String? languagesCursor; - final String languageSearchTerm; final ContentStatus contentStatus; final HttpException? exception; final Source? updatedSource; @@ -88,12 +84,10 @@ final class EditSourceState extends Equatable { bool? countriesHasMore, bool? countriesIsLoadingMore, String? countriesCursor, - String? countrySearchTerm, List? languages, bool? languagesHasMore, bool? languagesIsLoadingMore, String? languagesCursor, - String? languageSearchTerm, ContentStatus? contentStatus, HttpException? exception, Source? updatedSource, @@ -112,13 +106,11 @@ final class EditSourceState extends Equatable { countriesIsLoadingMore: countriesIsLoadingMore ?? this.countriesIsLoadingMore, countriesCursor: countriesCursor ?? this.countriesCursor, - countrySearchTerm: countrySearchTerm ?? this.countrySearchTerm, languages: languages ?? this.languages, languagesHasMore: languagesHasMore ?? this.languagesHasMore, languagesIsLoadingMore: languagesIsLoadingMore ?? this.languagesIsLoadingMore, languagesCursor: languagesCursor ?? this.languagesCursor, - languageSearchTerm: languageSearchTerm ?? this.languageSearchTerm, contentStatus: contentStatus ?? this.contentStatus, exception: exception, updatedSource: updatedSource ?? this.updatedSource, @@ -139,12 +131,10 @@ final class EditSourceState extends Equatable { countriesHasMore, countriesIsLoadingMore, countriesCursor, - countrySearchTerm, languages, languagesHasMore, languagesIsLoadingMore, languagesCursor, - languageSearchTerm, contentStatus, exception, updatedSource, diff --git a/lib/content_management/view/create_headline_page.dart b/lib/content_management/view/create_headline_page.dart index 70dfc29..5829651 100644 --- a/lib/content_management/view/create_headline_page.dart +++ b/lib/content_management/view/create_headline_page.dart @@ -214,57 +214,50 @@ class _CreateHeadlineViewState extends State<_CreateHeadlineView> { .add(CreateHeadlineTopicChanged(value)), ), const SizedBox(height: AppSpacing.lg), - SearchableDropdownFormField( - labelText: l10n.countryName, - bloc: context.read(), - initialValue: state.eventCountry, - itemsExtractor: (state) => state.countries, - hasMoreExtractor: (state) => state.countriesHasMore, - isLoadingExtractor: (state) => - state.status == CreateHeadlineStatus.loading, - onChanged: (value) => context - .read() - .add(CreateHeadlineCountryChanged(value)), - onSearchChanged: (value) => context - .read() - .add(CreateHeadlineCountrySearchChanged(value)), - onLoadMore: () => context.read().add( - const CreateHeadlineLoadMoreCountriesRequested(), - ), - itemBuilder: (context, country) { - return ListTile( - leading: SizedBox( - width: 32, - height: 20, - child: Image.network( - country.flagUrl, - fit: BoxFit.cover, - errorBuilder: (context, error, stackTrace) => - const Icon(Icons.flag), + DropdownButtonFormField( + value: state.eventCountry, + decoration: InputDecoration( + labelText: l10n.countryName, + border: const OutlineInputBorder(), + ), + items: [ + DropdownMenuItem(value: null, child: Text(l10n.none)), + ...state.countries.map( + (country) => DropdownMenuItem( + value: country, + child: Row( + children: [ + SizedBox( + width: 32, + height: 20, + child: Image.network( + country.flagUrl, + fit: BoxFit.cover, + errorBuilder: + (context, error, stackTrace) => + const Icon(Icons.flag), + ), + ), + const SizedBox(width: AppSpacing.md), + Text(country.name), + ], ), ), - title: Text(country.name), - ); - }, - selectedItemBuilder: (context, country) { - return Row( - children: [ - SizedBox( - width: 32, - height: 20, - child: Image.network( - country.flagUrl, - fit: BoxFit.cover, - errorBuilder: (context, error, stackTrace) => - const Icon(Icons.flag), - ), + ), + if (state.countriesHasMore) + DropdownMenuItem( + value: null, + child: const Center( + child: Text('Load More'), ), - const SizedBox(width: AppSpacing.md), - Text(country.name), - ], - ); - }, + onTap: () => context.read().add( + const CreateHeadlineLoadMoreCountriesRequested(), + ), + ), + ], + onChanged: (value) => context + .read() + .add(CreateHeadlineCountryChanged(value)), ), const SizedBox(height: AppSpacing.lg), DropdownButtonFormField( diff --git a/lib/content_management/view/create_source_page.dart b/lib/content_management/view/create_source_page.dart index 82c921c..d073d2a 100644 --- a/lib/content_management/view/create_source_page.dart +++ b/lib/content_management/view/create_source_page.dart @@ -161,32 +161,34 @@ class _CreateSourceViewState extends State<_CreateSourceView> { .add(CreateSourceUrlChanged(value)), ), const SizedBox(height: AppSpacing.lg), - SearchableDropdownFormField( - labelText: l10n.language, - bloc: context.read(), - initialValue: state.language, - itemsExtractor: (state) => state.languages, - hasMoreExtractor: (state) => state.languagesHasMore, - isLoadingExtractor: (state) => - state.status == CreateSourceStatus.loading, + DropdownButtonFormField( + value: state.language, + decoration: InputDecoration( + labelText: l10n.language, + border: const OutlineInputBorder(), + ), + items: [ + DropdownMenuItem(value: null, child: Text(l10n.none)), + ...state.languages.map( + (language) => DropdownMenuItem( + value: language, + child: Text(language.name), + ), + ), + if (state.languagesHasMore) + DropdownMenuItem( + value: null, + child: const Center( + child: Text('Load More'), + ), + onTap: () => context.read().add( + const CreateSourceLoadMoreLanguagesRequested(), + ), + ), + ], onChanged: (value) => context .read() .add(CreateSourceLanguageChanged(value)), - onSearchChanged: (value) => context - .read() - .add(CreateSourceLanguageSearchChanged(value)), - onLoadMore: () => context.read().add( - const CreateSourceLoadMoreLanguagesRequested(), - ), - itemBuilder: (context, language) { - return ListTile( - title: Text(language.name), - ); - }, - selectedItemBuilder: (context, language) { - return Text(language.name); - }, ), const SizedBox(height: AppSpacing.lg), DropdownButtonFormField( @@ -209,57 +211,50 @@ class _CreateSourceViewState extends State<_CreateSourceView> { .add(CreateSourceTypeChanged(value)), ), const SizedBox(height: AppSpacing.lg), - SearchableDropdownFormField( - labelText: l10n.headquarters, - bloc: context.read(), - initialValue: state.headquarters, - itemsExtractor: (state) => state.countries, - hasMoreExtractor: (state) => state.countriesHasMore, - isLoadingExtractor: (state) => - state.status == CreateSourceStatus.loading, - onChanged: (value) => context - .read() - .add(CreateSourceHeadquartersChanged(value)), - onSearchChanged: (value) => context - .read() - .add(CreateSourceCountrySearchChanged(value)), - onLoadMore: () => context.read().add( - const CreateSourceLoadMoreCountriesRequested(), - ), - itemBuilder: (context, country) { - return ListTile( - leading: SizedBox( - width: 32, - height: 20, - child: Image.network( - country.flagUrl, - fit: BoxFit.cover, - errorBuilder: (context, error, stackTrace) => - const Icon(Icons.flag), + DropdownButtonFormField( + value: state.headquarters, + decoration: InputDecoration( + labelText: l10n.headquarters, + border: const OutlineInputBorder(), + ), + items: [ + DropdownMenuItem(value: null, child: Text(l10n.none)), + ...state.countries.map( + (country) => DropdownMenuItem( + value: country, + child: Row( + children: [ + SizedBox( + width: 32, + height: 20, + child: Image.network( + country.flagUrl, + fit: BoxFit.cover, + errorBuilder: + (context, error, stackTrace) => + const Icon(Icons.flag), + ), + ), + const SizedBox(width: AppSpacing.md), + Text(country.name), + ], ), ), - title: Text(country.name), - ); - }, - selectedItemBuilder: (context, country) { - return Row( - children: [ - SizedBox( - width: 32, - height: 20, - child: Image.network( - country.flagUrl, - fit: BoxFit.cover, - errorBuilder: (context, error, stackTrace) => - const Icon(Icons.flag), - ), + ), + if (state.countriesHasMore) + DropdownMenuItem( + value: null, + child: const Center( + child: Text('Load More'), ), - const SizedBox(width: AppSpacing.md), - Text(country.name), - ], - ); - }, + onTap: () => context.read().add( + const CreateSourceLoadMoreCountriesRequested(), + ), + ), + ], + onChanged: (value) => context + .read() + .add(CreateSourceHeadquartersChanged(value)), ), const SizedBox(height: AppSpacing.lg), DropdownButtonFormField( diff --git a/lib/content_management/view/edit_headline_page.dart b/lib/content_management/view/edit_headline_page.dart index b0b9df2..5b5b006 100644 --- a/lib/content_management/view/edit_headline_page.dart +++ b/lib/content_management/view/edit_headline_page.dart @@ -282,57 +282,50 @@ class _EditHeadlineViewState extends State<_EditHeadlineView> { .add(EditHeadlineTopicChanged(value)), ), const SizedBox(height: AppSpacing.lg), - SearchableDropdownFormField( - labelText: l10n.countryName, - bloc: context.read(), - initialValue: selectedCountry, - itemsExtractor: (state) => state.countries, - hasMoreExtractor: (state) => state.countriesHasMore, - isLoadingExtractor: (state) => - state.status == EditHeadlineStatus.loading, - onChanged: (value) => context - .read() - .add(EditHeadlineCountryChanged(value)), - onSearchChanged: (value) => context - .read() - .add(EditHeadlineCountrySearchChanged(value)), - onLoadMore: () => context.read().add( - const EditHeadlineLoadMoreCountriesRequested(), - ), - itemBuilder: (context, country) { - return ListTile( - leading: SizedBox( - width: 32, - height: 20, - child: Image.network( - country.flagUrl, - fit: BoxFit.cover, - errorBuilder: (context, error, stackTrace) => - const Icon(Icons.flag), + DropdownButtonFormField( + value: selectedCountry, + decoration: InputDecoration( + labelText: l10n.countryName, + border: const OutlineInputBorder(), + ), + items: [ + DropdownMenuItem(value: null, child: Text(l10n.none)), + ...state.countries.map( + (country) => DropdownMenuItem( + value: country, + child: Row( + children: [ + SizedBox( + width: 32, + height: 20, + child: Image.network( + country.flagUrl, + fit: BoxFit.cover, + errorBuilder: + (context, error, stackTrace) => + const Icon(Icons.flag), + ), + ), + const SizedBox(width: AppSpacing.md), + Text(country.name), + ], ), ), - title: Text(country.name), - ); - }, - selectedItemBuilder: (context, country) { - return Row( - children: [ - SizedBox( - width: 32, - height: 20, - child: Image.network( - country.flagUrl, - fit: BoxFit.cover, - errorBuilder: (context, error, stackTrace) => - const Icon(Icons.flag), - ), + ), + if (state.countriesHasMore) + DropdownMenuItem( + value: null, + child: const Center( + child: Text('Load More'), ), - const SizedBox(width: AppSpacing.md), - Text(country.name), - ], - ); - }, + onTap: () => context.read().add( + const EditHeadlineLoadMoreCountriesRequested(), + ), + ), + ], + onChanged: (value) => context + .read() + .add(EditHeadlineCountryChanged(value)), ), const SizedBox(height: AppSpacing.lg), DropdownButtonFormField( diff --git a/lib/content_management/view/edit_source_page.dart b/lib/content_management/view/edit_source_page.dart index 22529b3..c050df9 100644 --- a/lib/content_management/view/edit_source_page.dart +++ b/lib/content_management/view/edit_source_page.dart @@ -191,32 +191,34 @@ class _EditSourceViewState extends State<_EditSourceView> { ), ), const SizedBox(height: AppSpacing.lg), - SearchableDropdownFormField( - labelText: l10n.language, - bloc: context.read(), - initialValue: state.language, - itemsExtractor: (state) => state.languages, - hasMoreExtractor: (state) => state.languagesHasMore, - isLoadingExtractor: (state) => - state.status == EditSourceStatus.loading, + DropdownButtonFormField( + value: state.language, + decoration: InputDecoration( + labelText: l10n.language, + border: const OutlineInputBorder(), + ), + items: [ + DropdownMenuItem(value: null, child: Text(l10n.none)), + ...state.languages.map( + (language) => DropdownMenuItem( + value: language, + child: Text(language.name), + ), + ), + if (state.languagesHasMore) + DropdownMenuItem( + value: null, + child: const Center( + child: Text('Load More'), + ), + onTap: () => context.read().add( + const EditSourceLoadMoreLanguagesRequested(), + ), + ), + ], onChanged: (value) => context .read() .add(EditSourceLanguageChanged(value)), - onSearchChanged: (value) => context - .read() - .add(EditSourceLanguageSearchChanged(value)), - onLoadMore: () => context.read().add( - const EditSourceLoadMoreLanguagesRequested(), - ), - itemBuilder: (context, language) { - return ListTile( - title: Text(language.name), - ); - }, - selectedItemBuilder: (context, language) { - return Text(language.name); - }, ), const SizedBox(height: AppSpacing.lg), DropdownButtonFormField( @@ -239,57 +241,50 @@ class _EditSourceViewState extends State<_EditSourceView> { ), ), const SizedBox(height: AppSpacing.lg), - SearchableDropdownFormField( - labelText: l10n.headquarters, - bloc: context.read(), - initialValue: state.headquarters, - itemsExtractor: (state) => state.countries, - hasMoreExtractor: (state) => state.countriesHasMore, - isLoadingExtractor: (state) => - state.status == EditSourceStatus.loading, - onChanged: (value) => context - .read() - .add(EditSourceHeadquartersChanged(value)), - onSearchChanged: (value) => context - .read() - .add(EditSourceCountrySearchChanged(value)), - onLoadMore: () => context.read().add( - const EditSourceLoadMoreCountriesRequested(), - ), - itemBuilder: (context, country) { - return ListTile( - leading: SizedBox( - width: 32, - height: 20, - child: Image.network( - country.flagUrl, - fit: BoxFit.cover, - errorBuilder: (context, error, stackTrace) => - const Icon(Icons.flag), + DropdownButtonFormField( + value: state.headquarters, + decoration: InputDecoration( + labelText: l10n.headquarters, + border: const OutlineInputBorder(), + ), + items: [ + DropdownMenuItem(value: null, child: Text(l10n.none)), + ...state.countries.map( + (country) => DropdownMenuItem( + value: country, + child: Row( + children: [ + SizedBox( + width: 32, + height: 20, + child: Image.network( + country.flagUrl, + fit: BoxFit.cover, + errorBuilder: + (context, error, stackTrace) => + const Icon(Icons.flag), + ), + ), + const SizedBox(width: AppSpacing.md), + Text(country.name), + ], ), ), - title: Text(country.name), - ); - }, - selectedItemBuilder: (context, country) { - return Row( - children: [ - SizedBox( - width: 32, - height: 20, - child: Image.network( - country.flagUrl, - fit: BoxFit.cover, - errorBuilder: (context, error, stackTrace) => - const Icon(Icons.flag), - ), + ), + if (state.countriesHasMore) + DropdownMenuItem( + value: null, + child: const Center( + child: Text('Load More'), ), - const SizedBox(width: AppSpacing.md), - Text(country.name), - ], - ); - }, + onTap: () => context.read().add( + const EditSourceLoadMoreCountriesRequested(), + ), + ), + ], + onChanged: (value) => context + .read() + .add(EditSourceHeadquartersChanged(value)), ), const SizedBox(height: AppSpacing.lg), DropdownButtonFormField(