Skip to content

Instantly share code, notes, and snippets.

View AndroidPoet's full-sized avatar
God Mode

Ranbir Singh AndroidPoet

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