diff --git a/Shared/Navigation/ContentView.swift b/Shared/Navigation/ContentView.swift index 88e9cf6..722c695 100644 --- a/Shared/Navigation/ContentView.swift +++ b/Shared/Navigation/ContentView.swift @@ -1,38 +1,28 @@ import SwiftUI struct ContentView: View { @EnvironmentObject var model: WriteFreelyModel var body: some View { NavigationView { SidebarView() PostListView(selectedCollection: nil, showAllPosts: true) Text("Select a post, or create a new local draft.") .foregroundColor(.secondary) } .environmentObject(model) } } -//struct ContentView_Previews: PreviewProvider { -// static var previews: some View { -// let userCollection1 = WFACollection(context: PersistenceManager.persistentContainer.viewContext) -// let userCollection2 = WFACollection(context: PersistenceManager.persistentContainer.viewContext) -// let userCollection3 = WFACollection(context: PersistenceManager.persistentContainer.viewContext) -// userCollection1.title = "Collection 1" -// userCollection2.title = "Collection 2" -// userCollection3.title = "Collection 3" -// -// let model = WriteFreelyModel() -// model.collections = CollectionListModel() -// -// for post in testPostData { -// model.store.add(post) -// } -// return ContentView() -// .environmentObject(model) -// .environment(\.managedObjectContext, PersistenceManager.persistentContainer.viewContext) -// } -//} +struct ContentView_Previews: PreviewProvider { + static var previews: some View { + let context = PersistenceManager.persistentContainer.viewContext + let model = WriteFreelyModel() + + return ContentView() + .environment(\.managedObjectContext, context) + .environmentObject(model) + } +} diff --git a/Shared/Navigation/SidebarView.swift b/Shared/Navigation/SidebarView.swift index 7175fa4..74be4ca 100644 --- a/Shared/Navigation/SidebarView.swift +++ b/Shared/Navigation/SidebarView.swift @@ -1,25 +1,18 @@ import SwiftUI struct SidebarView: View { var body: some View { CollectionListView() } } struct SidebarView_Previews: PreviewProvider { static var previews: some View { - let userCollection1 = WFACollection(context: PersistenceManager.persistentContainer.viewContext) - let userCollection2 = WFACollection(context: PersistenceManager.persistentContainer.viewContext) - let userCollection3 = WFACollection(context: PersistenceManager.persistentContainer.viewContext) - userCollection1.title = "Collection 1" - userCollection2.title = "Collection 2" - userCollection3.title = "Collection 3" - + let context = PersistenceManager.persistentContainer.viewContext let model = WriteFreelyModel() - model.collections = CollectionListModel() return SidebarView() + .environment(\.managedObjectContext, context) .environmentObject(model) - .environment(\.managedObjectContext, PersistenceManager.persistentContainer.viewContext) } } diff --git a/Shared/PostCollection/CollectionListView.swift b/Shared/PostCollection/CollectionListView.swift index 9606fcc..32afa9f 100644 --- a/Shared/PostCollection/CollectionListView.swift +++ b/Shared/PostCollection/CollectionListView.swift @@ -1,53 +1,44 @@ import SwiftUI struct CollectionListView: View { @EnvironmentObject var model: WriteFreelyModel @Environment(\.managedObjectContext) var moc @FetchRequest( entity: WFACollection.entity(), sortDescriptors: [NSSortDescriptor(keyPath: \WFACollection.title, ascending: true)] ) var collections: FetchedResults var body: some View { List { NavigationLink(destination: PostListView(selectedCollection: nil, showAllPosts: true)) { Text("All Posts") } NavigationLink(destination: PostListView(selectedCollection: nil, showAllPosts: false)) { Text(model.account.server == "https://write.as" ? "Anonymous" : "Drafts") } Section(header: Text("Your Blogs")) { ForEach(collections, id: \.alias) { collection in NavigationLink( destination: PostListView(selectedCollection: collection, showAllPosts: false) ) { Text(collection.title) } } } } .navigationTitle("Collections") .listStyle(SidebarListStyle()) } } -struct CollectionSidebar_Previews: PreviewProvider { - @Environment(\.managedObjectContext) var moc - +struct CollectionListView_Previews: PreviewProvider { static var previews: some View { - let userCollection1 = WFACollection(context: PersistenceManager.persistentContainer.viewContext) - let userCollection2 = WFACollection(context: PersistenceManager.persistentContainer.viewContext) - let userCollection3 = WFACollection(context: PersistenceManager.persistentContainer.viewContext) - userCollection1.title = "Collection 1" - userCollection2.title = "Collection 2" - userCollection3.title = "Collection 3" - + let context = PersistenceManager.persistentContainer.viewContext let model = WriteFreelyModel() - model.collections = CollectionListModel() return CollectionListView() + .environment(\.managedObjectContext, context) .environmentObject(model) - .environment(\.managedObjectContext, PersistenceManager.persistentContainer.viewContext) } } diff --git a/Shared/PostEditor/PostEditorStatusToolbarView.swift b/Shared/PostEditor/PostEditorStatusToolbarView.swift index 85c5e65..4763012 100644 --- a/Shared/PostEditor/PostEditorStatusToolbarView.swift +++ b/Shared/PostEditor/PostEditorStatusToolbarView.swift @@ -1,136 +1,87 @@ import SwiftUI struct PostEditorStatusToolbarView: View { #if os(iOS) @Environment(\.horizontalSizeClass) var horizontalSizeClass #endif @EnvironmentObject var model: WriteFreelyModel @ObservedObject var post: WFAPost var body: some View { if post.hasNewerRemoteCopy { #if os(iOS) if horizontalSizeClass == .compact { VStack { PostStatusBadgeView(post: post) HStack { Text("⚠️ Newer copy on server. Replace local copy?") .font(.caption) .foregroundColor(.secondary) Button(action: { model.updateFromServer(post: post) }, label: { Image(systemName: "square.and.arrow.down") }) } .padding(.bottom) } .padding(.top) } else { HStack { PostStatusBadgeView(post: post) .padding(.trailing) Text("⚠️ Newer copy on server. Replace local copy?") .font(.callout) .foregroundColor(.secondary) Button(action: { model.updateFromServer(post: post) }, label: { Image(systemName: "square.and.arrow.down") }) } } #else HStack { PostStatusBadgeView(post: post) .padding(.trailing) Text("⚠️ Newer copy on server. Replace local copy?") .font(.callout) .foregroundColor(.secondary) Button(action: { model.updateFromServer(post: post) }, label: { Image(systemName: "square.and.arrow.down") }) } #endif } else { PostStatusBadgeView(post: post) } } } -//#if DEBUG -//let testPost = Post( -// title: "Test Post Title", -// body: """ -// Here's some cool sample body text. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ultrices \ -// posuere dignissim. Vestibulum a libero tempor, lacinia nulla vitae, congue purus. Nunc ac nulla quam. Duis \ -// tincidunt eros augue, et volutpat tortor pulvinar ut. Nullam sit amet maximus urna. Phasellus non dignissim \ -// lacus. Nulla ac posuere ex. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus \ -// mus. Donec non molestie mauris. Suspendisse potenti. Vivamus at erat turpis. -// -// Pellentesque porttitor gravida tincidunt. Sed vitae eros non metus aliquam hendrerit. Aliquam sed risus suscipit \ -// turpis dictum dictum. Duis lacus lectus, dictum vel felis in, rhoncus fringilla felis. Nunc id dolor nisl. \ -// Aliquam euismod purus elit. Nullam egestas neque leo, sed aliquet ligula ultrices nec. -// """, -// createdDate: Date() -//) -//#endif -// -//struct ToolbarView_LocalPreviews: PreviewProvider { -// static var previews: some View { -// let model = WriteFreelyModel() -// let post = testPost -// return PostEditorStatusToolbarView(post: post) -// .environmentObject(model) -// } -//} -// -//struct ToolbarView_RemotePreviews: PreviewProvider { -// static var previews: some View { -// let model = WriteFreelyModel() -// let newerRemotePost = Post( -// title: testPost.wfPost.title ?? "", -// body: testPost.wfPost.body, -// createdDate: testPost.wfPost.createdDate ?? Date(), -// status: testPost.status, -// collection: testPost.collection -// ) -// newerRemotePost.hasNewerRemoteCopy = true -// return PostEditorStatusToolbarView(post: newerRemotePost) -// .environmentObject(model) -// } -//} -// -//#if os(iOS) -//struct ToolbarView_CompactLocalPreviews: PreviewProvider { -// static var previews: some View { -// let model = WriteFreelyModel() -// let post = testPost -// return PostEditorStatusToolbarView(post: post) -// .environmentObject(model) -// .environment(\.horizontalSizeClass, .compact) -// } -//} -//#endif -// -//#if os(iOS) -//struct ToolbarView_CompactRemotePreviews: PreviewProvider { -// static var previews: some View { -// let model = WriteFreelyModel() -// let newerRemotePost = Post( -// title: testPost.wfPost.title ?? "", -// body: testPost.wfPost.body, -// createdDate: testPost.wfPost.createdDate ?? Date(), -// status: testPost.status, -// collection: testPost.collection -// ) -// newerRemotePost.hasNewerRemoteCopy = true -// return PostEditorStatusToolbarView(post: newerRemotePost) -// .environmentObject(model) -// .environment(\.horizontalSizeClass, .compact) -// } -//} -//#endif +struct PESTView_StandardPreviews: PreviewProvider { + static var previews: some View { + let context = PersistenceManager.persistentContainer.viewContext + let model = WriteFreelyModel() + let testPost = WFAPost(context: context) + testPost.status = PostStatus.published.rawValue + + return PostEditorStatusToolbarView(post: testPost) + .environmentObject(model) + } +} + +struct PESTView_OutdatedLocalCopyPreviews: PreviewProvider { + static var previews: some View { + let context = PersistenceManager.persistentContainer.viewContext + let model = WriteFreelyModel() + let testPost = WFAPost(context: context) + testPost.status = PostStatus.published.rawValue + testPost.hasNewerRemoteCopy = true + + return PostEditorStatusToolbarView(post: testPost) + .environmentObject(model) + } +} diff --git a/Shared/PostEditor/PostEditorView.swift b/Shared/PostEditor/PostEditorView.swift index 983aa54..671192a 100644 --- a/Shared/PostEditor/PostEditorView.swift +++ b/Shared/PostEditor/PostEditorView.swift @@ -1,82 +1,69 @@ import SwiftUI struct PostEditorView: View { @EnvironmentObject var model: WriteFreelyModel @ObservedObject var post: WFAPost var body: some View { VStack { TextEditor(text: $post.title) .font(.title) .frame(height: 100) .onChange(of: post.title) { _ in if post.status == PostStatus.published.rawValue { post.status = PostStatus.edited.rawValue } } TextEditor(text: $post.body) .font(.body) .onChange(of: post.body) { _ in if post.status == PostStatus.published.rawValue { post.status = PostStatus.edited.rawValue } } } .padding() .toolbar { ToolbarItem(placement: .status) { PostEditorStatusToolbarView(post: post) } ToolbarItem(placement: .primaryAction) { Button(action: { model.publish(post: post) post.status = PostStatus.published.rawValue }, label: { Image(systemName: "paperplane") }) } } .onChange(of: post.hasNewerRemoteCopy, perform: { _ in if post.status == PostStatus.edited.rawValue && !post.hasNewerRemoteCopy { post.status = PostStatus.published.rawValue } }) .onDisappear(perform: { if post.status == PostStatus.edited.rawValue { DispatchQueue.main.async { PersistenceManager().saveContext() } } }) } } -//struct PostEditorView_NewLocalDraftPreviews: PreviewProvider { -// static var previews: some View { -// PostEditorView(post: Post()) -// .environmentObject(WriteFreelyModel()) -// } -//} -// -//struct PostEditorView_NewerLocalPostPreviews: PreviewProvider { -// static var previews: some View { -// return PostEditorView(post: testPost) -// .environmentObject(WriteFreelyModel()) -// } -//} -// -//struct PostEditorView_NewerRemotePostPreviews: PreviewProvider { -// static var previews: some View { -// let newerRemotePost = Post( -// title: testPost.wfPost.title ?? "", -// body: testPost.wfPost.body, -// createdDate: testPost.wfPost.createdDate ?? Date(), -// status: testPost.status, -// collection: testPost.collection -// ) -// newerRemotePost.hasNewerRemoteCopy = true -// return PostEditorView(post: newerRemotePost) -// .environmentObject(WriteFreelyModel()) -// } -//} +struct PostEditorView_Previews: PreviewProvider { + static var previews: some View { + let context = PersistenceManager.persistentContainer.viewContext + let testPost = WFAPost(context: context) + testPost.title = "Test Post Title" + testPost.body = "Here's some cool sample body text." + testPost.createdDate = Date() + + let model = WriteFreelyModel() + + return PostEditorView(post: testPost) + .environment(\.managedObjectContext, context) + .environmentObject(model) + } +} diff --git a/Shared/PostList/PostCellView.swift b/Shared/PostList/PostCellView.swift index 3f65070..8738101 100644 --- a/Shared/PostList/PostCellView.swift +++ b/Shared/PostList/PostCellView.swift @@ -1,40 +1,42 @@ import SwiftUI struct PostCellView: View { @ObservedObject var post: WFAPost var body: some View { HStack { VStack(alignment: .leading) { Text(post.title) .font(.headline) .lineLimit(1) Text(buildDateString(from: post.createdDate ?? Date())) .font(.caption) .lineLimit(1) } Spacer() PostStatusBadgeView(post: post) } .padding(5) } func buildDateString(from date: Date) -> String { let dateFormatter = DateFormatter() dateFormatter.dateStyle = .long dateFormatter.timeStyle = .short return dateFormatter.string(from: date) } } -//struct PostCell_Previews: PreviewProvider { -// static var previews: some View { -// let testPost = Post( -// title: "Test Post Title", -// body: "Here's some cool sample body text.", -// createdDate: Date() -// ) -// return PostCellView(post: testPost) -// } -//} +struct PostCell_Previews: PreviewProvider { + static var previews: some View { + let context = PersistenceManager.persistentContainer.viewContext + let testPost = WFAPost(context: context) + testPost.title = "Test Post Title" + testPost.body = "Here's some cool sample body text." + testPost.createdDate = Date() + + return PostCellView(post: testPost) + .environment(\.managedObjectContext, context) + } +} diff --git a/Shared/PostList/PostListFilteredView.swift b/Shared/PostList/PostListFilteredView.swift index 474b2f0..35e84a7 100644 --- a/Shared/PostList/PostListFilteredView.swift +++ b/Shared/PostList/PostListFilteredView.swift @@ -1,36 +1,45 @@ import SwiftUI struct PostListFilteredView: View { var fetchRequest: FetchRequest init(filter: String?, showAllPosts: Bool) { if showAllPosts { fetchRequest = FetchRequest( entity: WFAPost.entity(), sortDescriptors: [NSSortDescriptor(key: "createdDate", ascending: false)] ) } else { if let filter = filter { fetchRequest = FetchRequest( entity: WFAPost.entity(), sortDescriptors: [NSSortDescriptor(key: "createdDate", ascending: false)], predicate: NSPredicate(format: "collectionAlias == %@", filter) ) } else { fetchRequest = FetchRequest( entity: WFAPost.entity(), sortDescriptors: [NSSortDescriptor(key: "createdDate", ascending: false)], predicate: NSPredicate(format: "collectionAlias == nil") ) } } } var body: some View { List(fetchRequest.wrappedValue, id: \.self) { post in NavigationLink(destination: PostEditorView(post: post)) { PostCellView(post: post) } } } } + +struct PostListFilteredView_Previews: PreviewProvider { + static var previews: some View { + let context = PersistenceManager.persistentContainer.viewContext + + return PostListFilteredView(filter: nil, showAllPosts: false) + .environment(\.managedObjectContext, context) + } +} diff --git a/Shared/PostList/PostListView.swift b/Shared/PostList/PostListView.swift index 8f731b6..42d649b 100644 --- a/Shared/PostList/PostListView.swift +++ b/Shared/PostList/PostListView.swift @@ -1,186 +1,136 @@ import SwiftUI struct PostListView: View { @EnvironmentObject var model: WriteFreelyModel @Environment(\.managedObjectContext) var moc @State var selectedCollection: WFACollection? @State var showAllPosts: Bool = false #if os(iOS) @State private var isPresentingSettings = false #endif var body: some View { #if os(iOS) GeometryReader { geometry in PostListFilteredView(filter: selectedCollection?.alias, showAllPosts: showAllPosts) .navigationTitle( showAllPosts ? "All Posts" : selectedCollection?.title ?? ( model.account.server == "https://write.as" ? "Anonymous" : "Drafts" ) ) .toolbar { ToolbarItem(placement: .primaryAction) { Button(action: { createNewLocalDraft() }, label: { Image(systemName: "square.and.pencil") }) } ToolbarItem(placement: .bottomBar) { HStack { Button(action: { isPresentingSettings = true }, label: { Image(systemName: "gear") }).sheet( isPresented: $isPresentingSettings, onDismiss: { isPresentingSettings = false }, content: { SettingsView(isPresented: $isPresentingSettings) } ) .padding(.leading) Spacer() Text(pluralizedPostCount(for: showPosts(for: selectedCollection))) .foregroundColor(.secondary) Spacer() Button(action: { reloadFromServer() }, label: { Image(systemName: "arrow.clockwise") }) .disabled(!model.account.isLoggedIn) } .padding() .frame(width: geometry.size.width) } } } #else //if os(macOS) PostListFilteredView(filter: selectedCollection?.alias, showAllPosts: showAllPosts) .navigationTitle( showAllPosts ? "All Posts" : selectedCollection?.title ?? ( model.account.server == "https://write.as" ? "Anonymous" : "Drafts" ) ) .navigationSubtitle(pluralizedPostCount(for: showPosts(for: selectedCollection))) .toolbar { Button(action: { createNewLocalDraft() }, label: { Image(systemName: "square.and.pencil") }) Button(action: { reloadFromServer() }, label: { Image(systemName: "arrow.clockwise") }) .disabled(!model.account.isLoggedIn) } #endif } private func pluralizedPostCount(for posts: [WFAPost]) -> String { if posts.count == 1 { return "1 post" } else { return "\(posts.count) posts" } } private func showPosts(for collection: WFACollection?) -> [WFAPost] { if showAllPosts { return model.posts.userPosts } else { if let selectedCollection = collection { return model.posts.userPosts.filter { $0.collectionAlias == selectedCollection.alias } } else { return model.posts.userPosts.filter { $0.collectionAlias == nil } } } } private func reloadFromServer() { DispatchQueue.main.async { model.collections.clearUserCollection() model.fetchUserCollections() model.fetchUserPosts() } } private func createNewLocalDraft() { let managedPost = WFAPost(context: PersistenceManager.persistentContainer.viewContext) managedPost.createdDate = Date() managedPost.title = "" managedPost.body = "" managedPost.status = PostStatus.local.rawValue DispatchQueue.main.async { PersistenceManager().saveContext() } } } -//struct PostList_Previews: PreviewProvider { -// static var previews: some View { -// let userCollection1 = WFACollection(context: PersistenceManager.persistentContainer.viewContext) -// let userCollection2 = WFACollection(context: PersistenceManager.persistentContainer.viewContext) -// let userCollection3 = WFACollection(context: PersistenceManager.persistentContainer.viewContext) -// -// userCollection1.title = "Collection 1" -// userCollection2.title = "Collection 2" -// userCollection3.title = "Collection 3" -// -// let testPostData = [ -// Post( -// title: "My First Post", -// body: "Look at me, creating a first post! That's cool.", -// createdDate: Date(timeIntervalSince1970: 1595429452), -// status: .published, -// collection: userCollection1 -// ), -// Post( -// title: "Post 2: The Quickening", -// body: "See, here's the rule about Highlander jokes: _there can be only one_.", -// createdDate: Date(timeIntervalSince1970: 1595514125), -// status: .edited, -// collection: userCollection1 -// ), -// Post( -// title: "The Post Revolutions", -// body: "I can never keep the Matrix movie order straight. Why not just call them part 2 and part 3?", -// createdDate: Date(timeIntervalSince1970: 1595600006) -// ), -// Post( -// title: "Episode IV: A New Post", -// body: "How many movies does this person watch? How many movie-title jokes will they make?", -// createdDate: Date(timeIntervalSince1970: 1596219877), -// status: .published, -// collection: userCollection2 -// ), -// Post( -// title: "Fast (Post) Five", -// body: "Look, it was either a Fast and the Furious reference, or a Resident Evil reference." -// ), -// Post( -// title: "Post: The Final Chapter", -// body: "And there you have it, a Resident Evil movie reference.", -// createdDate: Date(timeIntervalSince1970: 1596043684), -// status: .edited, -// collection: userCollection3 -// ) -// ] -// -// let model = WriteFreelyModel() -// for post in testPostData { -// model.store.add(post) -// } -// return Group { -// PostListView(selectedCollection: userCollection1) -// .environmentObject(model) -// } -// } -//} +struct PostListView_Previews: PreviewProvider { + static var previews: some View { + let context = PersistenceManager.persistentContainer.viewContext + let model = WriteFreelyModel() + + return PostListView() + .environment(\.managedObjectContext, context) + .environmentObject(model) + } +} diff --git a/Shared/PostList/PostStatusBadgeView.swift b/Shared/PostList/PostStatusBadgeView.swift index 6681ced..e17cce6 100644 --- a/Shared/PostList/PostStatusBadgeView.swift +++ b/Shared/PostList/PostStatusBadgeView.swift @@ -1,103 +1,70 @@ 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)) } 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) } } -//#if DEBUG -//let userCollection1 = WFACollection(context: PersistenceManager.persistentContainer.viewContext) -//let userCollection2 = WFACollection(context: PersistenceManager.persistentContainer.viewContext) -//let userCollection3 = WFACollection(context: PersistenceManager.persistentContainer.viewContext) -// -//let testPostData = [ -// Post( -// title: "My First Post", -// body: "Look at me, creating a first post! That's cool.", -// createdDate: Date(timeIntervalSince1970: 1595429452), -// status: .published, -// collection: userCollection1 -// ), -// Post( -// title: "Post 2: The Quickening", -// body: "See, here's the rule about Highlander jokes: _there can be only one_.", -// createdDate: Date(timeIntervalSince1970: 1595514125), -// status: .edited, -// collection: userCollection1 -// ), -// Post( -// title: "The Post Revolutions", -// body: "I can never keep the Matrix movie order straight. Why not just call them part 2 and part 3?", -// createdDate: Date(timeIntervalSince1970: 1595600006) -// ), -// Post( -// title: "Episode IV: A New Post", -// body: "How many movies does this person watch? How many movie-title jokes will they make?", -// createdDate: Date(timeIntervalSince1970: 1596219877), -// status: .published, -// collection: userCollection2 -// ), -// Post( -// title: "Fast (Post) Five", -// body: "Look, it was either a Fast and the Furious reference, or a Resident Evil reference." -// ), -// Post( -// title: "Post: The Final Chapter", -// body: "And there you have it, a Resident Evil movie reference.", -// createdDate: Date(timeIntervalSince1970: 1596043684), -// status: .edited, -// collection: userCollection3 -// ) -//] -//#endif -// -//struct PostStatusBadge_LocalDraftPreviews: PreviewProvider { -// static var previews: some View { -// userCollection1.title = "Collection 1" -// return PostStatusBadgeView(post: testPostData[2]) -// } -//} -// -//struct PostStatusBadge_EditedPreviews: PreviewProvider { -// static var previews: some View { -// userCollection1.title = "Collection 1" -// return PostStatusBadgeView(post: testPostData[1]) -// } -//} -// -//struct PostStatusBadge_PublishedPreviews: PreviewProvider { -// static var previews: some View { -// PostStatusBadgeView(post: testPostData[0]) -// } -//} +struct PostStatusBadge_LocalDraftPreviews: PreviewProvider { + static var previews: some View { + let context = PersistenceManager.persistentContainer.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 = PersistenceManager.persistentContainer.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 = PersistenceManager.persistentContainer.viewContext + let testPost = WFAPost(context: context) + testPost.status = PostStatus.published.rawValue + + return PostStatusBadgeView(post: testPost) + .environment(\.managedObjectContext, context) + } +}