From 0f3ed42340ce9ed7a77dbdf9bad54c4cb4feaca2 Mon Sep 17 00:00:00 2001 From: Seiike <122684677+Seeike@users.noreply.github.com> Date: Thu, 3 Apr 2025 23:42:44 +0200 Subject: [PATCH] added brightness bar and check desc. https://discord.com/channels/1293430817841741899/1357429131054289118/1357442581784559847 --- .../Components/VerticalBrightnessSlider.swift | 2 +- .../CustomPlayer/CustomPlayer.swift | 26 ++++++++++++++----- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/Sora/Utils/MediaPlayer/CustomPlayer/Components/VerticalBrightnessSlider.swift b/Sora/Utils/MediaPlayer/CustomPlayer/Components/VerticalBrightnessSlider.swift index 3e33aea..7bae219 100644 --- a/Sora/Utils/MediaPlayer/CustomPlayer/Components/VerticalBrightnessSlider.swift +++ b/Sora/Utils/MediaPlayer/CustomPlayer/Components/VerticalBrightnessSlider.swift @@ -98,7 +98,7 @@ struct VerticalBrightnessSlider: View { } } } - .frame(width: isActive ? width * 2.2 : width, alignment: .center) + .frame(width: isActive ? width * 1.9 : width, alignment: .center) .offset(x: isActive ? -10 : 0) .onChange(of: value) { newValue in UIScreen.main.brightness = CGFloat(newValue) diff --git a/Sora/Utils/MediaPlayer/CustomPlayer/CustomPlayer.swift b/Sora/Utils/MediaPlayer/CustomPlayer/CustomPlayer.swift index 2e1380f..6cc7b08 100644 --- a/Sora/Utils/MediaPlayer/CustomPlayer/CustomPlayer.swift +++ b/Sora/Utils/MediaPlayer/CustomPlayer/CustomPlayer.swift @@ -419,7 +419,7 @@ class CustomMediaPlayerViewController: UIViewController { func holdForPause() { let holdForPauseGesture = UILongPressGestureRecognizer(target: self, action: #selector(handleHoldForPause(_:))) - holdForPauseGesture.minimumPressDuration = 2.0 + holdForPauseGesture.minimumPressDuration = 1 holdForPauseGesture.numberOfTouchesRequired = 2 view.addGestureRecognizer(holdForPauseGesture) } @@ -437,7 +437,7 @@ class CustomMediaPlayerViewController: UIViewController { activeFillColor: .white, // Preserves original active color fillColor: .white.opacity(0.5), // Preserves original fill color emptyColor: .white.opacity(0.3), // Preserves original empty color - width: 16, // Keeps the original width and corner style + width: 22, // Keeps the original width and corner style onEditingChanged: { editing in // Optionally handle editing events here. } @@ -454,9 +454,9 @@ class CustomMediaPlayerViewController: UIViewController { // Constrain the container so that its bounds follow the slider's visual position. NSLayoutConstraint.activate([ - brightnessContainer.leadingAnchor.constraint(equalTo: controlsContainerView.leadingAnchor, constant: 1.8), + brightnessContainer.leadingAnchor.constraint(equalTo: controlsContainerView.leadingAnchor, constant: -4), brightnessContainer.centerYAnchor.constraint(equalTo: controlsContainerView.centerYAnchor, constant: -10), - brightnessContainer.widthAnchor.constraint(equalToConstant: 16), + brightnessContainer.widthAnchor.constraint(equalToConstant: 22), brightnessContainer.heightAnchor.constraint(equalToConstant: 170) ]) @@ -505,9 +505,8 @@ class CustomMediaPlayerViewController: UIViewController { } } - let swipeDownGesture = UISwipeGestureRecognizer(target: self, action: #selector(handleSwipeDown(_:))) - swipeDownGesture.direction = .down - view.addGestureRecognizer(swipeDownGesture) + let panGesture = UIPanGestureRecognizer(target: self, action: #selector(handlePanGesture(_:))) + view.addGestureRecognizer(panGesture) } func showSkipFeedback(direction: String) { @@ -1465,6 +1464,19 @@ class CustomMediaPlayerViewController: UIViewController { } } + @objc private func handlePanGesture(_ gesture: UIPanGestureRecognizer) { + let translation = gesture.translation(in: view) + + switch gesture.state { + case .ended: + if translation.y > 100 { + dismiss(animated: true, completion: nil) + } + default: + break + } + } + private func beginHoldSpeed() { guard let player = player else { return } originalRate = player.rate