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
// create properties | |
data class SharedToolbarProps( | |
val title: String, | |
val subtitle: String, | |
val isMenuIconVisible: Boolean, | |
val onMenuIconClicked: () -> Unit | |
) { | |
companion object { | |
val default: SharedToolbarProps = SharedToolbarProps( | |
title = "Lorem Title", |
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
//Utils - Declaration | |
object PromptUtils { | |
fun alertDialog(context: Context, @StyleRes style: Int, dialogBuilder: AlertDialog.Builder.() -> Unit): Dialog { | |
val builder = AlertDialog.Builder(context, style).also { | |
it.setCancelable(false) | |
it.dialogBuilder() | |
} | |
return builder.create() | |
} |
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 CaptureBitmap( | |
content: @Composable () -> Unit, | |
): () -> Bitmap { | |
val context = LocalContext.current | |
/** | |
* ComposeView that would take composable as its content | |
* Kept in remember so recomposition doesn't re-initialize it |
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
/* | |
* MIT License | |
* | |
* Copyright (c) 2022 Albert Chang | |
* | |
* 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 |
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
// Create a counter state | |
var count by remember { | |
mutableStateOf(value = 0) | |
} | |
Column( | |
modifier = Modifier | |
.fillMaxSize() | |
.background(Color.White), | |
verticalArrangement = Arrangement.Center, | |
horizontalAlignment = Alignment.CenterHorizontally |
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 Foo() { | |
val countState = remember { mutableStateOf(0) } | |
Button(onClick = { | |
val count = countState.value //👈 count is 0 | |
val setCount = { lastestCount: Int -> | |
countState.value = lastestCount |
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
Button( | |
onClick = { | |
// thing that is happening is : | |
setCount(count + 1) //👉 0 + 1 | |
setCount(count + 1) //👉 0 + 1 | |
} | |
) { | |
Text(text = "Increment by 2") | |
} // button end |
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
// Create a counter state | |
val(count, setCount) = remember { | |
mutableStateOf(0) | |
} | |
Column( | |
modifier = Modifier | |
.fillMaxSize() | |
.background(Color.White), | |
verticalArrangement = Arrangement.Center, | |
horizontalAlignment = Alignment.CenterHorizontally |
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
// Create a counter state | |
val(count, setCount) = remember { | |
mutableStateOf(0) | |
} | |
Column( | |
modifier = Modifier | |
.fillMaxSize() | |
.background(Color.White), | |
verticalArrangement = Arrangement.Center, | |
horizontalAlignment = Alignment.CenterHorizontally |
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
val(isChecked, setChecked) = remember { | |
mutableStateOf(value = false) | |
} | |
Checkbox( | |
checked = isChecked, | |
onCheckedChange = setChecked | |
) | |
// vs |
NewerOlder