Remove iOS-version-checks (#806)
This commit is contained in:
parent
80c145111a
commit
a51f203546
|
@ -10,14 +10,9 @@ import SwiftUI
|
||||||
class AltViewController: UIViewController {
|
class AltViewController: UIViewController {
|
||||||
private var alt: String
|
private var alt: String
|
||||||
let label = {
|
let label = {
|
||||||
if #available(iOS 16, *) {
|
return UITextView()
|
||||||
// TODO: update code below to use TextKit 2 when dropping iOS 15 support
|
|
||||||
return UITextView(usingTextLayoutManager: false)
|
|
||||||
} else {
|
|
||||||
return UITextView()
|
|
||||||
}
|
|
||||||
}()
|
}()
|
||||||
|
|
||||||
init(alt: String, sourceView: UIView?) {
|
init(alt: String, sourceView: UIView?) {
|
||||||
self.alt = alt
|
self.alt = alt
|
||||||
super.init(nibName: nil, bundle: nil)
|
super.init(nibName: nil, bundle: nil)
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
|
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
@available(iOS 15.0, *)
|
|
||||||
struct MediaAltTextOverlay: View {
|
struct MediaAltTextOverlay: View {
|
||||||
var altDescription: String?
|
var altDescription: String?
|
||||||
|
|
||||||
|
@ -69,7 +68,6 @@ struct MediaAltTextOverlay: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@available(iOS 15.0, *)
|
|
||||||
struct MediaAltTextOverlay_Previews: PreviewProvider {
|
struct MediaAltTextOverlay_Previews: PreviewProvider {
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
MediaAltTextOverlay(altDescription: "Hello, world!")
|
MediaAltTextOverlay(altDescription: "Hello, world!")
|
||||||
|
|
|
@ -73,20 +73,12 @@ public final class MediaView: UIView {
|
||||||
return label
|
return label
|
||||||
}()
|
}()
|
||||||
|
|
||||||
let _altViewController: UIViewController! = {
|
let altViewController: UIHostingController<MediaAltTextOverlay> = {
|
||||||
if #available(iOS 15.0, *) {
|
let vc = UIHostingController(rootView: MediaAltTextOverlay())
|
||||||
let vc = UIHostingController(rootView: MediaAltTextOverlay())
|
vc.view.backgroundColor = .clear
|
||||||
vc.view.backgroundColor = .clear
|
return vc
|
||||||
return vc
|
|
||||||
} else {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}()
|
}()
|
||||||
@available(iOS 15.0, *)
|
|
||||||
var altViewController: UIHostingController<MediaAltTextOverlay> {
|
|
||||||
_altViewController as! UIHostingController<MediaAltTextOverlay>
|
|
||||||
}
|
|
||||||
|
|
||||||
public override init(frame: CGRect) {
|
public override init(frame: CGRect) {
|
||||||
super.init(frame: frame)
|
super.init(frame: frame)
|
||||||
_init()
|
_init()
|
||||||
|
@ -228,9 +220,8 @@ extension MediaView {
|
||||||
} else {
|
} else {
|
||||||
accessibilityLabel = altDescription
|
accessibilityLabel = altDescription
|
||||||
}
|
}
|
||||||
if #available(iOS 15.0, *) {
|
|
||||||
altViewController.rootView.altDescription = altDescription
|
altViewController.rootView.altDescription = altDescription
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private func layoutBlurhash() {
|
private func layoutBlurhash() {
|
||||||
|
@ -262,11 +253,9 @@ extension MediaView {
|
||||||
}
|
}
|
||||||
|
|
||||||
private func layoutAlt() {
|
private func layoutAlt() {
|
||||||
if #available(iOS 15.0, *) {
|
altViewController.view.translatesAutoresizingMaskIntoConstraints = false
|
||||||
altViewController.view.translatesAutoresizingMaskIntoConstraints = false
|
container.addSubview(altViewController.view)
|
||||||
container.addSubview(altViewController.view)
|
altViewController.view.pinToParent()
|
||||||
altViewController.view.pinToParent()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public func prepareForReuse() {
|
public func prepareForReuse() {
|
||||||
|
@ -303,10 +292,7 @@ extension MediaView {
|
||||||
// reset container
|
// reset container
|
||||||
container.removeFromSuperview()
|
container.removeFromSuperview()
|
||||||
container.removeConstraints(container.constraints)
|
container.removeConstraints(container.constraints)
|
||||||
|
altViewController.rootView.altDescription = nil
|
||||||
if #available(iOS 15.0, *) {
|
|
||||||
altViewController.rootView.altDescription = nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// reset configuration
|
// reset configuration
|
||||||
configuration = nil
|
configuration = nil
|
||||||
|
|
Loading…
Reference in New Issue