|
1 | 1 | import 'package:core/core.dart'; |
2 | 2 | import 'package:flutter/material.dart'; |
3 | 3 | import 'package:flutter_bloc/flutter_bloc.dart'; |
4 | | -import 'package:flutter_news_app_mobile_client_full_source_code/ads/services/interstitial_ad_manager.dart'; |
5 | 4 | import 'package:flutter_news_app_mobile_client_full_source_code/app/bloc/app_bloc.dart'; |
6 | 5 | import 'package:flutter_news_app_mobile_client_full_source_code/app/models/app_life_cycle_status.dart'; |
7 | 6 | 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'; |
9 | 7 | import 'package:flutter_news_app_mobile_client_full_source_code/shared/widgets/feed_core/feed_core.dart'; |
10 | 8 | import 'package:go_router/go_router.dart'; |
11 | 9 | import 'package:ui_kit/ui_kit.dart'; |
@@ -74,21 +72,6 @@ class SavedHeadlinesPage extends StatelessWidget { |
74 | 72 | ); |
75 | 73 | } |
76 | 74 |
|
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 | | - |
92 | 75 | return ListView.separated( |
93 | 76 | padding: const EdgeInsets.symmetric( |
94 | 77 | vertical: AppSpacing.paddingSmall, |
@@ -130,19 +113,22 @@ class SavedHeadlinesPage extends StatelessWidget { |
130 | 113 | case FeedItemImageStyle.hidden: |
131 | 114 | tile = HeadlineTileTextOnly( |
132 | 115 | headline: headline, |
133 | | - onHeadlineTap: () => onHeadlineTap(headline), |
| 116 | + onHeadlineTap: () => |
| 117 | + HeadlineTapHandler.handleHeadlineTap(context, headline), |
134 | 118 | trailing: trailingButton, |
135 | 119 | ); |
136 | 120 | case FeedItemImageStyle.smallThumbnail: |
137 | 121 | tile = HeadlineTileImageStart( |
138 | 122 | headline: headline, |
139 | | - onHeadlineTap: () => onHeadlineTap(headline), |
| 123 | + onHeadlineTap: () => |
| 124 | + HeadlineTapHandler.handleHeadlineTap(context, headline), |
140 | 125 | trailing: trailingButton, |
141 | 126 | ); |
142 | 127 | case FeedItemImageStyle.largeThumbnail: |
143 | 128 | tile = HeadlineTileImageTop( |
144 | 129 | headline: headline, |
145 | | - onHeadlineTap: () => onHeadlineTap(headline), |
| 130 | + onHeadlineTap: () => |
| 131 | + HeadlineTapHandler.handleHeadlineTap(context, headline), |
146 | 132 | trailing: trailingButton, |
147 | 133 | ); |
148 | 134 | } |
|
0 commit comments