55 lines
1.8 KiB
Swift
55 lines
1.8 KiB
Swift
//
|
|
// MANavigationDestination.swift
|
|
// Mobile Music Assistant
|
|
//
|
|
// Created by Sven Hanold on 26.03.26.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
/// Central navigation destination enum for type-safe navigation throughout the app
|
|
enum MANavigationDestination: Hashable {
|
|
case artist(MAArtist)
|
|
case album(MAAlbum)
|
|
case playlist(MAPlaylist)
|
|
case podcast(MAPodcast)
|
|
}
|
|
|
|
/// ViewModifier to apply all navigation destinations consistently
|
|
struct MANavigationDestinations: ViewModifier {
|
|
func body(content: Content) -> some View {
|
|
content
|
|
.navigationDestination(for: MAArtist.self) { artist in
|
|
ArtistDetailView(artist: artist)
|
|
}
|
|
.navigationDestination(for: MAAlbum.self) { album in
|
|
AlbumDetailView(album: album)
|
|
}
|
|
.navigationDestination(for: MAPlaylist.self) { playlist in
|
|
PlaylistDetailView(playlist: playlist)
|
|
}
|
|
.navigationDestination(for: MAPodcast.self) { podcast in
|
|
PodcastDetailView(podcast: podcast)
|
|
}
|
|
.navigationDestination(for: MANavigationDestination.self) { destination in
|
|
switch destination {
|
|
case .artist(let artist):
|
|
ArtistDetailView(artist: artist)
|
|
case .album(let album):
|
|
AlbumDetailView(album: album)
|
|
case .playlist(let playlist):
|
|
PlaylistDetailView(playlist: playlist)
|
|
case .podcast(let podcast):
|
|
PodcastDetailView(podcast: podcast)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
extension View {
|
|
/// Apply standard Music Assistant navigation destinations to any view
|
|
func withMANavigation() -> some View {
|
|
modifier(MANavigationDestinations())
|
|
}
|
|
}
|