mirror of
https://github.com/writeas/writefreely-swiftui-multiplatform.git
synced 2024-11-15 01:11:02 +00:00
Use TextEditor views for both title and body of PostEditor
This commit is contained in:
parent
4b4608709e
commit
85e99c720c
@ -6,30 +6,31 @@ struct PostEditor: View {
|
|||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack {
|
VStack {
|
||||||
TextField(post.title, text: $post.title)
|
TextEditor(text: $post.title)
|
||||||
|
.border(Color.blue, width: 1)
|
||||||
.font(.title)
|
.font(.title)
|
||||||
.multilineTextAlignment(.center)
|
.frame(height: 100)
|
||||||
.padding(.bottom)
|
|
||||||
.onChange(of: post.title) { _ in
|
.onChange(of: post.title) { _ in
|
||||||
if post.status == .published {
|
if post.status == .published {
|
||||||
hasUnpublishedChanges = true
|
hasUnpublishedChanges = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TextEditor(text: $post.body)
|
TextEditor(text: $post.body)
|
||||||
|
.border(Color.red, width: 1)
|
||||||
.font(.body)
|
.font(.body)
|
||||||
.padding(.leading)
|
|
||||||
.onChange(of: post.body) { _ in
|
.onChange(of: post.body) { _ in
|
||||||
if post.status == .published {
|
if post.status == .published {
|
||||||
hasUnpublishedChanges = true
|
hasUnpublishedChanges = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.toolbar {
|
}
|
||||||
if hasUnpublishedChanges {
|
.padding()
|
||||||
PostStatusBadge(postStatus: .edited)
|
.toolbar {
|
||||||
} else {
|
if hasUnpublishedChanges {
|
||||||
PostStatusBadge(postStatus: post.status)
|
PostStatusBadge(postStatus: .edited)
|
||||||
}
|
} else {
|
||||||
}
|
PostStatusBadge(postStatus: post.status)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user