gui/pkg/display/interfaces.go
Snider bba743d2cb
Some checks failed
Security Scan / security (push) Failing after 9s
Test / test (push) Failing after 1m33s
refactor(display): remove extracted clipboard/dialog/notification/theme/screen code
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-13 14:24:06 +00:00

78 lines
2.5 KiB
Go

// pkg/display/interfaces.go
package display
import (
"github.com/wailsapp/wails/v3/pkg/application"
"github.com/wailsapp/wails/v3/pkg/events"
)
// App abstracts the Wails application for the orchestrator.
type App interface {
Dialog() DialogManager
Env() EnvManager
Event() EventManager
Logger() Logger
Quit()
}
// DialogManager wraps Wails dialog operations.
type DialogManager interface {
Info() *application.MessageDialog
Warning() *application.MessageDialog
OpenFile() *application.OpenFileDialogStruct
}
// EnvManager wraps Wails environment queries.
type EnvManager interface {
Info() application.EnvironmentInfo
IsDarkMode() bool
}
// EventManager wraps Wails application events.
type EventManager interface {
OnApplicationEvent(eventType events.ApplicationEventType, handler func(*application.ApplicationEvent)) func()
Emit(name string, data ...any) bool
}
// Logger wraps Wails logging.
type Logger interface {
Info(message string, args ...any)
}
// wailsApp wraps *application.App for the App interface.
type wailsApp struct {
app *application.App
}
func newWailsApp(app *application.App) App {
return &wailsApp{app: app}
}
func (w *wailsApp) Dialog() DialogManager { return &wailsDialogManager{app: w.app} }
func (w *wailsApp) Env() EnvManager { return &wailsEnvManager{app: w.app} }
func (w *wailsApp) Event() EventManager { return &wailsEventManager{app: w.app} }
func (w *wailsApp) Logger() Logger { return w.app.Logger }
func (w *wailsApp) Quit() { w.app.Quit() }
type wailsDialogManager struct{ app *application.App }
func (d *wailsDialogManager) Info() *application.MessageDialog { return d.app.Dialog.Info() }
func (d *wailsDialogManager) Warning() *application.MessageDialog { return d.app.Dialog.Warning() }
func (d *wailsDialogManager) OpenFile() *application.OpenFileDialogStruct {
return d.app.Dialog.OpenFile()
}
type wailsEnvManager struct{ app *application.App }
func (e *wailsEnvManager) Info() application.EnvironmentInfo { return e.app.Env.Info() }
func (e *wailsEnvManager) IsDarkMode() bool { return e.app.Env.IsDarkMode() }
type wailsEventManager struct{ app *application.App }
func (ev *wailsEventManager) OnApplicationEvent(eventType events.ApplicationEventType, handler func(*application.ApplicationEvent)) func() {
return ev.app.Event.OnApplicationEvent(eventType, handler)
}
func (ev *wailsEventManager) Emit(name string, data ...any) bool {
return ev.app.Event.Emit(name, data...)
}