From f83d8251d197ca7db8315997cf81005cd72943ea Mon Sep 17 00:00:00 2001 From: Francesco <100066266+cranci1@users.noreply.github.com> Date: Tue, 3 Jun 2025 20:17:37 +0200 Subject: [PATCH] =?UTF-8?q?bro=20=F0=9F=98=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sora/Views/MediaInfoView/MediaInfoView.swift | 67 +++++++++++--------- 1 file changed, 36 insertions(+), 31 deletions(-) diff --git a/Sora/Views/MediaInfoView/MediaInfoView.swift b/Sora/Views/MediaInfoView/MediaInfoView.swift index deaedb5..b292b97 100644 --- a/Sora/Views/MediaInfoView/MediaInfoView.swift +++ b/Sora/Views/MediaInfoView/MediaInfoView.swift @@ -128,8 +128,6 @@ struct MediaInfoView: View { return nil } - @State private var continueWatchingText: String = "Start Watching" - var body: some View { ZStack { bodyContent @@ -170,7 +168,6 @@ struct MediaInfoView: View { } } .onAppear { - updateContinueWatchingText() updateLatestProgress() buttonRefreshTrigger.toggle() @@ -268,20 +265,24 @@ struct MediaInfoView: View { ) ) .overlay( - LinearGradient( - gradient: Gradient(stops: [ - .init(color: .clear, location: 0.0), - .init(color: .clear, location: 0.7), - .init(color: (colorScheme == .dark ? Color.black : Color.white).opacity(0.9), location: 1.0) - ]), - startPoint: .top, - endPoint: .bottom - ) + VStack(spacing: 0) {Add commentMore actions + Spacer() + LinearGradient( + gradient: Gradient(stops: [ + .init(color: (colorScheme == .dark ? Color.black : Color.white).opacity(0.0), location: 0.0), + .init(color: (colorScheme == .dark ? Color.black : Color.white).opacity(0.5), location: 0.5), + .init(color: (colorScheme == .dark ? Color.black : Color.white).opacity(1.0), location: 1.0) + ]), + startPoint: .top, + endPoint: .bottom + ) + .frame(height: 150) + } ) VStack(spacing: 0) { Rectangle() .fill(Color.clear) - .frame(height: 400) + .frame(height: 450) VStack(alignment: .leading, spacing: 16) { headerSection if !episodeLinks.isEmpty { @@ -295,15 +296,15 @@ struct MediaInfoView: View { LinearGradient( gradient: Gradient(stops: [ .init(color: (colorScheme == .dark ? Color.black : Color.white).opacity(0.0), location: 0.0), - .init(color: (colorScheme == .dark ? Color.black : Color.white).opacity(0.5), location: 0.2), - .init(color: (colorScheme == .dark ? Color.black : Color.white).opacity(0.8), location: 0.5), - .init(color: (colorScheme == .dark ? Color.black : Color.white), location: 1.0) + .init(color: (colorScheme == .dark ? Color.black : Color.white).opacity(0.3), location: 0.1), + .init(color: (colorScheme == .dark ? Color.black : Color.white).opacity(0.6), location: 0.3), + .init(color: (colorScheme == .dark ? Color.black : Color.white).opacity(0.9), location: 0.7), ]), startPoint: .top, endPoint: .bottom ) .clipShape(RoundedRectangle(cornerRadius: 0)) - .shadow(color: (colorScheme == .dark ? Color.black : Color.white).opacity(1), radius: 10, x: 0, y: 10) + .shadow(color: (colorScheme == .dark ? Color.black : Color.white).opacity(1), radius: 15, x: 0, y: 15) ) } .deviceScaled() @@ -380,13 +381,11 @@ struct MediaInfoView: View { UserDefaults.standard.set(99999999.0, forKey: "totalTime_\(ep.href)") DropManager.shared.showDrop(title: "Marked as Watched", subtitle: "", duration: 1.0, icon: UIImage(systemName: "checkmark.circle.fill")) updateLatestProgress() - updateContinueWatchingText() } else { UserDefaults.standard.set(0.0, forKey: "lastPlayedTime_\(ep.href)") UserDefaults.standard.set(0.0, forKey: "totalTime_\(ep.href)") DropManager.shared.showDrop(title: "Progress Reset", subtitle: "", duration: 1.0, icon: UIImage(systemName: "arrow.counterclockwise")) updateLatestProgress() - updateContinueWatchingText() } } }) { @@ -615,16 +614,16 @@ struct MediaInfoView: View { let progress = latestProgress RoundedRectangle(cornerRadius: 25) - .fill(progress == 0 ? Color(.systemBackground) : Color.accentColor.opacity(0.25)) + .fill(Color.accentColor.opacity(0.25)) .frame(width: width, height: 48) - if progress > 0 { + if progress < 0.9 { Capsule() .fill(Color.accentColor) .frame(width: max(width * CGFloat(progress), 8), height: 48) .mask( HStack { - if progress < 0.05 { + if progress < 0.05 && progress != 0 { RoundedRectangle(cornerRadius: 24) .frame(width: 8) } else { @@ -643,7 +642,7 @@ struct MediaInfoView: View { HStack(spacing: 8) { Image(systemName: "play.fill") .foregroundColor(colorScheme == .dark ? .black : .white) - Text(latestProgressEpisode?.title ?? "Start Watching") + Text(continueWatchingText) .font(.system(size: 16, weight: .medium)) .foregroundColor(colorScheme == .dark ? .black : .white) } @@ -1031,22 +1030,28 @@ struct MediaInfoView: View { .padding(.vertical, 50) } - private func updateContinueWatchingText() { + private var continueWatchingText: String {Add commentMore actions for ep in episodeLinks { let last = UserDefaults.standard.double(forKey: "lastPlayedTime_\(ep.href)") let total = UserDefaults.standard.double(forKey: "totalTime_\(ep.href)") let progress = total > 0 ? last / total : 0 - if progress == 0 { - continueWatchingText = "Start Watching Episode \(ep.number)" - return - } else if progress < 0.9 { - continueWatchingText = "Continue Watching Episode \(ep.number)" - return + if progress > 0 && progress < 0.9 { + return "Continue Watching Episode \(ep.number)" } } - continueWatchingText = "Start Watching" + for ep in episodeLinks { + let last = UserDefaults.standard.double(forKey: "lastPlayedTime_\(ep.href)") + let total = UserDefaults.standard.double(forKey: "totalTime_\(ep.href)") + let progress = total > 0 ? last / total : 0 + + if progress < 0.9 { + return "Start Watching Episode \(ep.number)" + } + } + + return "Start Watching" } private func playFirstUnwatchedEpisode() {