2021-07-11 20:52:49 +00:00
|
|
|
import Foundation
|
|
|
|
import SwiftUI
|
|
|
|
|
2021-09-25 08:18:22 +00:00
|
|
|
final class NavigationModel: ObservableObject {
|
2021-08-29 21:36:18 +00:00
|
|
|
enum TabSelection: Hashable {
|
2021-11-01 21:56:18 +00:00
|
|
|
case favorites
|
2021-10-05 20:20:09 +00:00
|
|
|
case subscriptions
|
|
|
|
case popular
|
|
|
|
case trending
|
|
|
|
case playlists
|
|
|
|
case channel(String)
|
|
|
|
case playlist(String)
|
|
|
|
case recentlyOpened(String)
|
|
|
|
case nowPlaying
|
|
|
|
case search
|
2021-10-24 21:36:24 +00:00
|
|
|
|
|
|
|
var playlistID: Playlist.ID? {
|
|
|
|
if case let .playlist(id) = self {
|
|
|
|
return id
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
2021-08-29 21:36:18 +00:00
|
|
|
}
|
|
|
|
|
2021-12-01 11:22:19 +00:00
|
|
|
@Published var tabSelection: TabSelection!
|
2021-07-11 20:52:49 +00:00
|
|
|
|
2021-09-28 18:06:05 +00:00
|
|
|
@Published var presentingAddToPlaylist = false
|
|
|
|
@Published var videoToAddToPlaylist: Video!
|
|
|
|
|
2021-08-29 21:36:18 +00:00
|
|
|
@Published var presentingPlaylistForm = false
|
|
|
|
@Published var editedPlaylist: Playlist!
|
|
|
|
|
|
|
|
@Published var presentingUnsubscribeAlert = false
|
|
|
|
@Published var channelToUnsubscribe: Channel!
|
|
|
|
|
2021-10-22 23:04:03 +00:00
|
|
|
@Published var presentingChannel = false
|
|
|
|
@Published var presentingPlaylist = false
|
2021-08-31 21:17:50 +00:00
|
|
|
@Published var sidebarSectionChanged = false
|
|
|
|
|
2021-09-25 08:18:22 +00:00
|
|
|
@Published var presentingSettings = false
|
2021-10-17 23:06:00 +00:00
|
|
|
@Published var presentingWelcomeScreen = false
|
2021-09-25 08:18:22 +00:00
|
|
|
|
2021-09-28 23:01:49 +00:00
|
|
|
var tabSelectionBinding: Binding<TabSelection> {
|
|
|
|
Binding<TabSelection>(
|
2021-07-11 20:52:49 +00:00
|
|
|
get: {
|
2021-11-01 21:56:18 +00:00
|
|
|
self.tabSelection ?? .favorites
|
2021-07-11 20:52:49 +00:00
|
|
|
},
|
2021-08-31 21:17:50 +00:00
|
|
|
set: { newValue in
|
2021-09-28 23:01:49 +00:00
|
|
|
self.tabSelection = newValue
|
2021-07-11 20:52:49 +00:00
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
2021-08-29 21:36:18 +00:00
|
|
|
|
2021-09-28 18:06:05 +00:00
|
|
|
func presentAddToPlaylist(_ video: Video) {
|
|
|
|
videoToAddToPlaylist = video
|
|
|
|
presentingAddToPlaylist = true
|
|
|
|
}
|
|
|
|
|
2021-08-29 21:36:18 +00:00
|
|
|
func presentEditPlaylistForm(_ playlist: Playlist?) {
|
|
|
|
editedPlaylist = playlist
|
|
|
|
presentingPlaylistForm = editedPlaylist != nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func presentNewPlaylistForm() {
|
|
|
|
editedPlaylist = nil
|
|
|
|
presentingPlaylistForm = true
|
|
|
|
}
|
|
|
|
|
|
|
|
func presentUnsubscribeAlert(_ channel: Channel?) {
|
|
|
|
channelToUnsubscribe = channel
|
|
|
|
presentingUnsubscribeAlert = channelToUnsubscribe != nil
|
|
|
|
}
|
2021-07-11 20:52:49 +00:00
|
|
|
}
|
2021-08-29 21:36:18 +00:00
|
|
|
|
2021-09-25 08:18:22 +00:00
|
|
|
typealias TabSelection = NavigationModel.TabSelection
|