From b3f835c040b1b9998723cc90bb7914d2fd5653d7 Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Wed, 15 Jun 2022 00:51:58 +0200 Subject: [PATCH] Player will close with swipe animation when threshold is reached --- Shared/Player/VideoPlayerView.swift | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Shared/Player/VideoPlayerView.swift b/Shared/Player/VideoPlayerView.swift index c633f619..0ecc1f59 100644 --- a/Shared/Player/VideoPlayerView.swift +++ b/Shared/Player/VideoPlayerView.swift @@ -152,6 +152,10 @@ struct VideoPlayerView: View { .gesture( DragGesture(coordinateSpace: .global) .onChanged { value in + guard player.presentingPlayer else { + return // swiftlint:disable:this implicit_return + } + player.backend.setNeedsDrawing(false) let drag = value.translation.height @@ -159,6 +163,11 @@ struct VideoPlayerView: View { return // swiftlint:disable:this implicit_return } + guard drag < 100 else { + player.hide() + return + } + withAnimation(.easeInOut(duration: 0.2)) { viewVerticalOffset = drag }