mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 19:44:05 +00:00
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
|
@MainActor
|
||||||
/// A window manager that supports switching between a main app window with an overlay and
|
/// 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.
|
/// 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 {
|
class WindowManager {
|
||||||
weak var delegate: WindowManagerDelegate?
|
weak var delegate: WindowManagerDelegate?
|
||||||
|
|
||||||
@@ -40,13 +41,9 @@ class WindowManager {
|
|||||||
mainWindow = windowScene.keyWindow
|
mainWindow = windowScene.keyWindow
|
||||||
mainWindow.tintColor = .compound.textActionPrimary
|
mainWindow.tintColor = .compound.textActionPrimary
|
||||||
|
|
||||||
overlayWindow = UIWindow(windowScene: windowScene)
|
overlayWindow = PassthroughWindow(windowScene: windowScene)
|
||||||
overlayWindow.tintColor = .compound.textActionPrimary
|
overlayWindow.tintColor = .compound.textActionPrimary
|
||||||
overlayWindow.backgroundColor = .clear
|
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
|
overlayWindow.isHidden = false
|
||||||
|
|
||||||
alternateWindow = UIWindow(windowScene: windowScene)
|
alternateWindow = UIWindow(windowScene: windowScene)
|
||||||
@@ -74,3 +71,14 @@ class WindowManager {
|
|||||||
mainWindow.endEditing(true)
|
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
|
// DO NOT EDIT
|
||||||
|
|
||||||
// swiftlint:disable all
|
// swiftlint:disable all
|
||||||
|
|||||||
Reference in New Issue
Block a user