Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor local settings to use localization strings #1045

Merged
merged 3 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
264 changes: 174 additions & 90 deletions lib/core/enums/local_settings.dart

Large diffs are not rendered by default.

262 changes: 238 additions & 24 deletions lib/l10n/app_en.arb

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions lib/settings/pages/accessibility_settings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';

import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:thunder/community/utils/post_card_action_helpers.dart';

import 'package:thunder/core/enums/local_settings.dart';
import 'package:thunder/core/singletons/preferences.dart';
Expand Down Expand Up @@ -74,8 +75,8 @@ class _AccessibilitySettingsPageState extends State<AccessibilitySettingsPage> w
),
),
ToggleOption(
description: LocalSettings.reduceAnimations.label,
subtitle: AppLocalizations.of(context)!.reducesAnimations, // @TODO: Add subtitle field to LocalSettings for these strings
description: l10n.reduceAnimations,
subtitle: l10n.reducesAnimations,
value: reduceAnimations,
iconEnabled: Icons.animation,
iconDisabled: Icons.animation,
Expand Down
6 changes: 3 additions & 3 deletions lib/settings/pages/comment_appearance_settings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ class _CommentAppearanceSettingsPageState extends State<CommentAppearanceSetting
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: ToggleOption(
description: LocalSettings.showCommentActionButtons.label,
description: l10n.showCommentActionButtons,
value: showCommentButtonActions,
iconEnabled: Icons.mode_comment_rounded,
iconDisabled: Icons.mode_comment_outlined,
Expand Down Expand Up @@ -326,7 +326,7 @@ class _CommentAppearanceSettingsPageState extends State<CommentAppearanceSetting
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: ListOption(
description: LocalSettings.nestedCommentIndicatorStyle.label,
description: l10n.nestedCommentIndicatorStyle,
value: ListPickerItem(label: nestedIndicatorStyle.value, icon: Icons.local_fire_department_rounded, payload: nestedIndicatorStyle),
options: [
ListPickerItem(icon: Icons.view_list_rounded, label: NestedCommentIndicatorStyle.thick.value, payload: NestedCommentIndicatorStyle.thick),
Expand All @@ -341,7 +341,7 @@ class _CommentAppearanceSettingsPageState extends State<CommentAppearanceSetting
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: ListOption(
description: LocalSettings.nestedCommentIndicatorColor.label,
description: l10n.nestedCommentIndicatorColor,
value: ListPickerItem(label: nestedIndicatorColor.value, icon: Icons.local_fire_department_rounded, payload: nestedIndicatorColor),
options: [
ListPickerItem(icon: Icons.invert_colors_on_rounded, label: NestedCommentIndicatorColor.colorful.value, payload: NestedCommentIndicatorColor.colorful),
Expand Down
34 changes: 17 additions & 17 deletions lib/settings/pages/general_settings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ class _GeneralSettingsPageState extends State<GeneralSettingsPage> with SingleTi
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: ListOption(
description: LocalSettings.defaultFeedListingType.label,
description: l10n.defaultFeedType,
value: ListPickerItem(label: defaultListingType.value, icon: Icons.feed, payload: defaultListingType),
options: [
ListPickerItem(icon: Icons.view_list_rounded, label: ListingType.subscribed.value, payload: ListingType.subscribed),
Expand All @@ -270,15 +270,15 @@ class _GeneralSettingsPageState extends State<GeneralSettingsPage> with SingleTi
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: ListOption(
description: LocalSettings.defaultFeedSortType.label,
description: l10n.defaultFeedSortType,
value: ListPickerItem(label: defaultSortType.value, icon: Icons.local_fire_department_rounded, payload: defaultSortType),
options: [...SortPicker.getDefaultSortTypeItems(includeVersionSpecificFeature: IncludeVersionSpecificFeature.never), ...topSortTypeItems],
icon: Icons.sort_rounded,
onChanged: (_) {},
isBottomModalScrollControlled: true,
customListPicker: SortPicker(
includeVersionSpecificFeature: IncludeVersionSpecificFeature.never,
title: LocalSettings.defaultFeedSortType.label,
title: l10n.defaultFeedSortType,
onSelect: (value) {
setPreferences(LocalSettings.defaultFeedSortType, value.payload.name);
},
Expand All @@ -301,7 +301,7 @@ class _GeneralSettingsPageState extends State<GeneralSettingsPage> with SingleTi
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: ListOption(
description: LocalSettings.defaultCommentSortType.label,
description: l10n.defaultCommentSortType,
value: ListPickerItem(label: defaultCommentSortType.value, icon: Icons.local_fire_department_rounded, payload: defaultCommentSortType),
options: CommentSortPicker.getCommentSortTypeItems(includeVersionSpecificFeature: IncludeVersionSpecificFeature.never),
icon: Icons.comment_bank_rounded,
Expand Down Expand Up @@ -368,7 +368,7 @@ class _GeneralSettingsPageState extends State<GeneralSettingsPage> with SingleTi
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: ToggleOption(
description: LocalSettings.hideNsfwPosts.label,
description: l10n.hideNsfwPostsFromFeed,
value: hideNsfwPosts,
iconEnabled: Icons.no_adult_content,
iconDisabled: Icons.no_adult_content,
Expand All @@ -380,7 +380,7 @@ class _GeneralSettingsPageState extends State<GeneralSettingsPage> with SingleTi
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: ToggleOption(
description: LocalSettings.tappableAuthorCommunity.label,
description: l10n.tappableAuthorCommunity,
value: tappableAuthorCommunity,
iconEnabled: Icons.touch_app_rounded,
iconDisabled: Icons.touch_app_outlined,
Expand All @@ -392,7 +392,7 @@ class _GeneralSettingsPageState extends State<GeneralSettingsPage> with SingleTi
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: ToggleOption(
description: LocalSettings.markPostAsReadOnMediaView.label,
description: l10n.markPostAsReadOnMediaView,
value: markPostReadOnMediaView,
iconEnabled: Icons.visibility,
iconDisabled: Icons.remove_red_eye_outlined,
Expand All @@ -404,7 +404,7 @@ class _GeneralSettingsPageState extends State<GeneralSettingsPage> with SingleTi
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: ToggleOption(
description: LocalSettings.useTabletMode.label,
description: l10n.tabletMode,
value: tabletMode,
iconEnabled: Icons.tablet_rounded,
iconDisabled: Icons.smartphone_rounded,
Expand Down Expand Up @@ -436,7 +436,7 @@ class _GeneralSettingsPageState extends State<GeneralSettingsPage> with SingleTi
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: ToggleOption(
description: LocalSettings.useAdvancedShareSheet.label,
description: l10n.useAdvancedShareSheet,
value: useAdvancedShareSheet,
iconEnabled: Icons.screen_share_rounded,
iconDisabled: Icons.screen_share_outlined,
Expand All @@ -455,7 +455,7 @@ class _GeneralSettingsPageState extends State<GeneralSettingsPage> with SingleTi
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: ToggleOption(
description: LocalSettings.collapseParentCommentBodyOnGesture.label,
description: l10n.collapseParentCommentBodyOnGesture,
value: collapseParentCommentOnGesture,
iconEnabled: Icons.mode_comment_outlined,
iconDisabled: Icons.comment_outlined,
Expand All @@ -467,7 +467,7 @@ class _GeneralSettingsPageState extends State<GeneralSettingsPage> with SingleTi
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: ToggleOption(
description: LocalSettings.enableCommentNavigation.label,
description: l10n.enableCommentNavigation,
value: enableCommentNavigation,
iconEnabled: Icons.unfold_more_rounded,
iconDisabled: Icons.unfold_less_rounded,
Expand All @@ -479,8 +479,8 @@ class _GeneralSettingsPageState extends State<GeneralSettingsPage> with SingleTi
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: ToggleOption(
description: LocalSettings.combineNavAndFab.label,
subtitle: l10n.combineNavAndFab,
description: l10n.combineNavAndFab,
subtitle: l10n.combineNavAndFabDescription,
value: combineNavAndFab,
iconEnabled: Icons.join_full_rounded,
iconDisabled: Icons.join_inner_rounded,
Expand All @@ -500,7 +500,7 @@ class _GeneralSettingsPageState extends State<GeneralSettingsPage> with SingleTi
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: ToggleOption(
description: LocalSettings.openLinksInExternalBrowser.label,
description: l10n.openLinksInExternalBrowser,
value: openInExternalBrowser,
iconEnabled: Icons.add_link_rounded,
iconDisabled: Icons.link_rounded,
Expand All @@ -513,7 +513,7 @@ class _GeneralSettingsPageState extends State<GeneralSettingsPage> with SingleTi
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: ToggleOption(
description: LocalSettings.openLinksInReaderMode.label,
description: l10n.openLinksInReaderMode,
value: openInReaderMode,
iconEnabled: Icons.menu_book_rounded,
iconDisabled: Icons.menu_book_rounded,
Expand Down Expand Up @@ -554,7 +554,7 @@ class _GeneralSettingsPageState extends State<GeneralSettingsPage> with SingleTi
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: ToggleOption(
description: LocalSettings.scrapeMissingPreviews.label,
description: l10n.scrapeMissingPreviews,
subtitle: l10n.scrapeMissingPreviews,
value: scrapeMissingPreviews,
iconEnabled: Icons.image_search_rounded,
Expand Down Expand Up @@ -613,7 +613,7 @@ class _GeneralSettingsPageState extends State<GeneralSettingsPage> with SingleTi
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: ToggleOption(
description: LocalSettings.showInAppUpdateNotification.label,
description: l10n.showInAppUpdateNotifications,
value: showInAppUpdateNotification,
iconEnabled: Icons.update_rounded,
iconDisabled: Icons.update_disabled_rounded,
Expand Down
26 changes: 13 additions & 13 deletions lib/settings/pages/gesture_settings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ class _GestureSettingsPageState extends State<GestureSettingsPage> with TickerPr
),
),
ToggleOption(
description: LocalSettings.enableFullScreenSwipeNavigationGesture.label,
description: l10n.fullscreenSwipeGestures,
subtitle: l10n.fullScreenNavigationSwipeDescription,
value: enableFullScreenSwipeNavigationGesture,
iconEnabled: Icons.swipe_left_rounded,
Expand All @@ -227,15 +227,15 @@ class _GestureSettingsPageState extends State<GestureSettingsPage> with TickerPr
),
),
ToggleOption(
description: LocalSettings.sidebarBottomNavBarSwipeGesture.label,
description: l10n.navbarSwipeGestures,
subtitle: l10n.sidebarBottomNavSwipeDescription,
value: bottomNavBarSwipeGestures,
iconEnabled: Icons.swipe_right_rounded,
iconDisabled: Icons.swipe_right_outlined,
onToggle: (bool value) => setPreferences(LocalSettings.sidebarBottomNavBarSwipeGesture, value),
),
ToggleOption(
description: LocalSettings.sidebarBottomNavBarDoubleTapGesture.label,
description: l10n.navbarDoubleTapGestures,
subtitle: l10n.sidebarBottomNavDoubleTapDescription,
value: bottomNavBarDoubleTapGestures,
iconEnabled: Icons.touch_app_rounded,
Expand Down Expand Up @@ -268,7 +268,7 @@ class _GestureSettingsPageState extends State<GestureSettingsPage> with TickerPr
),
),
ToggleOption(
description: LocalSettings.enablePostGestures.label,
description: l10n.postSwipeActions,
value: enablePostGestures,
iconEnabled: Icons.swipe_rounded,
iconDisabled: Icons.swipe_outlined,
Expand Down Expand Up @@ -303,13 +303,13 @@ class _GestureSettingsPageState extends State<GestureSettingsPage> with TickerPr
side: SwipePickerSide.left,
items: [
SwipePickerItem(
label: LocalSettings.postGestureLeftPrimary.label,
label: l10n.leftShortSwipe,
options: postGestureOptions,
value: leftPrimaryPostGesture,
onChanged: (value) => setPreferences(LocalSettings.postGestureLeftPrimary, value.payload),
),
SwipePickerItem(
label: LocalSettings.postGestureLeftSecondary.label,
label: l10n.leftLongSwipe,
options: postGestureOptions,
value: leftSecondaryPostGesture,
onChanged: (value) => setPreferences(LocalSettings.postGestureLeftSecondary, value.payload),
Expand All @@ -323,13 +323,13 @@ class _GestureSettingsPageState extends State<GestureSettingsPage> with TickerPr
side: SwipePickerSide.right,
items: [
SwipePickerItem(
label: LocalSettings.postGestureRightPrimary.label,
label: l10n.rightShortSwipe,
options: postGestureOptions,
value: rightPrimaryPostGesture,
onChanged: (value) => setPreferences(LocalSettings.postGestureRightPrimary, value.payload),
),
SwipePickerItem(
label: LocalSettings.postGestureRightSecondary.label,
label: l10n.rightLongSwipe,
options: postGestureOptions,
value: rightSecondaryPostGesture,
onChanged: (value) => setPreferences(LocalSettings.postGestureRightSecondary, value.payload),
Expand Down Expand Up @@ -366,7 +366,7 @@ class _GestureSettingsPageState extends State<GestureSettingsPage> with TickerPr
),
),
ToggleOption(
description: LocalSettings.enableCommentGestures.label,
description: l10n.commentSwipeActions,
value: enableCommentGestures,
iconEnabled: Icons.swipe_rounded,
iconDisabled: Icons.swipe_outlined,
Expand Down Expand Up @@ -401,13 +401,13 @@ class _GestureSettingsPageState extends State<GestureSettingsPage> with TickerPr
side: SwipePickerSide.left,
items: [
SwipePickerItem(
label: LocalSettings.commentGestureLeftPrimary.label,
label: l10n.leftShortSwipe,
options: commentGestureOptions,
value: leftPrimaryCommentGesture,
onChanged: (value) => setPreferences(LocalSettings.commentGestureLeftPrimary, value.payload),
),
SwipePickerItem(
label: LocalSettings.commentGestureLeftSecondary.label,
label: l10n.leftLongSwipe,
options: commentGestureOptions,
value: leftSecondaryCommentGesture,
onChanged: (value) => setPreferences(LocalSettings.commentGestureLeftSecondary, value.payload),
Expand All @@ -421,13 +421,13 @@ class _GestureSettingsPageState extends State<GestureSettingsPage> with TickerPr
side: SwipePickerSide.right,
items: [
SwipePickerItem(
label: LocalSettings.commentGestureRightPrimary.label,
label: l10n.rightShortSwipe,
options: commentGestureOptions,
value: rightPrimaryCommentGesture,
onChanged: (value) => setPreferences(LocalSettings.commentGestureRightPrimary, value.payload),
),
SwipePickerItem(
label: LocalSettings.commentGestureRightSecondary.label,
label: l10n.rightLongSwipe,
options: commentGestureOptions,
value: rightSecondaryCommentGesture,
onChanged: (value) => setPreferences(LocalSettings.commentGestureRightSecondary, value.payload),
Expand Down
Loading
Loading