36 lines
544 B
Go
36 lines
544 B
Go
package models
|
|
|
|
import (
|
|
"encoding/gob"
|
|
"strings"
|
|
)
|
|
|
|
type WebTheme int
|
|
|
|
const (
|
|
DarkTheme WebTheme = iota
|
|
LightTheme
|
|
)
|
|
|
|
var webThemes = map[string]WebTheme{
|
|
"dark": DarkTheme,
|
|
"light": LightTheme,
|
|
}
|
|
|
|
func init() {
|
|
gob.Register(WebTheme(DarkTheme))
|
|
}
|
|
|
|
func WebThemeFromString(role string) WebTheme {
|
|
webTheme := webThemes[strings.ToLower(role)]
|
|
return webTheme // default -> 0 -> dark
|
|
}
|
|
|
|
func (theme WebTheme) IsDarkTheme() bool {
|
|
return theme == DarkTheme
|
|
}
|
|
|
|
func (theme WebTheme) IsLightTheme() bool {
|
|
return theme == LightTheme
|
|
}
|