mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-17 23:47:02 +05:30
app: switch to LazyColumn
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
parent
60620eccec
commit
4922f3daf8
2 changed files with 21 additions and 18 deletions
|
@ -8,7 +8,7 @@ import androidx.compose.foundation.layout.Row
|
|||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.lazy.LazyColumnFor
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.Surface
|
||||
import androidx.compose.material.Text
|
||||
|
@ -150,7 +150,8 @@ fun TagRow(
|
|||
@Preview
|
||||
fun Preview() {
|
||||
LobstersTheme {
|
||||
LazyColumnFor(items = listOf(TEST_POST, TEST_POST, TEST_POST, TEST_POST, TEST_POST)) { item ->
|
||||
LazyColumn {
|
||||
items(listOf(TEST_POST, TEST_POST, TEST_POST, TEST_POST, TEST_POST)) { item ->
|
||||
LobstersItem(
|
||||
post = item,
|
||||
onClick = {},
|
||||
|
@ -160,3 +161,4 @@ fun Preview() {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package dev.msfjarvis.lobsters.ui.posts
|
||||
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.lazy.LazyColumnFor
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
|
@ -21,11 +21,11 @@ fun SavedPosts(
|
|||
if (posts.isEmpty()) {
|
||||
EmptyList(saved = true)
|
||||
} else {
|
||||
LazyColumnFor(
|
||||
items = posts,
|
||||
LazyColumn(
|
||||
state = listState,
|
||||
modifier = Modifier.padding(horizontal = 8.dp).then(modifier)
|
||||
) { item ->
|
||||
) {
|
||||
items(posts) { item ->
|
||||
LobstersItem(
|
||||
post = item,
|
||||
onClick = { urlLauncher.launch(item.url.ifEmpty { item.commentsUrl }) },
|
||||
|
@ -35,3 +35,4 @@ fun SavedPosts(
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue