mirror of
https://github.com/yattee/yattee.git
synced 2025-08-09 20:24:06 +00:00
Previews environment objects fixtures
This commit is contained in:
@@ -61,5 +61,6 @@ struct ContentView: View {
|
||||
struct ContentView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
ContentView()
|
||||
.injectFixtureEnvironmentObjects()
|
||||
}
|
||||
}
|
||||
|
@@ -186,6 +186,6 @@ struct VideoDetails: View {
|
||||
struct VideoDetails_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
VideoDetails(video: Video.fixture)
|
||||
.environmentObject(SubscriptionsModel())
|
||||
.injectFixtureEnvironmentObjects()
|
||||
}
|
||||
}
|
||||
|
@@ -109,7 +109,7 @@ struct VideoPlayerView_Previews: PreviewProvider {
|
||||
}
|
||||
.sheet(isPresented: .constant(true)) {
|
||||
VideoPlayerView(Video.fixture)
|
||||
.environmentObject(NavigationModel())
|
||||
.injectFixtureEnvironmentObjects()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -171,8 +171,6 @@ struct AddToPlaylistView: View {
|
||||
struct AddToPlaylistView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
AddToPlaylistView(video: Video.fixture)
|
||||
.environmentObject(PlaylistsModel([Playlist.fixture]))
|
||||
.environmentObject(SubscriptionsModel())
|
||||
.environmentObject(NavigationModel())
|
||||
.injectFixtureEnvironmentObjects()
|
||||
}
|
||||
}
|
||||
|
@@ -220,6 +220,6 @@ struct PlaylistsView: View {
|
||||
struct PlaylistsView_Provider: PreviewProvider {
|
||||
static var previews: some View {
|
||||
PlaylistsView()
|
||||
.environmentObject(NavigationModel())
|
||||
.injectFixtureEnvironmentObjects()
|
||||
}
|
||||
}
|
||||
|
@@ -65,11 +65,7 @@ struct SettingsView: View {
|
||||
struct SettingsView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
SettingsView()
|
||||
.environmentObject(InstancesModel())
|
||||
.environmentObject(InvidiousAPI())
|
||||
.environmentObject(NavigationModel())
|
||||
.environmentObject(SearchModel())
|
||||
.environmentObject(SubscriptionsModel())
|
||||
.injectFixtureEnvironmentObjects()
|
||||
#if os(macOS)
|
||||
.frame(width: 600, height: 300)
|
||||
#endif
|
||||
|
@@ -4,7 +4,7 @@ import SwiftUI
|
||||
|
||||
struct TrendingView: View {
|
||||
@StateObject private var store = Store<[Video]>()
|
||||
private var videos: [Video]
|
||||
private var videos = [Video]()
|
||||
|
||||
@Default(.trendingCategory) private var category
|
||||
@Default(.trendingCountry) private var country
|
||||
@@ -149,9 +149,7 @@ struct TrendingView: View {
|
||||
|
||||
struct TrendingView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
TrendingView(Video.allFixtures + Video.allFixtures + Video.allFixtures)
|
||||
.environmentObject(InvidiousAPI())
|
||||
.environmentObject(NavigationModel())
|
||||
.environmentObject(SubscriptionsModel())
|
||||
TrendingView(Video.allFixtures)
|
||||
.injectFixtureEnvironmentObjects()
|
||||
}
|
||||
}
|
||||
|
@@ -60,7 +60,6 @@ struct VideosCellsHorizontal: View {
|
||||
struct VideoCellsHorizontal_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
VideosCellsHorizontal(videos: Video.allFixtures)
|
||||
.environmentObject(NavigationModel())
|
||||
.environmentObject(SubscriptionsModel())
|
||||
.injectFixtureEnvironmentObjects()
|
||||
}
|
||||
}
|
||||
|
@@ -75,7 +75,6 @@ struct VideosCellsVertical: View {
|
||||
struct VideoCellsVertical_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
VideosCellsVertical(videos: Video.allFixtures)
|
||||
.frame(minWidth: 1000)
|
||||
.environmentObject(NavigationModel())
|
||||
.injectFixtureEnvironmentObjects()
|
||||
}
|
||||
}
|
||||
|
@@ -20,8 +20,11 @@ struct SearchView: View {
|
||||
@EnvironmentObject<RecentsModel> private var recents
|
||||
@EnvironmentObject<SearchModel> private var state
|
||||
|
||||
init(_ query: SearchQuery? = nil) {
|
||||
private var videos = [Video]()
|
||||
|
||||
init(_ query: SearchQuery? = nil, videos: [Video] = [Video]()) {
|
||||
self.query = query
|
||||
self.videos = videos
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
@@ -82,6 +85,10 @@ struct SearchView: View {
|
||||
state.queryText = query!.query
|
||||
state.resetQuery(query!)
|
||||
}
|
||||
|
||||
if !videos.isEmpty {
|
||||
state.store.replace(videos)
|
||||
}
|
||||
}
|
||||
.searchable(text: $state.queryText, placement: searchFieldPlacement) {
|
||||
ForEach(state.querySuggestions.collection, id: \.self) { suggestion in
|
||||
@@ -269,7 +276,7 @@ struct SearchView: View {
|
||||
|
||||
var searchDurationButton: some View {
|
||||
Button(action: { self.searchDuration = self.searchDuration.next() }) {
|
||||
Text(self.searchDate.name)
|
||||
Text(self.searchDuration.name)
|
||||
.font(.system(size: 30))
|
||||
.padding(.horizontal)
|
||||
.padding(.vertical, 2)
|
||||
@@ -334,10 +341,8 @@ struct SearchView: View {
|
||||
struct SearchView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
NavigationView {
|
||||
SearchView(SearchQuery(query: "Is Google Evil"))
|
||||
.environmentObject(NavigationModel())
|
||||
.environmentObject(SearchModel())
|
||||
.environmentObject(SubscriptionsModel())
|
||||
SearchView(SearchQuery(query: "Is Google Evil"), videos: Video.fixtures(30))
|
||||
.injectFixtureEnvironmentObjects()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -44,9 +44,11 @@ struct SignInRequiredView<Content: View>: View {
|
||||
.font(.title3)
|
||||
.padding(.vertical)
|
||||
|
||||
if instances.isEmpty {
|
||||
openSettingsButton
|
||||
}
|
||||
#if !os(tvOS)
|
||||
if instances.isEmpty {
|
||||
openSettingsButton
|
||||
}
|
||||
#endif
|
||||
|
||||
#if os(tvOS)
|
||||
openSettingsButton
|
||||
@@ -73,5 +75,6 @@ struct SignInRequiredView_Previews: PreviewProvider {
|
||||
SignInRequiredView(title: "Subscriptions") {
|
||||
Text("Only when signed in")
|
||||
}
|
||||
.environmentObject(InvidiousAPI())
|
||||
}
|
||||
}
|
||||
|
@@ -40,7 +40,6 @@ struct WatchNowView: View {
|
||||
struct WatchNowView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
WatchNowView()
|
||||
.environmentObject(SubscriptionsModel())
|
||||
.environmentObject(NavigationModel())
|
||||
.injectFixtureEnvironmentObjects()
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user