mirror of
https://github.com/writeas/writefreely-swiftui-multiplatform.git
synced 2024-11-15 01:11:02 +00:00
Move new-post generation for Mac app to PostEditorModel
This commit is contained in:
parent
20f12fa7cc
commit
e1c5823cd6
@ -28,25 +28,7 @@ struct ContentView: View {
|
|||||||
self.model.selectedCollection = nil
|
self.model.selectedCollection = nil
|
||||||
}
|
}
|
||||||
// Create the new-post managed object
|
// Create the new-post managed object
|
||||||
let managedPost = WFAPost(context: LocalStorageManager.persistentContainer.viewContext)
|
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
|
|
||||||
managedPost.rtl = Locale.characterDirection(forLanguage: languageCode) == .rightToLeft
|
|
||||||
}
|
|
||||||
|
|
||||||
withAnimation {
|
withAnimation {
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now()) {
|
DispatchQueue.main.asyncAfter(deadline: .now()) {
|
||||||
// Load the new post in the editor
|
// Load the new post in the editor
|
||||||
|
@ -33,7 +33,7 @@ struct PostEditorModel {
|
|||||||
return post
|
return post
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateNewLocalPost(withAppearance appearance: Int) -> WFAPost {
|
func generateNewLocalPost(withFont appearance: Int) -> WFAPost {
|
||||||
let managedPost = WFAPost(context: LocalStorageManager.persistentContainer.viewContext)
|
let managedPost = WFAPost(context: LocalStorageManager.persistentContainer.viewContext)
|
||||||
managedPost.createdDate = Date()
|
managedPost.createdDate = Date()
|
||||||
managedPost.title = ""
|
managedPost.title = ""
|
||||||
|
@ -133,7 +133,7 @@ struct WriteFreely_MultiPlatformApp: App {
|
|||||||
self.model.selectedCollection = nil
|
self.model.selectedCollection = nil
|
||||||
}
|
}
|
||||||
// Create the new-post managed object
|
// Create the new-post managed object
|
||||||
let managedPost = model.editor.generateNewLocalPost(withAppearance: model.preferences.font)
|
let managedPost = model.editor.generateNewLocalPost(withFont: model.preferences.font)
|
||||||
withAnimation {
|
withAnimation {
|
||||||
// Set it as the selectedPost
|
// Set it as the selectedPost
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now()) {
|
DispatchQueue.main.asyncAfter(deadline: .now()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user