Move showPosts function from ContentView to PostList

This commit is contained in:
Angelo Stavrow 2020-08-07 09:54:22 -04:00
parent fce0c380d2
commit 51275bc747
No known key found for this signature in database
GPG Key ID: 1A49C7064E060EEE
2 changed files with 10 additions and 10 deletions

View File

@ -18,16 +18,6 @@ struct ContentView: View {
}
.environmentObject(postStore)
}
func showPosts(for collection: PostCollection) -> [Post] {
if collection == allPostsCollection {
return postStore.posts
} else {
return postStore.posts.filter {
$0.collection.title == collection.title
}
}
}
}
struct ContentView_Previews: PreviewProvider {

View File

@ -31,6 +31,16 @@ struct PostList: View {
return "\(posts.count) posts"
}
}
private func showPosts(for collection: PostCollection) -> [Post] {
if collection == allPostsCollection {
return postStore.posts
} else {
return postStore.posts.filter {
$0.collection.title == collection.title
}
}
}
}
struct PostList_Previews: PreviewProvider {