- Bidirectional progress sync: server's `lastUpdate` now parsed correctly; pull timer (60s) + scenePhase hook reconcile against local state. Server-newer while paused/playing stashes a `pendingServerProgress` and surfaces a prompt on next Play; server-older triggers an immediate push. - History: lockscreen/Control-Center skip & scrub now route through AppState via `onRemoteSkip`/`onRemoteSeek` callbacks (previously bypassed history). `AppState.skip(by:)` itself now records the pre-skip position. - Chapter detection moved to the AVPlayer periodic time observer — fires reliably while the app is backgrounded or the device is locked, where the 5s runloop Timer can be throttled. - Always fetch item detail when online (even for downloaded items) so `item.chapters` is populated and history entries get chapter titles. - DownloadManager: per-track byte-fraction progress, so single-track 1+GB audiobooks' ring grows smoothly instead of staying at 0% until done. - PlayerBar: extracted ScrubberView into its own struct so per-second time updates no longer re-render the parent (fixes iOS history-popup flicker). - App icon: re-embedded sRGB profile in marketing icon; bumped version 2.0 to 2.1. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
59 lines
1.6 KiB
Swift
59 lines
1.6 KiB
Swift
import SwiftUI
|
|
|
|
struct ContentView: View {
|
|
@Environment(AppState.self) private var app
|
|
@Environment(\.scenePhase) private var scenePhase
|
|
#if os(iOS)
|
|
@State private var splashVisible = true
|
|
#endif
|
|
|
|
var body: some View {
|
|
ZStack {
|
|
mainContent
|
|
#if os(iOS)
|
|
if splashVisible {
|
|
SplashView()
|
|
.zIndex(10)
|
|
.transition(.opacity.animation(.easeOut(duration: 0.55)))
|
|
}
|
|
#endif
|
|
}
|
|
.task { await boot() }
|
|
.onChange(of: scenePhase) { _, newPhase in
|
|
if newPhase == .active { app.onScenePhaseActive() }
|
|
}
|
|
}
|
|
|
|
@ViewBuilder
|
|
private var mainContent: some View {
|
|
Group {
|
|
if app.auth.isLoggedIn {
|
|
MainView()
|
|
} else {
|
|
LoginView()
|
|
}
|
|
}
|
|
.environment(\.locale, Locale(identifier: app.language))
|
|
#if os(iOS)
|
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
|
#else
|
|
.frame(minWidth: 900, minHeight: 600)
|
|
#endif
|
|
}
|
|
|
|
private func boot() async {
|
|
#if os(iOS)
|
|
// Run bootstrap and minimum splash time in parallel;
|
|
// dismiss splash only after BOTH complete.
|
|
await withTaskGroup(of: Void.self) { group in
|
|
group.addTask { await app.bootstrap() }
|
|
group.addTask { try? await Task.sleep(for: .seconds(1.2)) }
|
|
await group.waitForAll()
|
|
}
|
|
withAnimation { splashVisible = false }
|
|
#else
|
|
await app.bootstrap()
|
|
#endif
|
|
}
|
|
}
|