app: switch to LazyColumn

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
Harsh Shandilya 2020-12-17 01:12:08 +05:30
parent 60620eccec
commit 4922f3daf8
No known key found for this signature in database
GPG key ID: 366D7BBAD1031E80
2 changed files with 21 additions and 18 deletions

View file

@ -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() {
}
}
}
}

View file

@ -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(
}
}
}
}