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
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 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
@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
import android.util.Log | |
import com.currency.domain.CurrencyConverter | |
import io.ktor.client.* | |
import io.ktor.client.engine.android.* | |
import io.ktor.client.plugins.* | |
import io.ktor.client.plugins.contentnegotiation.* | |
import io.ktor.client.plugins.logging.* | |
import io.ktor.client.plugins.observer.* | |
import io.ktor.serialization.kotlinx.json.* | |
import kotlinx.serialization.json.Json |
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
//interface | |
interface CoroutineDispatcherProvider { | |
val main: CoroutineDispatcher | |
val io: CoroutineDispatcher | |
val default: CoroutineDispatcher | |
val unconfirmed: CoroutineDispatcher | |
} | |
//initialization using "by lazy" | |
open class RealCoroutineDispatcherProvider : CoroutineDispatcherProvider { |
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
fun main() { | |
//var can be reassigned | |
var varInt: Int = 1 | |
var varString: String = "Hello" | |
var varDouble: Double = 24.0 | |
var varLong: Long = 30L | |
//val can't be reassigned | |
val valInt: Int = 1 |
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
fun main() { | |
printMessage("Hello") | |
printMessageWithPrefix("Hello", "World") | |
sum(4, 5) | |
multiply(4, 5) | |
} | |
fun printMessage(message: String) { | |
println(message) |
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
fun main() { | |
val sumResult = calculate(4, 5, ::sum) //sumResult 9, | |
val mulResult = calculate(4, 5) { a, b -> a * b } // mulResult 20 | |
println("sumResult $sumResult, mulResult $mulResult") | |
} | |
fun calculate(x: Int, y: Int, operation: (Int, Int) -> Int): Int { | |
return operation(x, y) |
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 intList = mutableListOf(1, 2, 3, 4, 5, 6, 7) | |
val filtered = intList.filter { | |
it % 2 == 0 | |
} | |
println(filtered)///[2, 4, 6] | |
val mapped = intList.map { | |
it * it | |
} |