yattee/Model/NavigationModel.swift

68 lines
1.8 KiB
Swift
Raw Normal View History

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 {
case watchNow
case subscriptions
case popular
case trending
case playlists
case channel(String)
case playlist(String)
case recentlyOpened(String)
case nowPlaying
case search
2021-08-29 21:36:18 +00:00
}
2021-09-28 23:01:49 +00:00
@Published var tabSelection: TabSelection! = .watchNow
2021-07-11 20:52:49 +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!
@Published var isChannelOpen = false
@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-09-28 23:01:49 +00:00
self.tabSelection ?? .watchNow
2021-07-11 20:52:49 +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
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