mirror of
https://github.com/yattee/yattee.git
synced 2024-12-22 21:43:41 +00:00
77 lines
2.0 KiB
Swift
77 lines
2.0 KiB
Swift
import Foundation
|
|
import SwiftUI
|
|
|
|
final class NavigationModel: ObservableObject {
|
|
enum TabSelection: Hashable {
|
|
case watchNow
|
|
case subscriptions
|
|
case popular
|
|
case trending
|
|
case playlists
|
|
case channel(String)
|
|
case playlist(String)
|
|
case recentlyOpened(String)
|
|
case nowPlaying
|
|
case search
|
|
|
|
var playlistID: Playlist.ID? {
|
|
if case let .playlist(id) = self {
|
|
return id
|
|
}
|
|
|
|
return nil
|
|
}
|
|
}
|
|
|
|
@Published var tabSelection: TabSelection! = .watchNow
|
|
|
|
@Published var presentingAddToPlaylist = false
|
|
@Published var videoToAddToPlaylist: Video!
|
|
|
|
@Published var presentingPlaylistForm = false
|
|
@Published var editedPlaylist: Playlist!
|
|
|
|
@Published var presentingUnsubscribeAlert = false
|
|
@Published var channelToUnsubscribe: Channel!
|
|
|
|
@Published var presentingChannel = false
|
|
@Published var presentingPlaylist = false
|
|
@Published var sidebarSectionChanged = false
|
|
|
|
@Published var presentingSettings = false
|
|
@Published var presentingWelcomeScreen = false
|
|
|
|
var tabSelectionBinding: Binding<TabSelection> {
|
|
Binding<TabSelection>(
|
|
get: {
|
|
self.tabSelection ?? .watchNow
|
|
},
|
|
set: { newValue in
|
|
self.tabSelection = newValue
|
|
}
|
|
)
|
|
}
|
|
|
|
func presentAddToPlaylist(_ video: Video) {
|
|
videoToAddToPlaylist = video
|
|
presentingAddToPlaylist = true
|
|
}
|
|
|
|
func presentEditPlaylistForm(_ playlist: Playlist?) {
|
|
editedPlaylist = playlist
|
|
presentingPlaylistForm = editedPlaylist != nil
|
|
}
|
|
|
|
func presentNewPlaylistForm() {
|
|
editedPlaylist = nil
|
|
presentingPlaylistForm = true
|
|
}
|
|
|
|
func presentUnsubscribeAlert(_ channel: Channel?) {
|
|
channelToUnsubscribe = channel
|
|
presentingUnsubscribeAlert = channelToUnsubscribe != nil
|
|
}
|
|
}
|
|
|
|
typealias TabSelection = NavigationModel.TabSelection
|