mirror of
https://github.com/yattee/yattee.git
synced 2024-12-22 21:43:41 +00:00
Fix calculating progress on banner
This commit is contained in:
parent
cda6dc8b9b
commit
35c553cd05
@ -42,7 +42,7 @@ struct PlayerQueueItem: Hashable, Identifiable, Defaults.Serializable {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
return duration - seconds <= 20
|
return (seconds / duration) * 100 > Double(Defaults[.watchedThreshold])
|
||||||
}
|
}
|
||||||
|
|
||||||
var hasDetailsLoaded: Bool {
|
var hasDetailsLoaded: Bool {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import CoreMedia
|
import CoreMedia
|
||||||
|
import Defaults
|
||||||
import Foundation
|
import Foundation
|
||||||
import SDWebImageSwiftUI
|
import SDWebImageSwiftUI
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
@ -169,13 +170,19 @@ struct VideoBanner: View {
|
|||||||
private var progressView: some View {
|
private var progressView: some View {
|
||||||
Group {
|
Group {
|
||||||
if !playbackTime.isNil, !(video?.live ?? false) {
|
if !playbackTime.isNil, !(video?.live ?? false) {
|
||||||
ProgressView(value: progressViewValue, total: progressViewTotal)
|
ProgressView(value: watchValue, total: progressViewTotal)
|
||||||
.progressViewStyle(.linear)
|
.progressViewStyle(.linear)
|
||||||
.frame(maxWidth: thumbnailWidth)
|
.frame(maxWidth: thumbnailWidth)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var watchValue: Double {
|
||||||
|
if finished { return progressViewTotal }
|
||||||
|
|
||||||
|
return progressViewValue
|
||||||
|
}
|
||||||
|
|
||||||
private var progressViewValue: Double {
|
private var progressViewValue: Double {
|
||||||
guard videoDuration != 0 else { return 1 }
|
guard videoDuration != 0 else { return 1 }
|
||||||
return [playbackTime?.seconds, videoDuration].compactMap { $0 }.min() ?? 0
|
return [playbackTime?.seconds, videoDuration].compactMap { $0 }.min() ?? 0
|
||||||
@ -185,6 +192,10 @@ struct VideoBanner: View {
|
|||||||
guard videoDuration != 0 else { return 1 }
|
guard videoDuration != 0 else { return 1 }
|
||||||
return videoDuration ?? video?.length ?? 1
|
return videoDuration ?? video?.length ?? 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var finished: Bool {
|
||||||
|
(progressViewValue / progressViewTotal) * 100 > Double(Defaults[.watchedThreshold])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct VideoBanner_Previews: PreviewProvider {
|
struct VideoBanner_Previews: PreviewProvider {
|
||||||
|
Loading…
Reference in New Issue
Block a user