Skip to content

Commit

Permalink
Hide usernames on user feeds (#1259)
Browse files Browse the repository at this point in the history
  • Loading branch information
micahmo authored Apr 2, 2024
1 parent 493abe9 commit 8770d2c
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 20 deletions.
9 changes: 5 additions & 4 deletions lib/community/widgets/post_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ 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';
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;
Expand All @@ -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,
Expand Down Expand Up @@ -198,7 +199,7 @@ class _PostCardState extends State<PostCard> {
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),
Expand All @@ -209,7 +210,7 @@ class _PostCardState extends State<PostCard> {
showThumbnailPreviewOnRight: state.showThumbnailPreviewOnRight,
hideNsfwPreviews: state.hideNsfwPreviews,
markPostReadOnMediaView: state.markPostReadOnMediaView,
communityMode: widget.communityMode,
feedType: widget.feedType,
showPostAuthor: state.showPostAuthor,
showFullHeightImages: state.showFullHeightImages,
edgeToEdgeImages: state.showEdgeToEdgeImages,
Expand Down
5 changes: 4 additions & 1 deletion lib/community/widgets/post_card_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;
Expand All @@ -49,6 +51,7 @@ class PostCardList extends StatefulWidget {
this.blockedCommunity,
this.tagline = '',
this.indicateRead = true,
required this.feedType,
});

@override
Expand Down Expand Up @@ -161,7 +164,7 @@ class _PostCardListState extends State<PostCardList> {
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),
Expand Down
12 changes: 7 additions & 5 deletions lib/community/widgets/post_card_metadata.dart
Original file line number Diff line number Diff line change
Expand Up @@ -515,15 +515,15 @@ 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,
required this.showCommunitySubscription,
});

final bool showCommunityIcons;
final bool communityMode;
final FeedType? feedType;
final bool compactMode;
final PostView postView;
final TextStyle? textStyleAuthor;
Expand All @@ -536,6 +536,8 @@ class PostCommunityAndAuthor extends StatelessWidget {

return BlocBuilder<ThunderBloc, ThunderState>(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: [
Expand All @@ -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: [
Expand All @@ -571,7 +573,7 @@ class PostCommunityAndAuthor extends StatelessWidget {
textStyle: textStyleAuthor,
),
),
if (!communityMode)
if (showUsername && showCommunityName)
ScalableText(
' to ',
fontScale: state.metadataFontSizeScale,
Expand All @@ -587,7 +589,7 @@ class PostCommunityAndAuthor extends StatelessWidget {
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
if (!communityMode)
if (showCommunityName)
CommunityFullNameWidget(
context,
postView.community.name,
Expand Down
7 changes: 4 additions & 3 deletions lib/community/widgets/post_card_view_comfortable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;
Expand All @@ -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,
Expand Down Expand Up @@ -285,7 +286,7 @@ class PostCardViewComfortable extends StatelessWidget {
children: [
PostCommunityAndAuthor(
showCommunityIcons: showCommunityIcons,
communityMode: communityMode,
feedType: feedType,
postView: postViewMedia.postView,
textStyleCommunity: textStyleCommunityAndAuthor,
textStyleAuthor: textStyleCommunityAndAuthor,
Expand Down
7 changes: 4 additions & 3 deletions lib/community/widgets/post_card_view_compact.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand Down Expand Up @@ -145,7 +146,7 @@ class PostCardViewCompact extends StatelessWidget {
PostCommunityAndAuthor(
compactMode: true,
showCommunityIcons: false,
communityMode: communityMode,
feedType: feedType,
postView: postViewMedia.postView,
textStyleCommunity: textStyleCommunityAndAuthor,
textStyleAuthor: textStyleCommunityAndAuthor,
Expand Down
2 changes: 1 addition & 1 deletion lib/feed/view/feed_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class _FeedPostListState extends State<FeedPostList> {
},
child: PostCard(
postViewMedia: widget.postViewMedias[index],
communityMode: state.feedType == FeedType.community,
feedType: state.feedType,
onVoteAction: (int voteType) {
context.read<FeedBloc>().add(FeedItemActionedEvent(postId: widget.postViewMedias[index].postView.post.id, postAction: PostAction.vote, value: voteType));
},
Expand Down
2 changes: 1 addition & 1 deletion lib/moderator/view/report_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ class _ReportFeedViewState extends State<ReportFeedView> {
child: PostCardViewCompact(
showMedia: false,
postViewMedia: PostViewMedia(postView: postView, media: [Media(mediaType: MediaType.text)]),
communityMode: false,
feedType: FeedType.general,
isUserLoggedIn: false,
listingType: ListingType.all,
),
Expand Down
4 changes: 2 additions & 2 deletions lib/settings/pages/post_appearance_settings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ class _PostAppearanceSettingsPageState extends State<PostAppearanceSettingsPage>
? IgnorePointer(
child: PostCardViewCompact(
postViewMedia: snapshot.data![index]!,
communityMode: false,
feedType: FeedType.general,
isUserLoggedIn: true,
listingType: ListingType.all,
indicateRead: dimReadPosts,
Expand All @@ -512,7 +512,7 @@ class _PostAppearanceSettingsPageState extends State<PostAppearanceSettingsPage>
showThumbnailPreviewOnRight: showThumbnailPreviewOnRight,
showPostAuthor: showPostAuthor,
hideNsfwPreviews: hideNsfwPreviews,
communityMode: false,
feedType: FeedType.general,
markPostReadOnMediaView: false,
isUserLoggedIn: true,
listingType: ListingType.all,
Expand Down
3 changes: 3 additions & 0 deletions lib/user/pages/user_page_success.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -269,6 +270,7 @@ class _UserPageSuccessState extends State<UserPageSuccess> with TickerProviderSt
onVoteAction: (int postId, int voteType) => context.read<UserBloc>().add(VotePostEvent(postId: postId, score: voteType)),
onToggleReadAction: (int postId, bool read) => context.read<UserBloc>().add(MarkUserPostAsReadEvent(postId: postId, read: read)),
indicateRead: !widget.isAccountUser,
feedType: FeedType.user,
),
),
if (!savedToggle!.value && selectedUserOption == 1)
Expand Down Expand Up @@ -378,6 +380,7 @@ class _UserPageSuccessState extends State<UserPageSuccess> with TickerProviderSt
onVoteAction: (int postId, int voteType) => context.read<UserBloc>().add(VotePostEvent(postId: postId, score: voteType)),
onToggleReadAction: (int postId, bool read) => context.read<UserBloc>().add(MarkUserPostAsReadEvent(postId: postId, read: read)),
indicateRead: !widget.isAccountUser,
feedType: FeedType.user,
),
),
if (savedToggle!.value && selectedUserOption == 1)
Expand Down

0 comments on commit 8770d2c

Please sign in to comment.