diff --git a/Shared/Navigation/ContentView.swift b/Shared/Navigation/ContentView.swift index aba7984..6422683 100644 --- a/Shared/Navigation/ContentView.swift +++ b/Shared/Navigation/ContentView.swift @@ -1,24 +1,26 @@ import SwiftUI struct ContentView: View { @EnvironmentObject var model: WriteFreelyModel var body: some View { NavigationView { SidebarView() PostListView(selectedCollection: allPostsCollection) Text("Select a post, or create a new draft.") .foregroundColor(.secondary) } .environmentObject(model) } } struct ContentView_Previews: PreviewProvider { static var previews: some View { - ContentView() - .environmentObject(WriteFreelyModel()) + let model = WriteFreelyModel() + model.collections = CollectionListModel(with: [userCollection1, userCollection2, userCollection3]) + return ContentView() + .environmentObject(model) } } diff --git a/Shared/Navigation/SidebarView.swift b/Shared/Navigation/SidebarView.swift index 41d67d7..a95ee08 100644 --- a/Shared/Navigation/SidebarView.swift +++ b/Shared/Navigation/SidebarView.swift @@ -1,13 +1,16 @@ import SwiftUI struct SidebarView: View { var body: some View { CollectionListView() } } struct SidebarView_Previews: PreviewProvider { static var previews: some View { - SidebarView() + let model = WriteFreelyModel() + model.collections = CollectionListModel(with: [userCollection1, userCollection2, userCollection3]) + return SidebarView() + .environmentObject(model) } } diff --git a/Shared/PostCollection/CollectionListView.swift b/Shared/PostCollection/CollectionListView.swift index ce478fe..1e06865 100644 --- a/Shared/PostCollection/CollectionListView.swift +++ b/Shared/PostCollection/CollectionListView.swift @@ -1,25 +1,28 @@ import SwiftUI struct CollectionListView: View { @EnvironmentObject var model: WriteFreelyModel var body: some View { List { ForEach(model.collections.collectionsList) { collection in NavigationLink( destination: PostListView(selectedCollection: collection) ) { Text(collection.title) } } } .navigationTitle("Collections") .listStyle(SidebarListStyle()) } } struct CollectionSidebar_Previews: PreviewProvider { static var previews: some View { - CollectionListView() + let model = WriteFreelyModel() + model.collections = CollectionListModel(with: [userCollection1, userCollection2, userCollection3]) + return CollectionListView() + .environmentObject(model) } }