some tweaks to ui theming for Fyne 2.3
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"path"
|
||||
"supersonic/backend"
|
||||
"supersonic/ui"
|
||||
"supersonic/ui/theme"
|
||||
"time"
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
@@ -28,7 +29,7 @@ func main() {
|
||||
}
|
||||
|
||||
fyneApp := app.New()
|
||||
fyneApp.Settings().SetTheme(&ui.MyTheme{})
|
||||
fyneApp.Settings().SetTheme(&theme.MyTheme{})
|
||||
w := float32(myApp.Config.Application.WindowWidth)
|
||||
if w <= 1 {
|
||||
w = 1000
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package browsing
|
||||
|
||||
import (
|
||||
"image/color"
|
||||
"supersonic/backend"
|
||||
"supersonic/ui/controller"
|
||||
"supersonic/ui/layouts"
|
||||
myTheme "supersonic/ui/theme"
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/canvas"
|
||||
@@ -69,7 +69,9 @@ func NewBrowsingPane(app *backend.App) *BrowsingPane {
|
||||
b.app.PlaybackManager.OnSongChange(b.onSongChange)
|
||||
b.pageContainer = container.NewMax(
|
||||
// TODO: get this color into the theme
|
||||
canvas.NewRectangle(color.RGBA{R: 24, G: 24, B: 40, A: 255}),
|
||||
canvas.NewRectangle(fyne.CurrentApp().Settings().Theme().Color(
|
||||
myTheme.ColorNamePageBackground, theme.VariantDark,
|
||||
)),
|
||||
layout.NewSpacer())
|
||||
b.settingsBtn = widget.NewButtonWithIcon("", theme.SettingsIcon(), func() {
|
||||
p := widget.NewPopUpMenu(b.settingsMenu,
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package theme
|
||||
|
||||
import (
|
||||
"image/color"
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/theme"
|
||||
)
|
||||
|
||||
const ColorNamePageBackground fyne.ThemeColorName = "PageBackground"
|
||||
|
||||
type MyTheme struct{}
|
||||
|
||||
var _ fyne.Theme = (*MyTheme)(nil)
|
||||
|
||||
func (m MyTheme) Color(name fyne.ThemeColorName, variant fyne.ThemeVariant) color.Color {
|
||||
switch name {
|
||||
case ColorNamePageBackground:
|
||||
return color.RGBA{R: 20, G: 20, B: 20, A: 255}
|
||||
case theme.ColorNameBackground:
|
||||
return color.RGBA{R: 40, G: 40, B: 40, A: 255}
|
||||
case theme.ColorNameScrollBar:
|
||||
return theme.DarkTheme().Color(theme.ColorNameForeground, variant)
|
||||
case theme.ColorNameButton:
|
||||
return theme.DarkTheme().Color(theme.ColorNameInputBackground, variant)
|
||||
}
|
||||
return theme.DarkTheme().Color(name, variant)
|
||||
}
|
||||
|
||||
func (m MyTheme) Icon(name fyne.ThemeIconName) fyne.Resource {
|
||||
return theme.DefaultTheme().Icon(name)
|
||||
}
|
||||
|
||||
func (m MyTheme) Font(style fyne.TextStyle) fyne.Resource {
|
||||
return theme.DefaultTheme().Font(style)
|
||||
}
|
||||
|
||||
func (m MyTheme) Size(name fyne.ThemeSizeName) float32 {
|
||||
return theme.DefaultTheme().Size(name)
|
||||
}
|
||||
@@ -42,7 +42,7 @@ func NewListHeader(cols []ListColumn, layout *layouts.ColumnsLayout) *ListHeader
|
||||
for i, _ := range l.columnVisible {
|
||||
l.columnVisible[i] = true
|
||||
}
|
||||
l.container = container.NewMax(canvas.NewRectangle(theme.ButtonColor()), l.columnsContainer)
|
||||
l.container = container.NewMax(canvas.NewRectangle(theme.BackgroundColor()), l.columnsContainer)
|
||||
l.ExtendBaseWidget(l)
|
||||
l.buildColumns()
|
||||
return l
|
||||
|
||||
@@ -36,7 +36,7 @@ func NewNowPlayingCard() *NowPlayingCard {
|
||||
n.cover.SetMinSize(fyne.NewSize(85, 85))
|
||||
n.cover.FillMode = canvas.ImageFillContain
|
||||
|
||||
n.c = container.NewBorder(nil, nil, container.New(&layouts.CenterPadLayout{PadLeftRight: 3, PadTopBottom: 5}, n.cover), nil,
|
||||
n.c = container.NewBorder(nil, nil, n.cover, nil,
|
||||
container.New(&layouts.VboxCustomPadding{ExtraPad: -12}, n.trackName, n.artistName, n.albumName))
|
||||
return n
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user