mirror of
https://github.com/yattee/yattee.git
synced 2026-10-31 17:07:18 +00:00
Offer a delayed Cancel while the tvOS video page loads
The video page showed only a spinner until the video loaded, and rendered nothing at all in the frame before a videoID load started; either left the tvOS remote with nothing to focus. Both now show the spinner with the delayed Cancel, which pops the page.
This commit is contained in:
@@ -21,6 +21,9 @@ struct VideoInfoView: View {
|
|||||||
@Environment(\.appEnvironment) private var appEnvironment
|
@Environment(\.appEnvironment) private var appEnvironment
|
||||||
@Environment(\.presentAppSheet) private var presentAppSheet
|
@Environment(\.presentAppSheet) private var presentAppSheet
|
||||||
@Environment(\.videoQueueContext) private var videoQueueContext
|
@Environment(\.videoQueueContext) private var videoQueueContext
|
||||||
|
#if os(tvOS)
|
||||||
|
@Environment(\.dismiss) private var dismiss
|
||||||
|
#endif
|
||||||
|
|
||||||
private let initMode: VideoInfoInitMode
|
private let initMode: VideoInfoInitMode
|
||||||
|
|
||||||
@@ -274,14 +277,17 @@ struct VideoInfoView: View {
|
|||||||
var body: some View {
|
var body: some View {
|
||||||
Group {
|
Group {
|
||||||
if isLoadingInitialVideo || (displayedVideoIsPlaceholder && isLoadingVideoDetails) {
|
if isLoadingInitialVideo || (displayedVideoIsPlaceholder && isLoadingVideoDetails) {
|
||||||
ProgressView()
|
loadingView
|
||||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
|
||||||
} else if let error = initialVideoLoadError {
|
} else if let error = initialVideoLoadError {
|
||||||
videoLoadErrorView(error)
|
videoLoadErrorView(error)
|
||||||
} else if let error = videoDetailsLoadError, displayedVideoIsPlaceholder {
|
} else if let error = videoDetailsLoadError, displayedVideoIsPlaceholder {
|
||||||
videoLoadErrorView(error)
|
videoLoadErrorView(error)
|
||||||
} else if displayedVideo != nil {
|
} else if displayedVideo != nil {
|
||||||
videoContent
|
videoContent
|
||||||
|
} else {
|
||||||
|
// The first frame in videoID mode, before the load has started:
|
||||||
|
// rendering nothing here would leave tvOS nothing to focus.
|
||||||
|
loadingView
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Opaque background so the header gradient (which fades to windowBackgroundColor)
|
// Opaque background so the header gradient (which fades to windowBackgroundColor)
|
||||||
@@ -858,6 +864,14 @@ struct VideoInfoView: View {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
private var loadingView: some View {
|
||||||
|
ProgressView()
|
||||||
|
#if os(tvOS)
|
||||||
|
.tvStalledLoadCancel { dismiss() }
|
||||||
|
#endif
|
||||||
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||||
|
}
|
||||||
|
|
||||||
/// Error view shown when the video fails to load — either the initial
|
/// Error view shown when the video fails to load — either the initial
|
||||||
/// fetch in videoID mode, or the details fetch for a placeholder video
|
/// fetch in videoID mode, or the details fetch for a placeholder video
|
||||||
/// that has no metadata of its own to fall back on.
|
/// that has no metadata of its own to fall back on.
|
||||||
|
|||||||
Reference in New Issue
Block a user