1
0
mirror of https://github.com/yattee/yattee.git synced 2024-12-12 21:30:32 +05:30
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 { final class Watch: NSManagedObject, Identifiable {
@Default(.watchedThreshold) private var watchedThreshold @Default(.watchedThreshold) private var watchedThreshold
@Default(.saveHistory) private var saveHistory @Default(.saveHistory) private var saveHistory
@Default(.showWatchingProgress) private var showWatchingProgress
} }
extension Watch { extension Watch {
@ -102,4 +103,8 @@ extension Watch {
return Video(app: app ?? AccountsModel.shared.current?.app ?? .local, instanceURL: instanceURL, videoID: videoID) return Video(app: app ?? AccountsModel.shared.current?.app ?? .local, instanceURL: instanceURL, videoID: videoID)
} }
var isShowingProgress: Bool {
saveHistory && showWatchingProgress && (finished || progress > 0)
}
} }

View File

@ -37,14 +37,22 @@ struct VideoBanner: View {
var body: some View { var body: some View {
HStack(alignment: .top, spacing: 12) { HStack(alignment: .top, spacing: 12) {
VStack(alignment: .trailing, spacing: 2) { ZStack(alignment: .bottom) {
smallThumbnail VStack(alignment: .trailing, spacing: 2) {
smallThumbnail
if !timeOnThumbnail, let timeLabel { if !timeOnThumbnail, let timeLabel {
Text(timeLabel) Text(timeLabel)
.font(.caption.monospacedDigit()) .font(.caption.monospacedDigit())
.foregroundColor(.secondary) .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) { VStack(alignment: .leading, spacing: 2) {
@ -193,6 +201,7 @@ struct VideoBanner: View {
if timeOnThumbnail { if timeOnThumbnail {
timeView timeView
.offset(y: watch?.isShowingProgress ?? false ? -4 : 0)
} }
} }
.frame(width: thumbnailWidth, height: thumbnailHeight) .frame(width: thumbnailWidth, height: thumbnailHeight)
@ -279,7 +288,7 @@ struct VideoBanner: View {
struct VideoBanner_Previews: PreviewProvider { struct VideoBanner_Previews: PreviewProvider {
static var previews: some View { static var previews: some View {
VStack(spacing: 2) { ScrollView {
VideoBanner(video: Video.fixture, playbackTime: CMTime(seconds: 400, preferredTimescale: 10000)) VideoBanner(video: Video.fixture, playbackTime: CMTime(seconds: 400, preferredTimescale: 10000))
VideoBanner(video: Video.fixtureUpcomingWithoutPublishedOrViews) 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")!)) 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) (!timeOnThumbnail && !videoDuration.isNil)
} }
private var showProgressView: Bool {
saveHistory && showWatchingProgress && ((watch?.finished ?? false) || watch?.progress ?? 0 > 0)
}
private var thumbnail: some View { private var thumbnail: some View {
ZStack(alignment: .leading) { ZStack(alignment: .leading) {
ZStack(alignment: .bottomLeading) { ZStack(alignment: .bottomLeading) {
@ -380,7 +376,7 @@ struct VideoCell: View {
#else #else
.offset(x: 0, y: -3) .offset(x: 0, y: -3)
#endif #endif
.opacity(showProgressView ? 1 : 0) .opacity(watch?.isShowingProgress ?? false ? 1 : 0)
} }
VStack { VStack {