Files
Amphlify/Amphlify/App/Router.swift
T

51 lines
988 B
Swift

import Domain
import Observation
enum AppTab: Hashable {
case home, radio, library, search
}
enum LibrarySection: Hashable, CaseIterable {
case playlists, artists, albums, songs, genres
}
enum Route: Hashable {
case album(EntityID)
case artist(EntityID)
case playlist(EntityID)
case genre(String)
case favorites
case section(LibrarySection)
}
@Observable
final class Router {
var tab: AppTab = .home
var paths: [AppTab: [Route]] = [:]
var showsNowPlaying = false
var showsQueue = false {
didSet {
if showsQueue {
showsLyrics = false
}
}
}
var showsLyrics = false {
didSet {
if showsLyrics {
showsQueue = false
}
}
}
func path(for tab: AppTab) -> [Route] {
paths[tab] ?? []
}
func open(_ route: Route) {
showsNowPlaying = false
paths[tab, default: []].append(route)
}
}