diff options
-rw-r--r-- | main.go | 16 |
1 files changed, 7 insertions, 9 deletions
@@ -44,7 +44,6 @@ type State struct { Title string UrlSelector widget.Enum PlayPauseButton widget.Clickable - PlayPauseButtonText string PlayerContext context.Context PlayerCancel context.CancelFunc } @@ -67,7 +66,6 @@ func NewUi(config Config) *Ui { ui.Window.Option(app.Title("soundbox")) ui.State.Title = "soundbox" - ui.State.PlayPauseButtonText = "Play" return &ui } @@ -134,7 +132,13 @@ func (ui *Ui) Layout(gtx layout.Context) layout.Dimensions { h1.Color = color.NRGBA{R: 88, G: 88, B: 88, A: 255} h1.Alignment = text.Middle - button := material.Button(ui.State.Theme, &ui.State.PlayPauseButton, ui.State.PlayPauseButtonText) + var playPauseButtonText string + if ui.State.IsPlaying { + playPauseButtonText = "Stop" + } else { + playPauseButtonText = "Play" + } + button := material.Button(ui.State.Theme, &ui.State.PlayPauseButton, playPauseButtonText) entries := []layout.FlexChild{ layout.Rigid(h1.Layout), @@ -160,13 +164,7 @@ func play(ctx context.Context, url string, targets []net.HardwareAddr, ui *Ui) { ui.State.Lock() defer ui.Window.Invalidate() defer ui.State.Unlock() - ui.State.IsPlaying = isPlaying - if ui.State.IsPlaying { - ui.State.PlayPauseButtonText = "Stop" - } else { - ui.State.PlayPauseButtonText = "Play" - } } setPlayingState(true) |