diff --git a/mosaic-runtime/src/commonMain/kotlin/com/jakewharton/mosaic/Static.kt b/mosaic-runtime/src/commonMain/kotlin/com/jakewharton/mosaic/Static.kt index e8f2d91f..c6eef567 100644 --- a/mosaic-runtime/src/commonMain/kotlin/com/jakewharton/mosaic/Static.kt +++ b/mosaic-runtime/src/commonMain/kotlin/com/jakewharton/mosaic/Static.kt @@ -27,56 +27,34 @@ public fun Static( } } - Static( - postRender = { - // Remove any items which have been rendered. - pending.removeAll { it.rendered } - } - ) { - for (item in pending) { - Row { - // Render item and mark it as having been included in render. - content(item.value) - item.rendered = true - } - } - } -} - -/** - * Renders [content] permanently above the normal canvas. When content has - * actually been written to a [TextCanvas], the [postRender] callback will be - * invoked to allow clearing of content. - * - * @param postRender Callback after rendering to a [TextCanvas] is complete. - * @param content Content which should be rendered permanently above normal - * canvas. - */ -@Composable -internal fun Static( - postRender: () -> Unit = {}, - content: @Composable () -> Unit, -) { ComposeNode( - factory = ::StaticNode, - update = { - set(postRender) { - this.postRender = postRender + factory = { + StaticNode { + pending.removeAll { it.rendered } + } + }, + update = {}, + content = { + for (item in pending) { + Row { + // Render item and mark it as having been included in render. + content(item.value) + item.rendered = true + } } }, - content = content, ) } -internal class StaticNode : ContainerNode() { +internal class StaticNode( + private val postRender: () -> Unit, +) : ContainerNode() { // Delegate container column for static content. private val box = LinearNode(isRow = false) override val children: MutableList get() = box.children - var postRender: () -> Unit = {} - override fun measure() { // Not visible. }