mirror of
https://github.com/writeas/writefreely-swiftui-multiplatform.git
synced 2024-11-15 01:11:02 +00:00
Move showPosts function from ContentView to PostList
This commit is contained in:
parent
fce0c380d2
commit
51275bc747
@ -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 {
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user