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 RootComposable() { | |
var name by rememberSaveable { mutableStateOf("") } | |
HelloContent(name = name, onNameChange = { name = it }) | |
} | |
@Composable | |
fun HelloContent(name: String, onNameChange: (String) -> Unit) { | |
Column(modifier = Modifier.padding(16.dp)) { | |
Text( |
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 TextFieldDemo() { | |
Column(Modifier.padding(16.dp)) { | |
val textState = remember {mutableStateOf(mutableStateOf(""))} | |
TextField( | |
value = textState.value, | |
onValueChange = { textState.value = it } | |
) | |
Text("The textfield has this text:textState.value.text) | |
} |
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
var name by remember { 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 SecondRootComposable() { | |
Box(Modifier.fillMaxSize()) { // Recomposition Scope Start | |
val scroll = rememberScrollState(0) | |
Title(snack = snack,scroll=scroll.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 SecondRootComposable() { | |
Box(Modifier.fillMaxSize()) { // Recomposition Scope Start | |
val scroll = rememberScrollState(0) | |
Title(snack = snack, scrollProvider = {scroll.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 TestComposable(modifier: Modifier = Modifier, data: () -> Unit) { | |
//scope of the composebale | |
// | |
} |
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 DemoLaunchedEffect(key1: String, key2: String, key3: String, list: Array<String>) { | |
LaunchedEffect(key1 = key1) { | |
//CoroutineScope | |
} | |
LaunchedEffect(key1 = key1, key2 = key2) { | |
//CoroutineScope |
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 DemoCoroutineScope() { | |
val scope = rememberCoroutineScope() | |
Button(onClick = { | |
scope.launch { | |
//CoroutineScope | |
//run any suspend functions inside this scope |
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 rememberMapViewWithLifecycle() { | |
DisposableEffect(key1 = lifecycle, key2 = mapView) { | |
// Make MapView follow the current lifecycle | |
val lifecycleObserver = getMapLifecycleObserver(mapView) | |
lifecycle.addObserver(lifecycleObserver) | |
onDispose { | |
} |
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
//function we call in our code | |
@Composable | |
@NonRestartableComposable | |
@OptIn(InternalComposeApi::class) | |
fun LaunchedEffect( | |
key1: Any?, | |
block: suspend CoroutineScope.() -> Unit | |
) { | |
val applyContext = currentComposer.applyCoroutineContext |