Skip to content

Commit e338f2c

Browse files
committed
update
1 parent c6109c8 commit e338f2c

File tree

1 file changed

+29
-25
lines changed
  • src/main/kotlin/com/hoc081098/kotlin_playground/compose

1 file changed

+29
-25
lines changed

src/main/kotlin/com/hoc081098/kotlin_playground/compose/main.kt

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,40 +7,44 @@ import androidx.compose.runtime.Composable
77
import androidx.compose.ui.window.singleWindowApplication
88

99
fun main() {
10+
val demo = Demo()
1011
singleWindowApplication {
11-
MyComposable()
12+
demo.MyComposable()
1213
}
1314
}
1415

15-
fun func1() {
16-
println("Func 1")
17-
}
18-
19-
fun func2(i: Int) {
20-
println("Func 2: $i")
21-
}
22-
23-
@Composable
24-
fun MyComposable() {
25-
val func3 = {
26-
println("Func 3")
16+
class Demo {
17+
private fun func1() {
18+
println("Func 1")
2719
}
28-
val func4 = { i: Int ->
29-
println("Func 4: $i")
20+
21+
private fun func2(i: Int) {
22+
println("Func 2: $i")
3023
}
3124

32-
Column {
33-
Button(onClick = ::func1) {
34-
Text("Func 1")
35-
}
36-
Button(onClick = { func2(1) }) {
37-
Text("Func 2")
25+
@Composable
26+
fun MyComposable() {
27+
val func3 = {
28+
println("Func 3")
3829
}
39-
Button(onClick = func3) {
40-
Text("Func 3")
30+
val func4 = { i: Int ->
31+
println("Func 4: $i")
4132
}
42-
Button(onClick = { func4(1) }) {
43-
Text("Func 4")
33+
34+
Column {
35+
Button(onClick = ::func1) {
36+
Text("Func 1")
37+
}
38+
Button(onClick = { func2(1) }) {
39+
Text("Func 2")
40+
}
41+
Button(onClick = func3) {
42+
Text("Func 3")
43+
}
44+
Button(onClick = { func4(1) }) {
45+
Text("Func 4")
46+
}
4447
}
4548
}
49+
4650
}

0 commit comments

Comments
 (0)