Fixes #329 - Simplify video player UI until we agree on final designs. (#375)

This commit is contained in:
Stefan Ceriu
2022-12-19 12:17:37 +02:00
committed by GitHub
parent dbfd38fa52
commit 1992bfc737
6 changed files with 13 additions and 50 deletions

View File

@@ -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)
}
}

View File

@@ -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?) {

View File

@@ -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

View File

@@ -23,7 +23,6 @@ enum VideoPlayerViewModelAction {
struct VideoPlayerViewState: BindableState {
let videoURL: URL
let autoplay: Bool
let isModallyPresented: Bool
}
enum VideoPlayerViewAction {

View File

@@ -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 {

View File

@@ -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 {