Created
September 29, 2021 13:35
-
-
Save bng86/04f79a6e36429488729f2bbe215c202b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sealed class WidgetType { | |
data class SlideBar(val min: Int, val max: Int, val step: Int) : WidgetType() | |
data class Radio(val items: List<RadioItem>) : WidgetType() | |
} | |
data class RadioItem( | |
val name: String, | |
val value: Int | |
) | |
enum class Widget(val widgetType: WidgetType) { | |
FOO(WidgetType.SlideBar(0, 9, 3)), | |
Bar(WidgetType.SlideBar(0, 100, 3)), | |
XXX(WidgetType.Radio( | |
listOf(RadioItem("aaa", 0), RadioItem("bbb", 1))) | |
) | |
} | |
fun main() { | |
val widgets = TODO() | |
val widgetType = Widget.FOO.widgetType | |
when (widgetType) { | |
is WidgetType.Radio -> { | |
widgetType.items | |
} | |
is WidgetType.SlideBar -> { | |
widgetType.min | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment