2022-12-12 05:48:29 +05:30
|
|
|
import Defaults
|
2021-09-01 02:47:50 +05:30
|
|
|
import Foundation
|
|
|
|
import SwiftUI
|
|
|
|
|
2021-10-28 22:44:55 +05:30
|
|
|
private struct InChannelViewKey: EnvironmentKey {
|
|
|
|
static let defaultValue = false
|
|
|
|
}
|
|
|
|
|
2021-12-20 03:57:20 +05:30
|
|
|
private struct InChannelPlaylistViewKey: EnvironmentKey {
|
|
|
|
static let defaultValue = false
|
|
|
|
}
|
|
|
|
|
2021-09-19 02:06:42 +05:30
|
|
|
private struct HorizontalCellsKey: EnvironmentKey {
|
|
|
|
static let defaultValue = false
|
|
|
|
}
|
|
|
|
|
2021-09-19 18:12:47 +05:30
|
|
|
enum NavigationStyle {
|
|
|
|
case tab, sidebar
|
|
|
|
}
|
|
|
|
|
|
|
|
private struct NavigationStyleKey: EnvironmentKey {
|
|
|
|
static let defaultValue = NavigationStyle.tab
|
|
|
|
}
|
|
|
|
|
2022-12-12 05:48:29 +05:30
|
|
|
private struct ListingStyleKey: EnvironmentKey {
|
|
|
|
static let defaultValue = ListingStyle.cells
|
|
|
|
}
|
|
|
|
|
2022-12-13 06:20:26 +05:30
|
|
|
private struct InNavigationViewKey: EnvironmentKey {
|
|
|
|
static let defaultValue = true
|
|
|
|
}
|
|
|
|
|
2022-12-19 04:39:54 +05:30
|
|
|
private struct InQueueListingKey: EnvironmentKey {
|
|
|
|
static let defaultValue = false
|
|
|
|
}
|
|
|
|
|
2022-12-19 04:40:05 +05:30
|
|
|
private struct NoListingDividersKey: EnvironmentKey {
|
|
|
|
static let defaultValue = false
|
|
|
|
}
|
|
|
|
|
2022-12-12 05:48:29 +05:30
|
|
|
enum ListingStyle: String, CaseIterable, Defaults.Serializable {
|
|
|
|
case cells
|
|
|
|
case list
|
|
|
|
|
|
|
|
var systemImage: String {
|
|
|
|
switch self {
|
|
|
|
case .cells:
|
|
|
|
return "rectangle.grid.2x2"
|
|
|
|
case .list:
|
|
|
|
return "list.dash"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-25 03:06:24 +05:30
|
|
|
private struct CurrentPlaylistID: EnvironmentKey {
|
|
|
|
static let defaultValue: String? = nil
|
|
|
|
}
|
|
|
|
|
2022-02-04 23:08:29 +05:30
|
|
|
typealias LoadMoreContentHandlerType = () -> Void
|
|
|
|
|
2022-01-05 04:48:01 +05:30
|
|
|
private struct LoadMoreContentHandler: EnvironmentKey {
|
2022-01-09 20:35:05 +05:30
|
|
|
static let defaultValue: LoadMoreContentHandlerType = {}
|
2022-01-05 04:48:01 +05:30
|
|
|
}
|
|
|
|
|
2022-02-04 23:08:29 +05:30
|
|
|
private struct ScrollViewBottomPaddingKey: EnvironmentKey {
|
|
|
|
static let defaultValue: Double = 30
|
|
|
|
}
|
2022-01-05 04:48:01 +05:30
|
|
|
|
2023-02-25 21:12:18 +05:30
|
|
|
private struct HideShortsKey: EnvironmentKey {
|
|
|
|
static let defaultValue = false
|
|
|
|
}
|
|
|
|
|
2021-09-01 02:47:50 +05:30
|
|
|
extension EnvironmentValues {
|
2021-10-28 22:44:55 +05:30
|
|
|
var inChannelView: Bool {
|
|
|
|
get { self[InChannelViewKey.self] }
|
|
|
|
set { self[InChannelViewKey.self] = newValue }
|
|
|
|
}
|
|
|
|
|
2021-12-20 03:57:20 +05:30
|
|
|
var inChannelPlaylistView: Bool {
|
|
|
|
get { self[InChannelPlaylistViewKey.self] }
|
|
|
|
set { self[InChannelPlaylistViewKey.self] = newValue }
|
|
|
|
}
|
|
|
|
|
2021-09-19 02:06:42 +05:30
|
|
|
var horizontalCells: Bool {
|
|
|
|
get { self[HorizontalCellsKey.self] }
|
|
|
|
set { self[HorizontalCellsKey.self] = newValue }
|
|
|
|
}
|
2021-09-19 18:12:47 +05:30
|
|
|
|
|
|
|
var navigationStyle: NavigationStyle {
|
|
|
|
get { self[NavigationStyleKey.self] }
|
|
|
|
set { self[NavigationStyleKey.self] = newValue }
|
|
|
|
}
|
2021-10-25 03:06:24 +05:30
|
|
|
|
|
|
|
var currentPlaylistID: String? {
|
|
|
|
get { self[CurrentPlaylistID.self] }
|
|
|
|
set { self[CurrentPlaylistID.self] = newValue }
|
|
|
|
}
|
2022-01-05 04:48:01 +05:30
|
|
|
|
2022-01-09 20:17:24 +05:30
|
|
|
var loadMoreContentHandler: LoadMoreContentHandlerType {
|
2022-01-05 04:48:01 +05:30
|
|
|
get { self[LoadMoreContentHandler.self] }
|
|
|
|
set { self[LoadMoreContentHandler.self] = newValue }
|
|
|
|
}
|
2022-02-04 23:08:29 +05:30
|
|
|
|
|
|
|
var scrollViewBottomPadding: Double {
|
|
|
|
get { self[ScrollViewBottomPaddingKey.self] }
|
|
|
|
set { self[ScrollViewBottomPaddingKey.self] = newValue }
|
|
|
|
}
|
2022-12-12 05:48:29 +05:30
|
|
|
|
|
|
|
var listingStyle: ListingStyle {
|
|
|
|
get { self[ListingStyleKey.self] }
|
|
|
|
set { self[ListingStyleKey.self] = newValue }
|
|
|
|
}
|
2022-12-13 06:20:26 +05:30
|
|
|
|
|
|
|
var inNavigationView: Bool {
|
|
|
|
get { self[InNavigationViewKey.self] }
|
|
|
|
set { self[InNavigationViewKey.self] = newValue }
|
|
|
|
}
|
2022-12-19 04:39:54 +05:30
|
|
|
|
|
|
|
var inQueueListing: Bool {
|
|
|
|
get { self[InQueueListingKey.self] }
|
|
|
|
set { self[InQueueListingKey.self] = newValue }
|
|
|
|
}
|
|
|
|
|
2022-12-19 04:40:05 +05:30
|
|
|
var noListingDividers: Bool {
|
|
|
|
get { self[NoListingDividersKey.self] }
|
|
|
|
set { self[NoListingDividersKey.self] = newValue }
|
|
|
|
}
|
2023-02-25 21:12:18 +05:30
|
|
|
|
|
|
|
var hideShorts: Bool {
|
|
|
|
get { self[HideShortsKey.self] }
|
|
|
|
set { self[HideShortsKey.self] = newValue }
|
|
|
|
}
|
2021-09-01 02:47:50 +05:30
|
|
|
}
|