diff --git a/main.go b/main.go index e206a43..6608ce4 100644 --- a/main.go +++ b/main.go @@ -4,19 +4,18 @@ import ( "fyne.io/fyne/v2" "fyne.io/fyne/v2/app" "github.com/ryanehamil/computerinfo/src/computerinfo" + "github.com/ryanehamil/computerinfo/src/utils" ) func main() { - a := app.New() + App := app.New() + App.Settings().SetTheme(&utils.Theme{}) - // create fyne resource for icon.png - // a.SetIcon(resourceIconPng) + Window := App.NewWindow("Computer Info") - 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()) - - w.ShowAndRun() + Window.ShowAndRun() } diff --git a/src/utils/theme.go b/src/utils/theme.go new file mode 100644 index 0000000..65ea087 --- /dev/null +++ b/src/utils/theme.go @@ -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) +}