Rename "Auxiliary" windows to "Secondary" windows

This commit is contained in:
Stefan Ceriu
2026-03-31 18:56:13 +03:00
committed by Stefan Ceriu
parent ec9cf76f2d
commit 4abf9112f4
11 changed files with 78 additions and 78 deletions
@@ -13,11 +13,11 @@ import SwiftUI
class AccessibilityTestsAppCoordinator: AppCoordinatorProtocol { class AccessibilityTestsAppCoordinator: AppCoordinatorProtocol {
var windowManager: any SecureWindowManagerProtocol var windowManager: any SecureWindowManagerProtocol
func handleDeepLink(_ url: URL, isExternalURL: Bool, windowType: WindowManagerWindowType?) -> Bool { func handleDeepLink(_ url: URL, isExternalURL: Bool, windowType: SecondaryWindowType?) -> Bool {
fatalError("Not implemented") fatalError("Not implemented")
} }
func handleAppRoute(_ appRoute: AppRoute, windowType: WindowManagerWindowType?) { func handleAppRoute(_ appRoute: AppRoute, windowType: SecondaryWindowType?) {
fatalError("Not implemented.") fatalError("Not implemented.")
} }
@@ -189,9 +189,9 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
} }
.store(in: &cancellables) .store(in: &cancellables)
windowManager.auxiliaryWindowsEnabled = !appLockService.isEnabled windowManager.secondaryWindowsEnabled = !appLockService.isEnabled
appLockService.isEnabledPublisher.sink { [weak windowManager] appLockEnabled in appLockService.isEnabledPublisher.sink { [weak windowManager] appLockEnabled in
windowManager?.auxiliaryWindowsEnabled = !appLockEnabled windowManager?.secondaryWindowsEnabled = !appLockEnabled
} }
.store(in: &cancellables) .store(in: &cancellables)
} }
@@ -240,7 +240,7 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
return true return true
} }
func handleAppRoute(_ appRoute: AppRoute, windowType: WindowManagerWindowType?) { func handleAppRoute(_ appRoute: AppRoute, windowType: SecondaryWindowType?) {
if let windowType { if let windowType {
windowManager.handleRoute(appRoute, windowType: windowType) windowManager.handleRoute(appRoute, windowType: windowType)
return return
@@ -266,7 +266,7 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
} }
} }
func handleDeepLink(_ url: URL, isExternalURL: Bool, windowType: WindowManagerWindowType?) -> Bool { func handleDeepLink(_ url: URL, isExternalURL: Bool, windowType: SecondaryWindowType?) -> Bool {
// Parse into an AppRoute to redirect these in a type safe way. // Parse into an AppRoute to redirect these in a type safe way.
if let route = appRouteURLParser.route(from: url) { if let route = appRouteURLParser.route(from: url) {
@@ -799,7 +799,7 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
fatalError("User session not setup") fatalError("User session not setup")
} }
windowManager.closeAllAuxiliaryWindows() windowManager.closeAllSecondaryWindows()
showLoadingIndicator() showLoadingIndicator()
@@ -12,9 +12,9 @@ import Foundation
protocol AppCoordinatorProtocol: CoordinatorProtocol { protocol AppCoordinatorProtocol: CoordinatorProtocol {
var windowManager: SecureWindowManagerProtocol { get } var windowManager: SecureWindowManagerProtocol { get }
@discardableResult func handleDeepLink(_ url: URL, isExternalURL: Bool, windowType: WindowManagerWindowType?) -> Bool @discardableResult func handleDeepLink(_ url: URL, isExternalURL: Bool, windowType: SecondaryWindowType?) -> Bool
func handleAppRoute(_ appRoute: AppRoute, windowType: WindowManagerWindowType?) func handleAppRoute(_ appRoute: AppRoute, windowType: SecondaryWindowType?)
func handlePotentialPhishingAttempt(url: URL, openURLAction: @escaping (URL) -> Void) -> Bool func handlePotentialPhishingAttempt(url: URL, openURLAction: @escaping (URL) -> Void) -> Bool
@@ -81,7 +81,7 @@ struct Application: App {
// This is invoked in response of the WindowManager receiving a register // This is invoked in response of the WindowManager receiving a register
// coordinator request and invoking the `OpenWindowAction` with which // coordinator request and invoking the `OpenWindowAction` with which
// it's configured in the task above. // it's configured in the task above.
WindowGroup(for: WindowManagerWindowType.self) { $type in WindowGroup(for: SecondaryWindowType.self) { $type in
if let type { if let type {
appCoordinator.windowManager.windowForType(type) appCoordinator.windowManager.windowForType(type)
.environment(\.openURL, openURLAction(appCoordinator: appCoordinator, windowType: type)) .environment(\.openURL, openURLAction(appCoordinator: appCoordinator, windowType: type))
@@ -91,7 +91,7 @@ struct Application: App {
.windowResizability(.contentSize) .windowResizability(.contentSize)
} }
private func openURLAction(appCoordinator: AppCoordinatorProtocol, windowType: WindowManagerWindowType?) -> OpenURLAction { private func openURLAction(appCoordinator: AppCoordinatorProtocol, windowType: SecondaryWindowType?) -> OpenURLAction {
.init { url in .init { url in
if appCoordinator.handleDeepLink(url, isExternalURL: false, windowType: windowType) { if appCoordinator.handleDeepLink(url, isExternalURL: false, windowType: windowType) {
return .handled return .handled
@@ -23,10 +23,10 @@ class WindowManager: SecureWindowManagerProtocol {
private(set) var openWindowAction: OpenWindowAction! private(set) var openWindowAction: OpenWindowAction!
private(set) var dismissWindowAction: DismissWindowAction! private(set) var dismissWindowAction: DismissWindowAction!
var auxiliaryWindowsEnabled = true { var secondaryWindowsEnabled = true {
didSet { didSet {
if auxiliaryWindowsEnabled == false { if secondaryWindowsEnabled == false {
closeAllAuxiliaryWindows() closeAllSecondaryWindows()
} }
} }
} }
@@ -41,7 +41,7 @@ class WindowManager: SecureWindowManagerProtocol {
/// A duration that allows window switching to wait a couple of frames to avoid a transition through black. /// A duration that allows window switching to wait a couple of frames to avoid a transition through black.
private let windowHideDelay = Duration.milliseconds(33) private let windowHideDelay = Duration.milliseconds(33)
private var coordinators: [WindowManagerWindowType: (coordinator: CoordinatorProtocol, flowCoordinator: FlowCoordinatorProtocol?)] = [:] private var coordinators: [SecondaryWindowType: (coordinator: CoordinatorProtocol, flowCoordinator: FlowCoordinatorProtocol?)] = [:]
init(appDelegate: AppDelegate) { init(appDelegate: AppDelegate) {
self.appDelegate = appDelegate self.appDelegate = appDelegate
@@ -82,7 +82,7 @@ class WindowManager: SecureWindowManagerProtocol {
self.dismissWindowAction = dismissWindowAction self.dismissWindowAction = dismissWindowAction
} }
func handleRoute(_ appRoute: AppRoute, windowType: WindowManagerWindowType) { func handleRoute(_ appRoute: AppRoute, windowType: SecondaryWindowType) {
if let flowCoordinator = coordinators[windowType]?.flowCoordinator { if let flowCoordinator = coordinators[windowType]?.flowCoordinator {
flowCoordinator.handleAppRoute(appRoute, animated: true) flowCoordinator.handleAppRoute(appRoute, animated: true)
} }
@@ -160,9 +160,9 @@ class WindowManager: SecureWindowManagerProtocol {
appDelegate.orientationLock = orientation appDelegate.orientationLock = orientation
} }
// MARK: - Auxiliary window support // MARK: - Secondary window support
func windowForType(_ type: WindowManagerWindowType) -> AnyView { func windowForType(_ type: SecondaryWindowType) -> AnyView {
guard let coordinator = coordinators[type]?.coordinator else { guard let coordinator = coordinators[type]?.coordinator else {
return AnyView(InstantlyDismissingWindow()) return AnyView(InstantlyDismissingWindow())
} }
@@ -174,9 +174,9 @@ class WindowManager: SecureWindowManagerProtocol {
}) })
} }
func registerCoordinator(_ coordinator: CoordinatorProtocol, flowCoordinator: FlowCoordinatorProtocol?, forWindowType type: WindowManagerWindowType) { func registerCoordinator(_ coordinator: CoordinatorProtocol, flowCoordinator: FlowCoordinatorProtocol?, forWindowType type: SecondaryWindowType) {
if auxiliaryWindowsEnabled == false { if secondaryWindowsEnabled == false {
MXLog.error("Cannot register coordinator, auxiliary windows are disabled.") MXLog.error("Cannot register coordinator, secondary windows are disabled.")
return return
} }
@@ -184,11 +184,11 @@ class WindowManager: SecureWindowManagerProtocol {
openWindowAction(value: type) openWindowAction(value: type)
} }
func closeAuxiliaryWindow(forType type: WindowManagerWindowType) { func closeSecondaryWindow(forType type: SecondaryWindowType) {
dismissWindowAction(value: type) dismissWindowAction(value: type)
} }
func closeAllAuxiliaryWindows() { func closeAllSecondaryWindows() {
for key in coordinators.keys { for key in coordinators.keys {
dismissWindowAction(value: key) dismissWindowAction(value: key)
} }
@@ -8,7 +8,7 @@
import SwiftUI import SwiftUI
enum WindowManagerWindowType: Hashable, Codable { enum SecondaryWindowType: Hashable, Codable {
case room(roomID: String) case room(roomID: String)
case settings case settings
} }
@@ -27,7 +27,7 @@ protocol SecureWindowManagerProtocol: WindowManagerProtocol {
func configure(withOpenWinddowAction openWindowAction: OpenWindowAction, dismissWindowAction: DismissWindowAction) func configure(withOpenWinddowAction openWindowAction: OpenWindowAction, dismissWindowAction: DismissWindowAction)
func handleRoute(_ appRoute: AppRoute, windowType: WindowManagerWindowType) func handleRoute(_ appRoute: AppRoute, windowType: SecondaryWindowType)
/// Shows the main and overlay window combo, hiding the alternate window. /// Shows the main and overlay window combo, hiding the alternate window.
func switchToMain() func switchToMain()
@@ -35,10 +35,10 @@ protocol SecureWindowManagerProtocol: WindowManagerProtocol {
/// Shows the alternate window, hiding the main and overlay combo. /// Shows the alternate window, hiding the main and overlay combo.
func switchToAlternate() func switchToAlternate()
// MARK: - Auxiliary window support // MARK: - Secondary window support
/// Used by the Application to retrieve the root view for an auxiliary window /// Used by the Application to retrieve the root view for an secondary window
func windowForType(_ type: WindowManagerWindowType) -> AnyView func windowForType(_ type: SecondaryWindowType) -> AnyView
} }
/// 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
@@ -62,21 +62,21 @@ protocol WindowManagerProtocol: AnyObject, OrientationManagerProtocol {
func hideGlobalSearch() func hideGlobalSearch()
// MARK: - Auxiliary window support // MARK: - Secondary window support
var auxiliaryWindowsEnabled: Bool { get set } var secondaryWindowsEnabled: Bool { get set }
/// Register a coordinator and it's respective flow (if any) within the WindowManager which in turn /// Register a coordinator and it's respective flow (if any) within the WindowManager which in turn
/// invokes the Application's `OpenWindowAction` /// invokes the Application's `OpenWindowAction`
func registerCoordinator(_ coordinator: CoordinatorProtocol, func registerCoordinator(_ coordinator: CoordinatorProtocol,
flowCoordinator: FlowCoordinatorProtocol?, flowCoordinator: FlowCoordinatorProtocol?,
forWindowType type: WindowManagerWindowType) forWindowType type: SecondaryWindowType)
/// Closes any window previously opened by registering a coordinator /// Closes any window previously opened by registering a coordinator
func closeAllAuxiliaryWindows() func closeAllSecondaryWindows()
/// Closes a previously opened window for the given type. /// Closes a previously opened window for the given type.
func closeAuxiliaryWindow(forType type: WindowManagerWindowType) func closeSecondaryWindow(forType type: SecondaryWindowType)
} }
// sourcery: AutoMockable // sourcery: AutoMockable
@@ -900,7 +900,7 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
// iPhone the compact module diffs call the dismissal callback and we present a blank space flow 🙈 // iPhone the compact module diffs call the dismissal callback and we present a blank space flow 🙈
if spaceRoomListProxy == nil { if spaceRoomListProxy == nil {
navigationStackCoordinator.setRootCoordinator(nil, animated: false) navigationStackCoordinator.setRootCoordinator(nil, animated: false)
flowParameters.windowManager.closeAuxiliaryWindow(forType: .room(roomID: roomID)) flowParameters.windowManager.closeSecondaryWindow(forType: .room(roomID: roomID))
} }
} }
+2 -2
View File
@@ -17,8 +17,8 @@ extension AppMediatorMock {
mock.underlyingNetworkMonitor = NetworkMonitorMock.default mock.underlyingNetworkMonitor = NetworkMonitorMock.default
let windowManagerMock = WindowManagerMock() let windowManagerMock = WindowManagerMock()
windowManagerMock.closeAllAuxiliaryWindowsClosure = { } windowManagerMock.closeAllSecondaryWindowsClosure = { }
windowManagerMock.closeAuxiliaryWindowForTypeClosure = { _ in } windowManagerMock.closeSecondaryWindowForTypeClosure = { _ in }
mock.underlyingWindowManager = windowManagerMock mock.underlyingWindowManager = windowManagerMock
return mock return mock
@@ -21357,11 +21357,11 @@ class WindowManagerMock: WindowManagerProtocol, @unchecked Sendable {
var globalSearchWindow: UIWindow! var globalSearchWindow: UIWindow!
var alternateWindow: UIWindow! var alternateWindow: UIWindow!
var windows: [UIWindow] = [] var windows: [UIWindow] = []
var auxiliaryWindowsEnabled: Bool { var secondaryWindowsEnabled: Bool {
get { return underlyingAuxiliaryWindowsEnabled } get { return underlyingSecondaryWindowsEnabled }
set(value) { underlyingAuxiliaryWindowsEnabled = value } set(value) { underlyingSecondaryWindowsEnabled = value }
} }
var underlyingAuxiliaryWindowsEnabled: Bool! var underlyingSecondaryWindowsEnabled: Bool!
//MARK: - showGlobalSearch //MARK: - showGlobalSearch
@@ -21462,11 +21462,11 @@ class WindowManagerMock: WindowManagerProtocol, @unchecked Sendable {
var registerCoordinatorFlowCoordinatorForWindowTypeCalled: Bool { var registerCoordinatorFlowCoordinatorForWindowTypeCalled: Bool {
return registerCoordinatorFlowCoordinatorForWindowTypeCallsCount > 0 return registerCoordinatorFlowCoordinatorForWindowTypeCallsCount > 0
} }
var registerCoordinatorFlowCoordinatorForWindowTypeReceivedArguments: (coordinator: CoordinatorProtocol, flowCoordinator: FlowCoordinatorProtocol?, type: WindowManagerWindowType)? var registerCoordinatorFlowCoordinatorForWindowTypeReceivedArguments: (coordinator: CoordinatorProtocol, flowCoordinator: FlowCoordinatorProtocol?, type: SecondaryWindowType)?
var registerCoordinatorFlowCoordinatorForWindowTypeReceivedInvocations: [(coordinator: CoordinatorProtocol, flowCoordinator: FlowCoordinatorProtocol?, type: WindowManagerWindowType)] = [] var registerCoordinatorFlowCoordinatorForWindowTypeReceivedInvocations: [(coordinator: CoordinatorProtocol, flowCoordinator: FlowCoordinatorProtocol?, type: SecondaryWindowType)] = []
var registerCoordinatorFlowCoordinatorForWindowTypeClosure: ((CoordinatorProtocol, FlowCoordinatorProtocol?, WindowManagerWindowType) -> Void)? var registerCoordinatorFlowCoordinatorForWindowTypeClosure: ((CoordinatorProtocol, FlowCoordinatorProtocol?, SecondaryWindowType) -> Void)?
func registerCoordinator(_ coordinator: CoordinatorProtocol, flowCoordinator: FlowCoordinatorProtocol?, forWindowType type: WindowManagerWindowType) { func registerCoordinator(_ coordinator: CoordinatorProtocol, flowCoordinator: FlowCoordinatorProtocol?, forWindowType type: SecondaryWindowType) {
registerCoordinatorFlowCoordinatorForWindowTypeCallsCount += 1 registerCoordinatorFlowCoordinatorForWindowTypeCallsCount += 1
registerCoordinatorFlowCoordinatorForWindowTypeReceivedArguments = (coordinator: coordinator, flowCoordinator: flowCoordinator, type: type) registerCoordinatorFlowCoordinatorForWindowTypeReceivedArguments = (coordinator: coordinator, flowCoordinator: flowCoordinator, type: type)
DispatchQueue.main.async { DispatchQueue.main.async {
@@ -21474,17 +21474,17 @@ class WindowManagerMock: WindowManagerProtocol, @unchecked Sendable {
} }
registerCoordinatorFlowCoordinatorForWindowTypeClosure?(coordinator, flowCoordinator, type) registerCoordinatorFlowCoordinatorForWindowTypeClosure?(coordinator, flowCoordinator, type)
} }
//MARK: - closeAllAuxiliaryWindows //MARK: - closeAllSecondaryWindows
var closeAllAuxiliaryWindowsUnderlyingCallsCount = 0 var closeAllSecondaryWindowsUnderlyingCallsCount = 0
var closeAllAuxiliaryWindowsCallsCount: Int { var closeAllSecondaryWindowsCallsCount: Int {
get { get {
if Thread.isMainThread { if Thread.isMainThread {
return closeAllAuxiliaryWindowsUnderlyingCallsCount return closeAllSecondaryWindowsUnderlyingCallsCount
} else { } else {
var returnValue: Int? = nil var returnValue: Int? = nil
DispatchQueue.main.sync { DispatchQueue.main.sync {
returnValue = closeAllAuxiliaryWindowsUnderlyingCallsCount returnValue = closeAllSecondaryWindowsUnderlyingCallsCount
} }
return returnValue! return returnValue!
@@ -21492,34 +21492,34 @@ class WindowManagerMock: WindowManagerProtocol, @unchecked Sendable {
} }
set { set {
if Thread.isMainThread { if Thread.isMainThread {
closeAllAuxiliaryWindowsUnderlyingCallsCount = newValue closeAllSecondaryWindowsUnderlyingCallsCount = newValue
} else { } else {
DispatchQueue.main.sync { DispatchQueue.main.sync {
closeAllAuxiliaryWindowsUnderlyingCallsCount = newValue closeAllSecondaryWindowsUnderlyingCallsCount = newValue
} }
} }
} }
} }
var closeAllAuxiliaryWindowsCalled: Bool { var closeAllSecondaryWindowsCalled: Bool {
return closeAllAuxiliaryWindowsCallsCount > 0 return closeAllSecondaryWindowsCallsCount > 0
} }
var closeAllAuxiliaryWindowsClosure: (() -> Void)? var closeAllSecondaryWindowsClosure: (() -> Void)?
func closeAllAuxiliaryWindows() { func closeAllSecondaryWindows() {
closeAllAuxiliaryWindowsCallsCount += 1 closeAllSecondaryWindowsCallsCount += 1
closeAllAuxiliaryWindowsClosure?() closeAllSecondaryWindowsClosure?()
} }
//MARK: - closeAuxiliaryWindow //MARK: - closeSecondaryWindow
var closeAuxiliaryWindowForTypeUnderlyingCallsCount = 0 var closeSecondaryWindowForTypeUnderlyingCallsCount = 0
var closeAuxiliaryWindowForTypeCallsCount: Int { var closeSecondaryWindowForTypeCallsCount: Int {
get { get {
if Thread.isMainThread { if Thread.isMainThread {
return closeAuxiliaryWindowForTypeUnderlyingCallsCount return closeSecondaryWindowForTypeUnderlyingCallsCount
} else { } else {
var returnValue: Int? = nil var returnValue: Int? = nil
DispatchQueue.main.sync { DispatchQueue.main.sync {
returnValue = closeAuxiliaryWindowForTypeUnderlyingCallsCount returnValue = closeSecondaryWindowForTypeUnderlyingCallsCount
} }
return returnValue! return returnValue!
@@ -21527,28 +21527,28 @@ class WindowManagerMock: WindowManagerProtocol, @unchecked Sendable {
} }
set { set {
if Thread.isMainThread { if Thread.isMainThread {
closeAuxiliaryWindowForTypeUnderlyingCallsCount = newValue closeSecondaryWindowForTypeUnderlyingCallsCount = newValue
} else { } else {
DispatchQueue.main.sync { DispatchQueue.main.sync {
closeAuxiliaryWindowForTypeUnderlyingCallsCount = newValue closeSecondaryWindowForTypeUnderlyingCallsCount = newValue
} }
} }
} }
} }
var closeAuxiliaryWindowForTypeCalled: Bool { var closeSecondaryWindowForTypeCalled: Bool {
return closeAuxiliaryWindowForTypeCallsCount > 0 return closeSecondaryWindowForTypeCallsCount > 0
} }
var closeAuxiliaryWindowForTypeReceivedType: WindowManagerWindowType? var closeSecondaryWindowForTypeReceivedType: SecondaryWindowType?
var closeAuxiliaryWindowForTypeReceivedInvocations: [WindowManagerWindowType] = [] var closeSecondaryWindowForTypeReceivedInvocations: [SecondaryWindowType] = []
var closeAuxiliaryWindowForTypeClosure: ((WindowManagerWindowType) -> Void)? var closeSecondaryWindowForTypeClosure: ((SecondaryWindowType) -> Void)?
func closeAuxiliaryWindow(forType type: WindowManagerWindowType) { func closeSecondaryWindow(forType type: SecondaryWindowType) {
closeAuxiliaryWindowForTypeCallsCount += 1 closeSecondaryWindowForTypeCallsCount += 1
closeAuxiliaryWindowForTypeReceivedType = type closeSecondaryWindowForTypeReceivedType = type
DispatchQueue.main.async { DispatchQueue.main.async {
self.closeAuxiliaryWindowForTypeReceivedInvocations.append(type) self.closeSecondaryWindowForTypeReceivedInvocations.append(type)
} }
closeAuxiliaryWindowForTypeClosure?(type) closeSecondaryWindowForTypeClosure?(type)
} }
//MARK: - setOrientation //MARK: - setOrientation
@@ -65,11 +65,11 @@ class UITestsAppCoordinator: AppCoordinatorProtocol, SecureWindowManagerDelegate
fatalError("Not implemented.") fatalError("Not implemented.")
} }
func handleDeepLink(_ url: URL, isExternalURL: Bool, windowType: WindowManagerWindowType?) -> Bool { func handleDeepLink(_ url: URL, isExternalURL: Bool, windowType: SecondaryWindowType?) -> Bool {
fatalError("Not implemented.") fatalError("Not implemented.")
} }
func handleAppRoute(_ appRoute: AppRoute, windowType: WindowManagerWindowType?) { func handleAppRoute(_ appRoute: AppRoute, windowType: SecondaryWindowType?) {
fatalError("Not implemented.") fatalError("Not implemented.")
} }
@@ -50,11 +50,11 @@ class UnitTestsAppCoordinator: AppCoordinatorProtocol {
fatalError("Not implemented.") fatalError("Not implemented.")
} }
func handleDeepLink(_ url: URL, isExternalURL: Bool, windowType: WindowManagerWindowType?) -> Bool { func handleDeepLink(_ url: URL, isExternalURL: Bool, windowType: SecondaryWindowType?) -> Bool {
fatalError("Not implemented.") fatalError("Not implemented.")
} }
func handleAppRoute(_ appRoute: AppRoute, windowType: WindowManagerWindowType?) { func handleAppRoute(_ appRoute: AppRoute, windowType: SecondaryWindowType?) {
fatalError("Not implemented.") fatalError("Not implemented.")
} }