2020-01-18 21:00:38 +00:00
|
|
|
//
|
|
|
|
// ContentTextView.swift
|
|
|
|
// Tusker
|
|
|
|
//
|
|
|
|
// Created by Shadowfacts on 1/18/20.
|
|
|
|
// Copyright © 2020 Shadowfacts. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import UIKit
|
|
|
|
import SwiftSoup
|
|
|
|
import Pachyderm
|
|
|
|
import SafariServices
|
2022-03-29 16:40:16 +00:00
|
|
|
import WebURL
|
|
|
|
import WebURLFoundationExtras
|
2020-01-18 21:00:38 +00:00
|
|
|
|
|
|
|
private let emojiRegex = try! NSRegularExpression(pattern: ":(\\w+):", options: [])
|
|
|
|
|
2021-11-07 18:11:49 +00:00
|
|
|
class ContentTextView: LinkTextView, BaseEmojiLabel {
|
2020-01-18 21:00:38 +00:00
|
|
|
|
2020-01-20 04:02:07 +00:00
|
|
|
weak var navigationDelegate: TuskerNavigationDelegate?
|
2020-01-20 20:25:23 +00:00
|
|
|
weak var overrideMastodonController: MastodonController?
|
|
|
|
var mastodonController: MastodonController? { overrideMastodonController ?? navigationDelegate?.apiController }
|
|
|
|
|
2020-01-18 21:00:38 +00:00
|
|
|
var defaultFont: UIFont = .systemFont(ofSize: 17)
|
2020-01-18 23:21:01 +00:00
|
|
|
var defaultColor: UIColor = .label
|
2020-01-18 21:00:38 +00:00
|
|
|
|
2020-12-29 16:56:40 +00:00
|
|
|
private(set) var hasEmojis = false
|
|
|
|
|
2021-11-07 18:11:49 +00:00
|
|
|
var emojiIdentifier: String?
|
|
|
|
var emojiRequests: [ImageCache.Request] = []
|
|
|
|
var emojiFont: UIFont { defaultFont }
|
|
|
|
var emojiTextColor: UIColor { defaultColor }
|
|
|
|
|
2020-07-01 22:50:20 +00:00
|
|
|
// The link range currently being previewed
|
|
|
|
private var currentPreviewedLinkRange: NSRange?
|
|
|
|
// The preview created in the previewForHighlighting method, so that we can use the same one in previewForDismissing.
|
|
|
|
private weak var currentTargetedPreview: UITargetedPreview?
|
|
|
|
|
2020-01-18 21:00:38 +00:00
|
|
|
override func awakeFromNib() {
|
|
|
|
super.awakeFromNib()
|
|
|
|
|
|
|
|
delegate = self
|
|
|
|
|
2020-06-25 14:42:46 +00:00
|
|
|
// Disable layer masking, otherwise the context menu opening animation
|
|
|
|
// may be clipped if it's at an edge of the text view
|
|
|
|
layer.masksToBounds = false
|
2020-01-18 21:00:38 +00:00
|
|
|
addInteraction(UIContextMenuInteraction(delegate: self))
|
|
|
|
|
|
|
|
textDragInteraction?.isEnabled = false
|
2020-01-18 21:27:18 +00:00
|
|
|
|
|
|
|
textContainerInset = .zero
|
|
|
|
textContainer.lineFragmentPadding = 0
|
2020-01-19 00:32:39 +00:00
|
|
|
|
|
|
|
// the text view's builtin link interaction code is tied to isSelectable, so we need to use our own tap recognizer
|
|
|
|
let recognizer = UITapGestureRecognizer(target: self, action: #selector(textTapped(_:)))
|
|
|
|
addGestureRecognizer(recognizer)
|
2020-01-18 21:00:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// MARK: - Emojis
|
|
|
|
func setEmojis(_ emojis: [Emoji]) {
|
2021-11-07 18:11:49 +00:00
|
|
|
replaceEmojis(in: attributedText!, emojis: emojis, identifier: emojiIdentifier) { attributedString, didReplaceEmojis in
|
|
|
|
guard didReplaceEmojis else {
|
|
|
|
return
|
2020-01-18 21:00:38 +00:00
|
|
|
}
|
2021-11-07 18:11:49 +00:00
|
|
|
self.attributedText = attributedString
|
2020-01-18 21:00:38 +00:00
|
|
|
self.setNeedsLayout()
|
|
|
|
self.setNeedsDisplay()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// MARK: - HTML Parsing
|
|
|
|
func setTextFromHtml(_ html: String) {
|
|
|
|
let doc = try! SwiftSoup.parse(html)
|
|
|
|
let body = doc.body()!
|
|
|
|
|
|
|
|
let attributedText = attributedTextForHTMLNode(body)
|
|
|
|
let mutAttrString = NSMutableAttributedString(attributedString: attributedText)
|
|
|
|
mutAttrString.trimTrailingCharactersInSet(.whitespacesAndNewlines)
|
2020-01-22 02:21:23 +00:00
|
|
|
mutAttrString.collapseWhitespace()
|
2020-01-18 21:00:38 +00:00
|
|
|
|
2022-05-15 19:42:48 +00:00
|
|
|
let style = NSMutableParagraphStyle()
|
|
|
|
// 2 points is enough that it doesn't make things look weirdly spaced out, but leaves a slight gap when there are multiple lines of emojis
|
|
|
|
style.lineSpacing = 2
|
|
|
|
mutAttrString.addAttribute(.paragraphStyle, value: style, range: mutAttrString.fullRange)
|
|
|
|
|
2020-01-18 21:00:38 +00:00
|
|
|
self.attributedText = mutAttrString
|
|
|
|
}
|
|
|
|
|
2020-01-22 02:21:23 +00:00
|
|
|
private func attributedTextForHTMLNode(_ node: Node, usePreformattedText: Bool = false) -> NSAttributedString {
|
2020-01-18 21:00:38 +00:00
|
|
|
switch node {
|
|
|
|
case let node as TextNode:
|
2020-01-18 21:05:44 +00:00
|
|
|
let text: String
|
|
|
|
if usePreformattedText {
|
|
|
|
text = node.getWholeText()
|
|
|
|
} else {
|
|
|
|
text = node.text()
|
|
|
|
}
|
2020-01-18 23:21:01 +00:00
|
|
|
return NSAttributedString(string: text, attributes: [.font: defaultFont, .foregroundColor: defaultColor])
|
2020-01-18 21:00:38 +00:00
|
|
|
case let node as Element:
|
2020-01-18 23:21:01 +00:00
|
|
|
let attributed = NSMutableAttributedString(string: "", attributes: [.font: defaultFont, .foregroundColor: defaultColor])
|
2020-01-18 21:00:38 +00:00
|
|
|
for child in node.getChildNodes() {
|
2020-01-18 21:05:44 +00:00
|
|
|
attributed.append(attributedTextForHTMLNode(child, usePreformattedText: usePreformattedText || node.tagName() == "pre"))
|
2020-01-18 21:00:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
switch node.tagName() {
|
|
|
|
case "br":
|
2022-05-15 19:42:48 +00:00
|
|
|
// need to specify defaultFont here b/c otherwise it uses the default 12pt Helvetica which
|
|
|
|
// screws up its determination of the line height making multiple lines of emojis squash together
|
|
|
|
attributed.append(NSAttributedString(string: "\n", attributes: [.font: defaultFont]))
|
2020-01-18 21:00:38 +00:00
|
|
|
case "a":
|
|
|
|
if let link = try? node.attr("href"),
|
2022-03-29 16:40:16 +00:00
|
|
|
let webURL = WebURL(link),
|
|
|
|
let url = URL(webURL) {
|
2020-01-18 21:00:38 +00:00
|
|
|
attributed.addAttribute(.link, value: url, range: attributed.fullRange)
|
|
|
|
}
|
|
|
|
case "p":
|
2022-05-15 19:42:48 +00:00
|
|
|
attributed.append(NSAttributedString(string: "\n\n", attributes: [.font: defaultFont]))
|
2020-01-18 21:00:38 +00:00
|
|
|
case "em", "i":
|
2022-04-09 19:05:39 +00:00
|
|
|
let currentFont: UIFont
|
|
|
|
if attributed.length == 0 {
|
|
|
|
currentFont = defaultFont
|
|
|
|
} else {
|
|
|
|
currentFont = attributed.attribute(.font, at: 0, effectiveRange: nil) as? UIFont ?? defaultFont
|
|
|
|
}
|
2020-11-10 00:39:42 +00:00
|
|
|
attributed.addAttribute(.font, value: currentFont.withTraits(.traitItalic)!, range: attributed.fullRange)
|
2020-01-18 21:00:38 +00:00
|
|
|
case "strong", "b":
|
2022-04-09 19:05:39 +00:00
|
|
|
let currentFont: UIFont
|
|
|
|
if attributed.length == 0 {
|
|
|
|
currentFont = defaultFont
|
|
|
|
} else {
|
|
|
|
currentFont = attributed.attribute(.font, at: 0, effectiveRange: nil) as? UIFont ?? defaultFont
|
|
|
|
}
|
2020-11-10 00:39:42 +00:00
|
|
|
attributed.addAttribute(.font, value: currentFont.withTraits(.traitBold)!, range: attributed.fullRange)
|
2020-01-18 21:00:38 +00:00
|
|
|
case "del":
|
|
|
|
attributed.addAttribute(.strikethroughStyle, value: NSUnderlineStyle.single.rawValue, range: attributed.fullRange)
|
|
|
|
case "code":
|
2021-08-13 01:03:11 +00:00
|
|
|
attributed.addAttribute(.font, value: UIFont.monospacedSystemFont(ofSize: defaultFont.pointSize, weight: .regular), range: attributed.fullRange)
|
2020-01-18 21:00:38 +00:00
|
|
|
case "pre":
|
|
|
|
attributed.append(NSAttributedString(string: "\n\n"))
|
2022-05-15 19:42:48 +00:00
|
|
|
attributed.addAttribute(.font, value: UIFont.monospacedSystemFont(ofSize: defaultFont.pointSize, weight: .regular), range: attributed.fullRange)
|
2020-01-18 21:00:38 +00:00
|
|
|
case "ol", "ul":
|
|
|
|
attributed.append(NSAttributedString(string: "\n\n"))
|
2022-05-15 19:42:48 +00:00
|
|
|
attributed.trimLeadingCharactersInSet(.whitespacesAndNewlines)
|
2020-01-18 21:00:38 +00:00
|
|
|
case "li":
|
|
|
|
let parentEl = node.parent()!
|
|
|
|
let parentTag = parentEl.tagName()
|
|
|
|
let bullet: NSAttributedString
|
|
|
|
if parentTag == "ol" {
|
|
|
|
let index = (try? node.elementSiblingIndex()) ?? 0
|
|
|
|
// we use the monospace digit font so that the periods of all the list items line up
|
2021-08-13 01:03:11 +00:00
|
|
|
bullet = NSAttributedString(string: "\(index + 1).\t", attributes: [.font: UIFont.monospacedDigitSystemFont(ofSize: defaultFont.pointSize, weight: .regular)])
|
2020-01-18 21:00:38 +00:00
|
|
|
} else if parentTag == "ul" {
|
2022-05-15 19:42:48 +00:00
|
|
|
bullet = NSAttributedString(string: "\u{2022}\t", attributes: [.font: defaultFont])
|
2020-01-18 21:00:38 +00:00
|
|
|
} else {
|
|
|
|
bullet = NSAttributedString()
|
|
|
|
}
|
|
|
|
attributed.insert(bullet, at: 0)
|
2022-05-15 19:42:48 +00:00
|
|
|
attributed.append(NSAttributedString(string: "\n", attributes: [.font: defaultFont]))
|
2020-01-18 21:00:38 +00:00
|
|
|
default:
|
|
|
|
break
|
|
|
|
}
|
|
|
|
|
|
|
|
return attributed
|
|
|
|
default:
|
|
|
|
fatalError("Unexpected node type \(type(of: node))")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// MARK: - Interaction
|
|
|
|
|
|
|
|
// only accept touches that are over a link
|
|
|
|
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
|
2020-01-18 21:18:32 +00:00
|
|
|
if getLinkAtPoint(point) != nil || isSelectable {
|
2020-01-18 23:38:00 +00:00
|
|
|
return super.hitTest(point, with: event)
|
2020-01-18 21:00:38 +00:00
|
|
|
} else {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-19 00:32:39 +00:00
|
|
|
@objc func textTapped(_ recognizer: UITapGestureRecognizer) {
|
2020-05-08 01:46:59 +00:00
|
|
|
// if there currently is a selection, deselct it on single-tap
|
|
|
|
if selectedRange.length > 0 {
|
|
|
|
// location doesn't matter since we are non-editable and the cursor isn't visible
|
|
|
|
selectedRange = NSRange(location: 0, length: 0)
|
|
|
|
}
|
|
|
|
|
2020-01-19 00:32:39 +00:00
|
|
|
let location = recognizer.location(in: self)
|
|
|
|
if let (link, range) = getLinkAtPoint(location) {
|
|
|
|
let text = (self.text as NSString).substring(with: range)
|
|
|
|
handleLinkTapped(url: link, text: text)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-18 21:00:38 +00:00
|
|
|
func getLinkAtPoint(_ point: CGPoint) -> (URL, NSRange)? {
|
|
|
|
let locationInTextContainer = CGPoint(x: point.x - textContainerInset.left, y: point.y - textContainerInset.top)
|
|
|
|
var partialFraction: CGFloat = 0
|
|
|
|
let characterIndex = layoutManager.characterIndex(for: locationInTextContainer, in: textContainer, fractionOfDistanceBetweenInsertionPoints: &partialFraction)
|
2020-08-16 18:52:08 +00:00
|
|
|
if characterIndex < textStorage.length && partialFraction < 1 {
|
2020-01-18 21:00:38 +00:00
|
|
|
var range = NSRange()
|
|
|
|
if let link = textStorage.attribute(.link, at: characterIndex, longestEffectiveRange: &range, in: textStorage.fullRange) as? URL {
|
|
|
|
return (link, range)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-01-19 00:32:39 +00:00
|
|
|
func handleLinkTapped(url: URL, text: String) {
|
|
|
|
if let mention = getMention(for: url, text: text) {
|
|
|
|
navigationDelegate?.selected(mention: mention)
|
|
|
|
} else if let tag = getHashtag(for: url, text: text) {
|
|
|
|
navigationDelegate?.selected(tag: tag)
|
|
|
|
} else {
|
|
|
|
navigationDelegate?.selected(url: url)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-18 21:00:38 +00:00
|
|
|
// MARK: - Navigation
|
|
|
|
|
|
|
|
func getViewController(forLink url: URL, inRange range: NSRange) -> UIViewController {
|
|
|
|
let text = (self.text as NSString).substring(with: range)
|
|
|
|
|
|
|
|
if let mention = getMention(for: url, text: text) {
|
2020-07-05 20:17:56 +00:00
|
|
|
return ProfileViewController(accountID: mention.id, mastodonController: mastodonController!)
|
2020-01-18 21:00:38 +00:00
|
|
|
} else if let tag = getHashtag(for: url, text: text) {
|
2020-01-18 23:56:36 +00:00
|
|
|
return HashtagTimelineViewController(for: tag, mastodonController: mastodonController!)
|
2020-01-18 21:00:38 +00:00
|
|
|
} else {
|
|
|
|
return SFSafariViewController(url: url)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
open func getMention(for url: URL, text: String) -> Mention? {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
open func getHashtag(for url: URL, text: String) -> Hashtag? {
|
|
|
|
if text.starts(with: "#") {
|
|
|
|
let tag = String(text.dropFirst())
|
|
|
|
return Hashtag(name: tag, url: url)
|
|
|
|
} else {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
extension ContentTextView: UITextViewDelegate {
|
|
|
|
func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool {
|
2020-01-19 00:32:39 +00:00
|
|
|
// disable the text view's link interactions, we handle tapping links ourself with a gesture recognizer
|
2020-01-18 21:00:38 +00:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-02 03:04:56 +00:00
|
|
|
extension ContentTextView: MenuActionProvider {
|
|
|
|
var toastableViewController: ToastableViewController? {
|
|
|
|
// todo: pass this down through the text view
|
|
|
|
nil
|
2020-01-18 21:00:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
extension ContentTextView: UIContextMenuInteractionDelegate {
|
|
|
|
func contextMenuInteraction(_ interaction: UIContextMenuInteraction, configurationForMenuAtLocation location: CGPoint) -> UIContextMenuConfiguration? {
|
|
|
|
if let (link, range) = getLinkAtPoint(location) {
|
2020-07-01 22:50:20 +00:00
|
|
|
// Store the previewed link range for use in the previewForHighlighting method
|
|
|
|
currentPreviewedLinkRange = range
|
2020-06-25 14:42:46 +00:00
|
|
|
|
2020-01-18 21:00:38 +00:00
|
|
|
let preview: UIContextMenuContentPreviewProvider = {
|
|
|
|
self.getViewController(forLink: link, inRange: range)
|
|
|
|
}
|
|
|
|
let actions: UIContextMenuActionProvider = { (_) in
|
|
|
|
let text = (self.text as NSString).substring(with: range)
|
2020-06-27 04:22:14 +00:00
|
|
|
let actions: [UIMenuElement]
|
2020-01-18 21:00:38 +00:00
|
|
|
if let mention = self.getMention(for: link, text: text) {
|
|
|
|
actions = self.actionsForProfile(accountID: mention.id, sourceView: self)
|
|
|
|
} else if let tag = self.getHashtag(for: link, text: text) {
|
|
|
|
actions = self.actionsForHashtag(tag, sourceView: self)
|
|
|
|
} else {
|
|
|
|
actions = self.actionsForURL(link, sourceView: self)
|
|
|
|
}
|
|
|
|
return UIMenu(title: "", image: nil, identifier: nil, options: [], children: actions)
|
|
|
|
}
|
2020-06-25 14:42:46 +00:00
|
|
|
|
2020-07-01 22:50:20 +00:00
|
|
|
return UIContextMenuConfiguration(identifier: nil, previewProvider: preview, actionProvider: actions)
|
2020-01-18 21:00:38 +00:00
|
|
|
} else {
|
2020-07-01 22:50:20 +00:00
|
|
|
currentPreviewedLinkRange = nil
|
2020-01-18 21:00:38 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
2020-06-25 14:42:46 +00:00
|
|
|
|
|
|
|
func contextMenuInteraction(_ interaction: UIContextMenuInteraction, previewForHighlightingMenuWithConfiguration configuration: UIContextMenuConfiguration) -> UITargetedPreview? {
|
2020-07-01 22:50:20 +00:00
|
|
|
// If there isn't a link range, use the default system-generated preview.
|
|
|
|
guard let range = currentPreviewedLinkRange else {
|
2020-06-25 14:42:46 +00:00
|
|
|
return nil
|
|
|
|
}
|
2020-07-01 22:50:20 +00:00
|
|
|
currentPreviewedLinkRange = nil
|
2020-06-25 14:42:46 +00:00
|
|
|
|
2020-07-01 22:50:20 +00:00
|
|
|
// Determine the line rects that the link takes up in the coordinate space of this view.
|
|
|
|
var rects = [CGRect]()
|
|
|
|
layoutManager.enumerateEnclosingRects(forGlyphRange: range, withinSelectedGlyphRange: NSRange(location: NSNotFound, length: 0), in: textContainer) { (rect, stop) in
|
|
|
|
rects.append(rect)
|
2020-06-25 14:42:46 +00:00
|
|
|
}
|
|
|
|
|
2020-07-01 22:50:20 +00:00
|
|
|
// Try to create a snapshot view of this view to disply as the preview.
|
2020-06-25 14:42:46 +00:00
|
|
|
// If a snapshot view cannot be created, we bail and use the system-provided preview.
|
2020-07-01 22:50:20 +00:00
|
|
|
guard let snapshot = self.snapshotView(afterScreenUpdates: false) else {
|
2020-06-25 14:42:46 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-07-01 03:24:03 +00:00
|
|
|
// Mask the snapshot layer to only show the text of the link, and nothing else.
|
|
|
|
// By default, the system-applied mask is too wide and other content may seep in.
|
2020-07-01 22:50:20 +00:00
|
|
|
let path = UIBezierPath(wrappingAround: rects)
|
2020-07-01 03:24:03 +00:00
|
|
|
let maskLayer = CAShapeLayer()
|
|
|
|
maskLayer.path = path.cgPath
|
|
|
|
snapshot.layer.mask = maskLayer
|
2020-06-25 14:42:46 +00:00
|
|
|
|
2020-07-01 22:50:20 +00:00
|
|
|
// The preview parameters describe how the preview view is shown inside the preview.
|
|
|
|
let parameters = UIPreviewParameters(textLineRects: rects as [NSValue])
|
|
|
|
|
|
|
|
// Calculate the smallest rect enclosing all of the text line rects, in the coordinate space of this view.
|
|
|
|
var minX: CGFloat = .greatestFiniteMagnitude, maxX: CGFloat = -.greatestFiniteMagnitude, minY: CGFloat = .greatestFiniteMagnitude, maxY: CGFloat = -.greatestFiniteMagnitude
|
|
|
|
for rect in rects {
|
|
|
|
minX = min(rect.minX, minX)
|
|
|
|
maxX = max(rect.maxX, maxX)
|
|
|
|
minY = min(rect.minY, minY)
|
|
|
|
maxY = max(rect.maxY, maxY)
|
|
|
|
}
|
2020-06-25 14:42:46 +00:00
|
|
|
// The center point of the the minimum enclosing rect in our coordinate space is the point where the
|
|
|
|
// center of the preview should be, since that's also in this view's coordinate space.
|
2020-07-01 22:50:20 +00:00
|
|
|
let rectsCenter = CGPoint(x: (minX + maxX) / 2, y: (minY + maxY) / 2)
|
2020-06-25 14:42:46 +00:00
|
|
|
|
|
|
|
// The preview target describes how the preview is positioned.
|
|
|
|
let target = UIPreviewTarget(container: self, center: rectsCenter)
|
|
|
|
|
2020-07-01 03:24:03 +00:00
|
|
|
// Create a dummy containerview for the snapshot view, since using a view with a CALayer mask and UIPreviewParameters(textLineRects:)
|
|
|
|
// causes the mask to be ignored. See FB7832297
|
|
|
|
let snapshotContainer = UIView(frame: snapshot.bounds)
|
2020-08-16 18:45:01 +00:00
|
|
|
snapshotContainer.backgroundColor = .systemBackground
|
2020-07-01 03:24:03 +00:00
|
|
|
snapshotContainer.addSubview(snapshot)
|
|
|
|
|
2020-07-01 22:50:20 +00:00
|
|
|
let preview = UITargetedPreview(view: snapshotContainer, parameters: parameters, target: target)
|
|
|
|
currentTargetedPreview = preview
|
|
|
|
return preview
|
|
|
|
}
|
|
|
|
|
|
|
|
func contextMenuInteraction(_ interaction: UIContextMenuInteraction, previewForDismissingMenuWithConfiguration configuration: UIContextMenuConfiguration) -> UITargetedPreview? {
|
|
|
|
// Use the same preview for dismissing as was used for highlighting, so that the link animates back to the original position.
|
|
|
|
return currentTargetedPreview
|
2020-06-25 14:42:46 +00:00
|
|
|
}
|
|
|
|
|
2020-01-18 21:00:38 +00:00
|
|
|
func contextMenuInteraction(_ interaction: UIContextMenuInteraction, willPerformPreviewActionForMenuWith configuration: UIContextMenuConfiguration, animator: UIContextMenuInteractionCommitAnimating) {
|
|
|
|
if let viewController = animator.previewViewController {
|
|
|
|
animator.preferredCommitStyle = .pop
|
|
|
|
animator.addCompletion {
|
|
|
|
self.navigationDelegate?.show(viewController)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|