mirror of
https://github.com/cranci1/Sora.git
synced 2026-04-20 16:12:50 +00:00
test
This commit is contained in:
parent
159c48b1ab
commit
a582bf7ab8
1 changed files with 57 additions and 48 deletions
|
|
@ -127,7 +127,29 @@ struct MediaInfoView: View {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@State private var continueWatchingText: String = "Start Watching"
|
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"
|
||||||
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
ZStack {
|
ZStack {
|
||||||
|
|
@ -169,7 +191,6 @@ struct MediaInfoView: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.onAppear {
|
.onAppear {
|
||||||
updateContinueWatchingText()
|
|
||||||
buttonRefreshTrigger.toggle()
|
buttonRefreshTrigger.toggle()
|
||||||
|
|
||||||
let savedID = UserDefaults.standard.integer(forKey: "custom_anilist_id_\(href)")
|
let savedID = UserDefaults.standard.integer(forKey: "custom_anilist_id_\(href)")
|
||||||
|
|
@ -266,20 +287,24 @@ struct MediaInfoView: View {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.overlay(
|
.overlay(
|
||||||
LinearGradient(
|
VStack(spacing: 0) {
|
||||||
gradient: Gradient(stops: [
|
Spacer()
|
||||||
.init(color: .clear, location: 0.0),
|
LinearGradient(
|
||||||
.init(color: .clear, location: 0.7),
|
gradient: Gradient(stops: [
|
||||||
.init(color: (colorScheme == .dark ? Color.black : Color.white).opacity(0.9), location: 1.0)
|
.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),
|
||||||
startPoint: .top,
|
.init(color: (colorScheme == .dark ? Color.black : Color.white).opacity(1.0), location: 1.0)
|
||||||
endPoint: .bottom
|
]),
|
||||||
)
|
startPoint: .top,
|
||||||
|
endPoint: .bottom
|
||||||
|
)
|
||||||
|
.frame(height: 150)
|
||||||
|
}
|
||||||
)
|
)
|
||||||
VStack(spacing: 0) {
|
VStack(spacing: 0) {
|
||||||
Rectangle()
|
Rectangle()
|
||||||
.fill(Color.clear)
|
.fill(Color.clear)
|
||||||
.frame(height: 400)
|
.frame(height: 450)
|
||||||
VStack(alignment: .leading, spacing: 16) {
|
VStack(alignment: .leading, spacing: 16) {
|
||||||
headerSection
|
headerSection
|
||||||
if !episodeLinks.isEmpty {
|
if !episodeLinks.isEmpty {
|
||||||
|
|
@ -293,15 +318,16 @@ struct MediaInfoView: View {
|
||||||
LinearGradient(
|
LinearGradient(
|
||||||
gradient: Gradient(stops: [
|
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.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.3), location: 0.1),
|
||||||
.init(color: (colorScheme == .dark ? Color.black : Color.white).opacity(0.8), location: 0.5),
|
.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), location: 1.0)
|
.init(color: (colorScheme == .dark ? Color.black : Color.white), location: 1.0)
|
||||||
]),
|
]),
|
||||||
startPoint: .top,
|
startPoint: .top,
|
||||||
endPoint: .bottom
|
endPoint: .bottom
|
||||||
)
|
)
|
||||||
.clipShape(RoundedRectangle(cornerRadius: 0))
|
.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()
|
.deviceScaled()
|
||||||
|
|
@ -612,20 +638,22 @@ struct MediaInfoView: View {
|
||||||
.fill(Color.accentColor.opacity(0.25))
|
.fill(Color.accentColor.opacity(0.25))
|
||||||
.frame(width: width, height: 48)
|
.frame(width: width, height: 48)
|
||||||
|
|
||||||
Capsule()
|
if progress < 0.9 {
|
||||||
.fill(Color.accentColor)
|
Capsule()
|
||||||
.frame(width: max(width * CGFloat(progress), 8), height: 48)
|
.fill(Color.accentColor)
|
||||||
.mask(
|
.frame(width: max(width * CGFloat(progress), 8), height: 48)
|
||||||
HStack {
|
.mask(
|
||||||
if progress < 0.05 && progress != 0 {
|
HStack {
|
||||||
RoundedRectangle(cornerRadius: 24)
|
if progress < 0.05 && progress != 0 {
|
||||||
.frame(width: 8)
|
RoundedRectangle(cornerRadius: 24)
|
||||||
} else {
|
.frame(width: 8)
|
||||||
RoundedRectangle(cornerRadius: 24)
|
} else {
|
||||||
|
RoundedRectangle(cornerRadius: 24)
|
||||||
|
}
|
||||||
|
Spacer()
|
||||||
}
|
}
|
||||||
Spacer()
|
)
|
||||||
}
|
}
|
||||||
)
|
|
||||||
}
|
}
|
||||||
.frame(height: 48)
|
.frame(height: 48)
|
||||||
|
|
||||||
|
|
@ -635,7 +663,7 @@ struct MediaInfoView: View {
|
||||||
HStack(spacing: 8) {
|
HStack(spacing: 8) {
|
||||||
Image(systemName: "play.fill")
|
Image(systemName: "play.fill")
|
||||||
.foregroundColor(colorScheme == .dark ? .black : .white)
|
.foregroundColor(colorScheme == .dark ? .black : .white)
|
||||||
Text(latestProgressEpisode?.title ?? "Start Watching")
|
Text(continueWatchingText)
|
||||||
.font(.system(size: 16, weight: .medium))
|
.font(.system(size: 16, weight: .medium))
|
||||||
.foregroundColor(colorScheme == .dark ? .black : .white)
|
.foregroundColor(colorScheme == .dark ? .black : .white)
|
||||||
}
|
}
|
||||||
|
|
@ -1011,24 +1039,6 @@ struct MediaInfoView: View {
|
||||||
.padding(.vertical, 50)
|
.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() {
|
private func playFirstUnwatchedEpisode() {
|
||||||
for ep in episodeLinks {
|
for ep in episodeLinks {
|
||||||
let last = UserDefaults.standard.double(forKey: "lastPlayedTime_\(ep.href)")
|
let last = UserDefaults.standard.double(forKey: "lastPlayedTime_\(ep.href)")
|
||||||
|
|
@ -1821,7 +1831,6 @@ struct MediaInfoView: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
print("Bulk download headers: \(headers)")
|
|
||||||
fetchEpisodeMetadataForDownload(episode: episode) { metadata in
|
fetchEpisodeMetadataForDownload(episode: episode) { metadata in
|
||||||
let episodeTitle = metadata?.title["en"] ?? metadata?.title.values.first ?? ""
|
let episodeTitle = metadata?.title["en"] ?? metadata?.title.values.first ?? ""
|
||||||
let episodeImageUrl = metadata?.imageUrl ?? ""
|
let episodeImageUrl = metadata?.imageUrl ?? ""
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue