mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-14 19:57:04 +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.height
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.requiredSize
|
import androidx.compose.foundation.layout.requiredSize
|
||||||
|
import androidx.compose.foundation.layout.width
|
||||||
import androidx.compose.foundation.shape.CircleShape
|
import androidx.compose.foundation.shape.CircleShape
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.material.ripple.rememberRipple
|
import androidx.compose.material.ripple.rememberRipple
|
||||||
|
@ -50,9 +51,14 @@ fun LobstersCard(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
var localSavedState by remember(post, isSaved) { mutableStateOf(isSaved) }
|
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(
|
Row(
|
||||||
modifier = Modifier.fillMaxWidth().padding(16.dp),
|
|
||||||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
) {
|
) {
|
||||||
|
@ -61,7 +67,7 @@ fun LobstersCard(
|
||||||
post = post,
|
post = post,
|
||||||
)
|
)
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier.weight(0.15f).fillMaxHeight(),
|
modifier = Modifier.fillMaxHeight(),
|
||||||
verticalArrangement = Arrangement.spacedBy(8.dp),
|
verticalArrangement = Arrangement.spacedBy(8.dp),
|
||||||
horizontalAlignment = Alignment.CenterHorizontally,
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
) {
|
) {
|
||||||
|
@ -77,7 +83,7 @@ fun LobstersCard(
|
||||||
postActions.toggleSave(post)
|
postActions.toggleSave(post)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
Divider()
|
Divider(modifier = Modifier.width(48.dp))
|
||||||
CommentsButton(
|
CommentsButton(
|
||||||
modifier =
|
modifier =
|
||||||
Modifier.combinedClickable(
|
Modifier.combinedClickable(
|
||||||
|
@ -148,27 +154,31 @@ fun SaveButton(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
Crossfade(targetState = isSaved) { saved ->
|
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.align(Alignment.Center)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun CommentsButton(
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
) {
|
||||||
|
Box(modifier = modifier.padding(12.dp)) {
|
||||||
Icon(
|
Icon(
|
||||||
painter = if (saved) heartIcon else heartBorderIcon,
|
painter = commentIcon,
|
||||||
tint = MaterialTheme.colorScheme.secondary,
|
tint = MaterialTheme.colorScheme.secondary,
|
||||||
contentDescription = if (saved) "Remove from saved posts" else "Add to saved posts",
|
contentDescription = "Open comments",
|
||||||
modifier = modifier.padding(12.dp),
|
modifier = Modifier.align(Alignment.Center),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
|
||||||
fun CommentsButton(
|
|
||||||
modifier: Modifier = Modifier,
|
|
||||||
) {
|
|
||||||
Icon(
|
|
||||||
painter = commentIcon,
|
|
||||||
tint = MaterialTheme.colorScheme.secondary,
|
|
||||||
contentDescription = "Open comments",
|
|
||||||
modifier = modifier.padding(12.dp),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun TagRow(
|
fun TagRow(
|
||||||
tags: List<String>,
|
tags: List<String>,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue