Documentation
¶
Overview ¶
Package app is Smolify's UI: one state, pure views, and handlers, drawn by Flatte in a terminal, window, or browser. It drives playback through Backend.
Index ¶
- func ContextMenu(s *State, target string) []flatte.MenuItem
- func Handle(s *State, ev flatte.Event, fx flatte.Effects[State])
- func Init(s *State, fx flatte.Effects[State])
- func Menus(s *State) []flatte.Menu
- func New(be Backend, img Images, web Web, debug io.Writer) flatte.App[State]
- func SettingsPath(dir string) string
- func View(s *State, ctx flatte.RenderContext) flatte.Frame
- func WindowFonts() [][]byte
- func WindowTheme() window.Theme
- func Windowed(app flatte.App[State]) flatte.App[State]
- func WithCache(app flatte.App[State], dir string) flatte.App[State]
- func WithCacheStore(app flatte.App[State], store librarycache.Cache) flatte.App[State]
- func WithSettings(a flatte.App[State], path string, st Settings) flatte.App[State]
- func WithSettingsStore(app flatte.App[State], store SettingsStore, st Settings) flatte.App[State]
- type Backend
- type HTTPImages
- type Images
- type Settings
- type SettingsStore
- type State
- type Web
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextMenu ¶
ContextMenu is the menu for a list in the library or a track in the table.
func Menus ¶
Menus is the menu bar; its shortcuts are Smolify's playback keys, in every host (plain keys for a terminal, ⌘ chords too in a window). While the search field has focus, plain keys type: only chords stay shortcuts.
func New ¶
New is the app for backend be, with web for search (nil: neither). debug, when not nil, receives a log of player events, commands, and request failures.
func SettingsPath ¶
SettingsPath is where settings live in dir (the player's state dir).
func View ¶
func View(s *State, ctx flatte.RenderContext) flatte.Frame
View draws the sign-in screen until the player is ready, then the library, the selected playlist, and the player bar.
func WindowFonts ¶
func WindowFonts() [][]byte
WindowFonts are the font files a window needs for WindowTheme.
func WindowTheme ¶
WindowTheme is Smolify's look in a window: dark, the brand violet for focus and default buttons, a soft white for selected rows.
func Windowed ¶
Windowed is app as a window app: errors and confirmations become system notifications rather than lines on screen.
func WithCache ¶
WithCache enables a persistent library cache rooted in dir. The cache is keyed by the signed-in Spotify username/account identifier.
func WithCacheStore ¶
WithCacheStore installs a host-provided library cache.
func WithSettings ¶
WithSettings preserves the native path-based setup for existing callers.
func WithSettingsStore ¶
WithSettingsStore installs host storage and applies the loaded settings.
Types ¶
type Backend ¶
type Backend interface {
Events() <-chan model.Event
Status(ctx context.Context) (model.Status, error)
Playlists(ctx context.Context) ([]model.Playlist, error)
Play(ctx context.Context, uri, skipTo string) error
PlayPause(ctx context.Context) error
Next(ctx context.Context) error
Prev(ctx context.Context) error
Seek(ctx context.Context, position time.Duration) error
SetVolume(ctx context.Context, v int) error
SetShuffle(ctx context.Context, on bool) error
SetRepeat(ctx context.Context, r model.Repeat) error
ContextTracks(ctx context.Context, uri string) (model.Listing, error)
Queue(ctx context.Context, uri string) error
SetLiked(ctx context.Context, uris []string, liked bool) error
Liked(ctx context.Context, uris []string) ([]bool, error)
// Configure changes how the player plays, restarting its session.
Configure(ctx context.Context, a model.Audio) error
SetDeviceName(ctx context.Context, name string) error
// SignOut forgets the sign-in; the player then reports Pairing.
SignOut(ctx context.Context) error
// RecentlyPlayed is the lists username played lately, newest first.
RecentlyPlayed(ctx context.Context, username string, limit int) ([]model.Played, error)
}
Backend is the playback service as the UI uses it (or a fake in tests). Requests block; the UI calls them off the loop.
type HTTPImages ¶
HTTPImages fetches and decodes cover art on native hosts.
type Settings ¶
type Settings struct {
// NotifyErrors posts errors and confirmations as notifications (in a
// window, which shows them nowhere else).
NotifyErrors bool `json:"notify_errors"`
// NotifyTracks posts each new track while Smolify is not in front.
NotifyTracks bool `json:"notify_tracks"`
Bitrate int `json:"bitrate"` // kbps: 96, 160, or 320
Normalise bool `json:"normalise"`
Crossfade int `json:"crossfade_seconds"`
Autoplay bool `json:"autoplay"`
// AudioBackend is the output driver: model.AudioBackendAuto, or one of
// model.AudioBackendOptions for this OS.
AudioBackend string `json:"audio_backend"`
DeviceName string `json:"device_name"`
Compact bool `json:"compact_rows"`
// Images is how a terminal shows covers: imagesPictures,
// imagesHalfBlocks, or imagesOff. A window always shows pictures.
Images int `json:"terminal_images"`
}
Settings are the user preferences changed on the Settings page. The host persists them through SettingsStore.
func DefaultSettings ¶
func DefaultSettings() Settings
DefaultSettings are a first launch's settings.
func LoadSettings ¶
LoadSettings reads the settings at path, using defaults when no file exists.
type SettingsStore ¶
SettingsStore persists user preferences for the current host.