wails/v3/pkg/services/dock/dock.go
Zach Botterman 1a5c6dceee
fix(v3): Dock ops sync and add GetBadge method (#4838)
* dock fixes and get method

* update changelog

* async -> sync

* cleanup iOS and darwin set call

* handle potential errors
2026-02-09 21:03:45 +11:00

83 lines
2.1 KiB
Go

package dock
import (
"context"
"image/color"
"github.com/wailsapp/wails/v3/pkg/application"
)
type platformDock interface {
// Lifecycle methods
Startup(ctx context.Context, options application.ServiceOptions) error
Shutdown() error
// Dock icon visibility methods
HideAppIcon()
ShowAppIcon()
// Badge methods
SetBadge(label string) error
SetCustomBadge(label string, options BadgeOptions) error
RemoveBadge() error
GetBadge() *string
}
// Service represents the dock service
type DockService struct {
impl platformDock
}
// BadgeOptions represents options for customizing badge appearance
type BadgeOptions struct {
TextColour color.RGBA
BackgroundColour color.RGBA
FontName string
FontSize int
SmallFontSize int
}
// ServiceName returns the name of the service.
func (d *DockService) ServiceName() string {
return "github.com/wailsapp/wails/v3/pkg/services/dock"
}
// ServiceStartup is called when the service is loaded.
func (d *DockService) ServiceStartup(ctx context.Context, options application.ServiceOptions) error {
return d.impl.Startup(ctx, options)
}
// ServiceShutdown is called when the service is unloaded.
func (d *DockService) ServiceShutdown() error {
return d.impl.Shutdown()
}
// HideAppIcon hides the app icon in the dock/taskbar.
func (d *DockService) HideAppIcon() {
d.impl.HideAppIcon()
}
// ShowAppIcon shows the app icon in the dock/taskbar.
func (d *DockService) ShowAppIcon() {
d.impl.ShowAppIcon()
}
// SetBadge sets the badge label on the application icon.
func (d *DockService) SetBadge(label string) error {
return d.impl.SetBadge(label)
}
// SetCustomBadge sets the badge label on the application icon with custom options.
func (d *DockService) SetCustomBadge(label string, options BadgeOptions) error {
return d.impl.SetCustomBadge(label, options)
}
// RemoveBadge removes the badge label from the application icon.
func (d *DockService) RemoveBadge() error {
return d.impl.RemoveBadge()
}
// GetBadge returns the badge label on the application icon.
func (d *DockService) GetBadge() *string {
return d.impl.GetBadge()
}