This file contains 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 androidx.compose.runtime.Composable | |
import androidx.compose.runtime.Composer | |
import androidx.compose.runtime.CompositionTracer | |
import androidx.compose.runtime.DisposableEffect | |
import androidx.compose.runtime.InternalComposeApi | |
import androidx.compose.runtime.InternalComposeTracingApi | |
import androidx.compose.runtime.remember | |
import androidx.compose.runtime.snapshots.MutableSnapshot | |
import androidx.compose.runtime.snapshots.Snapshot | |
import java.util.WeakHashMap |
This file contains 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 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 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 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 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 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 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 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 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