Initial
This commit is contained in:
commit
9240e1dfea
7 changed files with 842 additions and 0 deletions
10
rex_client/Makefile
Normal file
10
rex_client/Makefile
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
NAME = rexclient
|
||||
|
||||
run:
|
||||
go run .
|
||||
|
||||
debug:
|
||||
go run -tags debug,hints .
|
||||
|
||||
build:
|
||||
go build -tags no_emoji -trimpath -ldflags="-s -w" -buildvcs=false -o $(NAME)
|
||||
1
rex_client/commit.txt
Normal file
1
rex_client/commit.txt
Normal file
|
|
@ -0,0 +1 @@
|
|||
HEAD
|
||||
98
rex_client/main.go
Normal file
98
rex_client/main.go
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"embed"
|
||||
"time"
|
||||
|
||||
"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 HEAD) > commit.txt"
|
||||
//go:embed commit.txt
|
||||
var Commit 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("RexForge")
|
||||
w.Resize(fyne.NewSize(900, 600))
|
||||
|
||||
myList := []MyStruct{
|
||||
{"File1"},
|
||||
{"File2"},
|
||||
{"File3"},
|
||||
}
|
||||
|
||||
enc, err := json.MarshalIndent(myList, "", " ")
|
||||
if err == nil {
|
||||
println(string(enc))
|
||||
}
|
||||
|
||||
listContainer := container.NewVBox()
|
||||
|
||||
for _, item := range myList {
|
||||
current := item
|
||||
namelabel := widget.NewLabel(current.Name)
|
||||
dlbutton := widget.NewButton("Download", func() {
|
||||
current.Download()
|
||||
})
|
||||
|
||||
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()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue