mirror of
https://github.com/yattee/yattee.git
synced 2024-12-22 13:33:42 +00:00
Fix #450
This commit is contained in:
parent
e1f03bc025
commit
ac7dad2ab8
@ -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)
|
||||
}
|
||||
}
|
||||
|
@ -37,14 +37,22 @@ struct VideoBanner: View {
|
||||
|
||||
var body: some View {
|
||||
HStack(alignment: .top, spacing: 12) {
|
||||
VStack(alignment: .trailing, spacing: 2) {
|
||||
smallThumbnail
|
||||
ZStack(alignment: .bottom) {
|
||||
VStack(alignment: .trailing, spacing: 2) {
|
||||
smallThumbnail
|
||||
|
||||
if !timeOnThumbnail, let timeLabel {
|
||||
Text(timeLabel)
|
||||
.font(.caption.monospacedDigit())
|
||||
.foregroundColor(.secondary)
|
||||
if !timeOnThumbnail, let timeLabel {
|
||||
Text(timeLabel)
|
||||
.font(.caption.monospacedDigit())
|
||||
.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) {
|
||||
@ -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")!))
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user