Skip to content

Commit

Permalink
Fix mute
Browse files Browse the repository at this point in the history
  • Loading branch information
alexballas committed May 9, 2024
1 parent 1698842 commit 8473950
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 69 deletions.
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/go2tv.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/gui/actions_mobile.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func muteAction(screen *NewScreen) {
return
}

if screen.MuteUnmute.Icon == theme.VolumeDownIcon() {
if screen.MuteUnmute.Icon == theme.VolumeMuteIcon() {
unmuteAction(screen)
return
}
Expand Down
2 changes: 1 addition & 1 deletion internal/gui/gui_mobile.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func (p *NewScreen) Fini() {
// InitFyneNewScreen .
func InitFyneNewScreen(v string) *NewScreen {
go2tv := app.NewWithID("com.alexballas.go2tv")
go2tv.Settings().SetTheme(theme.DarkTheme())
go2tv.Settings().SetTheme(go2tvTheme{"Dark"})

w := go2tv.NewWindow("Go2TV")

Expand Down
67 changes: 0 additions & 67 deletions internal/gui/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
package gui

import (
"image/color"
"sync"
"time"

"fyne.io/fyne/v2"
Expand All @@ -16,71 +14,6 @@ import (
"fyne.io/fyne/v2/widget"
)

type go2tvTheme struct {
Theme string
}

var (
_ fyne.Theme = go2tvTheme{}
SystemVariant fyne.ThemeVariant = 999
signalSystemVariantChange = make(chan struct{})
once sync.Once
)

func (m go2tvTheme) Color(name fyne.ThemeColorName, variant fyne.ThemeVariant) color.Color {
switch m.Theme {
case "GrabVariant":
once.Do(func() {
SystemVariant = variant
go func() {
signalSystemVariantChange <- struct{}{}
}()
})

case "Dark":
variant = theme.VariantDark
switch name {
case theme.ColorNameDisabled:
return color.NRGBA{R: 0x55, G: 0x55, B: 0x55, A: 0xff}
case theme.ColorNameBackground:
return color.NRGBA{R: 0x30, G: 0x30, B: 0x30, A: 0xff}
case theme.ColorNameButton:
return color.NRGBA{R: 0x44, G: 0x44, B: 0x44, A: 0xff}
case theme.ColorNameDisabledButton:
return color.NRGBA{R: 0x26, G: 0x26, B: 0x26, A: 0xff}
case theme.ColorNameOverlayBackground:
return color.NRGBA{R: 0x30, G: 0x30, B: 0x30, A: 0xff}
case theme.ColorNameMenuBackground:
return color.NRGBA{R: 0x30, G: 0x30, B: 0x30, A: 0xff}
}

case "Light":
variant = theme.VariantLight
switch name {
case theme.ColorNameDisabled:
return color.NRGBA{R: 0xab, G: 0xab, B: 0xab, A: 0xff}
case theme.ColorNameInputBorder:
return color.NRGBA{R: 0xf3, G: 0xf3, B: 0xf3, A: 0xff}
case theme.ColorNameDisabledButton:
return color.NRGBA{R: 0xe5, G: 0xe5, B: 0xe5, A: 0xff}
}
}
theme.InnerPadding()
return theme.DefaultTheme().Color(name, variant)
}

func (m go2tvTheme) Icon(name fyne.ThemeIconName) fyne.Resource {
return theme.DefaultTheme().Icon(name)
}

func (m go2tvTheme) Font(style fyne.TextStyle) fyne.Resource {
return theme.DefaultTheme().Font(style)
}

func (m go2tvTheme) Size(name fyne.ThemeSizeName) float32 {
return theme.DefaultTheme().Size(name)
}

func settingsWindow(s *NewScreen) fyne.CanvasObject {
w := s.Current

Expand Down
74 changes: 74 additions & 0 deletions internal/gui/theme.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package gui

import (
"image/color"
"sync"

"fyne.io/fyne/v2"
"fyne.io/fyne/v2/theme"
)

type go2tvTheme struct {
Theme string
}

var (
_ fyne.Theme = go2tvTheme{}
SystemVariant fyne.ThemeVariant = 999
signalSystemVariantChange = make(chan struct{})
once sync.Once
)

func (m go2tvTheme) Color(name fyne.ThemeColorName, variant fyne.ThemeVariant) color.Color {
switch m.Theme {
case "GrabVariant":
once.Do(func() {
SystemVariant = variant
go func() {
signalSystemVariantChange <- struct{}{}
}()
})

case "Dark":
variant = theme.VariantDark
switch name {
case theme.ColorNameDisabled:
return color.NRGBA{R: 0x55, G: 0x55, B: 0x55, A: 0xff}
case theme.ColorNameBackground:
return color.NRGBA{R: 0x30, G: 0x30, B: 0x30, A: 0xff}
case theme.ColorNameButton:
return color.NRGBA{R: 0x44, G: 0x44, B: 0x44, A: 0xff}
case theme.ColorNameDisabledButton:
return color.NRGBA{R: 0x26, G: 0x26, B: 0x26, A: 0xff}
case theme.ColorNameOverlayBackground:
return color.NRGBA{R: 0x30, G: 0x30, B: 0x30, A: 0xff}
case theme.ColorNameMenuBackground:
return color.NRGBA{R: 0x30, G: 0x30, B: 0x30, A: 0xff}
}

case "Light":
variant = theme.VariantLight
switch name {
case theme.ColorNameDisabled:
return color.NRGBA{R: 0xab, G: 0xab, B: 0xab, A: 0xff}
case theme.ColorNameInputBorder:
return color.NRGBA{R: 0xf3, G: 0xf3, B: 0xf3, A: 0xff}
case theme.ColorNameDisabledButton:
return color.NRGBA{R: 0xe5, G: 0xe5, B: 0xe5, A: 0xff}
}
}
theme.InnerPadding()
return theme.DefaultTheme().Color(name, variant)
}

func (m go2tvTheme) Icon(name fyne.ThemeIconName) fyne.Resource {
return theme.DefaultTheme().Icon(name)
}

func (m go2tvTheme) Font(style fyne.TextStyle) fyne.Resource {
return theme.DefaultTheme().Font(style)
}

func (m go2tvTheme) Size(name fyne.ThemeSizeName) float32 {
return theme.DefaultTheme().Size(name)
}

0 comments on commit 8473950

Please sign in to comment.