more light theme work: themed icon button, colors adj
This commit is contained in:
+65
-22
@@ -14,16 +14,6 @@ import (
|
||||
|
||||
const ColorNamePageBackground fyne.ThemeColorName = "PageBackground"
|
||||
|
||||
var (
|
||||
normalFont fyne.Resource
|
||||
boldFont fyne.Resource
|
||||
)
|
||||
|
||||
type MyTheme struct {
|
||||
NormalFont string
|
||||
BoldFont string
|
||||
}
|
||||
|
||||
const (
|
||||
IconNameNowPlaying fyne.ThemeIconName = "NowPlaying"
|
||||
IconNameFavorite fyne.ThemeIconName = "Favorite"
|
||||
@@ -35,20 +25,40 @@ const (
|
||||
IconNameShuffle fyne.ThemeIconName = "Shuffle"
|
||||
)
|
||||
|
||||
type VariantMode int
|
||||
|
||||
const (
|
||||
VariantModeAuto VariantMode = iota
|
||||
VariantModeDark
|
||||
VariantModeLight
|
||||
)
|
||||
|
||||
var (
|
||||
normalFont fyne.Resource
|
||||
boldFont fyne.Resource
|
||||
)
|
||||
|
||||
type MyTheme struct {
|
||||
NormalFont string
|
||||
BoldFont string
|
||||
VariantMode VariantMode
|
||||
}
|
||||
|
||||
var _ fyne.Theme = (*MyTheme)(nil)
|
||||
|
||||
func (m *MyTheme) Color(name fyne.ThemeColorName, variant fyne.ThemeVariant) color.Color {
|
||||
func (m *MyTheme) Color(name fyne.ThemeColorName, _ fyne.ThemeVariant) color.Color {
|
||||
variant := m.getVariant()
|
||||
switch name {
|
||||
case ColorNamePageBackground:
|
||||
if variant == theme.VariantDark {
|
||||
return color.RGBA{R: 15, G: 15, B: 15, A: 255}
|
||||
}
|
||||
return color.RGBA{R: 255, G: 255, B: 255, A: 255}
|
||||
return color.RGBA{R: 250, G: 250, B: 250, A: 255}
|
||||
case theme.ColorNameBackground:
|
||||
if variant == theme.VariantDark {
|
||||
return color.RGBA{R: 35, G: 35, B: 35, A: 255}
|
||||
}
|
||||
return color.RGBA{R: 240, G: 240, B: 240, A: 255}
|
||||
return color.RGBA{R: 225, G: 225, B: 225, A: 255}
|
||||
case theme.ColorNameScrollBar:
|
||||
if variant == theme.VariantDark {
|
||||
return theme.DarkTheme().Color(theme.ColorNameForeground, variant)
|
||||
@@ -76,23 +86,48 @@ func (m *MyTheme) Color(name fyne.ThemeColorName, variant fyne.ThemeVariant) col
|
||||
}
|
||||
|
||||
func (m *MyTheme) Icon(name fyne.ThemeIconName) fyne.Resource {
|
||||
variant := m.getVariant()
|
||||
switch name {
|
||||
case IconNameAlbum:
|
||||
return res.ResDiscInvertPng
|
||||
if variant == theme.VariantDark {
|
||||
return res.ResDiscInvertPng
|
||||
}
|
||||
return res.ResDiscPng
|
||||
case IconNameArtist:
|
||||
return res.ResPeopleInvertPng
|
||||
if variant == theme.VariantDark {
|
||||
return res.ResPeopleInvertPng
|
||||
}
|
||||
return res.ResPeoplePng
|
||||
case IconNameFavorite:
|
||||
return res.ResHeartFilledInvertPng
|
||||
if variant == theme.VariantDark {
|
||||
return res.ResHeartFilledInvertPng
|
||||
}
|
||||
return res.ResHeartFilledPng
|
||||
case IconNameNotFavorite:
|
||||
return res.ResHeartOutlineInvertPng
|
||||
if variant == theme.VariantDark {
|
||||
return res.ResHeartOutlineInvertPng
|
||||
}
|
||||
return res.ResHeartOutlinePng
|
||||
case IconNameGenre:
|
||||
return res.ResTheatermasksInvertPng
|
||||
if variant == theme.VariantDark {
|
||||
return res.ResTheatermasksInvertPng
|
||||
}
|
||||
return res.ResTheatermasksPng
|
||||
case IconNameNowPlaying:
|
||||
return res.ResHeadphonesInvertPng
|
||||
if variant == theme.VariantDark {
|
||||
return res.ResHeadphonesInvertPng
|
||||
}
|
||||
return res.ResHeadphonesPng
|
||||
case IconNamePlaylist:
|
||||
return res.ResPlaylistInvertPng
|
||||
if variant == theme.VariantDark {
|
||||
return res.ResPlaylistInvertPng
|
||||
}
|
||||
return res.ResPlaylistPng
|
||||
case IconNameShuffle:
|
||||
return res.ResShuffleInvertSvg
|
||||
if variant == theme.VariantDark {
|
||||
return res.ResShuffleInvertSvg
|
||||
}
|
||||
return res.ResShuffleSvg
|
||||
default:
|
||||
return theme.DefaultTheme().Icon(name)
|
||||
}
|
||||
@@ -127,7 +162,6 @@ func (m *MyTheme) Font(style fyne.TextStyle) fyne.Resource {
|
||||
return normalFont
|
||||
}
|
||||
}
|
||||
|
||||
return theme.DefaultTheme().Font(style)
|
||||
}
|
||||
|
||||
@@ -135,6 +169,15 @@ func (m *MyTheme) Size(name fyne.ThemeSizeName) float32 {
|
||||
return theme.DefaultTheme().Size(name)
|
||||
}
|
||||
|
||||
func (m *MyTheme) getVariant() fyne.ThemeVariant {
|
||||
if m.VariantMode == VariantModeDark {
|
||||
return theme.VariantDark
|
||||
} else if m.VariantMode == VariantModeLight {
|
||||
return theme.VariantLight
|
||||
}
|
||||
return fyne.CurrentApp().Settings().ThemeVariant()
|
||||
}
|
||||
|
||||
func readTTFFile(filepath string) ([]byte, error) {
|
||||
if !strings.HasSuffix(filepath, ".ttf") {
|
||||
err := errors.New("only .ttf fonts are supported")
|
||||
|
||||
Reference in New Issue
Block a user