From f96d1d780cd578512770cb28dc66ca3d7d103172 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sat, 9 Jul 2022 11:25:23 -0400 Subject: [PATCH] Enable data detectors on main status text view Tapping detected items doesn't work because it conflicts with our tap gesture recognizer, but long pressing does --- Tusker/Views/ContentTextView.swift | 5 +++-- .../Views/Status/ConversationMainStatusTableViewCell.swift | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Tusker/Views/ContentTextView.swift b/Tusker/Views/ContentTextView.swift index 8f47a1aedc..27de5184bd 100644 --- a/Tusker/Views/ContentTextView.swift +++ b/Tusker/Views/ContentTextView.swift @@ -270,8 +270,9 @@ class ContentTextView: LinkTextView, BaseEmojiLabel { extension ContentTextView: UITextViewDelegate { func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool { - // disable the text view's link interactions, we handle tapping links ourself with a gesture recognizer - return false + // generally disable the text view's link interactions, we handle tapping links ourself with a gesture recognizer + // the builtin data detectors use the x-apple-data-detectors scheme, and we allow the text view to handle those itself + return URL.scheme == "x-apple-data-detectors" } } diff --git a/Tusker/Views/Status/ConversationMainStatusTableViewCell.swift b/Tusker/Views/Status/ConversationMainStatusTableViewCell.swift index e861e72160..ee447bcbe0 100644 --- a/Tusker/Views/Status/ConversationMainStatusTableViewCell.swift +++ b/Tusker/Views/Status/ConversationMainStatusTableViewCell.swift @@ -50,6 +50,10 @@ class ConversationMainStatusTableViewCell: BaseStatusTableViewCell { ] contentTextView.defaultFont = .systemFont(ofSize: 18) + contentTextView.dataDetectorTypes = [.flightNumber, .address, .shipmentTrackingNumber, .phoneNumber] + if #available(iOS 16.0, *) { + contentTextView.dataDetectorTypes.formUnion([.money, .physicalValue]) + } profileDetailContainerView.addInteraction(UIContextMenuInteraction(delegate: self))