generated from element-hq/.github
-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix unit and UI tests (+6 squashed commits)
Squashed commits: [1ece59e] Fix login flows [6884dc3] Use modules everywhere the underlying object is a NavigationModule [ab08d44] Rename navigation components to: SingleScreenCoordinator, SplitScreenCoordinator and StackScreenCoordinator [8f5d978] Working but incomplete [c065603] Experimenting [ada2be5] Add SplitNavigationController
- Loading branch information
1 parent
7f91852
commit 7115a31
Showing
15 changed files
with
752 additions
and
395 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
186 changes: 0 additions & 186 deletions
186
ElementX/Sources/Application/NavigationController.swift
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// | ||
// Copyright 2022 New Vector Ltd | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
import Foundation | ||
|
||
struct NavigationModule: Identifiable, Hashable { | ||
let id = UUID() | ||
let coordinator: any CoordinatorProtocol | ||
|
||
init(_ coordinator: any CoordinatorProtocol) { | ||
self.coordinator = coordinator | ||
} | ||
|
||
static func == (lhs: NavigationModule, rhs: NavigationModule) -> Bool { | ||
lhs.id == rhs.id | ||
} | ||
|
||
func hash(into hasher: inout Hasher) { | ||
hasher.combine(id) | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
ElementX/Sources/Application/SingleScreenCoordinator.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// | ||
// Copyright 2022 New Vector Ltd | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
import SwiftUI | ||
|
||
class SingleScreenCoordinator: ObservableObject, CoordinatorProtocol { | ||
private var dismissalCallbacks = [UUID: () -> Void]() | ||
|
||
@Published private(set) var rootModule: NavigationModule? { | ||
didSet { | ||
if let oldValue { | ||
oldValue.coordinator.stop() | ||
} | ||
|
||
if let rootModule { | ||
logPresentationChange("Set root", rootModule) | ||
rootModule.coordinator.start() | ||
} | ||
} | ||
} | ||
|
||
func setRootCoordinator(_ coordinator: any CoordinatorProtocol) { | ||
rootModule = NavigationModule(coordinator) | ||
} | ||
|
||
// MARK: - CoordinatorProtocol | ||
|
||
func toPresentable() -> AnyView { | ||
AnyView(SingleScreenCoordinatorView(singleScreenCoordinator: self)) | ||
} | ||
|
||
// MARK: - Private | ||
|
||
private func logPresentationChange(_ change: String, _ module: NavigationModule) { | ||
MXLog.info("\(change): \(module.coordinator)(\(module.id))") | ||
} | ||
} | ||
|
||
private struct SingleScreenCoordinatorView: View { | ||
@ObservedObject var singleScreenCoordinator: SingleScreenCoordinator | ||
|
||
var body: some View { | ||
singleScreenCoordinator.rootModule?.coordinator.toPresentable() | ||
} | ||
} |
Oops, something went wrong.