Files
cloudsave/cmd/gui/window/sync/sync.go
Aurélie DELHAIE f56d3c5857
Some checks failed
CloudSave/pipeline/head There was a failure building this commit
wip
2025-09-08 01:21:53 +02:00

48 lines
938 B
Go

package sync
import (
"image/color"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/dialog"
"fyne.io/fyne/v2/layout"
"fyne.io/fyne/v2/widget"
)
type (
SyncDialog struct {
*dialog.CustomDialog
label *canvas.Text
pg *widget.ProgressBar
}
)
func Make(total int, w fyne.Window) *SyncDialog {
title := canvas.NewText("Warming up...", color.Black)
title.Alignment = fyne.TextAlignCenter
pg := widget.NewProgressBar()
pg.Max = float64(total)
c := container.New(layout.NewVBoxLayout(), title, pg)
d := &SyncDialog{
CustomDialog: dialog.NewCustomWithoutButtons("Syncing", c, w),
label: title,
pg: pg,
}
return d
}
func (s *SyncDialog) UpdateLabel(msg string) {
s.label.Text = msg
s.Refresh()
}
func (s *SyncDialog) UpdateProgressBar(percentage int) {
s.pg.Value = float64(percentage)
s.Refresh()
}