Experiment with Icon as a button. Refactor FollowButton and UnfollowButton to take into account the modified design, without affecting other components.
This commit is contained in:
+40
-15
@@ -77,7 +77,6 @@ import androidx.compose.material3.ScrollableTabRow
|
|||||||
import androidx.compose.material3.Surface
|
import androidx.compose.material3.Surface
|
||||||
import androidx.compose.material3.Tab
|
import androidx.compose.material3.Tab
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.material3.VerticalDivider
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.DisposableEffect
|
import androidx.compose.runtime.DisposableEffect
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
@@ -94,6 +93,7 @@ import androidx.compose.ui.Modifier
|
|||||||
import androidx.compose.ui.draw.clip
|
import androidx.compose.ui.draw.clip
|
||||||
import androidx.compose.ui.geometry.Offset
|
import androidx.compose.ui.geometry.Offset
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
|
import androidx.compose.ui.graphics.Shape
|
||||||
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
|
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
|
||||||
import androidx.compose.ui.input.nestedscroll.NestedScrollSource
|
import androidx.compose.ui.input.nestedscroll.NestedScrollSource
|
||||||
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||||
@@ -174,6 +174,7 @@ import com.vitorpamplona.amethyst.ui.theme.BitcoinOrange
|
|||||||
import com.vitorpamplona.amethyst.ui.theme.ButtonBorder
|
import com.vitorpamplona.amethyst.ui.theme.ButtonBorder
|
||||||
import com.vitorpamplona.amethyst.ui.theme.ButtonPadding
|
import com.vitorpamplona.amethyst.ui.theme.ButtonPadding
|
||||||
import com.vitorpamplona.amethyst.ui.theme.DividerThickness
|
import com.vitorpamplona.amethyst.ui.theme.DividerThickness
|
||||||
|
import com.vitorpamplona.amethyst.ui.theme.HalfCircleButtonBorder
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Size100dp
|
import com.vitorpamplona.amethyst.ui.theme.Size100dp
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Size15Modifier
|
import com.vitorpamplona.amethyst.ui.theme.Size15Modifier
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Size16Modifier
|
import com.vitorpamplona.amethyst.ui.theme.Size16Modifier
|
||||||
@@ -911,7 +912,7 @@ private fun ProfileActions(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FollowSetsActionMenu()
|
FollowSetsActionMenu()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@@ -937,7 +938,9 @@ private fun DisplayFollowUnfollowButton(
|
|||||||
.observeAsState(initial = baseUser.isFollowing(accountViewModel.account.userProfile()))
|
.observeAsState(initial = baseUser.isFollowing(accountViewModel.account.userProfile()))
|
||||||
|
|
||||||
if (isLoggedInFollowingUser) {
|
if (isLoggedInFollowingUser) {
|
||||||
UnfollowButton {
|
UnfollowButton(
|
||||||
|
shape = HalfCircleButtonBorder,
|
||||||
|
) {
|
||||||
if (!accountViewModel.isWriteable()) {
|
if (!accountViewModel.isWriteable()) {
|
||||||
accountViewModel.toast(
|
accountViewModel.toast(
|
||||||
R.string.read_only_user,
|
R.string.read_only_user,
|
||||||
@@ -949,7 +952,10 @@ private fun DisplayFollowUnfollowButton(
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (isUserFollowingLoggedIn) {
|
if (isUserFollowingLoggedIn) {
|
||||||
FollowButton(R.string.follow_back) {
|
FollowButton(
|
||||||
|
text = R.string.follow_back,
|
||||||
|
shape = HalfCircleButtonBorder,
|
||||||
|
) {
|
||||||
if (!accountViewModel.isWriteable()) {
|
if (!accountViewModel.isWriteable()) {
|
||||||
accountViewModel.toast(
|
accountViewModel.toast(
|
||||||
R.string.read_only_user,
|
R.string.read_only_user,
|
||||||
@@ -960,7 +966,10 @@ private fun DisplayFollowUnfollowButton(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
FollowButton(R.string.follow) {
|
FollowButton(
|
||||||
|
text = R.string.follow,
|
||||||
|
shape = HalfCircleButtonBorder,
|
||||||
|
) {
|
||||||
if (!accountViewModel.isWriteable()) {
|
if (!accountViewModel.isWriteable()) {
|
||||||
accountViewModel.toast(
|
accountViewModel.toast(
|
||||||
R.string.read_only_user,
|
R.string.read_only_user,
|
||||||
@@ -972,6 +981,7 @@ private fun DisplayFollowUnfollowButton(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// FollowSetsActionMenu()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@@ -994,16 +1004,31 @@ fun FollowSetsActionMenu(modifier: Modifier = Modifier) {
|
|||||||
val isMenuOpen = remember { mutableStateOf(false) }
|
val isMenuOpen = remember { mutableStateOf(false) }
|
||||||
|
|
||||||
Box {
|
Box {
|
||||||
|
// TextButton(
|
||||||
|
// onClick = {
|
||||||
|
// isMenuOpen.value = !isMenuOpen.value
|
||||||
|
// },
|
||||||
|
// shape = ButtonBorder.copy(topStart = CornerSize(0f), bottomStart = CornerSize(0f)),
|
||||||
|
// colors =
|
||||||
|
// ButtonDefaults
|
||||||
|
// .buttonColors(containerColor = MaterialTheme.colorScheme.primary),
|
||||||
|
// contentPadding = ZeroPadding,
|
||||||
|
// ) {
|
||||||
|
// Icon(
|
||||||
|
// imageVector = if (isMenuOpen.value) Icons.Default.ArrowDropUp else Icons.Default.ArrowDropDown,
|
||||||
|
// contentDescription = "",
|
||||||
|
// )
|
||||||
|
// }
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = if (isMenuOpen.value) Icons.Default.ArrowDropUp else Icons.Default.ArrowDropDown,
|
imageVector = if (isMenuOpen.value) Icons.Default.ArrowDropUp else Icons.Default.ArrowDropDown,
|
||||||
contentDescription = "",
|
contentDescription = "",
|
||||||
modifier =
|
modifier =
|
||||||
Modifier
|
Modifier
|
||||||
|
.fillMaxHeight()
|
||||||
.background(
|
.background(
|
||||||
color = MaterialTheme.colorScheme.primary,
|
color = MaterialTheme.colorScheme.primary,
|
||||||
shape = ButtonBorder.copy(topStart = CornerSize(0f), bottomStart = CornerSize(0f)),
|
shape = HalfCircleButtonBorder,
|
||||||
).fillMaxHeight()
|
).border(
|
||||||
.border(
|
|
||||||
width = Dp.Hairline,
|
width = Dp.Hairline,
|
||||||
color = MaterialTheme.colorScheme.primary,
|
color = MaterialTheme.colorScheme.primary,
|
||||||
shape =
|
shape =
|
||||||
@@ -2015,11 +2040,14 @@ private fun InnerEditButton(onClick: () -> Unit) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun UnfollowButton(onClick: () -> Unit) {
|
fun UnfollowButton(
|
||||||
|
shape: Shape = ButtonBorder,
|
||||||
|
onClick: () -> Unit,
|
||||||
|
) {
|
||||||
Button(
|
Button(
|
||||||
modifier = Modifier.padding(horizontal = 3.dp),
|
modifier = Modifier.padding(horizontal = 3.dp),
|
||||||
onClick = onClick,
|
onClick = onClick,
|
||||||
shape = ButtonBorder.copy(topEnd = CornerSize(0f), bottomEnd = CornerSize(0f)),
|
shape = shape,
|
||||||
colors =
|
colors =
|
||||||
ButtonDefaults.buttonColors(
|
ButtonDefaults.buttonColors(
|
||||||
containerColor = MaterialTheme.colorScheme.primary,
|
containerColor = MaterialTheme.colorScheme.primary,
|
||||||
@@ -2028,19 +2056,18 @@ fun UnfollowButton(onClick: () -> Unit) {
|
|||||||
) {
|
) {
|
||||||
Text(text = stringRes(R.string.unfollow), color = Color.White)
|
Text(text = stringRes(R.string.unfollow), color = Color.White)
|
||||||
}
|
}
|
||||||
VerticalDivider()
|
|
||||||
FollowSetsActionMenu()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun FollowButton(
|
fun FollowButton(
|
||||||
text: Int = R.string.follow,
|
text: Int = R.string.follow,
|
||||||
|
shape: Shape = ButtonBorder,
|
||||||
onClick: () -> Unit,
|
onClick: () -> Unit,
|
||||||
) {
|
) {
|
||||||
Button(
|
Button(
|
||||||
modifier = Modifier.padding(start = 3.dp),
|
modifier = Modifier.padding(start = 3.dp),
|
||||||
onClick = onClick,
|
onClick = onClick,
|
||||||
shape = ButtonBorder.copy(topEnd = CornerSize(0f), bottomEnd = CornerSize(0f)),
|
shape = shape,
|
||||||
colors =
|
colors =
|
||||||
ButtonDefaults.buttonColors(
|
ButtonDefaults.buttonColors(
|
||||||
containerColor = MaterialTheme.colorScheme.primary,
|
containerColor = MaterialTheme.colorScheme.primary,
|
||||||
@@ -2049,8 +2076,6 @@ fun FollowButton(
|
|||||||
) {
|
) {
|
||||||
Text(text = stringRes(text), color = Color.White, textAlign = TextAlign.Center)
|
Text(text = stringRes(text), color = Color.White, textAlign = TextAlign.Center)
|
||||||
}
|
}
|
||||||
VerticalDivider()
|
|
||||||
FollowSetsActionMenu()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import androidx.compose.foundation.layout.size
|
|||||||
import androidx.compose.foundation.layout.width
|
import androidx.compose.foundation.layout.width
|
||||||
import androidx.compose.foundation.layout.widthIn
|
import androidx.compose.foundation.layout.widthIn
|
||||||
import androidx.compose.foundation.shape.CircleShape
|
import androidx.compose.foundation.shape.CircleShape
|
||||||
|
import androidx.compose.foundation.shape.CornerSize
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.material3.Shapes
|
import androidx.compose.material3.Shapes
|
||||||
import androidx.compose.material3.ripple
|
import androidx.compose.material3.ripple
|
||||||
@@ -61,6 +62,7 @@ val SmallishBorder = RoundedCornerShape(9.dp)
|
|||||||
val QuoteBorder = RoundedCornerShape(15.dp)
|
val QuoteBorder = RoundedCornerShape(15.dp)
|
||||||
|
|
||||||
val ButtonBorder = RoundedCornerShape(20.dp)
|
val ButtonBorder = RoundedCornerShape(20.dp)
|
||||||
|
val HalfCircleButtonBorder = ButtonBorder.copy(topEnd = CornerSize(0f), bottomEnd = CornerSize(0f))
|
||||||
val EditFieldBorder = RoundedCornerShape(25.dp)
|
val EditFieldBorder = RoundedCornerShape(25.dp)
|
||||||
|
|
||||||
val ChatBubbleShapeMe = RoundedCornerShape(15.dp, 15.dp, 3.dp, 15.dp)
|
val ChatBubbleShapeMe = RoundedCornerShape(15.dp, 15.dp, 3.dp, 15.dp)
|
||||||
|
|||||||
Reference in New Issue
Block a user