package ui import ( "fyne.io/fyne/v2" "fyne.io/fyne/v2/container" "fyne.io/fyne/v2/widget" "gitea.unprism.ru/KRBL/FemaInstaller/pkg/config" ) // UpdaterWindow represents the main window for the updater application type UpdaterWindow struct { Window fyne.Window ConfigDisplay *widget.Label UpdateButton *widget.Button StatusLabel *widget.Label } // NewUpdaterWindow creates a new window for the updater application func NewUpdaterWindow(app fyne.App, config *config.UpdaterConfig, updateHandler func() error) *UpdaterWindow { window := app.NewWindow("Обновление ПО Фема") // Create updater window updaterWindow := &UpdaterWindow{ Window: window, ConfigDisplay: widget.NewLabel(config.String()), StatusLabel: widget.NewLabel(""), } // Create update button updaterWindow.UpdateButton = widget.NewButton("Обновить ПО", func() { updaterWindow.StatusLabel.SetText("Начало обновления...") updaterWindow.UpdateButton.Disable() go func() { err := updateHandler() if err != nil { updaterWindow.StatusLabel.SetText("Ошибка обновления: " + err.Error()) } else { updaterWindow.StatusLabel.SetText("Обновление успешно завершено!") } updaterWindow.UpdateButton.Enable() }() }) // Create title title := widget.NewLabel("Программа обновления ПО Фема") title.Alignment = fyne.TextAlignCenter title.TextStyle = fyne.TextStyle{Bold: true} // Create config section title configTitle := widget.NewLabel("Текущая конфигурация:") configTitle.TextStyle = fyne.TextStyle{Bold: true} // Create layout content := container.NewVBox( title, widget.NewSeparator(), configTitle, updaterWindow.ConfigDisplay, widget.NewSeparator(), updaterWindow.UpdateButton, updaterWindow.StatusLabel, ) // Set window content and size window.SetContent(content) window.Resize(fyne.NewSize(400, 300)) return updaterWindow } // Show displays the updater window func (w *UpdaterWindow) Show() { w.Window.Show() } // ShowAndRun displays the updater window and starts the application func (w *UpdaterWindow) ShowAndRun() { w.Window.ShowAndRun() }