fckeuspy-go/fyne_ui.go
2025-09-15 22:42:22 +02:00

32 lines
661 B
Go

package main
import (
"os"
"path/filepath"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
)
func NewUI() (stprageDir string, window fyne.Window) {
// App + storage dir
a := app.New()
w := a.NewWindow("Encryptor (Fyne)")
prefs := a.Preferences()
width := prefs.IntWithFallback("winW", 1100)
height := prefs.IntWithFallback("winH", 720)
w.Resize(fyne.NewSize(float32(width), float32(height)))
w.SetOnClosed(func() {
sz := w.Canvas().Size()
prefs.SetInt("winW", int(sz.Width))
prefs.SetInt("winH", int(sz.Height))
})
base, err := os.UserConfigDir()
if err != nil {
base, _ = os.UserHomeDir()
}
return filepath.Join(base, "fckeuspy-go"), w
}