Skip to content

Commit c5ff3cb

Browse files
committed
feat(entity_details): add country support and improve entity handling
- Add support for displaying country details in entity page - Enhance entity description and icon handling for different content types - Improve appBar title and icon based on entity type - Update localization strings for country entity
1 parent eacd1cf commit c5ff3cb

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

lib/entity_details/view/entity_details_page.dart

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class EntityDetailsPage extends StatelessWidget {
5252
create: (context) {
5353
final topicsRepository = context.read<DataRepository<Topic>>();
5454
final sourcesRepository = context.read<DataRepository<Source>>();
55+
final countriesRepository = context.read<DataRepository<Country>>();
5556
final feedDecoratorService = FeedDecoratorService(
5657
topicsRepository: topicsRepository,
5758
sourcesRepository: sourcesRepository,
@@ -61,6 +62,7 @@ class EntityDetailsPage extends StatelessWidget {
6162
headlinesRepository: context.read<DataRepository<Headline>>(),
6263
topicRepository: topicsRepository,
6364
sourceRepository: sourcesRepository,
65+
countryRepository: countriesRepository,
6466
accountBloc: context.read<AccountBloc>(),
6567
appBloc: context.read<AppBloc>(),
6668
feedDecoratorService: feedDecoratorService,
@@ -131,6 +133,8 @@ class _EntityDetailsViewState extends State<EntityDetailsView> {
131133
name = l10n.entityDetailsTopicTitle;
132134
case ContentType.source:
133135
name = l10n.entityDetailsSourceTitle;
136+
case ContentType.country:
137+
name = l10n.entityDetailsCountryTitle;
134138
default:
135139
name = l10n.detailsPageTitle;
136140
}
@@ -190,6 +194,10 @@ class _EntityDetailsViewState extends State<EntityDetailsView> {
190194
final src = state.entity! as Source;
191195
appBarTitleText = src.name;
192196
appBarIconData = Icons.source_outlined;
197+
} else if (state.entity is Country) {
198+
final country = state.entity! as Country;
199+
appBarTitleText = country.name;
200+
appBarIconData = Icons.flag_outlined;
193201
} else {
194202
appBarTitleText = l10n.detailsPageTitle;
195203
}
@@ -198,10 +206,8 @@ class _EntityDetailsViewState extends State<EntityDetailsView> {
198206
? (state.entity! as Topic).description
199207
: state.entity is Source
200208
? (state.entity! as Source).description
201-
: null;
202-
203-
final entityIconUrl = (state.entity is Topic)
204-
? (state.entity! as Topic).iconUrl
209+
: state.entity is Country
210+
? (state.entity! as Country).name // Using name as description for country
205211
: null;
206212

207213
final followButton = IconButton(
@@ -219,6 +225,12 @@ class _EntityDetailsViewState extends State<EntityDetailsView> {
219225
},
220226
);
221227

228+
final entityIconUrl = (state.entity is Topic)
229+
? (state.entity! as Topic).iconUrl
230+
: (state.entity is Country)
231+
? (state.entity! as Country).flagUrl
232+
: null;
233+
222234
final Widget appBarTitleWidget = Row(
223235
mainAxisSize: MainAxisSize.min,
224236
children: [

0 commit comments

Comments
 (0)