diff --git a/Shared/Navigation/ContentView.swift b/Shared/Navigation/ContentView.swift index d10f9f0..efdeef3 100644 --- a/Shared/Navigation/ContentView.swift +++ b/Shared/Navigation/ContentView.swift @@ -1,29 +1,29 @@ import SwiftUI struct ContentView: View { @EnvironmentObject var model: WriteFreelyModel var body: some View { NavigationView { SidebarView() PostListView(selectedCollection: allPostsCollection) - Text("Select a post, or create a new draft.") + Text("Select a post, or create a new local draft.") .foregroundColor(.secondary) } .environmentObject(model) } } struct ContentView_Previews: PreviewProvider { static var previews: some View { let model = WriteFreelyModel() model.collections = CollectionListModel(with: [userCollection1, userCollection2, userCollection3]) for post in testPostData { model.store.add(post) } return ContentView() .environmentObject(model) } } diff --git a/Shared/PostEditor/PostEditorView.swift b/Shared/PostEditor/PostEditorView.swift index 47f1c10..cb88aec 100644 --- a/Shared/PostEditor/PostEditorView.swift +++ b/Shared/PostEditor/PostEditorView.swift @@ -1,76 +1,76 @@ import SwiftUI struct PostEditorView: View { @EnvironmentObject var model: WriteFreelyModel @ObservedObject var post: Post @State private var isNewPost = false @State private var title = "" var body: some View { VStack { TextEditor(text: $title) .font(.title) .frame(height: 100) .onChange(of: title) { _ in if post.status == .published && post.wfPost.title != title { post.status = .edited } post.wfPost.title = title } TextEditor(text: $post.wfPost.body) .font(.body) .onChange(of: post.wfPost.body) { _ in if post.status == .published { post.status = .edited } } } .padding() .toolbar { ToolbarItem(placement: .status) { PostStatusBadgeView(post: post) } ToolbarItem(placement: .primaryAction) { Button(action: { model.publish(post: post) post.status = .published }, label: { Image(systemName: "paperplane") }) } } .onAppear(perform: { title = post.wfPost.title ?? "" checkIfNewPost() if self.isNewPost { addNewPostToStore() } }) } private func checkIfNewPost() { self.isNewPost = !model.store.posts.contains(where: { $0.id == post.id }) } private func addNewPostToStore() { withAnimation { model.store.add(post) self.isNewPost = false } } } -struct PostEditorView_NewDraftPreviews: PreviewProvider { +struct PostEditorView_NewLocalDraftPreviews: PreviewProvider { static var previews: some View { PostEditorView(post: Post()) .environmentObject(WriteFreelyModel()) } } struct PostEditorView_ExistingPostPreviews: PreviewProvider { static var previews: some View { PostEditorView(post: testPostData[0]) .environmentObject(WriteFreelyModel()) } } diff --git a/Shared/PostList/PostStatusBadgeView.swift b/Shared/PostList/PostStatusBadgeView.swift index b660aab..3698fea 100644 --- a/Shared/PostList/PostStatusBadgeView.swift +++ b/Shared/PostList/PostStatusBadgeView.swift @@ -1,57 +1,57 @@ import SwiftUI struct PostStatusBadgeView: View { @ObservedObject var post: Post var body: some View { let (badgeLabel, badgeColor) = setupBadgeProperties(for: 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) } } -struct PostStatusBadge_DraftPreviews: PreviewProvider { +struct PostStatusBadge_LocalDraftPreviews: PreviewProvider { static var previews: some View { - PostStatusBadgeView(post: testPostData[0]) + PostStatusBadgeView(post: testPostData[2]) } } struct PostStatusBadge_EditedPreviews: PreviewProvider { static var previews: some View { Group { PostStatusBadgeView(post: testPostData[1]) } } } struct PostStatusBadge_PublishedPreviews: PreviewProvider { static var previews: some View { - PostStatusBadgeView(post: testPostData[2]) + PostStatusBadgeView(post: testPostData[0]) } } diff --git a/WriteFreely-MultiPlatform.xcodeproj/xcuserdata/angelo.xcuserdatad/xcschemes/xcschememanagement.plist b/WriteFreely-MultiPlatform.xcodeproj/xcuserdata/angelo.xcuserdatad/xcschemes/xcschememanagement.plist index 2723ebe..6cd8075 100644 --- a/WriteFreely-MultiPlatform.xcodeproj/xcuserdata/angelo.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/WriteFreely-MultiPlatform.xcodeproj/xcuserdata/angelo.xcuserdatad/xcschemes/xcschememanagement.plist @@ -1,19 +1,19 @@ SchemeUserState WriteFreely-MultiPlatform (iOS).xcscheme_^#shared#^_ orderHint - 0 + 1 WriteFreely-MultiPlatform (macOS).xcscheme_^#shared#^_ orderHint - 1 + 0