From 9d01bbabd76d66e0aeb3bdf99e6bd736f07a451c Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Tue, 7 Nov 2023 22:37:07 -0500 Subject: [PATCH] visionOS: Use UIColor.link for text links --- Tusker/Views/ContentTextView.swift | 6 ++++++ Tusker/Views/Profile Header/ProfileFieldValueView.swift | 4 ++++ Tusker/Views/Status/StatusCardView.swift | 4 ++++ 3 files changed, 14 insertions(+) diff --git a/Tusker/Views/ContentTextView.swift b/Tusker/Views/ContentTextView.swift index 9a5661f1..29b2d2de 100644 --- a/Tusker/Views/ContentTextView.swift +++ b/Tusker/Views/ContentTextView.swift @@ -78,9 +78,15 @@ class ContentTextView: LinkTextView, BaseEmojiLabel { textContainerInset = .zero textContainer.lineFragmentPadding = 0 + #if os(visionOS) + linkTextAttributes = [ + .foregroundColor: UIColor.link + ] + #else linkTextAttributes = [ .foregroundColor: UIColor.tintColor ] + #endif updateLinkUnderlineStyle() // the text view's builtin link interaction code is tied to isSelectable, so we need to use our own tap recognizer diff --git a/Tusker/Views/Profile Header/ProfileFieldValueView.swift b/Tusker/Views/Profile Header/ProfileFieldValueView.swift index 68688f72..0981343a 100644 --- a/Tusker/Views/Profile Header/ProfileFieldValueView.swift +++ b/Tusker/Views/Profile Header/ProfileFieldValueView.swift @@ -48,7 +48,11 @@ class ProfileFieldValueView: UIView { converted.enumerateAttribute(.link, in: converted.fullRange) { value, range, stop in guard value != nil else { return } + #if os(visionOS) + converted.addAttribute(.foregroundColor, value: UIColor.link, range: range) + #else converted.addAttribute(.foregroundColor, value: UIColor.tintColor, range: range) + #endif // the .link attribute in a UILabel always makes the color blue >.> converted.removeAttribute(.link, range: range) } diff --git a/Tusker/Views/Status/StatusCardView.swift b/Tusker/Views/Status/StatusCardView.swift index 378d096e..60ba2bb1 100644 --- a/Tusker/Views/Status/StatusCardView.swift +++ b/Tusker/Views/Status/StatusCardView.swift @@ -69,7 +69,11 @@ class StatusCardView: UIView { domainLabel.font = .preferredFont(forTextStyle: .caption2) domainLabel.adjustsFontForContentSizeCategory = true domainLabel.numberOfLines = 1 + #if os(visionOS) + domainLabel.textColor = .link + #else domainLabel.textColor = .tintColor + #endif vStack = UIStackView(arrangedSubviews: [ titleLabel,