mirror of
https://github.com/writeas/writefreely-swiftui-multiplatform.git
synced 2024-11-15 01:11:02 +00:00
Present publish-to menu for new local posts
This commit is contained in:
parent
82dbaba32b
commit
f52fae335b
@ -12,8 +12,10 @@ struct ActivePostToolbarView: View {
|
||||
) var collections: FetchedResults<WFACollection>
|
||||
|
||||
var body: some View {
|
||||
HStack(spacing: 4) {
|
||||
if model.account.isLoggedIn && activePost.status != PostStatus.local.rawValue {
|
||||
HStack {
|
||||
if model.account.isLoggedIn &&
|
||||
activePost.status != PostStatus.local.rawValue &&
|
||||
!(activePost.wasDeletedFromServer || activePost.hasNewerRemoteCopy) {
|
||||
Section(header: Text("Move To:")) {
|
||||
Picker(selection: $selectedCollection, label: Text("Move To…"), content: {
|
||||
Text("\(model.account.server == "https://write.as" ? "Anonymous" : "Drafts")")
|
||||
@ -26,13 +28,52 @@ struct ActivePostToolbarView: View {
|
||||
}
|
||||
}
|
||||
PostEditorStatusToolbarView(post: activePost)
|
||||
.frame(minWidth: 50, alignment: .center)
|
||||
.layoutPriority(1)
|
||||
.padding(.horizontal)
|
||||
if activePost.status == PostStatus.local.rawValue {
|
||||
Menu(content: {
|
||||
Label("Publish To:", systemImage: "paperplane")
|
||||
Divider()
|
||||
Button(action: {
|
||||
if model.account.isLoggedIn {
|
||||
withAnimation {
|
||||
activePost.collectionAlias = nil
|
||||
publishPost(activePost)
|
||||
}
|
||||
} else {
|
||||
// present login screen
|
||||
}
|
||||
}, label: {
|
||||
Text("\(model.account.server == "https://write.as" ? "Anonymous" : "Drafts")")
|
||||
})
|
||||
ForEach(collections) { collection in
|
||||
Button(action: {
|
||||
if model.account.isLoggedIn {
|
||||
withAnimation {
|
||||
activePost.collectionAlias = collection.alias
|
||||
publishPost(activePost)
|
||||
}
|
||||
} else {
|
||||
// present login screen
|
||||
}
|
||||
}, label: {
|
||||
Text("\(collection.title)")
|
||||
})
|
||||
}
|
||||
}, label: {
|
||||
Label("Publish…", systemImage: "paperplane")
|
||||
})
|
||||
.disabled(activePost.body.isEmpty)
|
||||
} else {
|
||||
HStack(spacing: 4) {
|
||||
Button(action: {}, label: { Image(systemName: "square.and.arrow.up") })
|
||||
.disabled(activePost.status == PostStatus.local.rawValue)
|
||||
Button(action: { publishPost(activePost) }, label: { Image(systemName: "paperplane") })
|
||||
.disabled(activePost.body.isEmpty || activePost.status == PostStatus.published.rawValue)
|
||||
}
|
||||
}
|
||||
}
|
||||
.onAppear(perform: {
|
||||
self.selectedCollection = collections.first { $0.alias == activePost.collectionAlias }
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user