forked from shadowfacts/Tusker
Add 3d touch preview actions
This commit is contained in:
parent
0b6459a806
commit
0462e57635
|
@ -66,6 +66,22 @@ class ConversationViewController: UITableViewController {
|
|||
}
|
||||
}
|
||||
|
||||
override var previewActionItems: [UIPreviewActionItem] {
|
||||
var actions = [UIPreviewActionItem]()
|
||||
if let status = MastodonCache.status(for: mainStatusID),
|
||||
let url = status.url {
|
||||
actions.append(UIPreviewAction(title: "Open in Safari", style: .default, handler: { (_, _) in
|
||||
let vc = self.viewController(forURL: url)
|
||||
UIApplication.shared.delegate!.window!!.rootViewController!.present(vc, animated: true)
|
||||
}))
|
||||
actions.append(UIPreviewAction(title: "Share", style: .default, handler: { (_, _) in
|
||||
let vc = UIActivityViewController(activityItems: [url], applicationActivities: nil)
|
||||
UIApplication.shared.delegate!.window!!.rootViewController!.present(vc, animated: true)
|
||||
}))
|
||||
}
|
||||
return actions
|
||||
}
|
||||
|
||||
func getDirectParents(of status: Status, from statuses: [Status]) -> [Status] {
|
||||
var statuses = statuses
|
||||
var parents: [Status] = []
|
||||
|
|
|
@ -99,6 +99,25 @@ class ProfileTableViewController: UITableViewController, PreferencesAdaptive {
|
|||
}
|
||||
}
|
||||
|
||||
override var previewActionItems: [UIPreviewActionItem] {
|
||||
var actions = [UIPreviewActionItem]()
|
||||
if let account = MastodonCache.account(for: accountID) {
|
||||
actions.append(UIPreviewAction(title: "Open in Safari", style: .default, handler: { (_, _) in
|
||||
let vc = self.viewController(forURL: account.url)
|
||||
UIApplication.shared.delegate!.window!!.rootViewController!.present(vc, animated: true)
|
||||
}))
|
||||
actions.append(UIPreviewAction(title: "Share", style: .default, handler: { (_, _) in
|
||||
let vc = UIActivityViewController(activityItems: [account.url], applicationActivities: nil)
|
||||
UIApplication.shared.delegate!.window!!.rootViewController!.present(vc, animated: true)
|
||||
}))
|
||||
actions.append(UIPreviewAction(title: "Send Message", style: .default, handler: { (_, _) in
|
||||
let vc = ComposeViewController.create(mentioning: account.acct)
|
||||
UIApplication.shared.delegate!.window!!.rootViewController!.present(vc, animated: true)
|
||||
}))
|
||||
}
|
||||
return actions
|
||||
}
|
||||
|
||||
func updateAccountUI() {
|
||||
loadingVC?.remove()
|
||||
|
||||
|
@ -226,15 +245,15 @@ extension ProfileTableViewController: ProfileHeaderTableViewCellDelegate {
|
|||
let account = MastodonCache.account(for: accountID)!
|
||||
|
||||
let alert = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
|
||||
alert.addAction(UIAlertAction(title: "Open in Safari...", style: .default, handler: { _ in
|
||||
alert.addAction(UIAlertAction(title: "Open in Safari", style: .default, handler: { _ in
|
||||
let vc = SFSafariViewController(url: account.url)
|
||||
self.present(vc, animated: true)
|
||||
}))
|
||||
alert.addAction(UIAlertAction(title: "Share...", style: .default, handler: { _ in
|
||||
alert.addAction(UIAlertAction(title: "Share", style: .default, handler: { _ in
|
||||
let vc = UIActivityViewController(activityItems: [account.url], applicationActivities: nil)
|
||||
self.present(vc, animated: true)
|
||||
}))
|
||||
alert.addAction(UIAlertAction(title: "Send Message...", style: .default, handler: { _ in
|
||||
alert.addAction(UIAlertAction(title: "Send Message", style: .default, handler: { _ in
|
||||
self.sendMessageMentioning()
|
||||
}))
|
||||
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
|
||||
|
|
|
@ -136,11 +136,11 @@ extension TuskerNavigationDelegate where Self: UIViewController {
|
|||
|
||||
let alert = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
|
||||
if let url = status.url {
|
||||
alert.addAction(UIAlertAction(title: "Open in Safari...", style: .default, handler: { _ in
|
||||
alert.addAction(UIAlertAction(title: "Open in Safari", style: .default, handler: { _ in
|
||||
let vc = SFSafariViewController(url: url)
|
||||
self.present(vc, animated: true)
|
||||
}))
|
||||
alert.addAction(UIAlertAction(title: "Share...", style: .default, handler: { _ in
|
||||
alert.addAction(UIAlertAction(title: "Share", style: .default, handler: { _ in
|
||||
let vc = UIActivityViewController(activityItems: [url], applicationActivities: nil)
|
||||
self.present(vc, animated: true)
|
||||
}))
|
||||
|
|
Loading…
Reference in New Issue