Page Menu
Home
Musing Studio
Search
Configure Global Search
Log In
Files
F10669165
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Subscribers
None
View Options
diff --git a/Shared/PostList/PostStatusBadgeView.swift b/Shared/PostList/PostStatusBadgeView.swift
index 07696c2..ffecd2c 100644
--- a/Shared/PostList/PostStatusBadgeView.swift
+++ b/Shared/PostList/PostStatusBadgeView.swift
@@ -1,70 +1,71 @@
import SwiftUI
struct PostStatusBadgeView: View {
@ObservedObject var post: WFAPost
var body: some View {
let (badgeLabel, badgeColor) = setupBadgeProperties(for: PostStatus(rawValue: post.status)!)
Text(badgeLabel)
.font(.caption)
.fontWeight(.semibold)
.foregroundColor(.white)
.textCase(.uppercase)
.lineLimit(1)
.padding(EdgeInsets(top: 2.5, leading: 7.5, bottom: 2.5, trailing: 7.5))
.background(badgeColor)
.clipShape(RoundedRectangle(cornerRadius: 5.0, style: .circular))
+ .frame(width: .infinity)
}
func setupBadgeProperties(for status: PostStatus) -> (String, Color) {
var badgeLabel: String
var badgeColor: Color
switch status {
case .local:
badgeLabel = "local"
badgeColor = Color(red: 0.75, green: 0.5, blue: 0.85, opacity: 1.0)
case .edited:
badgeLabel = "edited"
badgeColor = Color(red: 0.75, green: 0.7, blue: 0.1, opacity: 1.0)
case .published:
badgeLabel = "published"
badgeColor = .gray
}
return (badgeLabel, badgeColor)
}
}
struct PostStatusBadge_LocalDraftPreviews: PreviewProvider {
static var previews: some View {
let context = LocalStorageManager.standard.container.viewContext
let testPost = WFAPost(context: context)
testPost.status = PostStatus.local.rawValue
return PostStatusBadgeView(post: testPost)
.environment(\.managedObjectContext, context)
}
}
struct PostStatusBadge_EditedPreviews: PreviewProvider {
static var previews: some View {
let context = LocalStorageManager.standard.container.viewContext
let testPost = WFAPost(context: context)
testPost.status = PostStatus.edited.rawValue
return PostStatusBadgeView(post: testPost)
.environment(\.managedObjectContext, context)
}
}
struct PostStatusBadge_PublishedPreviews: PreviewProvider {
static var previews: some View {
let context = LocalStorageManager.standard.container.viewContext
let testPost = WFAPost(context: context)
testPost.status = PostStatus.published.rawValue
return PostStatusBadgeView(post: testPost)
.environment(\.managedObjectContext, context)
}
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Thu, May 15, 5:47 PM (1 d, 11 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3239847
Attached To
rWFSUI WriteFreely SwiftUI
Event Timeline
Log In to Comment