Skip to content

Commit a09d30e

Browse files
committed
refactor(app_config): Improve label formatting
- Removed redundant formatting function. - Use switch statement for localized labels. - Improved clarity and readability. - Localized description using localized action type. - Simplified label generation.
1 parent 36b64cb commit a09d30e

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

lib/app_configuration/view/app_configuration_page.dart

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,15 +1237,6 @@ class _AccountActionConfigFormState extends State<_AccountActionConfigForm> {
12371237
super.dispose();
12381238
}
12391239

1240-
String _formatLabel(String enumName, AppLocalizations l10n) {
1241-
// Converts camelCase to Title Case
1242-
final spaced = enumName.replaceAllMapped(
1243-
RegExp('([A-Z])'),
1244-
(match) => ' ${match.group(1)}',
1245-
);
1246-
return '${spaced[0].toUpperCase()}${spaced.substring(1)} ${l10n.daysSuffix}';
1247-
}
1248-
12491240
@override
12501241
Widget build(BuildContext context) {
12511242
final accountActionConfig = widget.remoteConfig.accountActionConfig;
@@ -1254,10 +1245,21 @@ class _AccountActionConfigFormState extends State<_AccountActionConfigForm> {
12541245

12551246
return Column(
12561247
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+
};
12571257
return widget.buildIntField(
12581258
context,
1259-
label: _formatLabel(actionType.name, l10n),
1260-
description: l10n.daysBetweenPromptDescription(actionType.name),
1259+
label: '$localizedActionType ${l10n.daysSuffix}',
1260+
description: l10n.daysBetweenPromptDescription(
1261+
localizedActionType,
1262+
),
12611263
value: _getDaysMap(accountActionConfig)[actionType] ?? 0,
12621264
onChanged: (value) {
12631265
final currentMap = _getDaysMap(accountActionConfig);

0 commit comments

Comments
 (0)