Skip to content

Commit efb3484

Browse files
committed
refactor(app_config): Improve user preference limits display
- Use AppLocalizations for labels/descriptions - Added helper methods for better readability - Improved code structure and organization - Simplified descriptions in some cases - Handle different user roles consistently
1 parent 719d736 commit efb3484

File tree

1 file changed

+50
-7
lines changed

1 file changed

+50
-7
lines changed

lib/app_configuration/view/app_configuration_page.dart

Lines changed: 50 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter_bloc/flutter_bloc.dart';
33
import 'package:ht_dashboard/app_configuration/bloc/app_configuration_bloc.dart';
4+
import 'package:ht_dashboard/l10n/app_localizations.dart';
45
import 'package:ht_dashboard/l10n/l10n.dart';
56
import 'package:ht_dashboard/shared/constants/app_spacing.dart';
67
import 'package:ht_dashboard/shared/widgets/widgets.dart';
@@ -772,8 +773,8 @@ class _UserPreferenceLimitsFormState extends State<_UserPreferenceLimitsForm> {
772773
children: [
773774
widget.buildIntField(
774775
context,
775-
label: l10n.followedItemsLimitLabel,
776-
description: l10n.followedItemsLimitDescription,
776+
label: _getFollowedItemsLimitLabel(l10n),
777+
description: _getFollowedItemsLimitDescription(l10n),
777778
value: _getFollowedItemsLimit(userPreferenceConfig),
778779
onChanged: (value) {
779780
widget.onConfigChanged(
@@ -789,8 +790,8 @@ class _UserPreferenceLimitsFormState extends State<_UserPreferenceLimitsForm> {
789790
),
790791
widget.buildIntField(
791792
context,
792-
label: l10n.savedHeadlinesLimitLabel,
793-
description: l10n.savedHeadlinesLimitDescription,
793+
label: _getSavedHeadlinesLimitLabel(l10n),
794+
description: _getSavedHeadlinesLimitDescription(l10n),
794795
value: _getSavedHeadlinesLimit(userPreferenceConfig),
795796
onChanged: (value) {
796797
widget.onConfigChanged(
@@ -808,6 +809,50 @@ class _UserPreferenceLimitsFormState extends State<_UserPreferenceLimitsForm> {
808809
);
809810
}
810811

812+
String _getFollowedItemsLimitLabel(AppLocalizations l10n) {
813+
switch (widget.userRole) {
814+
case AppUserRole.guestUser:
815+
return l10n.guestFollowedItemsLimitLabel;
816+
case AppUserRole.standardUser:
817+
return l10n.standardUserFollowedItemsLimitLabel;
818+
case AppUserRole.premiumUser:
819+
return l10n.premiumFollowedItemsLimitLabel;
820+
}
821+
}
822+
823+
String _getFollowedItemsLimitDescription(AppLocalizations l10n) {
824+
switch (widget.userRole) {
825+
case AppUserRole.guestUser:
826+
return l10n.guestFollowedItemsLimitDescription;
827+
case AppUserRole.standardUser:
828+
return l10n.standardUserFollowedItemsLimitDescription;
829+
case AppUserRole.premiumUser:
830+
return l10n.premiumFollowedItemsLimitDescription;
831+
}
832+
}
833+
834+
String _getSavedHeadlinesLimitLabel(AppLocalizations l10n) {
835+
switch (widget.userRole) {
836+
case AppUserRole.guestUser:
837+
return l10n.guestSavedHeadlinesLimitLabel;
838+
case AppUserRole.standardUser:
839+
return l10n.standardUserSavedHeadlinesLimitLabel;
840+
case AppUserRole.premiumUser:
841+
return l10n.premiumSavedHeadlinesLimitLabel;
842+
}
843+
}
844+
845+
String _getSavedHeadlinesLimitDescription(AppLocalizations l10n) {
846+
switch (widget.userRole) {
847+
case AppUserRole.guestUser:
848+
return l10n.guestSavedHeadlinesLimitDescription;
849+
case AppUserRole.standardUser:
850+
return l10n.standardUserSavedHeadlinesLimitDescription;
851+
case AppUserRole.premiumUser:
852+
return l10n.premiumSavedHeadlinesLimitDescription;
853+
}
854+
}
855+
811856
int _getFollowedItemsLimit(UserPreferenceConfig config) {
812857
switch (widget.userRole) {
813858
case AppUserRole.guestUser:
@@ -1212,9 +1257,7 @@ class _AccountActionConfigFormState extends State<_AccountActionConfigForm> {
12121257
return widget.buildIntField(
12131258
context,
12141259
label: _formatLabel(actionType.name, l10n),
1215-
description: l10n.daysBetweenPromptDescription(
1216-
actionType: actionType.name,
1217-
),
1260+
description: l10n.daysBetweenPromptDescription(actionType.name),
12181261
value: _getDaysMap(accountActionConfig)[actionType] ?? 0,
12191262
onChanged: (value) {
12201263
final currentMap = _getDaysMap(accountActionConfig);

0 commit comments

Comments
 (0)