Version 1 in App Store
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
//
|
||||
// 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 player(String) // playerId
|
||||
}
|
||||
|
||||
/// 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: 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 .player(let playerId):
|
||||
PlayerView(playerId: playerId)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension View {
|
||||
/// Apply standard Music Assistant navigation destinations to any view
|
||||
func withMANavigation() -> some View {
|
||||
modifier(MANavigationDestinations())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user