This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Copyright (c) 2025 Andrei Shikov | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is | |
furnished to do so, subject to the following conditions: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Preview | |
@Composable | |
private fun LazyColumnDemo() { | |
var spacerPositionOffset by remember { | |
mutableStateOf(Offset.Unspecified) | |
} | |
val configuration = LocalConfiguration.current | |
val windowSize = remember(configuration) { | |
DpSize(configuration.screenWidthDp.dp, configuration.screenHeightDp.dp) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new ReactNativeConfig() { | |
@Override | |
public boolean getBool(String s) { | |
return s.equals( | |
"react_fabric:enable_large_text_measure_cache_android"); | |
} | |
@Override | |
public long getInt64(String s) { | |
return 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.Context | |
import androidx.compose.material.Text | |
import androidx.compose.runtime.Composable | |
import androidx.compose.runtime.Composition | |
import androidx.compose.runtime.CompositionLocalProvider | |
import androidx.compose.runtime.LaunchedEffect | |
import androidx.compose.runtime.MonotonicFrameClock | |
import androidx.compose.runtime.Recomposer | |
import androidx.compose.runtime.getValue | |
import androidx.compose.runtime.mutableStateOf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun TodoList() { | |
h1 { text("TodoList") } | |
p(modifier = Modifier.lineHeight(1.5f)) { | |
text("Classic example interacting with a list of items.") | |
br() | |
text("Use input below to add more items to a list (submit using Enter)") | |
} | |
val todos = remember { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun Component(hasDiv: Boolean) { | |
// Note that Component does not add anything to tree directly | |
// Only calls to emit change "virtual DOM" | |
// Here it is called from div -> tag -> emit | |
if (hasDiv) { | |
div() // <-- adding or removing node here based on parameter, updating tree | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun input( | |
type: String, | |
value: String, | |
modifier: Modifier = Modifier | |
) { | |
tag( | |
tagName = 'input', | |
modifier = modifier.type(type).value(value) | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun input( | |
value: String, | |
type: String, | |
onChange: (String) -> Unit, | |
onKeyUp: (String) -> Unit | |
) { | |
tag( | |
tagName = 'input', | |
attributes = mapOf('value' to value, 'type' to type), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Click : Event { | |
override val type: String = "click" | |
object Payload : Event.Payload<Click> { | |
override val descriptor: Click = Click | |
} | |
class Callback(override val onReceive: (payload: Payload) -> Unit) : Event.Callback<Click, Payload> { | |
override val descriptor: Click = Click | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private val CommandDispatcherAmbient = staticAmbientOf<RenderCommandDispatcher>() | |
// Instantiate it | |
composition.setContent { | |
Providers(CommandDispatcherAmbient provides commandDispatcher) { | |
composable() | |
} | |
} | |
// Use it |
NewerOlder