Page Menu
Home
Musing Studio
Search
Configure Global Search
Log In
Files
F13830779
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/PostEditor.swift b/Shared/Post/PostEditor.swift
index ba197c6..10a1713 100644
--- a/Shared/Post/PostEditor.swift
+++ b/Shared/Post/PostEditor.swift
@@ -1,55 +1,62 @@
import SwiftUI
struct PostEditor: View {
@EnvironmentObject var postStore: PostStore
@ObservedObject var post: Post
@State private var isNewPost = false
var body: some View {
VStack {
TextEditor(text: $post.title)
.font(.title)
.frame(height: 100)
.onChange(of: post.title) { _ in
if post.status == .published {
post.status = .edited
}
}
TextEditor(text: $post.body)
.font(.body)
.onChange(of: post.body) { _ in
if post.status == .published {
post.status = .edited
}
}
}
.padding()
.toolbar {
ToolbarItem(placement: .status) {
PostStatusBadge(post: post)
}
+ ToolbarItem(placement: .primaryAction) {
+ Button(action: {
+ print("Publish button tapped!")
+ }, label: {
+ Image(systemName: "paperplane")
+ })
+ }
}
.onAppear(perform: checkIfNewPost)
.onDisappear(perform: addPostToStore)
}
private func checkIfNewPost() {
if !postStore.posts.contains(where: { $0.id == post.id }) {
self.isNewPost = true
}
}
private func addPostToStore() {
if isNewPost {
withAnimation {
postStore.add(post)
}
}
}
}
struct PostEditor_Previews: PreviewProvider {
static var previews: some View {
PostEditor(post: testPost)
}
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Fri, Feb 20, 5:32 AM (22 h, 27 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3633624
Attached To
rWFSUI WriteFreely SwiftUI
Event Timeline
Log In to Comment