From 8770d2c78b5c97dd8752fb3b889b183bf05e0e41 Mon Sep 17 00:00:00 2001 From: Micah Morrison Date: Tue, 2 Apr 2024 11:37:32 -0400 Subject: [PATCH] Hide usernames on user feeds (#1259) --- lib/community/widgets/post_card.dart | 9 +++++---- lib/community/widgets/post_card_list.dart | 5 ++++- lib/community/widgets/post_card_metadata.dart | 12 +++++++----- .../widgets/post_card_view_comfortable.dart | 7 ++++--- lib/community/widgets/post_card_view_compact.dart | 7 ++++--- lib/feed/view/feed_widget.dart | 2 +- lib/moderator/view/report_page.dart | 2 +- .../pages/post_appearance_settings_page.dart | 4 ++-- lib/user/pages/user_page_success.dart | 3 +++ 9 files changed, 31 insertions(+), 20 deletions(-) diff --git a/lib/community/widgets/post_card.dart b/lib/community/widgets/post_card.dart index 700e44764..b17c91d96 100644 --- a/lib/community/widgets/post_card.dart +++ b/lib/community/widgets/post_card.dart @@ -12,6 +12,7 @@ import 'package:thunder/core/auth/bloc/auth_bloc.dart'; import 'package:thunder/core/enums/swipe_action.dart'; import 'package:thunder/core/models/post_view_media.dart'; import 'package:thunder/feed/bloc/feed_bloc.dart'; +import 'package:thunder/feed/view/feed_page.dart'; import 'package:thunder/feed/widgets/widgets.dart'; import 'package:thunder/post/enums/post_action.dart'; import 'package:thunder/thunder/bloc/thunder_bloc.dart'; @@ -19,7 +20,7 @@ import 'package:thunder/post/utils/navigate_post.dart'; class PostCard extends StatefulWidget { final PostViewMedia postViewMedia; - final bool communityMode; + final FeedType? feedType; final bool indicateRead; final Function(int) onVoteAction; @@ -33,7 +34,7 @@ class PostCard extends StatefulWidget { const PostCard({ super.key, required this.postViewMedia, - required this.communityMode, + required this.feedType, required this.onVoteAction, required this.onSaveAction, required this.onReadAction, @@ -198,7 +199,7 @@ class _PostCardState extends State { child: state.useCompactView ? PostCardViewCompact( postViewMedia: widget.postViewMedia, - communityMode: widget.communityMode, + feedType: widget.feedType, isUserLoggedIn: isUserLoggedIn, listingType: widget.listingType, navigateToPost: ({PostViewMedia? postViewMedia}) async => await navigateToPost(context, postViewMedia: widget.postViewMedia), @@ -209,7 +210,7 @@ class _PostCardState extends State { showThumbnailPreviewOnRight: state.showThumbnailPreviewOnRight, hideNsfwPreviews: state.hideNsfwPreviews, markPostReadOnMediaView: state.markPostReadOnMediaView, - communityMode: widget.communityMode, + feedType: widget.feedType, showPostAuthor: state.showPostAuthor, showFullHeightImages: state.showFullHeightImages, edgeToEdgeImages: state.showEdgeToEdgeImages, diff --git a/lib/community/widgets/post_card_list.dart b/lib/community/widgets/post_card_list.dart index 507fd4004..ab465004e 100644 --- a/lib/community/widgets/post_card_list.dart +++ b/lib/community/widgets/post_card_list.dart @@ -8,6 +8,7 @@ import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart'; import 'package:thunder/community/bloc/community_bloc_old.dart'; import 'package:thunder/community/widgets/post_card.dart'; import 'package:thunder/core/models/post_view_media.dart'; +import 'package:thunder/feed/view/feed_page.dart'; import 'package:thunder/shared/text/scalable_text.dart'; import 'package:thunder/thunder/bloc/thunder_bloc.dart'; import 'package:thunder/user/bloc/user_bloc_old.dart'; @@ -25,6 +26,7 @@ class PostCardList extends StatefulWidget { final SortType? sortType; final String tagline; final bool indicateRead; + final FeedType feedType; final VoidCallback onScrollEndReached; final Function(int, int) onVoteAction; @@ -49,6 +51,7 @@ class PostCardList extends StatefulWidget { this.blockedCommunity, this.tagline = '', this.indicateRead = true, + required this.feedType, }); @override @@ -161,7 +164,7 @@ class _PostCardListState extends State { PostViewMedia postViewMedia = widget.postViews![(widget.communityId != null || widget.communityName != null || widget.tagline.isNotEmpty) ? index - 1 : index]; return PostCard( postViewMedia: postViewMedia, - communityMode: widget.communityId != null || widget.communityName != null, + feedType: widget.feedType, onVoteAction: (int voteType) => widget.onVoteAction(postViewMedia.postView.post.id, voteType), onSaveAction: (bool saved) => widget.onSaveAction(postViewMedia.postView.post.id, saved), onReadAction: (bool read) => widget.onToggleReadAction(postViewMedia.postView.post.id, read), diff --git a/lib/community/widgets/post_card_metadata.dart b/lib/community/widgets/post_card_metadata.dart index 4822e947e..17c21ed69 100644 --- a/lib/community/widgets/post_card_metadata.dart +++ b/lib/community/widgets/post_card_metadata.dart @@ -515,7 +515,7 @@ class PostCommunityAndAuthor extends StatelessWidget { super.key, required this.postView, required this.showCommunityIcons, - required this.communityMode, + required this.feedType, this.textStyleAuthor, this.textStyleCommunity, required this.compactMode, @@ -523,7 +523,7 @@ class PostCommunityAndAuthor extends StatelessWidget { }); final bool showCommunityIcons; - final bool communityMode; + final FeedType? feedType; final bool compactMode; final PostView postView; final TextStyle? textStyleAuthor; @@ -536,6 +536,8 @@ class PostCommunityAndAuthor extends StatelessWidget { return BlocBuilder(builder: (context, state) { final String? creatorName = postView.creator.displayName != null && state.useDisplayNames ? postView.creator.displayName : postView.creator.name; + final bool showUsername = (state.showPostAuthor || feedType == FeedType.community) && feedType != FeedType.user; + final bool showCommunityName = feedType != FeedType.community; return Row( children: [ @@ -555,7 +557,7 @@ class PostCommunityAndAuthor extends StatelessWidget { alignment: WrapAlignment.start, crossAxisAlignment: WrapCrossAlignment.end, children: [ - if (state.showPostAuthor || communityMode) + if (showUsername) Row( mainAxisSize: MainAxisSize.min, children: [ @@ -571,7 +573,7 @@ class PostCommunityAndAuthor extends StatelessWidget { textStyle: textStyleAuthor, ), ), - if (!communityMode) + if (showUsername && showCommunityName) ScalableText( ' to ', fontScale: state.metadataFontSizeScale, @@ -587,7 +589,7 @@ class PostCommunityAndAuthor extends StatelessWidget { child: Row( mainAxisSize: MainAxisSize.min, children: [ - if (!communityMode) + if (showCommunityName) CommunityFullNameWidget( context, postView.community.name, diff --git a/lib/community/widgets/post_card_view_comfortable.dart b/lib/community/widgets/post_card_view_comfortable.dart index e85c2f7b3..35c194d43 100644 --- a/lib/community/widgets/post_card_view_comfortable.dart +++ b/lib/community/widgets/post_card_view_comfortable.dart @@ -15,6 +15,7 @@ import 'package:thunder/core/enums/media_type.dart'; import 'package:thunder/core/enums/view_mode.dart'; import 'package:thunder/core/models/post_view_media.dart'; import 'package:thunder/core/theme/bloc/theme_bloc.dart'; +import 'package:thunder/feed/view/feed_page.dart'; import 'package:thunder/shared/media_view.dart'; import 'package:thunder/shared/text/scalable_text.dart'; import 'package:thunder/thunder/bloc/thunder_bloc.dart'; @@ -28,7 +29,7 @@ class PostCardViewComfortable extends StatelessWidget { final bool hideNsfwPreviews; final bool edgeToEdgeImages; final bool showTitleFirst; - final bool communityMode; + final FeedType? feedType; final bool showPostAuthor; final bool showFullHeightImages; final bool showVoteActions; @@ -48,7 +49,7 @@ class PostCardViewComfortable extends StatelessWidget { required this.hideNsfwPreviews, required this.edgeToEdgeImages, required this.showTitleFirst, - required this.communityMode, + required this.feedType, required this.showPostAuthor, required this.showFullHeightImages, required this.showVoteActions, @@ -285,7 +286,7 @@ class PostCardViewComfortable extends StatelessWidget { children: [ PostCommunityAndAuthor( showCommunityIcons: showCommunityIcons, - communityMode: communityMode, + feedType: feedType, postView: postViewMedia.postView, textStyleCommunity: textStyleCommunityAndAuthor, textStyleAuthor: textStyleCommunityAndAuthor, diff --git a/lib/community/widgets/post_card_view_compact.dart b/lib/community/widgets/post_card_view_compact.dart index 0bf1cb3bb..ccb1a270d 100644 --- a/lib/community/widgets/post_card_view_compact.dart +++ b/lib/community/widgets/post_card_view_compact.dart @@ -13,12 +13,13 @@ import 'package:thunder/core/enums/media_type.dart'; import 'package:thunder/core/enums/view_mode.dart'; import 'package:thunder/core/models/post_view_media.dart'; import 'package:thunder/core/theme/bloc/theme_bloc.dart'; +import 'package:thunder/feed/view/feed_page.dart'; import 'package:thunder/shared/media_view.dart'; import 'package:thunder/thunder/bloc/thunder_bloc.dart'; class PostCardViewCompact extends StatelessWidget { final PostViewMedia postViewMedia; - final bool communityMode; + final FeedType? feedType; final bool isUserLoggedIn; final ListingType? listingType; final void Function({PostViewMedia? postViewMedia})? navigateToPost; @@ -28,7 +29,7 @@ class PostCardViewCompact extends StatelessWidget { const PostCardViewCompact({ super.key, required this.postViewMedia, - required this.communityMode, + required this.feedType, required this.isUserLoggedIn, required this.listingType, this.navigateToPost, @@ -145,7 +146,7 @@ class PostCardViewCompact extends StatelessWidget { PostCommunityAndAuthor( compactMode: true, showCommunityIcons: false, - communityMode: communityMode, + feedType: feedType, postView: postViewMedia.postView, textStyleCommunity: textStyleCommunityAndAuthor, textStyleAuthor: textStyleCommunityAndAuthor, diff --git a/lib/feed/view/feed_widget.dart b/lib/feed/view/feed_widget.dart index 12293dfc5..580214fb1 100644 --- a/lib/feed/view/feed_widget.dart +++ b/lib/feed/view/feed_widget.dart @@ -131,7 +131,7 @@ class _FeedPostListState extends State { }, child: PostCard( postViewMedia: widget.postViewMedias[index], - communityMode: state.feedType == FeedType.community, + feedType: state.feedType, onVoteAction: (int voteType) { context.read().add(FeedItemActionedEvent(postId: widget.postViewMedias[index].postView.post.id, postAction: PostAction.vote, value: voteType)); }, diff --git a/lib/moderator/view/report_page.dart b/lib/moderator/view/report_page.dart index 7485f901e..ed4b26356 100644 --- a/lib/moderator/view/report_page.dart +++ b/lib/moderator/view/report_page.dart @@ -226,7 +226,7 @@ class _ReportFeedViewState extends State { child: PostCardViewCompact( showMedia: false, postViewMedia: PostViewMedia(postView: postView, media: [Media(mediaType: MediaType.text)]), - communityMode: false, + feedType: FeedType.general, isUserLoggedIn: false, listingType: ListingType.all, ), diff --git a/lib/settings/pages/post_appearance_settings_page.dart b/lib/settings/pages/post_appearance_settings_page.dart index fc7bf74d4..38d9e2f9d 100644 --- a/lib/settings/pages/post_appearance_settings_page.dart +++ b/lib/settings/pages/post_appearance_settings_page.dart @@ -500,7 +500,7 @@ class _PostAppearanceSettingsPageState extends State ? IgnorePointer( child: PostCardViewCompact( postViewMedia: snapshot.data![index]!, - communityMode: false, + feedType: FeedType.general, isUserLoggedIn: true, listingType: ListingType.all, indicateRead: dimReadPosts, @@ -512,7 +512,7 @@ class _PostAppearanceSettingsPageState extends State showThumbnailPreviewOnRight: showThumbnailPreviewOnRight, showPostAuthor: showPostAuthor, hideNsfwPreviews: hideNsfwPreviews, - communityMode: false, + feedType: FeedType.general, markPostReadOnMediaView: false, isUserLoggedIn: true, listingType: ListingType.all, diff --git a/lib/user/pages/user_page_success.dart b/lib/user/pages/user_page_success.dart index c8be331fb..88fa2575d 100644 --- a/lib/user/pages/user_page_success.dart +++ b/lib/user/pages/user_page_success.dart @@ -12,6 +12,7 @@ import 'package:thunder/community/widgets/post_card_list.dart'; import 'package:thunder/core/auth/bloc/auth_bloc.dart'; import 'package:thunder/core/enums/local_settings.dart'; import 'package:thunder/core/singletons/preferences.dart'; +import 'package:thunder/feed/view/feed_page.dart'; import 'package:thunder/post/bloc/post_bloc.dart' as post_bloc; import 'package:thunder/post/utils/comment_action_helpers.dart'; import 'package:thunder/shared/comment_reference.dart'; @@ -269,6 +270,7 @@ class _UserPageSuccessState extends State with TickerProviderSt onVoteAction: (int postId, int voteType) => context.read().add(VotePostEvent(postId: postId, score: voteType)), onToggleReadAction: (int postId, bool read) => context.read().add(MarkUserPostAsReadEvent(postId: postId, read: read)), indicateRead: !widget.isAccountUser, + feedType: FeedType.user, ), ), if (!savedToggle!.value && selectedUserOption == 1) @@ -378,6 +380,7 @@ class _UserPageSuccessState extends State with TickerProviderSt onVoteAction: (int postId, int voteType) => context.read().add(VotePostEvent(postId: postId, score: voteType)), onToggleReadAction: (int postId, bool read) => context.read().add(MarkUserPostAsReadEvent(postId: postId, read: read)), indicateRead: !widget.isAccountUser, + feedType: FeedType.user, ), ), if (savedToggle!.value && selectedUserOption == 1)