From 22ee62789ffc6a57e61fef329c07cb679ba10ceb Mon Sep 17 00:00:00 2001 From: poppingmoon <63451158+poppingmoon@users.noreply.github.com> Date: Sun, 15 Oct 2023 17:51:23 +0900 Subject: [PATCH] =?UTF-8?q?=E9=9D=9E=E5=85=AC=E9=96=8B=E3=81=AE=E3=81=A8?= =?UTF-8?q?=E3=81=8D=E3=83=95=E3=82=A9=E3=83=AD=E3=83=AF=E3=83=BC=E6=95=B0?= =?UTF-8?q?=E3=82=92=E8=A1=A8=E7=A4=BA=E3=81=97=E3=81=AA=E3=81=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/extensions/user_extension.dart | 32 +++++++++++++++++ lib/view/user_page/user_detail.dart | 56 +++++++++++++++-------------- 2 files changed, 61 insertions(+), 27 deletions(-) diff --git a/lib/extensions/user_extension.dart b/lib/extensions/user_extension.dart index 24e448a1d..dfef770b1 100644 --- a/lib/extensions/user_extension.dart +++ b/lib/extensions/user_extension.dart @@ -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, + }; + } +} diff --git a/lib/view/user_page/user_detail.dart b/lib/view/user_page/user_detail.dart index 17c894bd6..252f3b5b3 100644 --- a/lib/view/user_page/user_detail.dart +++ b/lib/view/user_page/user_detail.dart @@ -496,35 +496,37 @@ class UserDetailState extends ConsumerState { ) ], ), - 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, + ) + ], + ), ), - ), ]), ]), ),