Skip to content

Commit ef93f0d

Browse files
committed
feat(filter): enforce saved filter limits in UI
Integrates the `ContentLimitationService` into the `HeadlinesFilterPage` to enforce limits on saving new filters. When a user attempts to "Apply & Save" a filter, the app now checks if they have reached their limit. If the limit is met, a `ContentLimitationBottomSheet` is displayed to inform the user, and the save process is halted. This provides immediate, clear feedback and aligns the filter-saving feature with the app's overall content limitation strategy.
1 parent 4281410 commit ef93f0d

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

lib/headlines-feed/view/headlines_filter_page.dart

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import 'package:flutter_news_app_mobile_client_full_source_code/headlines-feed/b
99
import 'package:flutter_news_app_mobile_client_full_source_code/headlines-feed/bloc/headlines_filter_bloc.dart';
1010
import 'package:flutter_news_app_mobile_client_full_source_code/headlines-feed/models/headline_filter.dart';
1111
import 'package:flutter_news_app_mobile_client_full_source_code/headlines-feed/widgets/save_filter_dialog.dart';
12+
import 'package:flutter_news_app_mobile_client_full_source_code/shared/services/content_limitation_service.dart';
13+
import 'package:flutter_news_app_mobile_client_full_source_code/shared/widgets/content_limitation_bottom_sheet.dart';
1214
import 'package:flutter_news_app_mobile_client_full_source_code/l10n/app_localizations.dart';
1315
import 'package:flutter_news_app_mobile_client_full_source_code/l10n/l10n.dart';
1416
import 'package:flutter_news_app_mobile_client_full_source_code/router/routes.dart';
@@ -135,6 +137,24 @@ Future<void> _showApplyOptionsDialog(BuildContext context) async {
135137
/// be popped before the dialog is fully dismissed, which was causing a
136138
/// navigation stack error.
137139
Future<void> _saveAndApplyFilter(BuildContext context) async {
140+
// Before showing the save dialog, check if the user is allowed to save
141+
// another filter based on their subscription level and current usage.
142+
final contentLimitationService = context.read<ContentLimitationService>();
143+
final limitationStatus =
144+
contentLimitationService.checkAction(ContentAction.saveFilter);
145+
146+
// If the user has reached their limit, show the limitation bottom sheet
147+
// and halt the save process.
148+
if (limitationStatus != LimitationStatus.allowed) {
149+
await showModalBottomSheet<void>(
150+
context: context,
151+
builder: (context) => ContentLimitationBottomSheet(
152+
status: limitationStatus,
153+
),
154+
);
155+
return;
156+
}
157+
138158
final filterState = context.read<HeadlinesFilterBloc>().state;
139159

140160
// `showDialog` returns a Future that completes when the dialog is popped.

0 commit comments

Comments
 (0)