This commit is contained in:
@@ -23,7 +23,8 @@ struct FilePreviewScreen: View {
|
||||
|
||||
var body: some View {
|
||||
PreviewController(fileURL: context.viewState.fileURL, title: context.viewState.title)
|
||||
.ignoresSafeArea()
|
||||
.ignoresSafeArea(.all, edges: [.horizontal, .bottom])
|
||||
.navigationTitle(ElementL10n.attachmentTypeFile)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -81,25 +81,14 @@ final class RoomScreenCoordinator: CoordinatorProtocol {
|
||||
// MARK: - Private
|
||||
|
||||
private func displayVideo(for videoURL: URL) {
|
||||
let params = VideoPlayerCoordinatorParameters(videoURL: videoURL, isModallyPresented: false)
|
||||
let params = VideoPlayerCoordinatorParameters(videoURL: videoURL)
|
||||
let coordinator = VideoPlayerCoordinator(parameters: params)
|
||||
|
||||
if params.isModallyPresented {
|
||||
coordinator.callback = { [weak self] _ in
|
||||
self?.navigationStackCoordinator.setSheetCoordinator(nil)
|
||||
}
|
||||
|
||||
let controller = NavigationStackCoordinator()
|
||||
controller.setRootCoordinator(coordinator)
|
||||
|
||||
navigationStackCoordinator.setSheetCoordinator(controller)
|
||||
} else {
|
||||
coordinator.callback = { [weak self] _ in
|
||||
self?.navigationStackCoordinator.pop()
|
||||
}
|
||||
|
||||
navigationStackCoordinator.push(coordinator)
|
||||
|
||||
coordinator.callback = { [weak self] _ in
|
||||
self?.navigationStackCoordinator.pop()
|
||||
}
|
||||
|
||||
navigationStackCoordinator.push(coordinator)
|
||||
}
|
||||
|
||||
private func displayFile(for fileURL: URL, with title: String?) {
|
||||
|
||||
@@ -19,7 +19,6 @@ import SwiftUI
|
||||
|
||||
struct VideoPlayerCoordinatorParameters {
|
||||
let videoURL: URL
|
||||
let isModallyPresented: Bool
|
||||
}
|
||||
|
||||
enum VideoPlayerCoordinatorAction {
|
||||
@@ -36,8 +35,7 @@ final class VideoPlayerCoordinator: CoordinatorProtocol {
|
||||
self.parameters = parameters
|
||||
|
||||
viewModel = VideoPlayerViewModel(videoURL: parameters.videoURL,
|
||||
autoplay: UIApplication.shared.applicationState == .active,
|
||||
isModallyPresented: parameters.isModallyPresented)
|
||||
autoplay: UIApplication.shared.applicationState == .active)
|
||||
}
|
||||
|
||||
// MARK: - Public
|
||||
|
||||
@@ -23,7 +23,6 @@ enum VideoPlayerViewModelAction {
|
||||
struct VideoPlayerViewState: BindableState {
|
||||
let videoURL: URL
|
||||
let autoplay: Bool
|
||||
let isModallyPresented: Bool
|
||||
}
|
||||
|
||||
enum VideoPlayerViewAction {
|
||||
|
||||
@@ -21,10 +21,9 @@ typealias VideoPlayerViewModelType = StateStoreViewModel<VideoPlayerViewState, V
|
||||
class VideoPlayerViewModel: VideoPlayerViewModelType, VideoPlayerViewModelProtocol {
|
||||
var callback: ((VideoPlayerViewModelAction) -> Void)?
|
||||
|
||||
init(videoURL: URL, autoplay: Bool = true, isModallyPresented: Bool = true) {
|
||||
init(videoURL: URL, autoplay: Bool = true) {
|
||||
super.init(initialViewState: VideoPlayerViewState(videoURL: videoURL,
|
||||
autoplay: autoplay,
|
||||
isModallyPresented: isModallyPresented))
|
||||
autoplay: autoplay))
|
||||
}
|
||||
|
||||
override func process(viewAction: VideoPlayerViewAction) async {
|
||||
|
||||
@@ -22,31 +22,8 @@ struct VideoPlayerScreen: View {
|
||||
|
||||
var body: some View {
|
||||
VideoPlayer(player: player())
|
||||
.background(Color.black.ignoresSafeArea())
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.navigationBarBackButtonHidden()
|
||||
.toolbar { toolbar }
|
||||
.onSwipeGesture(minimumDistance: 3.0, down: {
|
||||
if context.viewState.isModallyPresented {
|
||||
context.send(viewAction: .cancel)
|
||||
}
|
||||
}, right: {
|
||||
if !context.viewState.isModallyPresented {
|
||||
context.send(viewAction: .cancel)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@ToolbarContentBuilder
|
||||
var toolbar: some ToolbarContent {
|
||||
ToolbarItem(placement: .cancellationAction) {
|
||||
Button { context.send(viewAction: .cancel) } label: {
|
||||
Image(systemName: context.viewState.isModallyPresented ? "xmark" : "chevron.backward")
|
||||
.foregroundColor(.white)
|
||||
.fontWeight(.semibold)
|
||||
}
|
||||
.accessibilityIdentifier("dismissButton")
|
||||
}
|
||||
.ignoresSafeArea(.all, edges: [.horizontal, .bottom])
|
||||
.navigationTitle(ElementL10n.a11yVideo)
|
||||
}
|
||||
|
||||
private func player() -> AVPlayer {
|
||||
|
||||
Reference in New Issue
Block a user