2021-08-31 21:17:50 +00:00
|
|
|
import Foundation
|
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
private struct InNavigationViewKey: EnvironmentKey {
|
|
|
|
static let defaultValue = false
|
|
|
|
}
|
|
|
|
|
2021-10-28 17:14:55 +00:00
|
|
|
private struct InChannelViewKey: EnvironmentKey {
|
|
|
|
static let defaultValue = false
|
|
|
|
}
|
|
|
|
|
2021-12-19 22:27:20 +00:00
|
|
|
private struct InChannelPlaylistViewKey: EnvironmentKey {
|
|
|
|
static let defaultValue = false
|
|
|
|
}
|
|
|
|
|
2021-09-18 20:36:42 +00:00
|
|
|
private struct HorizontalCellsKey: EnvironmentKey {
|
|
|
|
static let defaultValue = false
|
|
|
|
}
|
|
|
|
|
2021-09-19 12:42:47 +00:00
|
|
|
enum NavigationStyle {
|
|
|
|
case tab, sidebar
|
|
|
|
}
|
|
|
|
|
|
|
|
private struct NavigationStyleKey: EnvironmentKey {
|
|
|
|
static let defaultValue = NavigationStyle.tab
|
|
|
|
}
|
|
|
|
|
2021-10-24 21:36:24 +00:00
|
|
|
private struct CurrentPlaylistID: EnvironmentKey {
|
|
|
|
static let defaultValue: String? = nil
|
|
|
|
}
|
|
|
|
|
2022-01-04 23:18:01 +00:00
|
|
|
private struct LoadMoreContentHandler: EnvironmentKey {
|
|
|
|
static let defaultValue: LoadMoreContentHandlerClosure = { print("infinite load") }
|
|
|
|
}
|
|
|
|
|
|
|
|
typealias LoadMoreContentHandlerClosure = () -> Void
|
|
|
|
|
2021-08-31 21:17:50 +00:00
|
|
|
extension EnvironmentValues {
|
|
|
|
var inNavigationView: Bool {
|
|
|
|
get { self[InNavigationViewKey.self] }
|
|
|
|
set { self[InNavigationViewKey.self] = newValue }
|
|
|
|
}
|
2021-09-18 20:36:42 +00:00
|
|
|
|
2021-10-28 17:14:55 +00:00
|
|
|
var inChannelView: Bool {
|
|
|
|
get { self[InChannelViewKey.self] }
|
|
|
|
set { self[InChannelViewKey.self] = newValue }
|
|
|
|
}
|
|
|
|
|
2021-12-19 22:27:20 +00:00
|
|
|
var inChannelPlaylistView: Bool {
|
|
|
|
get { self[InChannelPlaylistViewKey.self] }
|
|
|
|
set { self[InChannelPlaylistViewKey.self] = newValue }
|
|
|
|
}
|
|
|
|
|
2021-09-18 20:36:42 +00:00
|
|
|
var horizontalCells: Bool {
|
|
|
|
get { self[HorizontalCellsKey.self] }
|
|
|
|
set { self[HorizontalCellsKey.self] = newValue }
|
|
|
|
}
|
2021-09-19 12:42:47 +00:00
|
|
|
|
|
|
|
var navigationStyle: NavigationStyle {
|
|
|
|
get { self[NavigationStyleKey.self] }
|
|
|
|
set { self[NavigationStyleKey.self] = newValue }
|
|
|
|
}
|
2021-10-24 21:36:24 +00:00
|
|
|
|
|
|
|
var currentPlaylistID: String? {
|
|
|
|
get { self[CurrentPlaylistID.self] }
|
|
|
|
set { self[CurrentPlaylistID.self] = newValue }
|
|
|
|
}
|
2022-01-04 23:18:01 +00:00
|
|
|
|
|
|
|
var loadMoreContentHandler: LoadMoreContentHandlerClosure {
|
|
|
|
get { self[LoadMoreContentHandler.self] }
|
|
|
|
set { self[LoadMoreContentHandler.self] = newValue }
|
|
|
|
}
|
2021-08-31 21:17:50 +00:00
|
|
|
}
|