From c17f2d202b9e1ece40b558feab8f753bde28304c Mon Sep 17 00:00:00 2001 From: Imbus <> Date: Sun, 26 Jan 2025 08:50:21 +0100 Subject: [PATCH] List layout, button icons, more sample data --- rex_client/main.go | 91 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 67 insertions(+), 24 deletions(-) diff --git a/rex_client/main.go b/rex_client/main.go index 2b06fb5..a7815c0 100644 --- a/rex_client/main.go +++ b/rex_client/main.go @@ -1,14 +1,15 @@ package main import ( + _ "embed" "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/theme" "fyne.io/fyne/v2/widget" ) @@ -31,6 +32,39 @@ func (s *MyStruct) Download() { fmt.Printf("Downloading %s...\n", s.Name) } +var myList = []MyStruct{ + {"AtlasLoot"}, + {"Bartender4"}, + {"Deadly Boss Mods"}, + {"Details! Damage Meter"}, + {"WeakAuras"}, + {"ElvUI"}, + {"BigWigs"}, + {"Recount"}, + {"GatherMate2"}, + {"TomTom"}, + {"Questie"}, + {"TradeSkillMaster"}, + {"HandyNotes"}, + {"Bagnon"}, + {"Threat Plates"}, + {"GTFO"}, + {"Plater Nameplates"}, + {"Rarity"}, + {"Pawn"}, + {"Auctioneer"}, + {"Shadowed Unit Frames"}, + {"SexyMap"}, + {"TidyPlates"}, + {"MoveAnything"}, + {"Postal"}, + {"OmniCC"}, + {"Leatrix Plus"}, + {"SimulationCraft"}, + {"VuhDo"}, + {"KuiNameplates"}, +} + func main() { clock := widget.NewLabel("") formatted := time.Now().Format("Time: 03:04:05") @@ -40,26 +74,29 @@ func main() { w := a.NewWindow(fmt.Sprintf("RexForge %s", git_rev)) w.Resize(fyne.NewSize(900, 600)) - myList := []MyStruct{ - {"AtlasLoot"}, - {"Bartender4"}, - {"Deadly Boss Mods"}, - } + list := widget.NewList( + func() int { + return len(myList) + }, + func() fyne.CanvasObject { + btn := widget.NewButton("", func() {}) + label := widget.NewLabel("") - listContainer := container.NewVBox() + return container.NewBorder(nil, nil, label, btn) + }, + func(i widget.ListItemID, o fyne.CanvasObject) { + o.(*fyne.Container).RemoveAll() - for _, item := range myList { - current := item - namelabel := widget.NewLabel(current.Name) - dlbutton := widget.NewButton("Download", func() { - current.Download() + btn := widget.NewButtonWithIcon("Download", theme.DownloadIcon(), func() { + myList[i].Download() + }) + btn.Importance = widget.LowImportance + + label := widget.NewLabel(myList[i].Name) + + row := container.NewBorder(nil, nil, label, btn) + o.(*fyne.Container).Add(row) }) - dlbutton.Importance = widget.LowImportance - - spacer := layout.NewSpacer() - ct := container.NewHBox(namelabel, spacer, dlbutton) - listContainer.Add(ct) - } go func() { for range time.Tick(time.Second) { @@ -67,25 +104,31 @@ func main() { } }() - refresh_button := widget.NewButton("Refresh", func() { + refresh_button := widget.NewButtonWithIcon("Refresh", theme.ViewRefreshIcon(), func() { println("Refresh") }) - upall_button := widget.NewButton("Update All", func() { + upall_button := widget.NewButtonWithIcon("Update All", theme.DownloadIcon(), func() { println("Update All") }) - about_button := widget.NewButton("About", func() { + about_button := widget.NewButtonWithIcon("About", theme.InfoIcon(), func() { println("About") }) - settings_button := widget.NewButton("Settings", func() { + settings_button := widget.NewButtonWithIcon("Settings", theme.SettingsIcon(), func() { println("Settings") }) - toprow := container.NewHBox(refresh_button, upall_button, clock, layout.NewSpacer(), about_button, settings_button) + toprow := container.NewVBox(container.NewHBox(refresh_button, upall_button, + clock, layout.NewSpacer(), about_button, settings_button), + widget.NewSeparator()) - c := container.New(layout.NewVBoxLayout(), toprow, widget.NewSeparator(), listContainer) + c := container.New( + layout.NewBorderLayout(toprow, nil, nil, nil), + toprow, + container.NewStack(list), + ) w.SetContent(c)