Skip to content

Commit

Permalink
非公開のときフォロワー数を表示しない
Browse files Browse the repository at this point in the history
  • Loading branch information
poppingmoon committed Jan 21, 2024
1 parent a52deee commit 22ee627
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 27 deletions.
32 changes: 32 additions & 0 deletions lib/extensions/user_extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,35 @@ extension UserExtension on User {
return "@$username${host != null ? "@$host" : ""}";
}
}

extension UserDetailedExtension on UserDetailed {
bool get isFollowersVisibleForMe {
if (this is MeDetailed) {
return true;
}

final user = this;

return switch (followersVisibility ?? ffVisibility) {
FFVisibility.public => true,
FFVisibility.followers =>
user is UserDetailedNotMeWithRelations && user.isFollowing,
FFVisibility.private || null => false,
};
}

bool get isFollowingVisibleForMe {
if (this is MeDetailed) {
return true;
}

final user = this;

return switch (followingVisibility ?? ffVisibility) {
FFVisibility.public => true,
FFVisibility.followers =>
user is UserDetailedNotMeWithRelations && user.isFollowing,
FFVisibility.private || null => false,
};
}
}
56 changes: 29 additions & 27 deletions lib/view/user_page/user_detail.dart
Original file line number Diff line number Diff line change
Expand Up @@ -496,35 +496,37 @@ class UserDetailState extends ConsumerState<UserDetail> {
)
],
),
InkWell(
onTap: () => context.pushRoute(UserFolloweeRoute(
userId: response.id, account: AccountScope.of(context))),
child: Column(
children: [
Text(response.followingCount.format(),
style: Theme.of(context).textTheme.titleMedium),
Text(
"フォロー",
style: Theme.of(context).textTheme.bodyMedium,
)
],
if (widget.response.isFollowingVisibleForMe)
InkWell(
onTap: () => context.pushRoute(UserFolloweeRoute(
userId: response.id, account: AccountScope.of(context))),
child: Column(
children: [
Text(response.followingCount.format(),
style: Theme.of(context).textTheme.titleMedium),
Text(
"フォロー",
style: Theme.of(context).textTheme.bodyMedium,
)
],
),
),
),
InkWell(
onTap: () => context.pushRoute(UserFollowerRoute(
userId: response.id, account: AccountScope.of(context))),
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
Text(response.followersCount.format(),
style: Theme.of(context).textTheme.titleMedium),
Text(
"フォロワー",
style: Theme.of(context).textTheme.bodyMedium,
)
],
if (widget.response.isFollowersVisibleForMe)
InkWell(
onTap: () => context.pushRoute(UserFollowerRoute(
userId: response.id, account: AccountScope.of(context))),
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
Text(response.followersCount.format(),
style: Theme.of(context).textTheme.titleMedium),
Text(
"フォロワー",
style: Theme.of(context).textTheme.bodyMedium,
)
],
),
),
),
]),
]),
),
Expand Down

0 comments on commit 22ee627

Please sign in to comment.