mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-14 17:37:05 +05:30
Align post action icons properly in LobstersCard
(#300)
This commit is contained in:
parent
3b833083e1
commit
01a2bbc55d
1 changed files with 29 additions and 19 deletions
|
@ -16,6 +16,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
|
|||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.requiredSize
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.ripple.rememberRipple
|
||||
|
@ -50,9 +51,14 @@ fun LobstersCard(
|
|||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
var localSavedState by remember(post, isSaved) { mutableStateOf(isSaved) }
|
||||
Box(modifier = modifier.clickable { postActions.viewPost(post.url, post.commentsUrl) }) {
|
||||
Box(
|
||||
modifier =
|
||||
modifier
|
||||
.fillMaxWidth()
|
||||
.clickable { postActions.viewPost(post.url, post.commentsUrl) }
|
||||
.padding(start = 16.dp, top = 16.dp, end = 4.dp, bottom = 16.dp),
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth().padding(16.dp),
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
|
@ -61,7 +67,7 @@ fun LobstersCard(
|
|||
post = post,
|
||||
)
|
||||
Column(
|
||||
modifier = Modifier.weight(0.15f).fillMaxHeight(),
|
||||
modifier = Modifier.fillMaxHeight(),
|
||||
verticalArrangement = Arrangement.spacedBy(8.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
) {
|
||||
|
@ -77,7 +83,7 @@ fun LobstersCard(
|
|||
postActions.toggleSave(post)
|
||||
},
|
||||
)
|
||||
Divider()
|
||||
Divider(modifier = Modifier.width(48.dp))
|
||||
CommentsButton(
|
||||
modifier =
|
||||
Modifier.combinedClickable(
|
||||
|
@ -148,26 +154,30 @@ fun SaveButton(
|
|||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
Crossfade(targetState = isSaved) { saved ->
|
||||
Box(modifier = modifier.padding(12.dp)) {
|
||||
Icon(
|
||||
painter = if (saved) heartIcon else heartBorderIcon,
|
||||
tint = MaterialTheme.colorScheme.secondary,
|
||||
contentDescription = if (saved) "Remove from saved posts" else "Add to saved posts",
|
||||
modifier = modifier.padding(12.dp),
|
||||
modifier = Modifier.align(Alignment.Center)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun CommentsButton(
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
Box(modifier = modifier.padding(12.dp)) {
|
||||
Icon(
|
||||
painter = commentIcon,
|
||||
tint = MaterialTheme.colorScheme.secondary,
|
||||
contentDescription = "Open comments",
|
||||
modifier = modifier.padding(12.dp),
|
||||
modifier = Modifier.align(Alignment.Center),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun TagRow(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue