From 94bb886b4ec93054e72dbba416339b7a1141252a Mon Sep 17 00:00:00 2001 From: Francesco <100066266+cranci1@users.noreply.github.com> Date: Tue, 3 Jun 2025 18:36:18 +0200 Subject: [PATCH] Revert "test" This reverts commit a582bf7ab8097c19cecc4b67e5f3944f51fe9a4d. --- Sora/Views/MediaInfoView/MediaInfoView.swift | 105 +++++++++---------- 1 file changed, 48 insertions(+), 57 deletions(-) diff --git a/Sora/Views/MediaInfoView/MediaInfoView.swift b/Sora/Views/MediaInfoView/MediaInfoView.swift index 054844a..60c7ba7 100644 --- a/Sora/Views/MediaInfoView/MediaInfoView.swift +++ b/Sora/Views/MediaInfoView/MediaInfoView.swift @@ -127,29 +127,7 @@ struct MediaInfoView: View { return nil } - private var continueWatchingText: String { - 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 && progress < 0.9 { - return "Continue Watching Episode \(ep.number)" - } - } - - 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" - } + @State private var continueWatchingText: String = "Start Watching" var body: some View { ZStack { @@ -191,6 +169,7 @@ struct MediaInfoView: View { } } .onAppear { + updateContinueWatchingText() buttonRefreshTrigger.toggle() let savedID = UserDefaults.standard.integer(forKey: "custom_anilist_id_\(href)") @@ -287,24 +266,20 @@ struct MediaInfoView: View { ) ) .overlay( - VStack(spacing: 0) { - 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) - } + 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) { Rectangle() .fill(Color.clear) - .frame(height: 450) + .frame(height: 400) VStack(alignment: .leading, spacing: 16) { headerSection if !episodeLinks.isEmpty { @@ -318,16 +293,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.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), + .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) ]), startPoint: .top, endPoint: .bottom ) .clipShape(RoundedRectangle(cornerRadius: 0)) - .shadow(color: (colorScheme == .dark ? Color.black : Color.white).opacity(1), radius: 15, x: 0, y: 15) + .shadow(color: (colorScheme == .dark ? Color.black : Color.white).opacity(1), radius: 10, x: 0, y: 10) ) } .deviceScaled() @@ -638,22 +612,20 @@ struct MediaInfoView: View { .fill(Color.accentColor.opacity(0.25)) .frame(width: width, height: 48) - if progress < 0.9 { - Capsule() - .fill(Color.accentColor) - .frame(width: max(width * CGFloat(progress), 8), height: 48) - .mask( - HStack { - if progress < 0.05 && progress != 0 { - RoundedRectangle(cornerRadius: 24) - .frame(width: 8) - } else { - RoundedRectangle(cornerRadius: 24) - } - Spacer() + Capsule() + .fill(Color.accentColor) + .frame(width: max(width * CGFloat(progress), 8), height: 48) + .mask( + HStack { + if progress < 0.05 && progress != 0 { + RoundedRectangle(cornerRadius: 24) + .frame(width: 8) + } else { + RoundedRectangle(cornerRadius: 24) } - ) - } + Spacer() + } + ) } .frame(height: 48) @@ -663,7 +635,7 @@ struct MediaInfoView: View { HStack(spacing: 8) { Image(systemName: "play.fill") .foregroundColor(colorScheme == .dark ? .black : .white) - Text(continueWatchingText) + Text(latestProgressEpisode?.title ?? "Start Watching") .font(.system(size: 16, weight: .medium)) .foregroundColor(colorScheme == .dark ? .black : .white) } @@ -1039,6 +1011,24 @@ struct MediaInfoView: View { .padding(.vertical, 50) } + private func updateContinueWatchingText() { + 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 + } + } + + continueWatchingText = "Start Watching" + } + private func playFirstUnwatchedEpisode() { for ep in episodeLinks { let last = UserDefaults.standard.double(forKey: "lastPlayedTime_\(ep.href)") @@ -1831,6 +1821,7 @@ struct MediaInfoView: View { } } + print("Bulk download headers: \(headers)") fetchEpisodeMetadataForDownload(episode: episode) { metadata in let episodeTitle = metadata?.title["en"] ?? metadata?.title.values.first ?? "" let episodeImageUrl = metadata?.imageUrl ?? ""