Modify Follow and Unfollow buttons to only change looks when in profile actions.
This commit is contained in:
+9
-3
@@ -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))
|
||||
|
||||
+3
-3
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user