我有三个主题。主题更改工作正常,但是当我转到其他子站点时,主题设置恢复为默认设置。我需要记住其他子站点的主题吗?是否需要其他班级的相关知识,或者只是想念一些东西?
CustomTheme.kt
enum class CustomTheme(val themeName: String)
{
MATERIAL_DARK("material-dark"),
MATERIAL_LIGHT("material-light"),
MY_THEME("mytheme")
}
ThemeSelectorComboBox.kt
private const val SELECT_THEME = "Select theme:"
class ThemeSelectorComboBox : CustomComponent()
{
private val comboBox = ComboBox<CustomTheme>()
init
{
init()
}
private fun init()
{
comboBox.caption = SELECT_THEME
comboBox.setItems(*CustomTheme.values())
comboBox.setSelectedItem(CustomTheme.MATERIAL_DARK)
comboBox.addValueChangeListener { event -> flipTheme(event.value) }
compositionRoot = comboBox
comboBox.setSizeUndefined()
setSizeUndefined()
}
private fun flipTheme(theme: CustomTheme?)
{
if (theme != null)
{
compositionRoot.ui.theme = theme.themeName
}
}
}