mirror of https://github.com/qwc/backive.git
filling ui, stuck at removing center content dynamically
This commit is contained in:
parent
a738650ca1
commit
01d7e36a3d
|
@ -16,6 +16,8 @@ var (
|
||||||
|
|
||||||
accord *widget.Accordion
|
accord *widget.Accordion
|
||||||
center *fyne.Container
|
center *fyne.Container
|
||||||
|
devBtnList []*widget.Button
|
||||||
|
bacBtnList []*widget.Button
|
||||||
)
|
)
|
||||||
|
|
||||||
func Init(a fyne.App, w fyne.Window, c backive.Configuration, d backive.Database) {
|
func Init(a fyne.App, w fyne.Window, c backive.Configuration, d backive.Database) {
|
||||||
|
@ -28,7 +30,59 @@ func Init(a fyne.App, w fyne.Window, c backive.Configuration, d backive.Database
|
||||||
|
|
||||||
func SetupLayout() {
|
func SetupLayout() {
|
||||||
accord = widget.NewAccordion()
|
accord = widget.NewAccordion()
|
||||||
|
devBtnList := []*widget.Button{}
|
||||||
|
devLayout := container.NewVBox()
|
||||||
|
for _, obj := range config.Devices {
|
||||||
|
btn := widget.NewButton(obj.Name, nil)
|
||||||
|
devBtnList = append(devBtnList, btn)
|
||||||
|
devLayout.Add(btn)
|
||||||
|
}
|
||||||
|
devices := widget.NewAccordionItem("Devices", devLayout)
|
||||||
|
accord.Append(devices)
|
||||||
|
bacBtnList := []*widget.Button{}
|
||||||
|
bacLayout := container.NewVBox()
|
||||||
|
for _, obj := range config.Backups {
|
||||||
|
btn := widget.NewButton(obj.Name, nil)
|
||||||
|
bacBtnList = append(bacBtnList, btn)
|
||||||
|
bacLayout.Add(btn)
|
||||||
|
}
|
||||||
|
backups := widget.NewAccordionItem("Backups", bacLayout)
|
||||||
|
accord.Append(backups)
|
||||||
center := container.NewMax()
|
center := container.NewMax()
|
||||||
content := container.New(layout.NewBorderLayout(nil, nil, accord, nil), accord, center)
|
left := container.NewMax()
|
||||||
|
left.Add(accord)
|
||||||
|
window.Resize(fyne.NewSize(800, 600))
|
||||||
|
content := container.New(layout.NewBorderLayout(nil, nil, left, nil), left, center)
|
||||||
window.SetContent(content)
|
window.SetContent(content)
|
||||||
|
|
||||||
|
// setup btns
|
||||||
|
for _, obj := range devBtnList {
|
||||||
|
obj.OnTapped = func() {
|
||||||
|
DisplayDevice(obj.Text)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func ClearCenter() {
|
||||||
|
if len(center.Objects) > 0 {
|
||||||
|
center.Objects = []fyne.CanvasObject{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func DisplayDevice(dev string) {
|
||||||
|
ClearCenter()
|
||||||
|
vbox := container.NewVBox()
|
||||||
|
dataForm := container.New(layout.NewFormLayout())
|
||||||
|
vbox.Add(dataForm)
|
||||||
|
device := config.Devices[dev]
|
||||||
|
dataForm.Add(widget.NewLabel("Name"))
|
||||||
|
dataForm.Add(widget.NewLabel(device.Name))
|
||||||
|
dataForm.Add(widget.NewLabel("UUID"))
|
||||||
|
dataForm.Add(widget.NewLabel(device.UUID))
|
||||||
|
dataForm.Add(widget.NewLabel("Owner"))
|
||||||
|
dataForm.Add(widget.NewLabel(device.OwnerUser))
|
||||||
|
}
|
||||||
|
|
||||||
|
func DisplayBackup(bac string) {
|
||||||
|
ClearCenter()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue