mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Cleanup following the AppMediator introduction (#2723)
- stop using multiple background task, the appCoordinator sync one is enough for the whole app - move the AppMeditor to the MainActor - expose the WindowManager through the AppMediator - hide sensitive WindowManager API behind a different protocol - remove the now unnecessary `BackgroundTaskService`
This commit is contained in:
@@ -20,7 +20,7 @@ import SwiftUI
|
||||
///
|
||||
/// We don't support multiple scenes right now, so the implementation is pretty basic.
|
||||
class SceneDelegate: NSObject, UIWindowSceneDelegate {
|
||||
weak static var windowManager: WindowManagerProtocol!
|
||||
weak static var windowManager: SecureWindowManagerProtocol!
|
||||
|
||||
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
|
||||
guard let windowScene = scene as? UIWindowScene else { return }
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
import Combine
|
||||
import SwiftUI
|
||||
|
||||
class WindowManager: WindowManagerProtocol {
|
||||
class WindowManager: SecureWindowManagerProtocol {
|
||||
private let appDelegate: AppDelegate
|
||||
weak var windowScene: UIWindowScene?
|
||||
weak var delegate: WindowManagerDelegate?
|
||||
weak var delegate: SecureWindowManagerDelegate?
|
||||
|
||||
private(set) var mainWindow: UIWindow!
|
||||
private(set) var overlayWindow: UIWindow!
|
||||
|
||||
@@ -16,18 +16,29 @@
|
||||
|
||||
import SwiftUI
|
||||
|
||||
protocol WindowManagerDelegate: AnyObject {
|
||||
protocol SecureWindowManagerDelegate: AnyObject {
|
||||
/// The window manager has configured its windows.
|
||||
func windowManagerDidConfigureWindows(_ windowManager: WindowManagerProtocol)
|
||||
func windowManagerDidConfigureWindows(_ windowManager: SecureWindowManagerProtocol)
|
||||
}
|
||||
|
||||
@MainActor
|
||||
protocol SecureWindowManagerProtocol: WindowManagerProtocol {
|
||||
var delegate: SecureWindowManagerDelegate? { get set }
|
||||
|
||||
/// Configures the window manager to operate on the supplied scene.
|
||||
func configure(with windowScene: UIWindowScene)
|
||||
|
||||
/// Shows the main and overlay window combo, hiding the alternate window.
|
||||
func switchToMain()
|
||||
|
||||
/// Shows the alternate window, hiding the main and overlay combo.
|
||||
func switchToAlternate()
|
||||
}
|
||||
|
||||
/// 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/
|
||||
protocol WindowManagerProtocol: AnyObject, OrientationManagerProtocol {
|
||||
var delegate: WindowManagerDelegate? { get set }
|
||||
|
||||
/// The app's main window (we only support a single scene).
|
||||
var mainWindow: UIWindow! { get }
|
||||
/// Presented on top of the main window, to display e.g. user indicators.
|
||||
@@ -40,15 +51,6 @@ protocol WindowManagerProtocol: AnyObject, OrientationManagerProtocol {
|
||||
/// All the windows being managed
|
||||
var windows: [UIWindow] { get }
|
||||
|
||||
/// Configures the window manager to operate on the supplied scene.
|
||||
func configure(with windowScene: UIWindowScene)
|
||||
|
||||
/// Shows the main and overlay window combo, hiding the alternate window.
|
||||
func switchToMain()
|
||||
|
||||
/// Shows the alternate window, hiding the main and overlay combo.
|
||||
func switchToAlternate()
|
||||
|
||||
/// Makes the global search window key. Used to get automatic text field focus.
|
||||
func showGlobalSearch()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user