@@ -5,10 +5,8 @@ import 'package:flutter_news_app_mobile_client_full_source_code/app/bloc/app_blo
55import 'package:flutter_news_app_mobile_client_full_source_code/l10n/app_localizations.dart' ;
66import 'package:flutter_news_app_mobile_client_full_source_code/l10n/l10n.dart' ;
77import 'package:flutter_news_app_mobile_client_full_source_code/notifications/services/push_notification_service.dart' ;
8- import 'package:flutter_news_app_mobile_client_full_source_code/router/routes.dart' ;
98import 'package:flutter_news_app_mobile_client_full_source_code/shared/services/content_limitation_service.dart' ;
109import 'package:flutter_news_app_mobile_client_full_source_code/shared/widgets/content_limitation_bottom_sheet.dart' ;
11- import 'package:go_router/go_router.dart' ;
1210import 'package:ui_kit/ui_kit.dart' ;
1311
1412/// {@template save_filter_dialog}
@@ -77,7 +75,7 @@ class _SaveFilterDialogState extends State<SaveFilterDialog> {
7775 final contentLimitationService = context.read <ContentLimitationService >();
7876
7977 final canPinStatus = await contentLimitationService.checkAction (
80- ContentAction .pinHeadlineFilter ,
78+ ContentAction .pinFilter ,
8179 );
8280 if (mounted) {
8381 setState (() {
@@ -91,7 +89,7 @@ class _SaveFilterDialogState extends State<SaveFilterDialog> {
9189 final isAlreadySubscribed =
9290 widget.filterToEdit? .deliveryTypes.contains (type) ?? false ;
9391 final limitationStatus = await contentLimitationService.checkAction (
94- ContentAction .subscribeToHeadlineFilterNotifications ,
92+ ContentAction .subscribeToSavedFilterNotifications ,
9593 deliveryType: type,
9694 );
9795 if (mounted) {
@@ -162,28 +160,15 @@ class _SaveFilterDialogState extends State<SaveFilterDialog> {
162160 try {
163161 final limitationService = context.read <ContentLimitationService >();
164162 final status = await limitationService.checkAction (
165- ContentAction .saveHeadlineFilter ,
163+ ContentAction .saveFilter ,
166164 );
167165
168166 if (status != LimitationStatus .allowed && widget.filterToEdit == null ) {
169167 if (mounted) {
170- final userRole = context.read <AppBloc >().state.user? .appRole;
171- final content = _getBottomSheetContent (
168+ showContentLimitationBottomSheet (
172169 context: context,
173- l10n: l10n,
174170 status: status,
175- userRole: userRole,
176- action: ContentAction .saveHeadlineFilter,
177- );
178-
179- await showModalBottomSheet <void >(
180- context: context,
181- builder: (_) => ContentLimitationBottomSheet (
182- title: content.title,
183- body: content.body,
184- buttonText: content.buttonText,
185- onButtonPressed: content.onPressed,
186- ),
171+ action: ContentAction .saveFilter,
187172 );
188173 }
189174 return ;
@@ -345,59 +330,6 @@ class _SaveFilterDialogState extends State<SaveFilterDialog> {
345330 }
346331}
347332
348- /// Determines the content for the [ContentLimitationBottomSheet] based on
349- /// the user's role and the limitation status.
350- ({String title, String body, String buttonText, VoidCallback ? onPressed})
351- _getBottomSheetContent ({
352- required BuildContext context,
353- required AppLocalizations l10n,
354- required LimitationStatus status,
355- required AppUserRole ? userRole,
356- required ContentAction action,
357- }) {
358- switch (status) {
359- case LimitationStatus .anonymousLimitReached:
360- return (
361- title: l10n.anonymousLimitTitle,
362- body: l10n.anonymousLimitBody,
363- buttonText: l10n.anonymousLimitButton,
364- onPressed: () {
365- Navigator .of (context).pop ();
366- context.pushNamed (Routes .accountLinkingName);
367- },
368- );
369- case LimitationStatus .standardUserLimitReached:
370- // TODO(fulleni): Implement upgrade flow.
371- return (
372- title: l10n.standardLimitTitle,
373- body: l10n.standardLimitBody,
374- buttonText: l10n.standardLimitButton,
375- onPressed: () {
376- Navigator .of (context).pop ();
377- },
378- );
379- case LimitationStatus .premiumUserLimitReached:
380- final body = switch (action) {
381- ContentAction .saveHeadlineFilter => l10n.limitReachedBodySaveFilters,
382- ContentAction .pinHeadlineFilter => l10n.limitReachedBodyPinFilters,
383- ContentAction .subscribeToHeadlineFilterNotifications =>
384- l10n.limitReachedBodySubscribeToNotifications,
385- _ => l10n.premiumLimitBody,
386- };
387- return (
388- title: l10n.premiumLimitTitle,
389- body: body,
390- buttonText: l10n.premiumLimitButton,
391- onPressed: () {
392- Navigator .of (context).pop ();
393- context.goNamed (Routes .savedHeadlineFiltersName);
394- },
395- );
396- case LimitationStatus .allowed:
397- return (title: '' , body: '' , buttonText: '' , onPressed: null );
398- }
399- }
400-
401333/// An extension to provide localized strings for [PushNotificationSubscriptionDeliveryType] .
402334extension on PushNotificationSubscriptionDeliveryType {
403335 String toL10n (AppLocalizations l10n) {
0 commit comments