mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 03:06:37 +00:00
02d9ed1f0e
- Drop the redundant searchService coordinator/view model parameter; derive it from the client proxy. - Rename the globalSearch avatar size to search. - Lift the query observation streams out of their tasks. - Restore the appeared and updateVisibleRange comments. - Use CompoundIcon defaults and a scaledFrame for media previews. - Simplify the result mapping with compactMap(makeResult) and drop unsupported events by returning nil. - Move the preview helpers beneath the previews.
55 lines
1.8 KiB
Swift
55 lines
1.8 KiB
Swift
//
|
|
// Copyright 2026 Element Creations Ltd.
|
|
//
|
|
// 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 SearchScreenCoordinatorParameters {
|
|
let roomSummaryProvider: RoomSummaryProviderProtocol
|
|
let clientProxy: ClientProxyProtocol
|
|
let mediaProvider: MediaProviderProtocol
|
|
}
|
|
|
|
enum SearchScreenCoordinatorAction {
|
|
case presentRoom(roomID: String, eventID: String?)
|
|
case cancel
|
|
}
|
|
|
|
final class SearchScreenCoordinator: CoordinatorProtocol {
|
|
private let viewModel: SearchScreenViewModelProtocol
|
|
|
|
private var cancellables = Set<AnyCancellable>()
|
|
|
|
private let actionsSubject: PassthroughSubject<SearchScreenCoordinatorAction, Never> = .init()
|
|
var actionsPublisher: AnyPublisher<SearchScreenCoordinatorAction, Never> {
|
|
actionsSubject.eraseToAnyPublisher()
|
|
}
|
|
|
|
init(parameters: SearchScreenCoordinatorParameters) {
|
|
viewModel = SearchScreenViewModel(roomSummaryProvider: parameters.roomSummaryProvider,
|
|
clientProxy: parameters.clientProxy,
|
|
mediaProvider: parameters.mediaProvider)
|
|
}
|
|
|
|
func start() {
|
|
viewModel.actionsPublisher.sink { [weak self] action in
|
|
guard let self else { return }
|
|
switch action {
|
|
case .presentRoom(let roomID, let eventID):
|
|
actionsSubject.send(.presentRoom(roomID: roomID, eventID: eventID))
|
|
case .cancel:
|
|
actionsSubject.send(.cancel)
|
|
}
|
|
}
|
|
.store(in: &cancellables)
|
|
}
|
|
|
|
func toPresentable() -> AnyView {
|
|
AnyView(SearchScreen(context: viewModel.context))
|
|
}
|
|
}
|