mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 01:20:12 +00:00
This commit is contained in:
@@ -23,7 +23,8 @@ struct FilePreviewScreen: View {
|
|||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
PreviewController(fileURL: context.viewState.fileURL, title: context.viewState.title)
|
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
|
// MARK: - Private
|
||||||
|
|
||||||
private func displayVideo(for videoURL: URL) {
|
private func displayVideo(for videoURL: URL) {
|
||||||
let params = VideoPlayerCoordinatorParameters(videoURL: videoURL, isModallyPresented: false)
|
let params = VideoPlayerCoordinatorParameters(videoURL: videoURL)
|
||||||
let coordinator = VideoPlayerCoordinator(parameters: params)
|
let coordinator = VideoPlayerCoordinator(parameters: params)
|
||||||
|
|
||||||
if params.isModallyPresented {
|
coordinator.callback = { [weak self] _ in
|
||||||
coordinator.callback = { [weak self] _ in
|
self?.navigationStackCoordinator.pop()
|
||||||
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)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
navigationStackCoordinator.push(coordinator)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func displayFile(for fileURL: URL, with title: String?) {
|
private func displayFile(for fileURL: URL, with title: String?) {
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import SwiftUI
|
|||||||
|
|
||||||
struct VideoPlayerCoordinatorParameters {
|
struct VideoPlayerCoordinatorParameters {
|
||||||
let videoURL: URL
|
let videoURL: URL
|
||||||
let isModallyPresented: Bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enum VideoPlayerCoordinatorAction {
|
enum VideoPlayerCoordinatorAction {
|
||||||
@@ -36,8 +35,7 @@ final class VideoPlayerCoordinator: CoordinatorProtocol {
|
|||||||
self.parameters = parameters
|
self.parameters = parameters
|
||||||
|
|
||||||
viewModel = VideoPlayerViewModel(videoURL: parameters.videoURL,
|
viewModel = VideoPlayerViewModel(videoURL: parameters.videoURL,
|
||||||
autoplay: UIApplication.shared.applicationState == .active,
|
autoplay: UIApplication.shared.applicationState == .active)
|
||||||
isModallyPresented: parameters.isModallyPresented)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Public
|
// MARK: - Public
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ enum VideoPlayerViewModelAction {
|
|||||||
struct VideoPlayerViewState: BindableState {
|
struct VideoPlayerViewState: BindableState {
|
||||||
let videoURL: URL
|
let videoURL: URL
|
||||||
let autoplay: Bool
|
let autoplay: Bool
|
||||||
let isModallyPresented: Bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enum VideoPlayerViewAction {
|
enum VideoPlayerViewAction {
|
||||||
|
|||||||
@@ -21,10 +21,9 @@ typealias VideoPlayerViewModelType = StateStoreViewModel<VideoPlayerViewState, V
|
|||||||
class VideoPlayerViewModel: VideoPlayerViewModelType, VideoPlayerViewModelProtocol {
|
class VideoPlayerViewModel: VideoPlayerViewModelType, VideoPlayerViewModelProtocol {
|
||||||
var callback: ((VideoPlayerViewModelAction) -> Void)?
|
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,
|
super.init(initialViewState: VideoPlayerViewState(videoURL: videoURL,
|
||||||
autoplay: autoplay,
|
autoplay: autoplay))
|
||||||
isModallyPresented: isModallyPresented))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override func process(viewAction: VideoPlayerViewAction) async {
|
override func process(viewAction: VideoPlayerViewAction) async {
|
||||||
|
|||||||
@@ -22,31 +22,8 @@ struct VideoPlayerScreen: View {
|
|||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VideoPlayer(player: player())
|
VideoPlayer(player: player())
|
||||||
.background(Color.black.ignoresSafeArea())
|
.ignoresSafeArea(.all, edges: [.horizontal, .bottom])
|
||||||
.navigationBarTitleDisplayMode(.inline)
|
.navigationTitle(ElementL10n.a11yVideo)
|
||||||
.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")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private func player() -> AVPlayer {
|
private func player() -> AVPlayer {
|
||||||
|
|||||||
Reference in New Issue
Block a user