feat: define theme, might not need this but oh well
This commit is contained in:
15
main.go
15
main.go
@@ -4,19 +4,18 @@ import (
|
|||||||
"fyne.io/fyne/v2"
|
"fyne.io/fyne/v2"
|
||||||
"fyne.io/fyne/v2/app"
|
"fyne.io/fyne/v2/app"
|
||||||
"github.com/ryanehamil/computerinfo/src/computerinfo"
|
"github.com/ryanehamil/computerinfo/src/computerinfo"
|
||||||
|
"github.com/ryanehamil/computerinfo/src/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
a := app.New()
|
App := app.New()
|
||||||
|
App.Settings().SetTheme(&utils.Theme{})
|
||||||
|
|
||||||
// create fyne resource for icon.png
|
Window := App.NewWindow("Computer Info")
|
||||||
// a.SetIcon(resourceIconPng)
|
|
||||||
|
|
||||||
w := a.NewWindow("Computer Info")
|
Window.Resize(fyne.NewSize(800, 200))
|
||||||
|
|
||||||
w.Resize(fyne.NewSize(800, 200))
|
Window.SetContent(computerinfo.Container())
|
||||||
|
|
||||||
w.SetContent(computerinfo.Container())
|
Window.ShowAndRun()
|
||||||
|
|
||||||
w.ShowAndRun()
|
|
||||||
}
|
}
|
||||||
|
|||||||
59
src/utils/theme.go
Normal file
59
src/utils/theme.go
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
package utils
|
||||||
|
|
||||||
|
import (
|
||||||
|
"image/color"
|
||||||
|
|
||||||
|
"fyne.io/fyne/v2"
|
||||||
|
"fyne.io/fyne/v2/theme"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Theme struct{}
|
||||||
|
|
||||||
|
var _ fyne.Theme = (*Theme)(nil)
|
||||||
|
|
||||||
|
// The color package has to be imported from "image/color".
|
||||||
|
|
||||||
|
func (m Theme) Color(name fyne.ThemeColorName, variant fyne.ThemeVariant) color.Color {
|
||||||
|
if name == theme.ColorNameBackground {
|
||||||
|
if variant == theme.VariantLight {
|
||||||
|
// return color #eeeeee
|
||||||
|
return color.RGBA{238, 238, 238, 255}
|
||||||
|
}
|
||||||
|
// return color #222222
|
||||||
|
return color.RGBA{34, 34, 34, 255}
|
||||||
|
}
|
||||||
|
if name == theme.ColorNameForeground {
|
||||||
|
if variant == theme.VariantLight {
|
||||||
|
// return color #222222
|
||||||
|
return color.RGBA{34, 34, 34, 255}
|
||||||
|
}
|
||||||
|
// return color #eeeeee
|
||||||
|
return color.RGBA{238, 238, 238, 255}
|
||||||
|
}
|
||||||
|
if name == theme.ColorNameButton {
|
||||||
|
if variant == theme.VariantLight {
|
||||||
|
// return color #eeeeee
|
||||||
|
return color.RGBA{238, 238, 238, 255}
|
||||||
|
}
|
||||||
|
// return color #222222
|
||||||
|
return color.RGBA{34, 34, 34, 255}
|
||||||
|
}
|
||||||
|
|
||||||
|
return theme.DefaultTheme().Color(name, variant)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m Theme) Icon(name fyne.ThemeIconName) fyne.Resource {
|
||||||
|
// if name == theme.IconNameHome {
|
||||||
|
// return fyne.NewStaticResource("myHome", homeBytes)
|
||||||
|
// }
|
||||||
|
|
||||||
|
return theme.DefaultTheme().Icon(name)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m Theme) Font(style fyne.TextStyle) fyne.Resource {
|
||||||
|
return theme.DefaultTheme().Font(style)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m Theme) Size(name fyne.ThemeSizeName) float32 {
|
||||||
|
return theme.DefaultTheme().Size(name)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user