Skip to content

Commit

Permalink
button test screen
Browse files Browse the repository at this point in the history
  • Loading branch information
MeiNanziiii committed May 23, 2024
1 parent fb4d396 commit 9281764
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
37 changes: 37 additions & 0 deletions src/test/kotlin/ua/mei/kuwu/client/ButtonTestScreen.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package ua.mei.kuwu.client

import io.wispforest.owo.ui.container.Containers
import io.wispforest.owo.ui.container.FlowLayout
import io.wispforest.owo.ui.core.Sizing
import ua.mei.kowo.ops.button
import ua.mei.kowo.ops.label
import ua.mei.kowo.ops.literal
import ua.mei.kowo.ui.base.BaseKowoScreen

class ButtonTestScreen : BaseKowoScreen<FlowLayout>() {
override fun createRoot(horizontalSizing: Sizing, verticalSizing: Sizing): FlowLayout {
return Containers.verticalFlow(horizontalSizing, verticalSizing)
}

override fun build() {
// like rootComponent, but better
root {
// components can be stored in variables...
val exampleLabel = label {
text("Example screen: 0".literal())
}

// or directly added to the root
button {
message = "Example button".literal()

// variables can be stored within components
var value = 0
onPress {
// components stored in variables can be modified
exampleLabel.text("Example screen: ${++value}".literal())
}
}
}
}
}
8 changes: 7 additions & 1 deletion src/test/kotlin/ua/mei/kuwu/client/SelectKuwuScreenScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,20 @@ class SelectKuwuScreenScreen : BaseKowoScreen<FlowLayout>() {
surface(Surface.PANEL)
horizontalAlignment(HorizontalAlignment.CENTER)

button {
message = "button test".literal()

onPress {
client?.setScreen(ButtonTestScreen())
}
}
button {
message = "optimization test".literal()

onPress {
client?.setScreen(TooManyComponentsScreen())
}
}

button {
message = "sizenite".literal()

Expand Down

0 comments on commit 9281764

Please sign in to comment.