yattee/Fixtures/View+Fixtures.swift

32 lines
844 B
Swift
Raw Normal View History

2021-09-29 11:45:00 +00:00
import Foundation
import SwiftUI
struct FixtureEnvironmentObjectsModifier: ViewModifier {
func body(content: Content) -> some View {
content
.environmentObject(InstancesModel())
2021-09-29 12:36:52 +00:00
.environmentObject(api)
2021-09-29 11:45:00 +00:00
.environmentObject(NavigationModel())
.environmentObject(PlaybackModel())
.environmentObject(PlaylistsModel())
.environmentObject(RecentsModel())
.environmentObject(SearchModel())
2021-09-29 12:36:52 +00:00
.environmentObject(SubscriptionsModel(api: api))
}
private var api: InvidiousAPI {
let api = InvidiousAPI()
api.validInstance = true
api.signedIn = true
return api
2021-09-29 11:45:00 +00:00
}
}
extension View {
func injectFixtureEnvironmentObjects() -> some View {
modifier(FixtureEnvironmentObjectsModifier())
}
}