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.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.width
|
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.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.material.Surface
|
import androidx.compose.material.Surface
|
||||||
import androidx.compose.material.Text
|
import androidx.compose.material.Text
|
||||||
|
@ -150,13 +150,15 @@ fun TagRow(
|
||||||
@Preview
|
@Preview
|
||||||
fun Preview() {
|
fun Preview() {
|
||||||
LobstersTheme {
|
LobstersTheme {
|
||||||
LazyColumnFor(items = listOf(TEST_POST, TEST_POST, TEST_POST, TEST_POST, TEST_POST)) { item ->
|
LazyColumn {
|
||||||
LobstersItem(
|
items(listOf(TEST_POST, TEST_POST, TEST_POST, TEST_POST, TEST_POST)) { item ->
|
||||||
post = item,
|
LobstersItem(
|
||||||
onClick = {},
|
post = item,
|
||||||
onLongClick = {},
|
onClick = {},
|
||||||
onSaveButtonClick = {},
|
onLongClick = {},
|
||||||
)
|
onSaveButtonClick = {},
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package dev.msfjarvis.lobsters.ui.posts
|
package dev.msfjarvis.lobsters.ui.posts
|
||||||
|
|
||||||
import androidx.compose.foundation.layout.padding
|
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.foundation.lazy.rememberLazyListState
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
@ -21,17 +21,18 @@ fun SavedPosts(
|
||||||
if (posts.isEmpty()) {
|
if (posts.isEmpty()) {
|
||||||
EmptyList(saved = true)
|
EmptyList(saved = true)
|
||||||
} else {
|
} else {
|
||||||
LazyColumnFor(
|
LazyColumn(
|
||||||
items = posts,
|
|
||||||
state = listState,
|
state = listState,
|
||||||
modifier = Modifier.padding(horizontal = 8.dp).then(modifier)
|
modifier = Modifier.padding(horizontal = 8.dp).then(modifier)
|
||||||
) { item ->
|
) {
|
||||||
LobstersItem(
|
items(posts) { item ->
|
||||||
post = item,
|
LobstersItem(
|
||||||
onClick = { urlLauncher.launch(item.url.ifEmpty { item.commentsUrl }) },
|
post = item,
|
||||||
onLongClick = { urlLauncher.launch(item.commentsUrl) },
|
onClick = { urlLauncher.launch(item.url.ifEmpty { item.commentsUrl }) },
|
||||||
onSaveButtonClick = { saveAction.invoke(item) },
|
onLongClick = { urlLauncher.launch(item.commentsUrl) },
|
||||||
)
|
onSaveButtonClick = { saveAction.invoke(item) },
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue