mirror of
https://github.com/writeas/writefreely-swiftui-multiplatform.git
synced 2024-11-15 01:11:02 +00:00
Remove PostListView toolbar (new post and reload from server)
This commit is contained in:
parent
1a8ae1d4d3
commit
1215a1727a
@ -61,56 +61,8 @@ struct PostListView: View {
|
||||
)
|
||||
)
|
||||
.navigationSubtitle(postCount == 1 ? "\(postCount) post" : "\(postCount) posts")
|
||||
.toolbar {
|
||||
Button(action: {
|
||||
createNewLocalDraft()
|
||||
}, label: {
|
||||
Image(systemName: "square.and.pencil")
|
||||
})
|
||||
Button(action: {
|
||||
reloadFromServer()
|
||||
}, label: {
|
||||
Image(systemName: "arrow.clockwise")
|
||||
})
|
||||
.disabled(!model.account.isLoggedIn)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
private func reloadFromServer() {
|
||||
DispatchQueue.main.async {
|
||||
model.fetchUserCollections()
|
||||
model.fetchUserPosts()
|
||||
}
|
||||
}
|
||||
|
||||
private func createNewLocalDraft() {
|
||||
let managedPost = WFAPost(context: self.managedObjectContext)
|
||||
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
|
||||
}
|
||||
DispatchQueue.main.async {
|
||||
self.selectedCollection = nil
|
||||
self.showAllPosts = false
|
||||
withAnimation {
|
||||
self.model.selectedPost = managedPost
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct PostListView_Previews: PreviewProvider {
|
||||
|
Loading…
Reference in New Issue
Block a user