-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
46 lines (38 loc) · 1.35 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package main
import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget"
"github.com/Jacalz/hegelmote/device"
"github.com/Jacalz/hegelmote/remote"
)
func buildUI(command *remote.Control) fyne.CanvasObject {
power := &widget.Button{Text: "Toggle Power", OnTapped: func() { command.TogglePower() }}
volumeMute := &widget.Button{Icon: theme.VolumeMuteIcon(), OnTapped: func() { command.ToggleVolumeMute() }}
volumeUp := &widget.Button{Icon: theme.VolumeUpIcon(), OnTapped: func() { command.VolumeUp() }}
volumeDown := &widget.Button{Icon: theme.VolumeDownIcon(), OnTapped: func() { command.VolumeDown() }}
deviceType := device.H95
inputs, _ := device.GetInputNames(deviceType)
inputSelector := &widget.Select{Options: inputs, PlaceHolder: "Select input to use", OnChanged: func(input string) { command.SetSourceName(deviceType, input) }}
return container.NewVBox(
power,
container.NewGridWithColumns(3, volumeMute, volumeDown, volumeUp),
inputSelector,
)
}
func main() {
a := app.NewWithID("io.github.jacalz.hegelmote")
w := a.NewWindow("Hegelmote")
command := &remote.Control{}
defer command.Disconnect()
err := command.Connect("192.168.1.251:50001")
if err != nil {
panic(err)
}
w.SetContent(buildUI(command))
w.Resize(fyne.NewSize(300, 400))
w.SetMaster()
w.ShowAndRun()
}