Page MenuHomeMusing Studio

CollectionPicker.swift
No OneTemporary

CollectionPicker.swift

import SwiftUI
struct CollectionSidebar: View {
@EnvironmentObject var postStore: PostStore
@Binding var selectedCollection: PostCollection?
private let collections = [
allPostsCollection,
defaultDraftCollection,
testPostCollection1,
testPostCollection2,
testPostCollection3
]
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
}
}
}
}

File Metadata

Mime Type
text/x-c
Expires
Fri, Oct 10, 12:29 AM (1 d, 7 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3428435

Event Timeline