ASMR/src/main/kotlin/net/shadowfacts/asmr/UITest.kt

54 lines
1.3 KiB
Kotlin

package net.shadowfacts.asmr
import net.shadowfacts.kiwidsl.dsl
import net.shadowfacts.shadowui.UIScreen
import net.shadowfacts.shadowui.UIView
import net.shadowfacts.shadowui.util.Color
class UITest: UIScreen() {
init {
val red = UIView().apply {
backgroundColor = Color(0xff0000)
addView(this)
}
val green = UIView().apply {
backgroundColor = Color(0x00ff00)
addView(this)
}
val blue = UIView().apply {
backgroundColor = Color(0x0000ff)
addView(this)
}
val purple = UIView().apply {
backgroundColor = Color(0x800080)
green.addSubview(this)
}
solver.dsl {
red.leftAnchor equalTo 0
red.widthAnchor equalTo 200
red.topAnchor equalTo 0
red.heightAnchor equalTo 100
green.leftAnchor equalTo (red.leftAnchor + red.widthAnchor + 20)
green.widthAnchor equalTo red.widthAnchor
green.topAnchor equalTo 0
green.heightAnchor equalTo (red.heightAnchor + 100)
blue.leftAnchor equalTo green.leftAnchor
blue.widthAnchor equalTo green.widthAnchor
blue.topAnchor equalTo (green.topAnchor + green.heightAnchor)
blue.heightAnchor equalTo 50
purple.widthAnchor equalTo 100
purple.heightAnchor equalTo 100
purple.centerXAnchor equalTo green.centerXAnchor
purple.centerYAnchor equalTo green.centerYAnchor
}
layout()
}
}