Nikolay Igotti
3 years ago
8 changed files with 77 additions and 38 deletions
@ -0,0 +1,33 @@
|
||||
package org.jetbrains.compose.kapp.demo |
||||
|
||||
import androidx.compose.foundation.layout.Column |
||||
import androidx.compose.material.Button |
||||
import androidx.compose.material.Text |
||||
import androidx.compose.runtime.* |
||||
|
||||
import org.jetbrains.compose.kapp.* |
||||
|
||||
fun multiFrameApp() = kapp(title = "Kapp demo") { |
||||
var visible = remember { mutableStateOf(5) } |
||||
|
||||
for (index in 0 .. visible.value) { |
||||
Frame { |
||||
FrameContent(index, visible) |
||||
} |
||||
} |
||||
} |
||||
|
||||
@Composable |
||||
fun FrameContent(index: Int, visible: MutableState<Int>) { |
||||
Column { |
||||
Text("I am frame $index") |
||||
if (index == 0) { |
||||
Button(onClick = { visible.value++ }) { |
||||
Text("Add") |
||||
} |
||||
Button(onClick = { if (visible.value > 1) visible.value-- }) { |
||||
Text("Remove") |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,30 +0,0 @@
|
||||
package org.jetbrains.compose.kapp.demo |
||||
|
||||
import androidx.compose.foundation.layout.Column |
||||
import androidx.compose.material.Button |
||||
import androidx.compose.material.Text |
||||
import androidx.compose.runtime.* |
||||
|
||||
import org.jetbrains.compose.kapp.* |
||||
|
||||
fun main() = kapp( |
||||
title = "App demo" |
||||
) { |
||||
var visible by remember { mutableStateOf(5) } |
||||
|
||||
for (index in 0 .. visible) { |
||||
Frame { |
||||
Column { |
||||
Text("I am frame $index") |
||||
if (index == 0) { |
||||
Button(onClick = { visible++ }) { |
||||
Text("Add") |
||||
} |
||||
Button(onClick = { if (visible > 1) visible-- }) { |
||||
Text("Remove") |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,19 @@
|
||||
package org.jetbrains.compose.kapp.demo |
||||
|
||||
import androidx.compose.desktop.ui.tooling.preview.Preview |
||||
import androidx.compose.runtime.Composable |
||||
import androidx.compose.runtime.mutableStateOf |
||||
|
||||
@Preview |
||||
@Composable |
||||
fun PreviewFrame0() { |
||||
FrameContent(0, mutableStateOf(1)) |
||||
} |
||||
|
||||
@Preview |
||||
@Composable |
||||
fun PreviewFrame1() { |
||||
FrameContent(1, mutableStateOf(2)) |
||||
} |
||||
|
||||
fun main() = multiFrameApp() |
@ -0,0 +1,12 @@
|
||||
package org.jetbrains.compose.kapp.demo |
||||
|
||||
import androidx.compose.desktop.ui.tooling.preview.Preview |
||||
import androidx.compose.runtime.Composable |
||||
|
||||
@Preview |
||||
@Composable |
||||
fun PreviewSimple() { |
||||
SimpleAppContent() |
||||
} |
||||
|
||||
fun main() = simpleDemoApp() |
Loading…
Reference in new issue