mirror of
https://github.com/InsanusMokrassar/JSUIKitKBindings.git
synced 2024-12-22 08:37:24 +00:00
improve support of List
This commit is contained in:
parent
8adbe8a1ca
commit
6daa57fe8f
@ -2,12 +2,30 @@ package dev.inmo.jsuikit.elements
|
|||||||
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.snapshots.SnapshotStateList
|
import androidx.compose.runtime.snapshots.SnapshotStateList
|
||||||
import dev.inmo.jsuikit.modifiers.UIKitModifier
|
import dev.inmo.jsuikit.modifiers.*
|
||||||
import dev.inmo.jsuikit.modifiers.include
|
import dev.inmo.jsuikit.utils.Attrs
|
||||||
import org.jetbrains.compose.web.dom.*
|
import org.jetbrains.compose.web.dom.*
|
||||||
import org.w3c.dom.HTMLHeadingElement
|
import org.w3c.dom.HTMLHeadingElement
|
||||||
import org.w3c.dom.HTMLUListElement
|
import org.w3c.dom.HTMLUListElement
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun <T> List(
|
||||||
|
data: SnapshotStateList<T>,
|
||||||
|
ukAttrs: Attrs<HTMLUListElement> = Attrs.empty(),
|
||||||
|
elementAllocator: @Composable ElementScope<HTMLUListElement>.(T) -> Unit
|
||||||
|
) {
|
||||||
|
Ul(
|
||||||
|
{
|
||||||
|
include(UIKitList)
|
||||||
|
ukAttrs.builder(this)
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
data.forEach {
|
||||||
|
elementAllocator(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun <T> List(
|
fun <T> List(
|
||||||
title: String,
|
title: String,
|
||||||
@ -23,15 +41,5 @@ fun <T> List(
|
|||||||
Text(title)
|
Text(title)
|
||||||
}
|
}
|
||||||
besidesTitleAndList ?.invoke()
|
besidesTitleAndList ?.invoke()
|
||||||
Ul(
|
List(data, Attrs(*ulModifiers) { ulCustomizer(this) }, elementAllocator)
|
||||||
{
|
|
||||||
classes("uk-list")
|
|
||||||
include(*ulModifiers)
|
|
||||||
ulCustomizer()
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
data.forEach {
|
|
||||||
elementAllocator(it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user