This commit is contained in:
Arkadiusz Fal 2023-05-23 18:00:33 +02:00
parent e1f03bc025
commit ac7dad2ab8
3 changed files with 22 additions and 12 deletions

View File

@ -7,6 +7,7 @@ import Foundation
final class Watch: NSManagedObject, Identifiable {
@Default(.watchedThreshold) private var watchedThreshold
@Default(.saveHistory) private var saveHistory
@Default(.showWatchingProgress) private var showWatchingProgress
}
extension Watch {
@ -102,4 +103,8 @@ extension Watch {
return Video(app: app ?? AccountsModel.shared.current?.app ?? .local, instanceURL: instanceURL, videoID: videoID)
}
var isShowingProgress: Bool {
saveHistory && showWatchingProgress && (finished || progress > 0)
}
}

View File

@ -37,6 +37,7 @@ struct VideoBanner: View {
var body: some View {
HStack(alignment: .top, spacing: 12) {
ZStack(alignment: .bottom) {
VStack(alignment: .trailing, spacing: 2) {
smallThumbnail
@ -46,6 +47,13 @@ struct VideoBanner: View {
.foregroundColor(.secondary)
}
}
.layoutPriority(1)
ProgressView(value: watch?.progress ?? 44, total: 100)
.frame(maxHeight: 4)
.progressViewStyle(LinearProgressViewStyle(tint: Color("AppRedColor")))
.opacity(watch?.isShowingProgress ?? false ? 1 : 0)
}
VStack(alignment: .leading, spacing: 2) {
Group {
@ -193,6 +201,7 @@ struct VideoBanner: View {
if timeOnThumbnail {
timeView
.offset(y: watch?.isShowingProgress ?? false ? -4 : 0)
}
}
.frame(width: thumbnailWidth, height: thumbnailHeight)
@ -279,7 +288,7 @@ struct VideoBanner: View {
struct VideoBanner_Previews: PreviewProvider {
static var previews: some View {
VStack(spacing: 2) {
ScrollView {
VideoBanner(video: Video.fixture, playbackTime: CMTime(seconds: 400, preferredTimescale: 10000))
VideoBanner(video: Video.fixtureUpcomingWithoutPublishedOrViews)
VideoBanner(video: .local(URL(string: "https://apple.com/a/directory/of/video+that+has+very+long+title+that+will+likely.mp4")!))

View File

@ -359,10 +359,6 @@ struct VideoCell: View {
(!timeOnThumbnail && !videoDuration.isNil)
}
private var showProgressView: Bool {
saveHistory && showWatchingProgress && ((watch?.finished ?? false) || watch?.progress ?? 0 > 0)
}
private var thumbnail: some View {
ZStack(alignment: .leading) {
ZStack(alignment: .bottomLeading) {
@ -380,7 +376,7 @@ struct VideoCell: View {
#else
.offset(x: 0, y: -3)
#endif
.opacity(showProgressView ? 1 : 0)
.opacity(watch?.isShowingProgress ?? false ? 1 : 0)
}
VStack {