From e8d04a2205c4965a14a6bc33d4d6c5f5a6a49bec Mon Sep 17 00:00:00 2001 From: KotlinGeekDev Date: Thu, 11 Sep 2025 15:01:27 +0100 Subject: [PATCH] Modify Follow and Unfollow buttons to only change looks when in profile actions. --- .../ui/screen/loggedIn/profile/FollowButtons.kt | 12 +++++++++--- .../profile/header/DisplayFollowUnfollowButton.kt | 6 +++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/FollowButtons.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/FollowButtons.kt index ad9f66381..94f1fb792 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/FollowButtons.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/FollowButtons.kt @@ -29,18 +29,21 @@ import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.ui.stringRes +import com.vitorpamplona.amethyst.ui.theme.ButtonBorder import com.vitorpamplona.amethyst.ui.theme.ButtonPadding import com.vitorpamplona.amethyst.ui.theme.LeftHalfCircleButtonBorder @Composable fun FollowButton( text: Int = R.string.follow, + // Needed for when browsing a user's profile, for list functionality. + isInProfileActions: Boolean = false, onClick: () -> Unit, ) { FilledTonalButton( modifier = Modifier.padding(start = 3.dp), onClick = onClick, - shape = LeftHalfCircleButtonBorder, + shape = if (isInProfileActions) LeftHalfCircleButtonBorder else ButtonBorder, contentPadding = ButtonPadding, ) { Text(text = stringRes(text), textAlign = TextAlign.Center) @@ -48,11 +51,14 @@ fun FollowButton( } @Composable -fun UnfollowButton(onClick: () -> Unit) { +fun UnfollowButton( + isInProfileActions: Boolean = false, + onClick: () -> Unit, +) { FilledTonalButton( modifier = Modifier.padding(horizontal = 3.dp), onClick = onClick, - shape = LeftHalfCircleButtonBorder, + shape = if (isInProfileActions) LeftHalfCircleButtonBorder else ButtonBorder, contentPadding = ButtonPadding, ) { Text(text = stringRes(R.string.unfollow)) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/header/DisplayFollowUnfollowButton.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/header/DisplayFollowUnfollowButton.kt index e71428e60..075e03916 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/header/DisplayFollowUnfollowButton.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/header/DisplayFollowUnfollowButton.kt @@ -38,7 +38,7 @@ fun DisplayFollowUnfollowButton( val isUserFollowingLoggedIn by observeUserIsFollowing(baseUser, accountViewModel.account.userProfile(), accountViewModel) if (isLoggedInFollowingUser) { - UnfollowButton { + UnfollowButton(isInProfileActions = true) { if (!accountViewModel.isWriteable()) { accountViewModel.toastManager.toast( R.string.read_only_user, @@ -50,7 +50,7 @@ fun DisplayFollowUnfollowButton( } } else { if (isUserFollowingLoggedIn) { - FollowButton(R.string.follow_back) { + FollowButton(R.string.follow_back, isInProfileActions = true) { if (!accountViewModel.isWriteable()) { accountViewModel.toastManager.toast( R.string.read_only_user, @@ -61,7 +61,7 @@ fun DisplayFollowUnfollowButton( } } } else { - FollowButton(R.string.follow) { + FollowButton(R.string.follow, true) { if (!accountViewModel.isWriteable()) { accountViewModel.toastManager.toast( R.string.read_only_user,