mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-17 20:17:02 +05:30
Tweak lambda parameters for LobstersItem
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
parent
5acab43669
commit
5678215b25
3 changed files with 15 additions and 12 deletions
|
@ -32,9 +32,9 @@ fun HottestPosts(
|
|||
}
|
||||
LobstersItem(
|
||||
post = item,
|
||||
onClick = { post -> urlLauncher.launch(post.url.ifEmpty { post.commentsUrl }) },
|
||||
onLongClick = { post -> urlLauncher.launch(post.commentsUrl) },
|
||||
onSaveButtonClick = saveAction,
|
||||
onClick = { urlLauncher.launch(item.url.ifEmpty { item.commentsUrl }) },
|
||||
onLongClick = { urlLauncher.launch(item.commentsUrl) },
|
||||
onSaveButtonClick = { saveAction.invoke(item) },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,15 +58,15 @@ val TEST_POST = LobstersPost(
|
|||
@Composable
|
||||
fun LobstersItem(
|
||||
post: LobstersPost,
|
||||
onClick: (LobstersPost) -> Unit = {},
|
||||
onLongClick: (LobstersPost) -> Unit = {},
|
||||
onSaveButtonClick: (LobstersPost) -> Unit = {},
|
||||
onClick: () -> Unit,
|
||||
onLongClick: () -> Unit,
|
||||
onSaveButtonClick: () -> Unit,
|
||||
) {
|
||||
Surface(
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
.clickable(
|
||||
onClick = { onClick.invoke(post) },
|
||||
onLongClick = { onLongClick.invoke(post) },
|
||||
onClick = onClick,
|
||||
onLongClick = onLongClick,
|
||||
),
|
||||
) {
|
||||
ConstraintLayout(
|
||||
|
@ -112,7 +112,7 @@ fun LobstersItem(
|
|||
resourceId = R.drawable.ic_favorite_border_24px,
|
||||
modifier = Modifier.padding(8.dp)
|
||||
.clickable(
|
||||
onClick = { onSaveButtonClick.invoke(post) },
|
||||
onClick = onSaveButtonClick,
|
||||
indication = RippleIndication(),
|
||||
)
|
||||
.constrainAs(saveButton) {
|
||||
|
@ -153,6 +153,9 @@ fun Preview() {
|
|||
LazyColumnFor(items = listOf(TEST_POST, TEST_POST, TEST_POST, TEST_POST, TEST_POST)) { item ->
|
||||
LobstersItem(
|
||||
post = item,
|
||||
onClick = {},
|
||||
onLongClick = {},
|
||||
onSaveButtonClick = {},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,9 +28,9 @@ fun SavedPosts(
|
|||
) { item ->
|
||||
LobstersItem(
|
||||
post = item,
|
||||
onClick = { post -> urlLauncher.launch(post.url.ifEmpty { post.commentsUrl }) },
|
||||
onLongClick = { post -> urlLauncher.launch(post.commentsUrl) },
|
||||
onSaveButtonClick = saveAction,
|
||||
onClick = { urlLauncher.launch(item.url.ifEmpty { item.commentsUrl }) },
|
||||
onLongClick = { urlLauncher.launch(item.commentsUrl) },
|
||||
onSaveButtonClick = { saveAction.invoke(item) },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue