Remove iOS-version-checks (#806)
This commit is contained in:
parent
80c145111a
commit
a51f203546
|
@ -10,12 +10,7 @@ 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()
|
||||
}
|
||||
}()
|
||||
|
||||
init(alt: String, sourceView: UIView?) {
|
||||
|
|
|
@ -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!")
|
||||
|
|
|
@ -73,19 +73,11 @@ public final class MediaView: UIView {
|
|||
return label
|
||||
}()
|
||||
|
||||
let _altViewController: UIViewController! = {
|
||||
if #available(iOS 15.0, *) {
|
||||
let altViewController: UIHostingController<MediaAltTextOverlay> = {
|
||||
let vc = UIHostingController(rootView: MediaAltTextOverlay())
|
||||
vc.view.backgroundColor = .clear
|
||||
return vc
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}()
|
||||
@available(iOS 15.0, *)
|
||||
var altViewController: UIHostingController<MediaAltTextOverlay> {
|
||||
_altViewController as! UIHostingController<MediaAltTextOverlay>
|
||||
}
|
||||
|
||||
public override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
|
@ -228,10 +220,9 @@ extension MediaView {
|
|||
} else {
|
||||
accessibilityLabel = altDescription
|
||||
}
|
||||
if #available(iOS 15.0, *) {
|
||||
|
||||
altViewController.rootView.altDescription = altDescription
|
||||
}
|
||||
}
|
||||
|
||||
private func layoutBlurhash() {
|
||||
blurhashImageView.translatesAutoresizingMaskIntoConstraints = false
|
||||
|
@ -262,12 +253,10 @@ extension MediaView {
|
|||
}
|
||||
|
||||
private func layoutAlt() {
|
||||
if #available(iOS 15.0, *) {
|
||||
altViewController.view.translatesAutoresizingMaskIntoConstraints = false
|
||||
container.addSubview(altViewController.view)
|
||||
altViewController.view.pinToParent()
|
||||
}
|
||||
}
|
||||
|
||||
public func prepareForReuse() {
|
||||
_disposeBag.removeAll()
|
||||
|
@ -303,10 +292,7 @@ extension MediaView {
|
|||
// reset container
|
||||
container.removeFromSuperview()
|
||||
container.removeConstraints(container.constraints)
|
||||
|
||||
if #available(iOS 15.0, *) {
|
||||
altViewController.rootView.altDescription = nil
|
||||
}
|
||||
|
||||
// reset configuration
|
||||
configuration = nil
|
||||
|
|
Loading…
Reference in New Issue