93 lines
1.9 KiB
Go
93 lines
1.9 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
_ "embed"
|
|
|
|
"fyne.io/fyne/v2"
|
|
"fyne.io/fyne/v2/app"
|
|
"fyne.io/fyne/v2/container"
|
|
"fyne.io/fyne/v2/layout"
|
|
"fyne.io/fyne/v2/widget"
|
|
)
|
|
|
|
func updateTime(clock *widget.Label) {
|
|
formatted := time.Now().Format("Time: 03:04:05")
|
|
clock.SetText(formatted)
|
|
}
|
|
|
|
// Define your custom struct
|
|
type MyStruct struct {
|
|
Name string
|
|
}
|
|
|
|
//go:generate sh -c "printf %s $(git rev-parse --short HEAD) > commit.txt"
|
|
//go:embed commit.txt
|
|
var git_rev string
|
|
|
|
// Download method for the struct
|
|
func (s *MyStruct) Download() {
|
|
fmt.Printf("Downloading %s...\n", s.Name)
|
|
}
|
|
|
|
func main() {
|
|
clock := widget.NewLabel("")
|
|
formatted := time.Now().Format("Time: 03:04:05")
|
|
clock.SetText(formatted)
|
|
|
|
a := app.New()
|
|
w := a.NewWindow(fmt.Sprintf("RexForge %s", git_rev))
|
|
w.Resize(fyne.NewSize(900, 600))
|
|
|
|
myList := []MyStruct{
|
|
{"AtlasLoot"},
|
|
{"Bartender4"},
|
|
{"Deadly Boss Mods"},
|
|
}
|
|
|
|
listContainer := container.NewVBox()
|
|
|
|
for _, item := range myList {
|
|
current := item
|
|
namelabel := widget.NewLabel(current.Name)
|
|
dlbutton := widget.NewButton("Download", func() {
|
|
current.Download()
|
|
})
|
|
dlbutton.Importance = widget.LowImportance
|
|
|
|
spacer := layout.NewSpacer()
|
|
ct := container.NewHBox(namelabel, spacer, dlbutton)
|
|
listContainer.Add(ct)
|
|
}
|
|
|
|
go func() {
|
|
for range time.Tick(time.Second) {
|
|
updateTime(clock)
|
|
}
|
|
}()
|
|
|
|
refresh_button := widget.NewButton("Refresh", func() {
|
|
println("Refresh")
|
|
})
|
|
|
|
upall_button := widget.NewButton("Update All", func() {
|
|
println("Update All")
|
|
})
|
|
|
|
about_button := widget.NewButton("About", func() {
|
|
println("About")
|
|
})
|
|
|
|
settings_button := widget.NewButton("Settings", func() {
|
|
println("Settings")
|
|
})
|
|
|
|
toprow := container.NewHBox(refresh_button, upall_button, clock, layout.NewSpacer(), about_button, settings_button)
|
|
|
|
c := container.New(layout.NewVBoxLayout(), toprow, widget.NewSeparator(), listContainer)
|
|
|
|
w.SetContent(c)
|
|
|
|
w.ShowAndRun()
|
|
}
|