2021-09-29 11:45:00 +00:00
|
|
|
import Foundation
|
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct FixtureEnvironmentObjectsModifier: ViewModifier {
|
|
|
|
func body(content: Content) -> some View {
|
|
|
|
content
|
2021-10-17 23:06:00 +00:00
|
|
|
.environmentObject(AccountsModel())
|
2022-06-24 23:39:29 +00:00
|
|
|
.environmentObject(comments)
|
2021-09-29 11:45:00 +00:00
|
|
|
.environmentObject(InstancesModel())
|
2021-10-17 23:06:00 +00:00
|
|
|
.environmentObject(invidious)
|
2021-09-29 11:45:00 +00:00
|
|
|
.environmentObject(NavigationModel())
|
2022-06-18 12:39:49 +00:00
|
|
|
.environmentObject(NetworkStateModel())
|
2021-10-17 23:06:00 +00:00
|
|
|
.environmentObject(PipedAPI())
|
2021-10-05 20:20:09 +00:00
|
|
|
.environmentObject(player)
|
2022-06-18 12:39:49 +00:00
|
|
|
.environmentObject(playerControls)
|
|
|
|
.environmentObject(PlayerTimeModel())
|
2021-09-29 11:45:00 +00:00
|
|
|
.environmentObject(PlaylistsModel())
|
|
|
|
.environmentObject(RecentsModel())
|
|
|
|
.environmentObject(SearchModel())
|
2021-10-05 20:20:09 +00:00
|
|
|
.environmentObject(subscriptions)
|
2021-11-01 21:56:18 +00:00
|
|
|
.environmentObject(ThumbnailsModel())
|
2021-09-29 12:36:52 +00:00
|
|
|
}
|
|
|
|
|
2022-06-24 23:39:29 +00:00
|
|
|
private var comments: CommentsModel {
|
|
|
|
let comments = CommentsModel()
|
|
|
|
comments.loaded = true
|
|
|
|
comments.all = [.fixture]
|
|
|
|
|
|
|
|
return comments
|
|
|
|
}
|
|
|
|
|
2021-10-17 23:06:00 +00:00
|
|
|
private var invidious: InvidiousAPI {
|
2021-09-29 12:36:52 +00:00
|
|
|
let api = InvidiousAPI()
|
|
|
|
|
|
|
|
api.validInstance = true
|
|
|
|
api.signedIn = true
|
|
|
|
|
|
|
|
return api
|
2021-09-29 11:45:00 +00:00
|
|
|
}
|
2021-10-05 20:20:09 +00:00
|
|
|
|
|
|
|
private var player: PlayerModel {
|
|
|
|
let player = PlayerModel()
|
|
|
|
|
|
|
|
player.currentItem = PlayerQueueItem(Video.fixture)
|
|
|
|
player.queue = Video.allFixtures.map { PlayerQueueItem($0) }
|
|
|
|
|
|
|
|
return player
|
|
|
|
}
|
|
|
|
|
2022-06-18 12:39:49 +00:00
|
|
|
private var playerControls: PlayerControlsModel {
|
|
|
|
PlayerControlsModel(presentingControls: true, player: player)
|
|
|
|
}
|
|
|
|
|
2021-10-05 20:20:09 +00:00
|
|
|
private var subscriptions: SubscriptionsModel {
|
|
|
|
let subscriptions = SubscriptionsModel()
|
|
|
|
|
|
|
|
subscriptions.channels = Video.allFixtures.map { $0.channel }
|
|
|
|
|
|
|
|
return subscriptions
|
|
|
|
}
|
2021-09-29 11:45:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
extension View {
|
|
|
|
func injectFixtureEnvironmentObjects() -> some View {
|
|
|
|
modifier(FixtureEnvironmentObjectsModifier())
|
|
|
|
}
|
|
|
|
}
|