Fix alerts presented by the user indicator controller not being inter… (#2056)
* Fix alerts presented by the user indicator controller not being interactive * Add back attribution
This commit is contained in:
@@ -25,6 +25,7 @@ protocol WindowManagerDelegate: AnyObject {
|
||||
@MainActor
|
||||
/// A window manager that supports switching between a main app window with an overlay and
|
||||
/// an alternate window to switch contexts whilst also preserving the main view hierarchy.
|
||||
/// Heavily inspired by https://www.fivestars.blog/articles/swiftui-windows/
|
||||
class WindowManager {
|
||||
weak var delegate: WindowManagerDelegate?
|
||||
|
||||
@@ -40,13 +41,9 @@ class WindowManager {
|
||||
mainWindow = windowScene.keyWindow
|
||||
mainWindow.tintColor = .compound.textActionPrimary
|
||||
|
||||
overlayWindow = UIWindow(windowScene: windowScene)
|
||||
overlayWindow = PassthroughWindow(windowScene: windowScene)
|
||||
overlayWindow.tintColor = .compound.textActionPrimary
|
||||
overlayWindow.backgroundColor = .clear
|
||||
// We don't support user interaction on our indicators so disable interaction, to pass
|
||||
// touches through to the main window. If this changes, there's another solution here:
|
||||
// https://www.fivestars.blog/articles/swiftui-windows/
|
||||
overlayWindow.isUserInteractionEnabled = false
|
||||
overlayWindow.isHidden = false
|
||||
|
||||
alternateWindow = UIWindow(windowScene: windowScene)
|
||||
@@ -74,3 +71,14 @@ class WindowManager {
|
||||
mainWindow.endEditing(true)
|
||||
}
|
||||
}
|
||||
|
||||
private class PassthroughWindow: UIWindow {
|
||||
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
|
||||
guard let hitView = super.hitTest(point, with: event) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
// If the returned view is the `UIHostingController`'s view, ignore.
|
||||
return rootViewController?.view == hitView ? nil : hitView
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated using Sourcery 2.1.1 — https://github.com/krzysztofzablocki/Sourcery
|
||||
// Generated using Sourcery 2.1.2 — https://github.com/krzysztofzablocki/Sourcery
|
||||
// DO NOT EDIT
|
||||
|
||||
// swiftlint:disable all
|
||||
|
||||
Reference in New Issue
Block a user