File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed
compose-multiplatform-material3/src
commonMain/kotlin/com/huanshankeji/compose/material3/lazy/ext
jsMain/kotlin/com/huanshankeji/compose/material3/lazy/ext Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -31,8 +31,14 @@ expect class ListScope {
3131
3232expect class ItemScope
3333
34+ /* *
35+ * @param isInteractiveJs whether the item is interactive on JS DOM,
36+ * aka whether it shows effects when the mouse pointer hovers above it or when it gets clicked.
37+ * On the `androidx.compose` targets, use `Modifier.clickable` for the same effect.
38+ */
3439class ListItemComponents (
3540 val contentModifier : Modifier = Modifier ,
41+ val isInteractiveJs : Boolean ,
3642 val headline : @Composable (Modifier ) -> Unit ,
3743 val start : @Composable ((Modifier ) -> Unit )? = null ,
3844 val end : @Composable ((Modifier ) -> Unit )? = null ,
@@ -42,6 +48,7 @@ class ListItemComponents(
4248) {
4349 constructor (
4450 contentModifier: Modifier = Modifier ,
51+ isInteractiveJs: Boolean ,
4552 headline: String ,
4653 start: Icon ? = null ,
4754 end: Icon ? = null ,
@@ -50,6 +57,7 @@ class ListItemComponents(
5057 overline: String? = null
5158 ) : this (
5259 contentModifier,
60+ isInteractiveJs,
5361 headline.toTextWithModifier(),
5462 start.toNullableContentWithModifier(),
5563 end.toNullableContentWithModifier(),
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import androidx.compose.runtime.Composable
44import com.huanshankeji.compose.foundation.verticalScrollPlatformModifier
55import com.huanshankeji.compose.html.material3.MdList
66import com.huanshankeji.compose.html.material3.MdListItemScope
7+ import com.huanshankeji.compose.html.material3.MdListItemType
78import com.huanshankeji.compose.html.material3.MdListScope
89import com.huanshankeji.compose.runtime.DeferredComposableRunner
910import com.huanshankeji.compose.ui.Modifier
@@ -39,9 +40,12 @@ actual class ListScope(val mdListScope: MdListScope) {
3940
4041
4142 @Composable
42- private fun ListItem (content : ListItemComponents ) =
43- mdListScope.MdListItem (attrs = content.contentModifier.toAttrs()) {
44- contentFromComponents(content)
43+ private fun ListItem (components : ListItemComponents ) =
44+ mdListScope.MdListItem (
45+ type = if (components.isInteractiveJs) MdListItemType .Button else null ,
46+ attrs = components.contentModifier.toAttrs()
47+ ) {
48+ contentFromComponents(components)
4549 }
4650
4751
You can’t perform that action at this time.
0 commit comments