Page Menu
Home
Musing Studio
Search
Configure Global Search
Log In
Files
F13831428
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
View Options
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
Details
Attached
Mime Type
text/x-diff
Expires
Fri, Feb 20, 9:02 AM (22 h, 3 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3633930
Attached To
rWFSUI WriteFreely SwiftUI
Event Timeline
Log In to Comment