mirror of
https://github.com/cranci1/Sora.git
synced 2026-04-20 08:02:16 +00:00
Fixes (#152)
* Mediainfoview: Fixed test in start button + pushed items a bit down for more clarity * Capped logs showing to 50k characters (copying logs still copies all the logs of that session)) * Fixed gradient + made it so that the progress bar in the play button resets when 90%> Resetting progress bar makes sense, as it now shows text for the next episode which doesn't have any progress. --------- Co-authored-by: cranci <100066266+cranci1@users.noreply.github.com>
This commit is contained in:
parent
2a3c58adbd
commit
8075de46fb
2 changed files with 88 additions and 55 deletions
|
|
@ -131,8 +131,29 @@ struct MediaInfoView: View {
|
|||
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 {
|
||||
ZStack {
|
||||
|
|
@ -179,7 +200,6 @@ struct MediaInfoView: View {
|
|||
}
|
||||
}
|
||||
.onAppear {
|
||||
updateContinueWatchingText()
|
||||
buttonRefreshTrigger.toggle()
|
||||
|
||||
let savedID = UserDefaults.standard.integer(forKey: "custom_anilist_id_\(href)")
|
||||
|
|
@ -274,20 +294,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) {
|
||||
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 {
|
||||
|
|
@ -301,15 +325,16 @@ 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).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), location: 1.0)
|
||||
]),
|
||||
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()
|
||||
|
|
@ -620,20 +645,22 @@ struct MediaInfoView: View {
|
|||
.fill(Color.accentColor.opacity(0.25))
|
||||
.frame(width: width, height: 48)
|
||||
|
||||
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)
|
||||
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()
|
||||
}
|
||||
Spacer()
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
.frame(height: 48)
|
||||
|
||||
|
|
@ -643,7 +670,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)
|
||||
}
|
||||
|
|
@ -1019,24 +1046,6 @@ 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)")
|
||||
|
|
|
|||
|
|
@ -62,8 +62,18 @@ fileprivate struct SettingsSection<Content: View>: View {
|
|||
struct SettingsViewLogger: View {
|
||||
@State private var logs: String = ""
|
||||
@State private var isLoading: Bool = true
|
||||
@State private var showFullLogs: Bool = false
|
||||
@StateObject private var filterViewModel = LogFilterViewModel.shared
|
||||
|
||||
private let displayCharacterLimit = 50_000
|
||||
|
||||
var displayedLogs: String {
|
||||
if showFullLogs || logs.count <= displayCharacterLimit {
|
||||
return logs
|
||||
}
|
||||
return String(logs.suffix(displayCharacterLimit))
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
ScrollView {
|
||||
VStack(spacing: 24) {
|
||||
|
|
@ -79,13 +89,26 @@ struct SettingsViewLogger: View {
|
|||
.frame(maxWidth: .infinity, alignment: .center)
|
||||
.padding(.vertical, 20)
|
||||
} else {
|
||||
Text(logs)
|
||||
.font(.footnote)
|
||||
.foregroundColor(.secondary)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.padding(.horizontal, 16)
|
||||
.padding(.vertical, 12)
|
||||
.textSelection(.enabled)
|
||||
VStack(alignment: .leading, spacing: 8) {
|
||||
Text(displayedLogs)
|
||||
.font(.footnote)
|
||||
.foregroundColor(.secondary)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.textSelection(.enabled)
|
||||
|
||||
if logs.count > displayCharacterLimit && !showFullLogs {
|
||||
Button(action: {
|
||||
showFullLogs = true
|
||||
}) {
|
||||
Text("Show More (\(logs.count - displayCharacterLimit) more characters)")
|
||||
.font(.footnote)
|
||||
.foregroundColor(.accentColor)
|
||||
}
|
||||
.padding(.top, 8)
|
||||
}
|
||||
}
|
||||
.padding(.horizontal, 16)
|
||||
.padding(.vertical, 12)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -139,6 +162,7 @@ struct SettingsViewLogger: View {
|
|||
await Logger.shared.clearLogsAsync()
|
||||
await MainActor.run {
|
||||
self.logs = ""
|
||||
self.showFullLogs = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue