Skip to content
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Added ability to subscribe/unsubscribe to community from long press action on posts
- Added option to hide top app bar on scroll
- Ability to search through settings/preferences contribution from @ggichure.
- Setting to use colorized usernames - contribution from @ggichure.
- Show the number of new comments a read post has received since last visited

## Changed
Expand Down
3 changes: 3 additions & 0 deletions lib/core/enums/local_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ enum LocalSettings {
name: 'setting_general_nested_comment_indicator_style', key: 'nestedCommentIndicatorStyle', category: LocalSettingsCategories.comments, subCategory: LocalSettingsSubCategories.comments),
nestedCommentIndicatorColor(
name: 'setting_general_nested_comment_indicator_color', key: 'nestedCommentIndicatorColor', category: LocalSettingsCategories.comments, subCategory: LocalSettingsSubCategories.comments),
commentUseColorizedUsername(
name: 'settings_general_comments_colorized_usernames', key: 'commentUseColorizedUsername', category: LocalSettingsCategories.comments, subCategory: LocalSettingsSubCategories.comments),

/// -------------------------- Accessibility Related Settings --------------------------
reduceAnimations(name: 'setting_accessibility_reduce_animations', key: 'reduceAnimations', category: LocalSettingsCategories.accessibility, subCategory: LocalSettingsSubCategories.animations),
Expand Down Expand Up @@ -340,6 +342,7 @@ extension LocalizationExt on AppLocalizations {
'feedTypeAndSorts': feedTypeAndSorts,
'profiles': profiles,
'animations': animations,
'commentUseColorizedUsername': commentUseColorizedUsername
};

if (localizationMap.containsKey(key)) {
Expand Down
4 changes: 4 additions & 0 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@
},
"commentSwipeGesturesHint": "Looking to use buttons instead? Enable them in the comments section in general settings.",
"@commentSwipeGesturesHint": {},
"commentUseColorizedUsername": "Colorized Usernames",
"@commentUseColorizedUsername": {
"description": "Setting used to toggle colorized comments creator display name."
},
"comments": "Comments",
"@comments": {},
"communities": "Communities",
Expand Down
22 changes: 21 additions & 1 deletion lib/settings/pages/comment_appearance_settings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,15 @@ class _CommentAppearanceSettingsPageState extends State<CommentAppearanceSetting
/// When toggled on, comments will show a row of actions to perform
bool showCommentButtonActions = false;

/// When toggled on, user intance is displayed alongside the display name/username
/// When toggled on, user instance is displayed alongside the display name/username
bool commentShowUserInstance = false;

/// When toggled on, comment scores will be combined instead of having separate upvotes and downvotes
bool combineCommentScores = false;

/// When toggled on, usernames in comments will be colorized.
bool commentUseColorizedUsername = false;

/// Indicates the style of the nested comment indicator
NestedCommentIndicatorStyle nestedIndicatorStyle = DEFAULT_NESTED_COMMENT_INDICATOR_STYLE;

Expand All @@ -56,6 +59,7 @@ class _CommentAppearanceSettingsPageState extends State<CommentAppearanceSetting
showCommentButtonActions = prefs.getBool(LocalSettings.showCommentActionButtons.name) ?? false;
commentShowUserInstance = prefs.getBool(LocalSettings.commentShowUserInstance.name) ?? false;
combineCommentScores = prefs.getBool(LocalSettings.combineCommentScores.name) ?? false;
commentUseColorizedUsername = prefs.getBool(LocalSettings.commentUseColorizedUsername.name) ?? false;
nestedIndicatorStyle = NestedCommentIndicatorStyle.values.byName(prefs.getString(LocalSettings.nestedCommentIndicatorStyle.name) ?? DEFAULT_NESTED_COMMENT_INDICATOR_STYLE.name);
nestedIndicatorColor = NestedCommentIndicatorColor.values.byName(prefs.getString(LocalSettings.nestedCommentIndicatorColor.name) ?? DEFAULT_NESTED_COMMENT_INDICATOR_COLOR.name);
});
Expand Down Expand Up @@ -87,6 +91,9 @@ class _CommentAppearanceSettingsPageState extends State<CommentAppearanceSetting
await prefs.setString(LocalSettings.nestedCommentIndicatorColor.name, value);
setState(() => nestedIndicatorColor = NestedCommentIndicatorColor.values.byName(value ?? DEFAULT_NESTED_COMMENT_INDICATOR_COLOR.name));
break;
case LocalSettings.commentUseColorizedUsername:
await prefs.setBool(LocalSettings.commentUseColorizedUsername.name, value);
setState(() => commentUseColorizedUsername = value);
}

if (context.mounted) {
Expand All @@ -103,6 +110,7 @@ class _CommentAppearanceSettingsPageState extends State<CommentAppearanceSetting
await prefs.remove(LocalSettings.nestedCommentIndicatorStyle.name);
await prefs.remove(LocalSettings.nestedCommentIndicatorColor.name);
await prefs.remove(LocalSettings.commentShowUserInstance.name);
await prefs.remove(LocalSettings.commentUseColorizedUsername.name);

await initPreferences();

Expand Down Expand Up @@ -322,6 +330,18 @@ class _CommentAppearanceSettingsPageState extends State<CommentAppearanceSetting
),
),
),
SliverToBoxAdapter(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: ToggleOption(
description: l10n.commentUseColorizedUsername,
value: commentUseColorizedUsername,
iconEnabled: Icons.brush_sharp,
iconDisabled: Icons.brush_outlined,
onToggle: (bool value) => setPreferences(LocalSettings.commentUseColorizedUsername, value),
),
),
),
SliverToBoxAdapter(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
Expand Down
2 changes: 2 additions & 0 deletions lib/shared/comment_header.dart
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ class CommentHeader extends StatelessWidget {
TextSpan(
style: theme.textTheme.bodyMedium?.copyWith(
fontWeight: FontWeight.w500,
color: state.commentUseColorizedUsername ? theme.colorScheme.secondary : theme.textTheme.bodyLarge?.color,
fontSize: MediaQuery.textScalerOf(context).scale(theme.textTheme.bodyMedium!.fontSize! * state.metadataFontSizeScale.textScaleFactor),
),
text: comment.creator.displayName != null && state.useDisplayNames ? comment.creator.displayName! : comment.creator.name,
Expand All @@ -166,6 +167,7 @@ class CommentHeader extends StatelessWidget {
text: generateUserFullNameSuffix(context, fetchInstanceNameFromUrl(comment.creator.actorId)),
style: theme.textTheme.bodyMedium?.copyWith(
fontWeight: FontWeight.w300,
color: state.commentUseColorizedUsername ? theme.colorScheme.secondary : theme.textTheme.bodyLarge?.color,
fontSize: MediaQuery.textScalerOf(context).scale(theme.textTheme.bodyMedium!.fontSize! * state.metadataFontSizeScale.textScaleFactor),
),
)
Expand Down
2 changes: 2 additions & 0 deletions lib/thunder/bloc/thunder_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ class ThunderBloc extends Bloc<ThunderEvent, ThunderState> {
bool showCommentButtonActions = prefs.getBool(LocalSettings.showCommentActionButtons.name) ?? false;
bool commentShowUserInstance = prefs.getBool(LocalSettings.commentShowUserInstance.name) ?? false;
bool combineCommentScores = prefs.getBool(LocalSettings.combineCommentScores.name) ?? false;
bool commentUseColorizedUsername = prefs.getBool(LocalSettings.commentUseColorizedUsername.name) ?? false;
NestedCommentIndicatorStyle nestedCommentIndicatorStyle =
NestedCommentIndicatorStyle.values.byName(prefs.getString(LocalSettings.nestedCommentIndicatorStyle.name) ?? DEFAULT_NESTED_COMMENT_INDICATOR_STYLE.name);
NestedCommentIndicatorColor nestedCommentIndicatorColor =
Expand Down Expand Up @@ -281,6 +282,7 @@ class ThunderBloc extends Bloc<ThunderEvent, ThunderState> {
combineCommentScores: combineCommentScores,
nestedCommentIndicatorStyle: nestedCommentIndicatorStyle,
nestedCommentIndicatorColor: nestedCommentIndicatorColor,
commentUseColorizedUsername: commentUseColorizedUsername,

/// -------------------------- Theme Related Settings --------------------------
// Theme Settings
Expand Down
5 changes: 5 additions & 0 deletions lib/thunder/bloc/thunder_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class ThunderState extends Equatable {
this.showCommentButtonActions = false,
this.commentShowUserInstance = false,
this.combineCommentScores = false,
this.commentUseColorizedUsername = false,
this.nestedCommentIndicatorStyle = NestedCommentIndicatorStyle.thick,
this.nestedCommentIndicatorColor = NestedCommentIndicatorColor.colorful,

Expand Down Expand Up @@ -196,6 +197,7 @@ class ThunderState extends Equatable {
final bool showCommentButtonActions;
final bool commentShowUserInstance;
final bool combineCommentScores;
final bool commentUseColorizedUsername;
final NestedCommentIndicatorStyle nestedCommentIndicatorStyle;
final NestedCommentIndicatorColor nestedCommentIndicatorColor;

Expand Down Expand Up @@ -330,6 +332,7 @@ class ThunderState extends Equatable {
bool? showCommentButtonActions,
bool? commentShowUserInstance,
bool? combineCommentScores,
bool? commentUseColorizedUsername,
NestedCommentIndicatorStyle? nestedCommentIndicatorStyle,
NestedCommentIndicatorColor? nestedCommentIndicatorColor,

Expand Down Expand Up @@ -460,6 +463,7 @@ class ThunderState extends Equatable {
showCommentButtonActions: showCommentButtonActions ?? this.showCommentButtonActions,
commentShowUserInstance: commentShowUserInstance ?? this.commentShowUserInstance,
combineCommentScores: combineCommentScores ?? this.combineCommentScores,
commentUseColorizedUsername: commentUseColorizedUsername ?? this.commentUseColorizedUsername,
nestedCommentIndicatorStyle: nestedCommentIndicatorStyle ?? this.nestedCommentIndicatorStyle,
nestedCommentIndicatorColor: nestedCommentIndicatorColor ?? this.nestedCommentIndicatorColor,

Expand Down Expand Up @@ -594,6 +598,7 @@ class ThunderState extends Equatable {
showCommentButtonActions,
commentShowUserInstance,
combineCommentScores,
commentUseColorizedUsername,

nestedCommentIndicatorStyle,
nestedCommentIndicatorColor,
Expand Down