diff --git a/Shared/PostCollection/CollectionSidebar.swift b/Shared/PostCollection/CollectionSidebar.swift index 37d64ee..4cba6db 100644 --- a/Shared/PostCollection/CollectionSidebar.swift +++ b/Shared/PostCollection/CollectionSidebar.swift @@ -1,36 +1,30 @@ import SwiftUI struct CollectionSidebar: View { @EnvironmentObject var postStore: PostStore @Binding var selectedCollection: PostCollection? - private let collections = [ - allPostsCollection, - defaultDraftCollection, - testPostCollection1, - testPostCollection2, - testPostCollection3 - ] + private let collections = postCollections var body: some View { List { ForEach(collections) { collection in NavigationLink( destination: PostList(title: collection.title, posts: showPosts(for: collection)).tag(collection)) { Text(collection.title) } } } .listStyle(SidebarListStyle()) } func showPosts(for collection: PostCollection) -> [Post] { if collection == allPostsCollection { return postStore.posts } else { return postStore.posts.filter { $0.collection.title == collection.title } } } } diff --git a/Shared/PostCollection/PostCollection.swift b/Shared/PostCollection/PostCollection.swift index 0b2b57c..a55b395 100644 --- a/Shared/PostCollection/PostCollection.swift +++ b/Shared/PostCollection/PostCollection.swift @@ -1,12 +1,22 @@ import Foundation struct PostCollection: Identifiable, Hashable { let id = UUID() let title: String } let allPostsCollection = PostCollection(title: "All Posts") let defaultDraftCollection = PostCollection(title: "Drafts") -let testPostCollection1 = PostCollection(title: "Collection 1") -let testPostCollection2 = PostCollection(title: "Collection 2") -let testPostCollection3 = PostCollection(title: "Collection 3") +let userCollections = [ + PostCollection(title: "Collection 1"), + PostCollection(title: "Collection 2"), + PostCollection(title: "Collection 3") +] + +let postCollections = [ + allPostsCollection, + defaultDraftCollection, + userCollections[0], + userCollections[1], + userCollections[2] +]