Move new-post generation for iOS app to PostEditorModel

This commit is contained in:
Angelo Stavrow 2021-01-25 13:22:15 -05:00
parent e1c5823cd6
commit 4ad076ccab
No known key found for this signature in database
GPG Key ID: 1A49C7064E060EEE

View File

@ -36,25 +36,7 @@ struct PostListView: View {
ZStack { ZStack {
Spacer() Spacer()
Button(action: { Button(action: {
let managedPost = WFAPost(context: self.managedObjectContext) let managedPost = model.editor.generateNewLocalPost(withFont: model.preferences.font)
managedPost.createdDate = Date()
managedPost.title = ""
managedPost.body = ""
managedPost.status = PostStatus.local.rawValue
managedPost.collectionAlias = nil
switch model.preferences.font {
case 1:
managedPost.appearance = "sans"
case 2:
managedPost.appearance = "wrap"
default:
managedPost.appearance = "serif"
}
if let languageCode = Locale.current.languageCode {
managedPost.language = languageCode
//swiftlint:disable:next line_length
managedPost.rtl = Locale.characterDirection(forLanguage: languageCode) == .rightToLeft
}
withAnimation { withAnimation {
self.model.showAllPosts = false self.model.showAllPosts = false
self.model.selectedCollection = nil self.model.selectedCollection = nil