forked from ITStudio_OUC/KMP_2026_National_Day_Project
优化
This commit is contained in:
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
[从 Kotlin 到 Kotlin Multiplatform](https://git.itouc.cn/ITStudio_OUC/From_Kotlin_to_Kotlin-Multiplatform)
|
[从 Kotlin 到 Kotlin Multiplatform](https://git.itouc.cn/ITStudio_OUC/From_Kotlin_to_Kotlin-Multiplatform)
|
||||||
|
|
||||||
完全掌握:引入 Kotlin,进入 KMP
|
完全掌握:引入 Kotlin,第一个 KMP 应用
|
||||||
|
|
||||||
简单了解:深入 Kotlin
|
简单了解:深入 Kotlin
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import kotlin.random.Random
|
|||||||
fun App() {
|
fun App() {
|
||||||
MaterialTheme {
|
MaterialTheme {
|
||||||
var showContent by remember { mutableStateOf(false) }
|
var showContent by remember { mutableStateOf(false) }
|
||||||
val r by remember(showContent) { mutableStateOf(Random.nextInt()) }
|
var randomInt by remember { mutableStateOf(Random.nextInt()) }
|
||||||
|
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
@@ -34,7 +34,12 @@ fun App() {
|
|||||||
.fillMaxSize(),
|
.fillMaxSize(),
|
||||||
horizontalAlignment = Alignment.CenterHorizontally,
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
) {
|
) {
|
||||||
Button(onClick = { showContent = !showContent }) {
|
Button(
|
||||||
|
onClick = {
|
||||||
|
showContent = !showContent
|
||||||
|
if (showContent) randomInt = Random.nextInt()
|
||||||
|
}
|
||||||
|
) {
|
||||||
Text("Click me!")
|
Text("Click me!")
|
||||||
}
|
}
|
||||||
AnimatedVisibility(showContent) {
|
AnimatedVisibility(showContent) {
|
||||||
@@ -43,7 +48,7 @@ fun App() {
|
|||||||
horizontalAlignment = Alignment.CenterHorizontally,
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
) {
|
) {
|
||||||
Image(painterResource(Res.drawable.compose_multiplatform), null)
|
Image(painterResource(Res.drawable.compose_multiplatform), null)
|
||||||
Text("a random int: $r")
|
Text("a random int: $randomInt")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user