mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
b5b28b9986
dds sending of multi-media "gallery" messages, gated behind the new galleryEnabled developer option (Developer Options → Room, off by default). Rendering of received galleries ships in a separate PR. Wires sendGallery through TimelineProxy/TimelineController onto the SDK's Timeline.sendGallery. MediaUploadPreviewScreen sends selected items as one gallery when the flag is on. Co-authored with the original author of #5601. NOTE: This PR allows to send gallery messages, but they won't be rendered without the gallery timeline item PR.
71 lines
2.7 KiB
Swift
71 lines
2.7 KiB
Swift
//
|
|
// Copyright 2025 Element Creations Ltd.
|
|
// Copyright 2022-2025 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 MediaUploadPreviewScreenCoordinatorParameters {
|
|
let mediaURLs: [URL]
|
|
let caption: NSAttributedString?
|
|
let title: String?
|
|
let shouldShowCaptionWarning: Bool
|
|
/// When `false`, multiple attachments are sent as individual messages.
|
|
let galleryEnabled: Bool
|
|
let mediaUploadingPreprocessor: MediaUploadingPreprocessor
|
|
let timelineController: TimelineControllerProtocol
|
|
let clientProxy: ClientProxyProtocol
|
|
let userIndicatorController: UserIndicatorControllerProtocol
|
|
}
|
|
|
|
enum MediaUploadPreviewScreenCoordinatorAction {
|
|
case dismiss
|
|
}
|
|
|
|
final class MediaUploadPreviewScreenCoordinator: CoordinatorProtocol {
|
|
private var viewModel: MediaUploadPreviewScreenViewModelProtocol
|
|
private let actionsSubject: PassthroughSubject<MediaUploadPreviewScreenCoordinatorAction, Never> = .init()
|
|
private var cancellables = Set<AnyCancellable>()
|
|
|
|
var actions: AnyPublisher<MediaUploadPreviewScreenCoordinatorAction, Never> {
|
|
actionsSubject.eraseToAnyPublisher()
|
|
}
|
|
|
|
init(parameters: MediaUploadPreviewScreenCoordinatorParameters) {
|
|
viewModel = MediaUploadPreviewScreenViewModel(mediaURLs: parameters.mediaURLs,
|
|
caption: parameters.caption,
|
|
title: parameters.title,
|
|
shouldShowCaptionWarning: parameters.shouldShowCaptionWarning,
|
|
galleryEnabled: parameters.galleryEnabled,
|
|
mediaUploadingPreprocessor: parameters.mediaUploadingPreprocessor,
|
|
timelineController: parameters.timelineController,
|
|
clientProxy: parameters.clientProxy,
|
|
userIndicatorController: parameters.userIndicatorController)
|
|
}
|
|
|
|
func start() {
|
|
viewModel.actions
|
|
.sink { [weak self] action in
|
|
guard let self else { return }
|
|
|
|
switch action {
|
|
case .dismiss:
|
|
actionsSubject.send(.dismiss)
|
|
}
|
|
}
|
|
.store(in: &cancellables)
|
|
}
|
|
|
|
func stop() {
|
|
viewModel.stopProcessing()
|
|
}
|
|
|
|
func toPresentable() -> AnyView {
|
|
AnyView(MediaUploadPreviewScreen(context: viewModel.context))
|
|
}
|
|
}
|