Skip to content

Commit 4e7f22d

Browse files
committed
refactor(account): update SavedHeadlinesPage to use external navigation
Refactors the `SavedHeadlinesPage` to align with the app's pivot. Tapping a saved headline now uses the `HeadlineTapHandler` to open the article in a browser. The "Remove from Bookmarks" action is now the primary interaction on the tile's trailing widget, removing the need to navigate to a details page.
1 parent ba005b8 commit 4e7f22d

File tree

1 file changed

+6
-20
lines changed

1 file changed

+6
-20
lines changed

lib/account/view/saved_headlines_page.dart

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import 'package:core/core.dart';
22
import 'package:flutter/material.dart';
33
import 'package:flutter_bloc/flutter_bloc.dart';
4-
import 'package:flutter_news_app_mobile_client_full_source_code/ads/services/interstitial_ad_manager.dart';
54
import 'package:flutter_news_app_mobile_client_full_source_code/app/bloc/app_bloc.dart';
65
import 'package:flutter_news_app_mobile_client_full_source_code/app/models/app_life_cycle_status.dart';
76
import 'package:flutter_news_app_mobile_client_full_source_code/l10n/l10n.dart';
8-
import 'package:flutter_news_app_mobile_client_full_source_code/router/routes.dart';
97
import 'package:flutter_news_app_mobile_client_full_source_code/shared/widgets/feed_core/feed_core.dart';
108
import 'package:go_router/go_router.dart';
119
import 'package:ui_kit/ui_kit.dart';
@@ -74,21 +72,6 @@ class SavedHeadlinesPage extends StatelessWidget {
7472
);
7573
}
7674

77-
Future<void> onHeadlineTap(Headline headline) async {
78-
// Await for the ad to be shown and dismissed.
79-
await context.read<InterstitialAdManager>().onPotentialAdTrigger();
80-
81-
// Check if the widget is still in the tree before navigating.
82-
if (!context.mounted) return;
83-
84-
// Proceed with navigation after the ad is closed.
85-
await context.pushNamed(
86-
Routes.accountArticleDetailsName,
87-
pathParameters: {'id': headline.id},
88-
extra: headline,
89-
);
90-
}
91-
9275
return ListView.separated(
9376
padding: const EdgeInsets.symmetric(
9477
vertical: AppSpacing.paddingSmall,
@@ -130,19 +113,22 @@ class SavedHeadlinesPage extends StatelessWidget {
130113
case FeedItemImageStyle.hidden:
131114
tile = HeadlineTileTextOnly(
132115
headline: headline,
133-
onHeadlineTap: () => onHeadlineTap(headline),
116+
onHeadlineTap: () =>
117+
HeadlineTapHandler.handleHeadlineTap(context, headline),
134118
trailing: trailingButton,
135119
);
136120
case FeedItemImageStyle.smallThumbnail:
137121
tile = HeadlineTileImageStart(
138122
headline: headline,
139-
onHeadlineTap: () => onHeadlineTap(headline),
123+
onHeadlineTap: () =>
124+
HeadlineTapHandler.handleHeadlineTap(context, headline),
140125
trailing: trailingButton,
141126
);
142127
case FeedItemImageStyle.largeThumbnail:
143128
tile = HeadlineTileImageTop(
144129
headline: headline,
145-
onHeadlineTap: () => onHeadlineTap(headline),
130+
onHeadlineTap: () =>
131+
HeadlineTapHandler.handleHeadlineTap(context, headline),
146132
trailing: trailingButton,
147133
);
148134
}

0 commit comments

Comments
 (0)