@@ -25,7 +25,8 @@ class EditHeadlinePage extends StatelessWidget {
25
25
create: (context) => EditHeadlineBloc (
26
26
headlinesRepository: context.read <HtDataRepository <Headline >>(),
27
27
sourcesRepository: context.read <HtDataRepository <Source >>(),
28
- categoriesRepository: context.read <HtDataRepository <Category >>(),
28
+ topicsRepository: context.read <HtDataRepository <Topic >>(),
29
+ countriesRepository: context.read <HtDataRepository <Country >>(),
29
30
headlineId: headlineId,
30
31
)..add (const EditHeadlineLoaded ()),
31
32
child: const _EditHeadlineView (),
@@ -43,7 +44,7 @@ class _EditHeadlineView extends StatefulWidget {
43
44
class _EditHeadlineViewState extends State <_EditHeadlineView > {
44
45
final _formKey = GlobalKey <FormState >();
45
46
late final TextEditingController _titleController;
46
- late final TextEditingController _descriptionController ;
47
+ late final TextEditingController _excerptController ;
47
48
late final TextEditingController _urlController;
48
49
late final TextEditingController _imageUrlController;
49
50
@@ -52,15 +53,15 @@ class _EditHeadlineViewState extends State<_EditHeadlineView> {
52
53
super .initState ();
53
54
final state = context.read <EditHeadlineBloc >().state;
54
55
_titleController = TextEditingController (text: state.title);
55
- _descriptionController = TextEditingController (text: state.description );
56
+ _excerptController = TextEditingController (text: state.excerpt );
56
57
_urlController = TextEditingController (text: state.url);
57
58
_imageUrlController = TextEditingController (text: state.imageUrl);
58
59
}
59
60
60
61
@override
61
62
void dispose () {
62
63
_titleController.dispose ();
63
- _descriptionController .dispose ();
64
+ _excerptController .dispose ();
64
65
_urlController.dispose ();
65
66
_imageUrlController.dispose ();
66
67
super .dispose ();
@@ -130,7 +131,7 @@ class _EditHeadlineViewState extends State<_EditHeadlineView> {
130
131
}
131
132
if (state.initialHeadline != null ) {
132
133
_titleController.text = state.title;
133
- _descriptionController .text = state.description ;
134
+ _excerptController .text = state.excerpt ;
134
135
_urlController.text = state.url;
135
136
_imageUrlController.text = state.imageUrl;
136
137
}
@@ -167,14 +168,25 @@ class _EditHeadlineViewState extends State<_EditHeadlineView> {
167
168
}
168
169
}
169
170
170
- Category ? selectedCategory ;
171
- if (state.category != null ) {
171
+ Topic ? selectedTopic ;
172
+ if (state.topic != null ) {
172
173
try {
173
- selectedCategory = state.categories .firstWhere (
174
- (c ) => c .id == state.category ! .id,
174
+ selectedTopic = state.topics .firstWhere (
175
+ (t ) => t .id == state.topic ! .id,
175
176
);
176
177
} catch (_) {
177
- selectedCategory = null ;
178
+ selectedTopic = null ;
179
+ }
180
+ }
181
+
182
+ Country ? selectedCountry;
183
+ if (state.eventCountry != null ) {
184
+ try {
185
+ selectedCountry = state.countries.firstWhere (
186
+ (c) => c.id == state.eventCountry! .id,
187
+ );
188
+ } catch (_) {
189
+ selectedCountry = null ;
178
190
}
179
191
}
180
192
@@ -198,15 +210,15 @@ class _EditHeadlineViewState extends State<_EditHeadlineView> {
198
210
),
199
211
const SizedBox (height: AppSpacing .lg),
200
212
TextFormField (
201
- controller: _descriptionController ,
213
+ controller: _excerptController ,
202
214
decoration: InputDecoration (
203
- labelText: l10n.description ,
215
+ labelText: l10n.excerpt ,
204
216
border: const OutlineInputBorder (),
205
217
),
206
218
maxLines: 3 ,
207
219
onChanged: (value) => context
208
220
.read <EditHeadlineBloc >()
209
- .add (EditHeadlineDescriptionChanged (value)),
221
+ .add (EditHeadlineExcerptChanged (value)),
210
222
),
211
223
const SizedBox (height: AppSpacing .lg),
212
224
TextFormField (
@@ -251,24 +263,44 @@ class _EditHeadlineViewState extends State<_EditHeadlineView> {
251
263
.add (EditHeadlineSourceChanged (value)),
252
264
),
253
265
const SizedBox (height: AppSpacing .lg),
254
- DropdownButtonFormField <Category ?>(
255
- value: selectedCategory,
266
+ DropdownButtonFormField <Topic ?>(
267
+ value: selectedTopic,
268
+ decoration: InputDecoration (
269
+ labelText: l10n.topicName,
270
+ border: const OutlineInputBorder (),
271
+ ),
272
+ items: [
273
+ DropdownMenuItem (value: null , child: Text (l10n.none)),
274
+ ...state.topics.map (
275
+ (topic) => DropdownMenuItem (
276
+ value: topic,
277
+ child: Text (topic.name),
278
+ ),
279
+ ),
280
+ ],
281
+ onChanged: (value) => context
282
+ .read <EditHeadlineBloc >()
283
+ .add (EditHeadlineTopicChanged (value)),
284
+ ),
285
+ const SizedBox (height: AppSpacing .lg),
286
+ DropdownButtonFormField <Country ?>(
287
+ value: selectedCountry,
256
288
decoration: InputDecoration (
257
- labelText: l10n.categoryName ,
289
+ labelText: l10n.countryName ,
258
290
border: const OutlineInputBorder (),
259
291
),
260
292
items: [
261
293
DropdownMenuItem (value: null , child: Text (l10n.none)),
262
- ...state.categories .map (
263
- (category ) => DropdownMenuItem (
264
- value: category ,
265
- child: Text (category .name),
294
+ ...state.countries .map (
295
+ (country ) => DropdownMenuItem (
296
+ value: country ,
297
+ child: Text (country .name),
266
298
),
267
299
),
268
300
],
269
301
onChanged: (value) => context
270
302
.read <EditHeadlineBloc >()
271
- .add (EditHeadlineCategoryChanged (value)),
303
+ .add (EditHeadlineCountryChanged (value)),
272
304
),
273
305
const SizedBox (height: AppSpacing .lg),
274
306
DropdownButtonFormField <ContentStatus >(
0 commit comments