2021-09-29 17:15:00 +05:30
|
|
|
import Foundation
|
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct FixtureEnvironmentObjectsModifier: ViewModifier {
|
|
|
|
func body(content: Content) -> some View {
|
|
|
|
content
|
|
|
|
.environmentObject(InstancesModel())
|
2021-09-29 18:06:52 +05:30
|
|
|
.environmentObject(api)
|
2021-09-29 17:15:00 +05:30
|
|
|
.environmentObject(NavigationModel())
|
2021-10-06 01:50:09 +05:30
|
|
|
.environmentObject(player)
|
2021-09-29 17:15:00 +05:30
|
|
|
.environmentObject(PlaylistsModel())
|
|
|
|
.environmentObject(RecentsModel())
|
|
|
|
.environmentObject(SearchModel())
|
2021-10-06 01:50:09 +05:30
|
|
|
.environmentObject(subscriptions)
|
2021-09-29 18:06:52 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
private var api: InvidiousAPI {
|
|
|
|
let api = InvidiousAPI()
|
|
|
|
|
|
|
|
api.validInstance = true
|
|
|
|
api.signedIn = true
|
|
|
|
|
|
|
|
return api
|
2021-09-29 17:15:00 +05:30
|
|
|
}
|
2021-10-06 01:50:09 +05:30
|
|
|
|
|
|
|
private var player: PlayerModel {
|
|
|
|
let player = PlayerModel()
|
|
|
|
|
|
|
|
player.currentItem = PlayerQueueItem(Video.fixture)
|
|
|
|
player.queue = Video.allFixtures.map { PlayerQueueItem($0) }
|
|
|
|
player.history = player.queue
|
|
|
|
|
|
|
|
return player
|
|
|
|
}
|
|
|
|
|
|
|
|
private var subscriptions: SubscriptionsModel {
|
|
|
|
let subscriptions = SubscriptionsModel()
|
|
|
|
|
|
|
|
subscriptions.channels = Video.allFixtures.map { $0.channel }
|
|
|
|
|
|
|
|
return subscriptions
|
|
|
|
}
|
2021-09-29 17:15:00 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
extension View {
|
|
|
|
func injectFixtureEnvironmentObjects() -> some View {
|
|
|
|
modifier(FixtureEnvironmentObjectsModifier())
|
|
|
|
}
|
|
|
|
}
|