* Allow MediaPickerScreen users to select the media selection mode (single or multiple) * Fix cancellation * Add support for multiple media URLs on the MediaUploadPreviewScreen. * Support processing more URLs on the `MediaUploadingPreprocessor` and sending more on the `MediaUploadPreviewScreen` * Add feature flag for `multipleAttachmentUploadEnabled` * Add a label showing the current preview item index in the MediaUploadPreviewScreen * Add support for dragging and dropping or pasting multiple items at the same time. * Support sharing more than one file through the share extension. * Limit the number of items that can be shared in one go to 5. * Fix unit tests * Fix incorrect fatal error when dealing with single selection media pickers. * Document the `multipleAttachmentUploadEnabled` usage in the context of the MediaPicker. * Use a task group for processing selected media in the photo library picker. * Use a task group for processing multiple selected media in the MediaUploadingPreprocessor * Switch the maximum number of items that can be shared to 10. * Allow multiple items to be pasted at the same time.
69 lines
2.7 KiB
Swift
69 lines
2.7 KiB
Swift
//
|
|
// Copyright 2022-2024 New Vector 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 CreateRoomCoordinatorParameters {
|
|
let userSession: UserSessionProtocol
|
|
let userIndicatorController: UserIndicatorControllerProtocol
|
|
let createRoomParameters: CurrentValuePublisher<CreateRoomFlowParameters, Never>
|
|
let selectedUsers: CurrentValuePublisher<[UserProfileProxy], Never>
|
|
}
|
|
|
|
enum CreateRoomCoordinatorAction {
|
|
case openRoom(withIdentifier: String)
|
|
case deselectUser(UserProfileProxy)
|
|
case updateDetails(CreateRoomFlowParameters)
|
|
case displayMediaPickerWithMode(MediaPickerScreenMode)
|
|
case removeImage
|
|
}
|
|
|
|
final class CreateRoomCoordinator: CoordinatorProtocol {
|
|
private var viewModel: CreateRoomViewModelProtocol
|
|
private let actionsSubject: PassthroughSubject<CreateRoomCoordinatorAction, Never> = .init()
|
|
private var cancellables = Set<AnyCancellable>()
|
|
|
|
var actions: AnyPublisher<CreateRoomCoordinatorAction, Never> {
|
|
actionsSubject.eraseToAnyPublisher()
|
|
}
|
|
|
|
init(parameters: CreateRoomCoordinatorParameters) {
|
|
viewModel = CreateRoomViewModel(userSession: parameters.userSession,
|
|
createRoomParameters: parameters.createRoomParameters,
|
|
selectedUsers: parameters.selectedUsers,
|
|
analytics: ServiceLocator.shared.analytics,
|
|
userIndicatorController: parameters.userIndicatorController,
|
|
appSettings: ServiceLocator.shared.settings)
|
|
}
|
|
|
|
func start() {
|
|
viewModel.actions.sink { [weak self] action in
|
|
guard let self else { return }
|
|
switch action {
|
|
case .deselectUser(let user):
|
|
actionsSubject.send(.deselectUser(user))
|
|
case .openRoom(let identifier):
|
|
actionsSubject.send(.openRoom(withIdentifier: identifier))
|
|
case .updateDetails(let details):
|
|
actionsSubject.send(.updateDetails(details))
|
|
case .displayCameraPicker:
|
|
actionsSubject.send(.displayMediaPickerWithMode(.init(source: .camera, selectionType: .single)))
|
|
case .displayMediaPicker:
|
|
actionsSubject.send(.displayMediaPickerWithMode(.init(source: .photoLibrary, selectionType: .single)))
|
|
case .removeImage:
|
|
actionsSubject.send(.removeImage)
|
|
}
|
|
}
|
|
.store(in: &cancellables)
|
|
}
|
|
|
|
func toPresentable() -> AnyView {
|
|
AnyView(CreateRoomScreen(context: viewModel.context))
|
|
}
|
|
}
|