Skip to content

Commit e11d351

Browse files
committed
refactor(content_management): replace custom country/language pickers
- Remove CountryPickerFormField and LanguagePickerFormField - Introduce CountryDropdownFormField and LanguageDropdownFormField - Update form field implementations for language and headquarters - Adjust import statements to remove unused package
1 parent 25aed47 commit e11d351

File tree

1 file changed

+11
-17
lines changed

1 file changed

+11
-17
lines changed

lib/content_management/view/edit_source_page.dart

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import 'package:core/core.dart';
2-
import 'package:country_picker/country_picker.dart' as picker;
32
import 'package:data_repository/data_repository.dart';
43
import 'package:flutter/material.dart';
54
import 'package:flutter_bloc/flutter_bloc.dart';
@@ -191,13 +190,13 @@ class _EditSourceViewState extends State<_EditSourceView> {
191190
),
192191
),
193192
const SizedBox(height: AppSpacing.lg),
194-
LanguagePickerFormField(
193+
LanguageDropdownFormField(
195194
labelText: l10n.language,
195+
languages: state.languages,
196196
initialValue: state.language,
197-
onChanged: (language) =>
198-
context.read<EditSourceBloc>().add(
199-
EditSourceLanguageChanged(language),
200-
),
197+
onChanged: (value) => context
198+
.read<EditSourceBloc>()
199+
.add(EditSourceLanguageChanged(value)),
201200
),
202201
const SizedBox(height: AppSpacing.lg),
203202
DropdownButtonFormField<SourceType?>(
@@ -220,18 +219,13 @@ class _EditSourceViewState extends State<_EditSourceView> {
220219
),
221220
),
222221
const SizedBox(height: AppSpacing.lg),
223-
CountryPickerFormField(
222+
CountryDropdownFormField(
224223
labelText: l10n.headquarters,
225-
initialValue: state.headquarters != null
226-
? adaptCoreCountryToPackageCountry(
227-
state.headquarters!,
228-
)
229-
: null,
230-
onChanged: (picker.Country country) {
231-
context.read<EditSourceBloc>().add(
232-
EditSourceHeadquartersChanged(country),
233-
);
234-
},
224+
countries: state.countries,
225+
initialValue: state.headquarters,
226+
onChanged: (value) => context
227+
.read<EditSourceBloc>()
228+
.add(EditSourceHeadquartersChanged(value)),
235229
),
236230
const SizedBox(height: AppSpacing.lg),
237231
DropdownButtonFormField<ContentStatus>(

0 commit comments

Comments
 (0)