Skip to content

Commit

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

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

final user = this;

return switch (ffVisibility) {
FFVisibility.public => true,
FFVisibility.followers =>
user is UserDetailedNotMeWithRelations && user.isFollowing,
FFVisibility.private => 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 @@ -500,35 +500,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.isFfVisibleForMe) ...[
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,
)
],
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 191a510

Please sign in to comment.