mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-17 22:37:03 +05:30
LobstersItem: add a dedicated comments button
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
parent
dbab82c533
commit
840361707a
3 changed files with 47 additions and 11 deletions
|
@ -3,7 +3,7 @@ package dev.msfjarvis.lobsters.ui.posts
|
|||
import androidx.compose.animation.Crossfade
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.combinedClickable
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
|
@ -15,6 +15,7 @@ import androidx.compose.foundation.layout.requiredWidth
|
|||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.IconButton
|
||||
import androidx.compose.material.IconToggleButton
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.material.Surface
|
||||
|
@ -59,27 +60,35 @@ fun LobstersItem(
|
|||
) {
|
||||
Surface(
|
||||
modifier = Modifier
|
||||
.combinedClickable(
|
||||
onClick = onClick,
|
||||
onLongClick = onLongClick,
|
||||
),
|
||||
.clickable { onClick.invoke() },
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier.padding(start = 12.dp, end = 24.dp),
|
||||
modifier = Modifier.padding(start = 12.dp, end = 12.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
) {
|
||||
Box(
|
||||
modifier = Modifier.weight(1f),
|
||||
modifier = Modifier.weight(0.8f),
|
||||
) {
|
||||
PostDetails(
|
||||
post,
|
||||
)
|
||||
}
|
||||
SaveButton(
|
||||
isSaved,
|
||||
onSaveButtonClick,
|
||||
)
|
||||
Box(
|
||||
modifier = Modifier.weight(0.1f),
|
||||
) {
|
||||
SaveButton(
|
||||
isSaved,
|
||||
onSaveButtonClick,
|
||||
)
|
||||
}
|
||||
Box(
|
||||
modifier = Modifier.weight(0.1f),
|
||||
) {
|
||||
CommentsButton(
|
||||
onClick = onLongClick,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -148,6 +157,23 @@ fun SaveButton(
|
|||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun CommentsButton(
|
||||
onClick: () -> Unit,
|
||||
) {
|
||||
IconButton(
|
||||
onClick = onClick,
|
||||
modifier = Modifier
|
||||
.requiredSize(24.dp),
|
||||
) {
|
||||
IconResource(
|
||||
resourceId = R.drawable.ic_insert_comment_24px,
|
||||
tint = MaterialTheme.colors.secondary,
|
||||
contentDescription = stringResource(R.string.open_comments),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun TagRow(
|
||||
tags: List<String>,
|
||||
|
|
9
app/src/main/res/drawable/ic_insert_comment_24px.xml
Normal file
9
app/src/main/res/drawable/ic_insert_comment_24px.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="#000000"
|
||||
android:pathData="M20,2L4,2c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h14l4,4L22,4c0,-1.1 -0.9,-2 -2,-2zM18,14L6,14v-2h12v2zM18,11L6,11L6,9h12v2zM18,8L6,8L6,6h12v2z" />
|
||||
</vector>
|
|
@ -9,4 +9,5 @@
|
|||
<string name="add_to_saved_posts">Add to saved posts</string>
|
||||
<string name="remove_from_saved_posts">Remove from saved posts</string>
|
||||
<string name="refresh_posts_content_description">Refresh posts</string>
|
||||
<string name="open_comments">Open comments</string>
|
||||
</resources>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue