1
0
mirror of https://github.com/yattee/yattee.git synced 2025-01-08 18:40:33 +05:30
yattee/Model/NavigationState.swift

58 lines
1.3 KiB
Swift
Raw Normal View History

2021-07-12 02:22:49 +05:30
import Foundation
import SwiftUI
final class NavigationState: ObservableObject {
@Published var tabSelection: TabSelection = .subscriptions
@Published var showingChannel = false
@Published var channel: Channel?
@Published var showingVideoDetails = false
2021-07-19 04:02:46 +05:30
@Published var showingVideo = false
2021-07-12 02:22:49 +05:30
@Published var video: Video?
2021-07-19 04:02:46 +05:30
@Published var returnToDetails = false
2021-07-12 02:22:49 +05:30
func openChannel(_ channel: Channel) {
2021-07-19 04:02:46 +05:30
returnToDetails = false
2021-07-12 02:22:49 +05:30
self.channel = channel
showingChannel = true
}
func closeChannel() {
showingChannel = false
channel = nil
}
func openVideoDetails(_ video: Video) {
self.video = video
showingVideoDetails = true
}
func closeVideoDetails() {
showingVideoDetails = false
video = nil
}
2021-07-19 04:02:46 +05:30
func playVideo(_ video: Video) {
self.video = video
showingVideo = true
}
func showVideoDetailsIfNeeded() {
showingVideoDetails = returnToDetails
returnToDetails = false
}
2021-07-12 02:22:49 +05:30
var tabSelectionOptionalBinding: Binding<TabSelection?> {
Binding<TabSelection?>(
get: {
self.tabSelection
},
set: {
self.tabSelection = $0 ?? .subscriptions
}
)
}
}