mirror of https://github.com/qwc/backive.git
Do not write code tired as hell...
This commit is contained in:
parent
01d7e36a3d
commit
2c14479f6e
|
@ -1,6 +1,8 @@
|
||||||
package ui
|
package ui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"fyne.io/fyne/v2"
|
"fyne.io/fyne/v2"
|
||||||
"fyne.io/fyne/v2/container"
|
"fyne.io/fyne/v2/container"
|
||||||
"fyne.io/fyne/v2/layout"
|
"fyne.io/fyne/v2/layout"
|
||||||
|
@ -16,6 +18,7 @@ var (
|
||||||
|
|
||||||
accord *widget.Accordion
|
accord *widget.Accordion
|
||||||
center *fyne.Container
|
center *fyne.Container
|
||||||
|
content *fyne.Container
|
||||||
devBtnList []*widget.Button
|
devBtnList []*widget.Button
|
||||||
bacBtnList []*widget.Button
|
bacBtnList []*widget.Button
|
||||||
)
|
)
|
||||||
|
@ -29,6 +32,7 @@ func Init(a fyne.App, w fyne.Window, c backive.Configuration, d backive.Database
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetupLayout() {
|
func SetupLayout() {
|
||||||
|
fmt.Print("Setting up layout\n")
|
||||||
accord = widget.NewAccordion()
|
accord = widget.NewAccordion()
|
||||||
devBtnList := []*widget.Button{}
|
devBtnList := []*widget.Button{}
|
||||||
devLayout := container.NewVBox()
|
devLayout := container.NewVBox()
|
||||||
|
@ -37,36 +41,44 @@ func SetupLayout() {
|
||||||
devBtnList = append(devBtnList, btn)
|
devBtnList = append(devBtnList, btn)
|
||||||
devLayout.Add(btn)
|
devLayout.Add(btn)
|
||||||
}
|
}
|
||||||
|
for _, obj := range devBtnList {
|
||||||
|
dev := obj.Text
|
||||||
|
fmt.Printf("Setting OnTapped on %s\n", dev)
|
||||||
|
obj.OnTapped = func() {
|
||||||
|
fmt.Printf("Btn %s\n", dev)
|
||||||
|
DisplayDevice(dev)
|
||||||
|
}
|
||||||
|
}
|
||||||
devices := widget.NewAccordionItem("Devices", devLayout)
|
devices := widget.NewAccordionItem("Devices", devLayout)
|
||||||
accord.Append(devices)
|
accord.Append(devices)
|
||||||
bacBtnList := []*widget.Button{}
|
bacBtnList := []*widget.Button{}
|
||||||
bacLayout := container.NewVBox()
|
bacLayout := container.NewVBox()
|
||||||
for _, obj := range config.Backups {
|
for _, obj := range config.Backups {
|
||||||
btn := widget.NewButton(obj.Name, nil)
|
bkp := obj.Name
|
||||||
|
btn := widget.NewButton(
|
||||||
|
bkp, func() {
|
||||||
|
DisplayBackup(bkp)
|
||||||
|
})
|
||||||
bacBtnList = append(bacBtnList, btn)
|
bacBtnList = append(bacBtnList, btn)
|
||||||
bacLayout.Add(btn)
|
bacLayout.Add(btn)
|
||||||
}
|
}
|
||||||
backups := widget.NewAccordionItem("Backups", bacLayout)
|
backups := widget.NewAccordionItem("Backups", bacLayout)
|
||||||
accord.Append(backups)
|
accord.Append(backups)
|
||||||
center := container.NewMax()
|
center = container.NewMax()
|
||||||
left := container.NewMax()
|
left := container.NewMax()
|
||||||
left.Add(accord)
|
left.Add(accord)
|
||||||
window.Resize(fyne.NewSize(800, 600))
|
window.Resize(fyne.NewSize(800, 600))
|
||||||
content := container.New(layout.NewBorderLayout(nil, nil, left, nil), left, center)
|
content = container.NewBorder(nil, nil, left, nil, center)
|
||||||
window.SetContent(content)
|
window.SetContent(content)
|
||||||
|
|
||||||
// setup btns
|
|
||||||
for _, obj := range devBtnList {
|
|
||||||
obj.OnTapped = func() {
|
|
||||||
DisplayDevice(obj.Text)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func ClearCenter() {
|
func ClearCenter() {
|
||||||
if len(center.Objects) > 0 {
|
fmt.Print("ClearCenter\n")
|
||||||
center.Objects = []fyne.CanvasObject{}
|
if center != nil && center.Objects != nil && len(center.Objects) > 0 {
|
||||||
|
center.Objects = nil
|
||||||
|
center.Refresh()
|
||||||
}
|
}
|
||||||
|
content.Refresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
func DisplayDevice(dev string) {
|
func DisplayDevice(dev string) {
|
||||||
|
@ -81,6 +93,8 @@ func DisplayDevice(dev string) {
|
||||||
dataForm.Add(widget.NewLabel(device.UUID))
|
dataForm.Add(widget.NewLabel(device.UUID))
|
||||||
dataForm.Add(widget.NewLabel("Owner"))
|
dataForm.Add(widget.NewLabel("Owner"))
|
||||||
dataForm.Add(widget.NewLabel(device.OwnerUser))
|
dataForm.Add(widget.NewLabel(device.OwnerUser))
|
||||||
|
fmt.Printf("Adding device %s\n", dev)
|
||||||
|
center.Add(vbox)
|
||||||
}
|
}
|
||||||
|
|
||||||
func DisplayBackup(bac string) {
|
func DisplayBackup(bac string) {
|
||||||
|
|
Loading…
Reference in New Issue