mirror of
https://github.com/cranci1/Sora.git
synced 2026-03-11 17:45:37 +00:00
hello 👋 (#95)
Some checks failed
Build and Release IPA / Build IPA (push) Has been cancelled
Some checks failed
Build and Release IPA / Build IPA (push) Has been cancelled
* bug fix dimming * improved the fetchEpisodeMetadata logic
This commit is contained in:
parent
83cf7b0e9f
commit
0ad4659d2c
2 changed files with 31 additions and 55 deletions
|
|
@ -1267,19 +1267,16 @@ class CustomMediaPlayerViewController: UIViewController, UIGestureRecognizerDele
|
|||
isPlaying = false
|
||||
playPauseButton.image = UIImage(systemName: "play.fill")
|
||||
|
||||
// Defer the UI animation so that it doesn't block the pause call
|
||||
DispatchQueue.main.async {
|
||||
if !self.isControlsVisible {
|
||||
self.isControlsVisible = true
|
||||
UIView.animate(withDuration: 0.1, animations: {
|
||||
self.controlsContainerView.alpha = 1.0
|
||||
self.skip85Button.alpha = 0.8
|
||||
// Removed layoutIfNeeded() to avoid forcing a layout pass here
|
||||
})
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Play immediately
|
||||
player.play()
|
||||
isPlaying = true
|
||||
playPauseButton.image = UIImage(systemName: "pause.fill")
|
||||
|
|
@ -1312,39 +1309,26 @@ class CustomMediaPlayerViewController: UIViewController, UIGestureRecognizerDele
|
|||
|
||||
@objc private func dimTapped() {
|
||||
isDimmed.toggle()
|
||||
dimButtonTimer?.invalidate()
|
||||
|
||||
if isDimmed {
|
||||
originalHiddenStates = [:]
|
||||
for view in controlsToHide {
|
||||
originalHiddenStates[view] = view.isHidden
|
||||
view.isHidden = true
|
||||
}
|
||||
|
||||
blackCoverView.alpha = 1.0
|
||||
|
||||
dimButtonToSlider.isActive = false
|
||||
dimButtonToRight.isActive = true
|
||||
|
||||
dimButton.isHidden = true
|
||||
|
||||
dimButtonTimer?.invalidate()
|
||||
} else {
|
||||
for view in controlsToHide {
|
||||
if let wasHidden = originalHiddenStates[view] {
|
||||
view.isHidden = wasHidden
|
||||
}
|
||||
}
|
||||
|
||||
blackCoverView.alpha = 0.4
|
||||
|
||||
dimButtonToRight.isActive = false
|
||||
dimButtonToSlider.isActive = true
|
||||
|
||||
dimButton.isHidden = false
|
||||
dimButton.alpha = 1.0
|
||||
|
||||
dimButtonTimer?.invalidate()
|
||||
// animate black overlay
|
||||
UIView.animate(withDuration: 0.25) {
|
||||
self.blackCoverView.alpha = self.isDimmed ? 1.0 : 0.4
|
||||
}
|
||||
|
||||
// fade controls instead of hiding
|
||||
UIView.animate(withDuration: 0.25) {
|
||||
for view in self.controlsToHide {
|
||||
view.alpha = self.isDimmed ? 0 : 1
|
||||
}
|
||||
// keep the dim button visible/in front
|
||||
self.dimButton.alpha = self.isDimmed ? 0 : 1
|
||||
}
|
||||
|
||||
// swap your trailing constraints on the dim‑button
|
||||
dimButtonToSlider.isActive = !isDimmed
|
||||
dimButtonToRight.isActive = isDimmed
|
||||
UIView.animate(withDuration: 0.25) { self.view.layoutIfNeeded() }
|
||||
}
|
||||
|
||||
func speedChangerMenu() -> UIMenu {
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ struct EpisodeCell: View {
|
|||
@State private var isLoading: Bool = true
|
||||
@State private var currentProgress: Double = 0.0
|
||||
|
||||
init(episodeIndex: Int, episode: String, episodeID: Int, progress: Double,
|
||||
init(episodeIndex: Int, episode: String, episodeID: Int, progress: Double,
|
||||
itemID: Int, onTap: @escaping (String) -> Void, onMarkAllPrevious: @escaping () -> Void) {
|
||||
self.episodeIndex = episodeIndex
|
||||
self.episode = episode
|
||||
|
|
@ -92,13 +92,9 @@ struct EpisodeCell: View {
|
|||
}
|
||||
.onAppear {
|
||||
updateProgress()
|
||||
|
||||
if UserDefaults.standard.object(forKey: "fetchEpisodeMetadata") == nil
|
||||
|| UserDefaults.standard.bool(forKey: "fetchEpisodeMetadata") {
|
||||
fetchEpisodeDetails()
|
||||
}
|
||||
fetchEpisodeDetails()
|
||||
}
|
||||
.onChange(of: progress) { newProgress in
|
||||
.onChange(of: progress) { _ in
|
||||
updateProgress()
|
||||
}
|
||||
.onTapGesture {
|
||||
|
|
@ -147,16 +143,12 @@ struct EpisodeCell: View {
|
|||
URLSession.custom.dataTask(with: url) { data, _, error in
|
||||
if let error = error {
|
||||
Logger.shared.log("Failed to fetch anime episode details: \(error)", type: "Error")
|
||||
DispatchQueue.main.async {
|
||||
self.isLoading = false
|
||||
}
|
||||
DispatchQueue.main.async { self.isLoading = false }
|
||||
return
|
||||
}
|
||||
|
||||
guard let data = data else {
|
||||
DispatchQueue.main.async {
|
||||
self.isLoading = false
|
||||
}
|
||||
DispatchQueue.main.async { self.isLoading = false }
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -168,21 +160,21 @@ struct EpisodeCell: View {
|
|||
let title = episodeDetails["title"] as? [String: String],
|
||||
let image = episodeDetails["image"] as? String else {
|
||||
Logger.shared.log("Invalid anime response format", type: "Error")
|
||||
DispatchQueue.main.async {
|
||||
self.isLoading = false
|
||||
}
|
||||
DispatchQueue.main.async { self.isLoading = false }
|
||||
return
|
||||
}
|
||||
|
||||
DispatchQueue.main.async {
|
||||
self.episodeTitle = title["en"] ?? ""
|
||||
self.episodeImageUrl = image
|
||||
// Always stop loading
|
||||
self.isLoading = false
|
||||
// Only display metadata if enabled
|
||||
if UserDefaults.standard.bool(forKey: "fetchEpisodeMetadata") {
|
||||
self.episodeTitle = title["en"] ?? ""
|
||||
self.episodeImageUrl = image
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
DispatchQueue.main.async {
|
||||
self.isLoading = false
|
||||
}
|
||||
DispatchQueue.main.async { self.isLoading = false }
|
||||
}
|
||||
}.resume()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue