1
1
import 'package:flutter/material.dart' ;
2
2
import 'package:flutter_bloc/flutter_bloc.dart' ;
3
3
import 'package:ht_dashboard/app_configuration/bloc/app_configuration_bloc.dart' ;
4
+ import 'package:ht_dashboard/l10n/app_localizations.dart' ;
4
5
import 'package:ht_dashboard/l10n/l10n.dart' ;
5
6
import 'package:ht_dashboard/shared/constants/app_spacing.dart' ;
6
7
import 'package:ht_dashboard/shared/widgets/widgets.dart' ;
@@ -766,15 +767,14 @@ class _UserPreferenceLimitsFormState extends State<_UserPreferenceLimitsForm> {
766
767
@override
767
768
Widget build (BuildContext context) {
768
769
final userPreferenceConfig = widget.remoteConfig.userPreferenceConfig;
770
+ final l10n = context.l10n;
769
771
770
772
return Column (
771
773
children: [
772
774
widget.buildIntField (
773
775
context,
774
- label: 'Followed Items Limit' ,
775
- description:
776
- 'Maximum number of countries, news sources, or categories this '
777
- 'user role can follow (each type has its own limit).' ,
776
+ label: _getFollowedItemsLimitLabel (l10n),
777
+ description: _getFollowedItemsLimitDescription (l10n),
778
778
value: _getFollowedItemsLimit (userPreferenceConfig),
779
779
onChanged: (value) {
780
780
widget.onConfigChanged (
@@ -790,8 +790,8 @@ class _UserPreferenceLimitsFormState extends State<_UserPreferenceLimitsForm> {
790
790
),
791
791
widget.buildIntField (
792
792
context,
793
- label: 'Saved Headlines Limit' ,
794
- description: 'Maximum number of headlines this user role can save.' ,
793
+ label: _getSavedHeadlinesLimitLabel (l10n) ,
794
+ description: _getSavedHeadlinesLimitDescription (l10n) ,
795
795
value: _getSavedHeadlinesLimit (userPreferenceConfig),
796
796
onChanged: (value) {
797
797
widget.onConfigChanged (
@@ -809,6 +809,50 @@ class _UserPreferenceLimitsFormState extends State<_UserPreferenceLimitsForm> {
809
809
);
810
810
}
811
811
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
+
812
856
int _getFollowedItemsLimit (UserPreferenceConfig config) {
813
857
switch (widget.userRole) {
814
858
case AppUserRole .guestUser:
@@ -990,15 +1034,14 @@ class _AdConfigFormState extends State<_AdConfigForm> {
990
1034
@override
991
1035
Widget build (BuildContext context) {
992
1036
final adConfig = widget.remoteConfig.adConfig;
1037
+ final l10n = context.l10n;
993
1038
994
1039
return Column (
995
1040
children: [
996
1041
widget.buildIntField (
997
1042
context,
998
- label: 'Ad Frequency' ,
999
- description:
1000
- 'How often an ad can appear for this user role (e.g., a value '
1001
- 'of 5 means an ad could be placed after every 5 news items).' ,
1043
+ label: l10n.adFrequencyLabel,
1044
+ description: l10n.adFrequencyDescription,
1002
1045
value: _getAdFrequency (adConfig),
1003
1046
onChanged: (value) {
1004
1047
widget.onConfigChanged (
@@ -1011,10 +1054,8 @@ class _AdConfigFormState extends State<_AdConfigForm> {
1011
1054
),
1012
1055
widget.buildIntField (
1013
1056
context,
1014
- label: 'Ad Placement Interval' ,
1015
- description:
1016
- 'Minimum number of news items that must be shown before the '
1017
- 'very first ad appears for this user role.' ,
1057
+ label: l10n.adPlacementIntervalLabel,
1058
+ description: l10n.adPlacementIntervalDescription,
1018
1059
value: _getAdPlacementInterval (adConfig),
1019
1060
onChanged: (value) {
1020
1061
widget.onConfigChanged (
@@ -1027,10 +1068,8 @@ class _AdConfigFormState extends State<_AdConfigForm> {
1027
1068
),
1028
1069
widget.buildIntField (
1029
1070
context,
1030
- label: 'Articles Before Interstitial Ads' ,
1031
- description:
1032
- 'Number of articles this user role needs to read before a '
1033
- 'full-screen interstitial ad is shown.' ,
1071
+ label: l10n.articlesBeforeInterstitialAdsLabel,
1072
+ description: l10n.articlesBeforeInterstitialAdsDescription,
1034
1073
value: _getArticlesBeforeInterstitial (adConfig),
1035
1074
onChanged: (value) {
1036
1075
widget.onConfigChanged (
@@ -1198,27 +1237,29 @@ class _AccountActionConfigFormState extends State<_AccountActionConfigForm> {
1198
1237
super .dispose ();
1199
1238
}
1200
1239
1201
- String _formatLabel (String enumName) {
1202
- // Converts camelCase to Title Case
1203
- final spaced = enumName.replaceAllMapped (
1204
- RegExp ('([A-Z])' ),
1205
- (match) => ' ${match .group (1 )}' ,
1206
- );
1207
- return '${spaced [0 ].toUpperCase ()}${spaced .substring (1 )} Days' ;
1208
- }
1209
-
1210
1240
@override
1211
1241
Widget build (BuildContext context) {
1212
1242
final accountActionConfig = widget.remoteConfig.accountActionConfig;
1213
1243
final relevantActionTypes = _getDaysMap (accountActionConfig).keys.toList ();
1244
+ final l10n = context.l10n;
1214
1245
1215
1246
return Column (
1216
1247
children: relevantActionTypes.map ((actionType) {
1248
+ final localizedActionType = switch (actionType) {
1249
+ FeedActionType .linkAccount => l10n.feedActionTypeLinkAccount,
1250
+ FeedActionType .rateApp => l10n.feedActionTypeRateApp,
1251
+ FeedActionType .followTopics => l10n.feedActionTypeFollowTopics,
1252
+ FeedActionType .followSources => l10n.feedActionTypeFollowSources,
1253
+ FeedActionType .upgrade => l10n.feedActionTypeUpgrade,
1254
+ FeedActionType .enableNotifications =>
1255
+ l10n.feedActionTypeEnableNotifications,
1256
+ };
1217
1257
return widget.buildIntField (
1218
1258
context,
1219
- label: _formatLabel (actionType.name),
1220
- description:
1221
- 'Minimum number of days before showing the ${actionType .name } prompt.' ,
1259
+ label: '$localizedActionType ${l10n .daysSuffix }' ,
1260
+ description: l10n.daysBetweenPromptDescription (
1261
+ localizedActionType,
1262
+ ),
1222
1263
value: _getDaysMap (accountActionConfig)[actionType] ?? 0 ,
1223
1264
onChanged: (value) {
1224
1265
final currentMap = _getDaysMap (accountActionConfig);
0 commit comments