Skip to content

Commit e73571b

Browse files
committed
feat(headline): link source/category to details
- Added Category, Source to shared - Added tap to source/category chips - Navigates to details page
1 parent df67eda commit e73571b

File tree

1 file changed

+37
-20
lines changed

1 file changed

+37
-20
lines changed

lib/headline-details/view/headline_details_page.dart

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@ import 'package:flutter_bloc/flutter_bloc.dart';
77
import 'package:go_router/go_router.dart'; // Import GoRouter
88
import 'package:ht_main/account/bloc/account_bloc.dart';
99
import 'package:ht_main/app/bloc/app_bloc.dart'; // Added AppBloc
10+
import 'package:ht_main/entity_details/view/entity_details_page.dart'; // Added for Page Arguments
1011
import 'package:ht_main/headline-details/bloc/headline_details_bloc.dart';
1112
import 'package:ht_main/headline-details/bloc/similar_headlines_bloc.dart';
1213
// HeadlineItemWidget import removed
1314
import 'package:ht_main/l10n/l10n.dart';
1415
import 'package:ht_main/router/routes.dart';
1516
import 'package:ht_main/shared/shared.dart';
1617
import 'package:ht_shared/ht_shared.dart'
17-
show Headline, HeadlineImageStyle; // Added HeadlineImageStyle
18+
show Headline, HeadlineImageStyle, Category, Source; // Added Category, Source
1819
import 'package:intl/intl.dart';
1920
import 'package:share_plus/share_plus.dart'; // Import share_plus
2021
import 'package:url_launcher/url_launcher_string.dart';
@@ -394,18 +395,26 @@ class _HeadlineDetailsPageState extends State<HeadlineDetailsPage> {
394395

395396
if (headline.source != null) {
396397
chips.add(
397-
Chip(
398-
avatar: Icon(
399-
Icons.source,
400-
size: chipAvatarSize,
401-
color: chipAvatarColor,
398+
GestureDetector( // Added GestureDetector
399+
onTap: () {
400+
context.push(
401+
Routes.sourceDetails,
402+
extra: EntityDetailsPageArguments(entity: headline.source!),
403+
);
404+
},
405+
child: Chip(
406+
avatar: Icon(
407+
Icons.source,
408+
size: chipAvatarSize,
409+
color: chipAvatarColor,
410+
),
411+
label: Text(headline.source!.name),
412+
labelStyle: chipLabelStyle,
413+
backgroundColor: chipBackgroundColor,
414+
padding: chipPadding,
415+
visualDensity: chipVisualDensity,
416+
materialTapTargetSize: chipMaterialTapTargetSize,
402417
),
403-
label: Text(headline.source!.name),
404-
labelStyle: chipLabelStyle,
405-
backgroundColor: chipBackgroundColor,
406-
padding: chipPadding,
407-
visualDensity: chipVisualDensity,
408-
materialTapTargetSize: chipMaterialTapTargetSize,
409418
),
410419
);
411420
}
@@ -434,7 +443,7 @@ class _HeadlineDetailsPageState extends State<HeadlineDetailsPage> {
434443
if (headline.source?.headquarters != null) {
435444
final country = headline.source!.headquarters!;
436445
chips.add(
437-
Chip(
446+
Chip( // Country chip is usually not tappable to a details page in this context
438447
avatar: CircleAvatar(
439448
radius: chipAvatarSize / 2,
440449
backgroundColor: Colors.transparent,
@@ -453,13 +462,21 @@ class _HeadlineDetailsPageState extends State<HeadlineDetailsPage> {
453462

454463
if (headline.category != null) {
455464
chips.add(
456-
Chip(
457-
label: Text(headline.category!.name),
458-
labelStyle: chipLabelStyle,
459-
backgroundColor: chipBackgroundColor,
460-
padding: chipPadding,
461-
visualDensity: chipVisualDensity,
462-
materialTapTargetSize: chipMaterialTapTargetSize,
465+
GestureDetector( // Added GestureDetector
466+
onTap: () {
467+
context.push(
468+
Routes.categoryDetails,
469+
extra: EntityDetailsPageArguments(entity: headline.category!),
470+
);
471+
},
472+
child: Chip(
473+
label: Text(headline.category!.name),
474+
labelStyle: chipLabelStyle,
475+
backgroundColor: chipBackgroundColor,
476+
padding: chipPadding,
477+
visualDensity: chipVisualDensity,
478+
materialTapTargetSize: chipMaterialTapTargetSize,
479+
),
463480
),
464481
);
465482
}

0 commit comments

Comments
 (0)