Page MenuHomeMusing Studio

No OneTemporary

diff --git a/Shared/Post/PostList.swift b/Shared/Post/PostList.swift
index a9cf72e..eabcad9 100644
--- a/Shared/Post/PostList.swift
+++ b/Shared/Post/PostList.swift
@@ -1,25 +1,33 @@
import SwiftUI
struct PostList: View {
@EnvironmentObject var postStore: PostStore
var title: String
var posts: [Post]
var body: some View {
List {
- Text("\(posts.count) Posts")
+ Text(pluralizedPostCount(for: posts))
.foregroundColor(.secondary)
ForEach(posts) { post in
PostCell(post: post)
}
}
.navigationTitle(title)
}
+
+ func pluralizedPostCount(for posts: [Post]) -> String {
+ if posts.count == 1 {
+ return "1 post"
+ } else {
+ return "\(posts.count) posts"
+ }
+ }
}
struct PostList_Previews: PreviewProvider {
static var previews: some View {
PostList(title: "Posts", posts: testPostData)
.environmentObject(testPostStore)
}
}

File Metadata

Mime Type
text/x-diff
Expires
Wed, Dec 2, 12:54 PM (1 d, 21 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3831898

Event Timeline