mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-10-31 08:15:24 +00:00
7adc963cf9
The rebase onto release/26.09.1 moved three things the fork depends on. Upstream now owns a UserProfileScreenHook of its own (#5980), which rewrites a screen's view state rather than injecting a view. The fork's section hook keeps its behaviour under the fork-only name ExtendedProfileSectionHook, so both can live side by side and upstream's file stays untouched. Upstream's new @AppHook macro generates the same register<Name> methods, so registration is unchanged. UserProfileScreenCoordinatorParameters lost appSettings and reordered its arguments, and UserDetailsEditScreenCoordinator now publishes its own UserDetailsEditScreenCoordinatorAction instead of borrowing the room one (#5893). The members flow and the profile editor follow both. AppSettings.override gained oAuthClientURIPath (#5934), whose default appends apps/ios to the website URL. HealthChat passes nil to keep the registered client_uri at https://healthchat.ch exactly as the shipped build has it — changing what the app registers with MAS is not a side effect a rebase should have.
89 lines
3.8 KiB
Swift
89 lines
3.8 KiB
Swift
//
|
|
// Copyright 2026 Novaloop AG
|
|
//
|
|
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
|
// Please see LICENSE files in the repository root for full details.
|
|
//
|
|
|
|
import Combine
|
|
import SwiftUI
|
|
|
|
struct HealthChatProfileEditScreenCoordinatorParameters {
|
|
let orientationManager: OrientationManagerProtocol
|
|
let userSession: UserSessionProtocol
|
|
let apiService: HealthChatAPIServiceProtocol
|
|
let mediaUploadingPreprocessor: MediaUploadingPreprocessor
|
|
weak var navigationStackCoordinator: NavigationStackCoordinator?
|
|
let userIndicatorController: UserIndicatorControllerProtocol
|
|
}
|
|
|
|
final class HealthChatProfileEditScreenCoordinator: CoordinatorProtocol, UserDetailsEditCoordinatorProtocol {
|
|
private let parameters: HealthChatProfileEditScreenCoordinatorParameters
|
|
private let viewModel: HealthChatProfileEditScreenViewModelProtocol
|
|
private var cancellables = Set<AnyCancellable>()
|
|
|
|
private let actionsSubject: PassthroughSubject<UserDetailsEditScreenCoordinatorAction, Never> = .init()
|
|
var actions: AnyPublisher<UserDetailsEditScreenCoordinatorAction, Never> {
|
|
actionsSubject.eraseToAnyPublisher()
|
|
}
|
|
|
|
init(parameters: HealthChatProfileEditScreenCoordinatorParameters) {
|
|
self.parameters = parameters
|
|
|
|
viewModel = HealthChatProfileEditScreenViewModel(userSession: parameters.userSession,
|
|
apiService: parameters.apiService,
|
|
mediaUploadingPreprocessor: parameters.mediaUploadingPreprocessor,
|
|
userIndicatorController: parameters.userIndicatorController)
|
|
}
|
|
|
|
func start() {
|
|
viewModel.actionsPublisher
|
|
.sink { [weak self] action in
|
|
guard let self else { return }
|
|
|
|
switch action {
|
|
case .dismiss:
|
|
actionsSubject.send(.dismiss)
|
|
case .displayCameraPicker:
|
|
displayMediaPickerWithMode(.init(source: .camera, selectionType: .single))
|
|
case .displayMediaPicker:
|
|
displayMediaPickerWithMode(.init(source: .photoLibrary, selectionType: .single))
|
|
case .displayFilePicker:
|
|
displayMediaPickerWithMode(.init(source: .documents(types: [.image]), selectionType: .single))
|
|
}
|
|
}
|
|
.store(in: &cancellables)
|
|
}
|
|
|
|
func toPresentable() -> AnyView {
|
|
AnyView(HealthChatProfileEditScreen(context: viewModel.context))
|
|
}
|
|
|
|
// MARK: Private
|
|
|
|
private func displayMediaPickerWithMode(_ mode: MediaPickerScreenMode) {
|
|
let stackCoordinator = NavigationStackCoordinator()
|
|
|
|
let mediaPickerCoordinator = MediaPickerScreenCoordinator(mode: mode,
|
|
userIndicatorController: parameters.userIndicatorController,
|
|
orientationManager: parameters.orientationManager) { [weak self] action in
|
|
guard let self else { return }
|
|
switch action {
|
|
case .cancel:
|
|
parameters.navigationStackCoordinator?.setSheetCoordinator(nil)
|
|
case .selectedMediaAtURLs(let urls):
|
|
guard urls.count == 1,
|
|
let url = urls.first else {
|
|
fatalError("Received an invalid number of URLs")
|
|
}
|
|
|
|
parameters.navigationStackCoordinator?.setSheetCoordinator(nil)
|
|
viewModel.didSelectMediaURL(url: url)
|
|
}
|
|
}
|
|
|
|
stackCoordinator.setRootCoordinator(mediaPickerCoordinator)
|
|
parameters.navigationStackCoordinator?.setSheetCoordinator(stackCoordinator)
|
|
}
|
|
}
|