mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Add support for quick room search through the Cmd+K shortcut (#2363)
This commit is contained in:
@@ -24,10 +24,11 @@ class WindowManager: WindowManagerProtocol {
|
||||
|
||||
private(set) var mainWindow: UIWindow!
|
||||
private(set) var overlayWindow: UIWindow!
|
||||
private(set) var globalSearchWindow: UIWindow!
|
||||
private(set) var alternateWindow: UIWindow!
|
||||
|
||||
var windows: [UIWindow] {
|
||||
[mainWindow, overlayWindow, alternateWindow]
|
||||
[mainWindow, overlayWindow, globalSearchWindow, alternateWindow]
|
||||
}
|
||||
|
||||
// periphery:ignore - auto cancels when reassigned
|
||||
@@ -50,6 +51,11 @@ class WindowManager: WindowManagerProtocol {
|
||||
overlayWindow.backgroundColor = .clear
|
||||
overlayWindow.isHidden = false
|
||||
|
||||
globalSearchWindow = UIWindow(windowScene: windowScene)
|
||||
globalSearchWindow.tintColor = .compound.textActionPrimary
|
||||
globalSearchWindow.backgroundColor = .clear
|
||||
globalSearchWindow.isHidden = true
|
||||
|
||||
alternateWindow = UIWindow(windowScene: windowScene)
|
||||
alternateWindow.tintColor = .compound.textActionPrimary
|
||||
|
||||
@@ -60,6 +66,8 @@ class WindowManager: WindowManagerProtocol {
|
||||
mainWindow.isHidden = false
|
||||
overlayWindow.isHidden = false
|
||||
|
||||
mainWindow.makeKey()
|
||||
|
||||
switchTask = Task {
|
||||
// Delay hiding to make sure the main windows are visible.
|
||||
try await Task.sleep(for: windowHideDelay)
|
||||
@@ -76,6 +84,8 @@ class WindowManager: WindowManagerProtocol {
|
||||
// e.g. the keyboard being displayed on top of a call sheet.
|
||||
mainWindow.endEditing(true)
|
||||
|
||||
hideGlobalSearch()
|
||||
|
||||
// alternateWindow.isHidden = false cannot got inside the Task otherwise the timing
|
||||
// is poor when you lock the phone - you briefly see the main window for a few
|
||||
// frames after you've unlocked the phone and then the placeholder animates in.
|
||||
@@ -83,11 +93,30 @@ class WindowManager: WindowManagerProtocol {
|
||||
// Delay hiding to make sure the alternate window is visible.
|
||||
try await Task.sleep(for: windowHideDelay)
|
||||
|
||||
overlayWindow.isHidden = true
|
||||
mainWindow.isHidden = true
|
||||
overlayWindow.isHidden = true
|
||||
globalSearchWindow.isHidden = true
|
||||
}
|
||||
}
|
||||
|
||||
func showGlobalSearch() {
|
||||
guard alternateWindow.isHidden else {
|
||||
return
|
||||
}
|
||||
|
||||
globalSearchWindow.isHidden = false
|
||||
globalSearchWindow.makeKey()
|
||||
}
|
||||
|
||||
func hideGlobalSearch() {
|
||||
guard alternateWindow.isHidden else {
|
||||
return
|
||||
}
|
||||
|
||||
globalSearchWindow.isHidden = true
|
||||
mainWindow.makeKey()
|
||||
}
|
||||
|
||||
func setOrientation(_ orientation: UIInterfaceOrientationMask) {
|
||||
windowScene?.requestGeometryUpdate(.iOS(interfaceOrientations: orientation))
|
||||
}
|
||||
@@ -103,7 +132,15 @@ private class PassthroughWindow: UIWindow {
|
||||
return nil
|
||||
}
|
||||
|
||||
guard let rootViewController else {
|
||||
return nil
|
||||
}
|
||||
|
||||
guard hitView != self else {
|
||||
return nil
|
||||
}
|
||||
|
||||
// If the returned view is the `UIHostingController`'s view, ignore.
|
||||
return rootViewController?.view == hitView ? nil : hitView
|
||||
return rootViewController.view == hitView ? nil : hitView
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user