Skip to content

Commit

Permalink
Compile fix for visionOS (#19)
Browse files Browse the repository at this point in the history
* Compile fix for visionOS
  • Loading branch information
nighthawk committed Oct 18, 2023
1 parent b96668e commit 3eeab8d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Sources/TGCardViewController/TGCardViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,9 @@ open class TGCardViewController: UIViewController {
var panner: UIPanGestureRecognizer!
var cardTapper: UITapGestureRecognizer!
var mapShadowTapper: UITapGestureRecognizer!
#if !os(visionOS)
var edgePanner: UIScreenEdgePanGestureRecognizer!
#endif

/// Builder that determines what kind of map to use. The builder's
/// `buildMapView` method will be once initially, and the map instance will
Expand Down Expand Up @@ -371,13 +373,15 @@ open class TGCardViewController: UIViewController {
mapShadow.addGestureRecognizer(mapTapper)
self.mapShadowTapper = mapTapper

#if !os(visionOS)
// Edge panning to go back
let edgePanner = UIScreenEdgePanGestureRecognizer()
edgePanner.addTarget(self, action: #selector(popMaybe))
edgePanner.isEnabled = mode == .floating
edgePanner.edges = traitCollection.layoutDirection == .leftToRight ? .left : .right
view.addGestureRecognizer(edgePanner)
self.edgePanner = edgePanner
#endif
}

override open func viewWillAppear(_ animated: Bool) {
Expand Down Expand Up @@ -1971,7 +1975,10 @@ extension TGCardViewController {
} else if !headerIsVisible {
headerStatusBarStyle = nil
}

#if !os(visionOS)
setNeedsStatusBarAppearanceUpdate()
#endif
}

}
Expand Down Expand Up @@ -2114,19 +2121,22 @@ extension TGCardViewController {
object: nil
)

#if !os(visionOS)
NotificationCenter.default.addObserver(
self,
selector: #selector(updateForVoiceOverFocusChange),
name: UIAccessibility.elementFocusedNotification,
object: nil
)
#endif
}

@objc
private func updateForVoiceOverStatusChange() {
updateCardScrolling(allow: cardPosition == .extended, view: topCardView)
}

#if !os(visionOS)
@objc
private func updateForVoiceOverFocusChange(notification: Notification) {
guard let selection = notification.userInfo?[UIAccessibility.focusedElementUserInfoKey] as? UIAccessibilityElement else { return }
Expand All @@ -2139,6 +2149,7 @@ extension TGCardViewController {
switchTo(.extended, direction: .up, animated: true)
}
}
#endif

private func buildCardHandleAccessibilityActions() -> [UIAccessibilityCustomAction] {
return [
Expand Down

0 comments on commit 3eeab8d

Please sign in to comment.