mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
Clean up the window manager and its protocols
This commit is contained in:
committed by
Stefan Ceriu
parent
bb61db285b
commit
b7333b9b5f
@@ -74,31 +74,6 @@ class WindowManager: SecureWindowManagerProtocol {
|
||||
self.dismissWindowAction = dismissWindowAction
|
||||
}
|
||||
|
||||
func registerCoordinator(_ coordinator: CoordinatorProtocol, flowCoordinator: FlowCoordinatorProtocol?, forWindowType type: WindowManagerWindowType) {
|
||||
coordinators[type] = (coordinator, flowCoordinator)
|
||||
openWindowAction(value: type)
|
||||
}
|
||||
|
||||
func closeAllAuxiliaryWindows() {
|
||||
for key in coordinators.keys {
|
||||
dismissWindowAction(value: key)
|
||||
}
|
||||
|
||||
coordinators.removeAll()
|
||||
}
|
||||
|
||||
func windowForType(_ type: WindowManagerWindowType) -> AnyView {
|
||||
guard let coordinator = coordinators[type]?.coordinator else {
|
||||
return AnyView(InstantlyDismissingWindow())
|
||||
}
|
||||
|
||||
// This behaves strangely and gets called late but cleans up enough
|
||||
// and is self contained enough to be just good .. enough
|
||||
return AnyView(coordinator.toPresentable().onDisappear { [weak self] in
|
||||
self?.coordinators[type] = nil
|
||||
})
|
||||
}
|
||||
|
||||
func handleRoute(_ appRoute: AppRoute, windowType: WindowManagerWindowType) {
|
||||
if let flowCoordinator = coordinators[windowType]?.flowCoordinator {
|
||||
flowCoordinator.handleAppRoute(appRoute, animated: true)
|
||||
@@ -167,6 +142,8 @@ class WindowManager: SecureWindowManagerProtocol {
|
||||
mainWindow.makeKey()
|
||||
}
|
||||
|
||||
// MARK: - OrientationManager
|
||||
|
||||
func setOrientation(_ orientation: UIInterfaceOrientationMask) {
|
||||
mainScene?.requestGeometryUpdate(.iOS(interfaceOrientations: orientation))
|
||||
}
|
||||
@@ -175,9 +152,36 @@ class WindowManager: SecureWindowManagerProtocol {
|
||||
appDelegate.orientationLock = orientation
|
||||
}
|
||||
|
||||
// MARK: - Auxiliary window support
|
||||
|
||||
func windowForType(_ type: WindowManagerWindowType) -> AnyView {
|
||||
guard let coordinator = coordinators[type]?.coordinator else {
|
||||
return AnyView(InstantlyDismissingWindow())
|
||||
}
|
||||
|
||||
// This behaves strangely and gets called late but cleans up enough
|
||||
// and is self contained enough to be just good .. enough
|
||||
return AnyView(coordinator.toPresentable().onDisappear { [weak self] in
|
||||
self?.coordinators[type] = nil
|
||||
})
|
||||
}
|
||||
|
||||
func registerCoordinator(_ coordinator: CoordinatorProtocol, flowCoordinator: FlowCoordinatorProtocol?, forWindowType type: WindowManagerWindowType) {
|
||||
coordinators[type] = (coordinator, flowCoordinator)
|
||||
openWindowAction(value: type)
|
||||
}
|
||||
|
||||
func closeAuxiliaryWindow(forType type: WindowManagerWindowType) {
|
||||
dismissWindowAction(value: type)
|
||||
}
|
||||
|
||||
func closeAllAuxiliaryWindows() {
|
||||
for key in coordinators.keys {
|
||||
dismissWindowAction(value: key)
|
||||
}
|
||||
|
||||
coordinators.removeAll()
|
||||
}
|
||||
}
|
||||
|
||||
private class PassthroughWindow: UIWindow {
|
||||
|
||||
Reference in New Issue
Block a user