mirror of
https://github.com/writeas/writefreely-swiftui-multiplatform.git
synced 2024-11-15 01:11:02 +00:00
Use Post.wfPost properties instead of redundant Post properties
This commit is contained in:
parent
a97bd5abb7
commit
d651776322
@ -6,20 +6,21 @@ struct PostEditorView: View {
|
||||
@ObservedObject var post: Post
|
||||
|
||||
@State private var isNewPost = false
|
||||
|
||||
@State private var title = ""
|
||||
var body: some View {
|
||||
VStack {
|
||||
TextEditor(text: $post.title)
|
||||
TextEditor(text: $title)
|
||||
.font(.title)
|
||||
.frame(height: 100)
|
||||
.onChange(of: post.title) { _ in
|
||||
if post.status == .published {
|
||||
.onChange(of: title) { _ in
|
||||
if post.status == .published && post.wfPost.title != title {
|
||||
post.status = .edited
|
||||
}
|
||||
post.wfPost.title = title
|
||||
}
|
||||
TextEditor(text: $post.body)
|
||||
TextEditor(text: $post.wfPost.body)
|
||||
.font(.body)
|
||||
.onChange(of: post.body) { _ in
|
||||
.onChange(of: post.wfPost.body) { _ in
|
||||
if post.status == .published {
|
||||
post.status = .edited
|
||||
}
|
||||
@ -40,6 +41,7 @@ struct PostEditorView: View {
|
||||
}
|
||||
}
|
||||
.onAppear(perform: {
|
||||
title = post.wfPost.title ?? ""
|
||||
checkIfNewPost()
|
||||
if self.isNewPost {
|
||||
addNewPostToStore()
|
||||
|
@ -6,10 +6,10 @@ struct PostCellView: View {
|
||||
var body: some View {
|
||||
HStack {
|
||||
VStack(alignment: .leading) {
|
||||
Text(post.title)
|
||||
Text(post.wfPost.title ?? "")
|
||||
.font(.headline)
|
||||
.lineLimit(1)
|
||||
Text(buildDateString(from: post.createdDate))
|
||||
Text(buildDateString(from: post.wfPost.createdDate ?? Date()))
|
||||
.font(.caption)
|
||||
.lineLimit(1)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user