List layout, button icons, more sample data
This commit is contained in:
parent
5ace5f0c97
commit
c17f2d202b
1 changed files with 67 additions and 24 deletions
|
@ -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()
|
||||
})
|
||||
dlbutton.Importance = widget.LowImportance
|
||||
btn.Importance = widget.LowImportance
|
||||
|
||||
spacer := layout.NewSpacer()
|
||||
ct := container.NewHBox(namelabel, spacer, dlbutton)
|
||||
listContainer.Add(ct)
|
||||
}
|
||||
label := widget.NewLabel(myList[i].Name)
|
||||
|
||||
row := container.NewBorder(nil, nil, label, btn)
|
||||
o.(*fyne.Container).Add(row)
|
||||
})
|
||||
|
||||
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)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue