forked from shadowfacts/Tusker
Fix context menu actions in beta 4
This commit is contained in:
parent
e269e23527
commit
7d7b457575
|
@ -47,7 +47,8 @@ extension EnhancedTableViewController {
|
|||
return nil
|
||||
}
|
||||
let actionProvider: UIContextMenuActionProvider = { (elements) in
|
||||
return UIMenu(title: "test", children: elements + actionsProvider())
|
||||
return UIMenu(title: "", image: nil, identifier: nil, options: [], children: elements + actionsProvider())
|
||||
// return UIMenu(title: "test", children: elements + actionsProvider())
|
||||
}
|
||||
return UIContextMenuConfiguration(identifier: nil, previewProvider: previewProvider, actionProvider: actionProvider)
|
||||
} else {
|
||||
|
|
|
@ -27,26 +27,26 @@ extension MenuPreviewProvider {
|
|||
func actionsForProfile(accountID: String) -> [UIAction] {
|
||||
guard let account = MastodonCache.account(for: accountID) else { return [] }
|
||||
return [
|
||||
UIAction(__title: "Open in Safari", image: UIImage(systemName: "safari")) { (_) in
|
||||
createAction(identifier: "openinsafari", title: "Open in Safari", systemImageName: "safari", handler: { (_) in
|
||||
self.present(SFSafariViewController(url: account.url))
|
||||
},
|
||||
UIAction(__title: "Send Message", image: UIImage(systemName: "envelope")) { (_) in
|
||||
}),
|
||||
createAction(identifier: "sendmessage", title: "Send Message", systemImageName: "envelope", handler: { (_) in
|
||||
self.present(UINavigationController(rootViewController: ComposeViewController(mentioningAcct: account.acct)))
|
||||
},
|
||||
UIAction(__title: "Share...", image: UIImage(systemName: "square.and.arrow.up")) { (_) in
|
||||
}),
|
||||
createAction(identifier: "share", title: "Share...", systemImageName: "square.and.arrow.up", handler: { (_) in
|
||||
self.present(UIActivityViewController(activityItems: [account.url], applicationActivities: nil))
|
||||
}
|
||||
})
|
||||
]
|
||||
}
|
||||
|
||||
func actionsForURL(_ url: URL) -> [UIAction] {
|
||||
return [
|
||||
UIAction(__title: "Open in Safari", image: UIImage(systemName: "safari")) { (_) in
|
||||
createAction(identifier: "openinsafari", title: "Open in Safari", systemImageName: "safari", handler: { (_) in
|
||||
self.present(SFSafariViewController(url: url))
|
||||
},
|
||||
UIAction(__title: "Share...", image: UIImage(systemName: "square.and.arrow.up")) { (_) in
|
||||
}),
|
||||
createAction(identifier: "share", title: "Share...", systemImageName: "square.and.arrow.up", handler: { (_) in
|
||||
self.present(UIActivityViewController(activityItems: [url], applicationActivities: nil))
|
||||
}
|
||||
})
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -57,16 +57,20 @@ extension MenuPreviewProvider {
|
|||
func actionsForStatus(statusID: String) -> [UIAction] {
|
||||
guard let status = MastodonCache.status(for: statusID) else { return [] }
|
||||
return [
|
||||
UIAction(__title: "Reply", image: UIImage(systemName: "arrowshape.turn.up.left")) { (_) in
|
||||
createAction(identifier: "reply", title: "Reply", systemImageName: "arrowshape.turn.up.left", handler: { (_) in
|
||||
self.present(UINavigationController(rootViewController: ComposeViewController(inReplyTo: statusID)))
|
||||
},
|
||||
UIAction(__title: "Open in Safari", image: UIImage(systemName: "safari")) { (_) in
|
||||
}),
|
||||
createAction(identifier: "openinsafari", title: "Open in Safari", systemImageName: "safari", handler: { (_) in
|
||||
self.present(SFSafariViewController(url: status.url!))
|
||||
},
|
||||
UIAction(__title: "Share...", image: UIImage(systemName: "square.and.arrow.up")) { (_) in
|
||||
}),
|
||||
createAction(identifier: "share", title: "Share...", systemImageName: "square.and.arrow.up", handler: { (_) in
|
||||
self.present(UIActivityViewController(activityItems: [status.url!], applicationActivities: nil))
|
||||
}
|
||||
})
|
||||
]
|
||||
}
|
||||
|
||||
private func createAction(identifier: String, title: String, systemImageName: String, handler: @escaping UIActionHandler) -> UIAction {
|
||||
return UIAction(title: title, image: UIImage(systemName: systemImageName), identifier: UIAction.Identifier(identifier), discoverabilityTitle: nil, attributes: [], state: .off, handler: handler)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue