From a51f20354686f217f86d05436ccffdaafb1ccd94 Mon Sep 17 00:00:00 2001 From: Nathan Mattes Date: Sat, 24 Dec 2022 00:40:15 +0100 Subject: [PATCH] Remove iOS-version-checks (#806) --- .../MediaPreview/AltViewController.swift | 9 ++--- .../View/Content/MediaAltTextOverlay.swift | 2 -- .../MastodonUI/View/Content/MediaView.swift | 36 ++++++------------- 3 files changed, 13 insertions(+), 34 deletions(-) diff --git a/Mastodon/Scene/MediaPreview/AltViewController.swift b/Mastodon/Scene/MediaPreview/AltViewController.swift index 668771fac..a483a45c3 100644 --- a/Mastodon/Scene/MediaPreview/AltViewController.swift +++ b/Mastodon/Scene/MediaPreview/AltViewController.swift @@ -10,14 +10,9 @@ import SwiftUI class AltViewController: UIViewController { private var alt: String let label = { - if #available(iOS 16, *) { - // TODO: update code below to use TextKit 2 when dropping iOS 15 support - return UITextView(usingTextLayoutManager: false) - } else { - return UITextView() - } + return UITextView() }() - + init(alt: String, sourceView: UIView?) { self.alt = alt super.init(nibName: nil, bundle: nil) diff --git a/MastodonSDK/Sources/MastodonUI/View/Content/MediaAltTextOverlay.swift b/MastodonSDK/Sources/MastodonUI/View/Content/MediaAltTextOverlay.swift index fec17f1ee..a625be292 100644 --- a/MastodonSDK/Sources/MastodonUI/View/Content/MediaAltTextOverlay.swift +++ b/MastodonSDK/Sources/MastodonUI/View/Content/MediaAltTextOverlay.swift @@ -7,7 +7,6 @@ import SwiftUI -@available(iOS 15.0, *) struct MediaAltTextOverlay: View { var altDescription: String? @@ -69,7 +68,6 @@ struct MediaAltTextOverlay: View { } } -@available(iOS 15.0, *) struct MediaAltTextOverlay_Previews: PreviewProvider { static var previews: some View { MediaAltTextOverlay(altDescription: "Hello, world!") diff --git a/MastodonSDK/Sources/MastodonUI/View/Content/MediaView.swift b/MastodonSDK/Sources/MastodonUI/View/Content/MediaView.swift index a140d9737..d8a3a9464 100644 --- a/MastodonSDK/Sources/MastodonUI/View/Content/MediaView.swift +++ b/MastodonSDK/Sources/MastodonUI/View/Content/MediaView.swift @@ -73,20 +73,12 @@ public final class MediaView: UIView { return label }() - let _altViewController: UIViewController! = { - if #available(iOS 15.0, *) { - let vc = UIHostingController(rootView: MediaAltTextOverlay()) - vc.view.backgroundColor = .clear - return vc - } else { - return nil - } + let altViewController: UIHostingController = { + let vc = UIHostingController(rootView: MediaAltTextOverlay()) + vc.view.backgroundColor = .clear + return vc }() - @available(iOS 15.0, *) - var altViewController: UIHostingController { - _altViewController as! UIHostingController - } - + public override init(frame: CGRect) { super.init(frame: frame) _init() @@ -228,9 +220,8 @@ extension MediaView { } else { accessibilityLabel = altDescription } - if #available(iOS 15.0, *) { - altViewController.rootView.altDescription = altDescription - } + + altViewController.rootView.altDescription = altDescription } private func layoutBlurhash() { @@ -262,11 +253,9 @@ extension MediaView { } private func layoutAlt() { - if #available(iOS 15.0, *) { - altViewController.view.translatesAutoresizingMaskIntoConstraints = false - container.addSubview(altViewController.view) - altViewController.view.pinToParent() - } + altViewController.view.translatesAutoresizingMaskIntoConstraints = false + container.addSubview(altViewController.view) + altViewController.view.pinToParent() } public func prepareForReuse() { @@ -303,10 +292,7 @@ extension MediaView { // reset container container.removeFromSuperview() container.removeConstraints(container.constraints) - - if #available(iOS 15.0, *) { - altViewController.rootView.altDescription = nil - } + altViewController.rootView.altDescription = nil // reset configuration configuration = nil