mirror of
https://github.com/yattee/yattee.git
synced 2026-10-28 15:37:17 +00:00
Present deep-link download options through the shared sheet host
The download deep link kept the video, streams and captions in separate states next to a presented flag, and the sheet was declared only at the app root, so it opened behind an expanded player. It is now a global request for the download options AppSheet.
This commit is contained in:
@@ -37,14 +37,6 @@ struct YatteeApp: App {
|
|||||||
@State private var lastCheckedClipboardURL: URL?
|
@State private var lastCheckedClipboardURL: URL?
|
||||||
@Environment(\.scenePhase) private var scenePhase
|
@Environment(\.scenePhase) private var scenePhase
|
||||||
|
|
||||||
// Deep link handling state
|
|
||||||
#if !os(tvOS)
|
|
||||||
@State private var deepLinkVideo: Video?
|
|
||||||
@State private var deepLinkStreams: [Stream] = []
|
|
||||||
@State private var deepLinkCaptions: [Caption] = []
|
|
||||||
@State private var showingDeepLinkDownloadSheet = false
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// First-launch state
|
// First-launch state
|
||||||
@State private var showingICloudAlert = false
|
@State private var showingICloudAlert = false
|
||||||
@State private var showingICloudProgress = false
|
@State private var showingICloudProgress = false
|
||||||
@@ -117,18 +109,6 @@ struct YatteeApp: App {
|
|||||||
Text(String(localized: "alert.openVideo.message \(url.host ?? "clipboard")"))
|
Text(String(localized: "alert.openVideo.message \(url.host ?? "clipboard")"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if !os(tvOS)
|
|
||||||
.sheet(isPresented: $showingDeepLinkDownloadSheet) {
|
|
||||||
if let video = deepLinkVideo {
|
|
||||||
DownloadQualitySheet(
|
|
||||||
video: video,
|
|
||||||
streams: deepLinkStreams,
|
|
||||||
captions: deepLinkCaptions
|
|
||||||
)
|
|
||||||
.appEnvironment(appEnvironment)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
// First-launch iCloud sync prompt
|
// First-launch iCloud sync prompt
|
||||||
.alert(
|
.alert(
|
||||||
@@ -702,10 +682,7 @@ struct YatteeApp: App {
|
|||||||
)
|
)
|
||||||
|
|
||||||
await MainActor.run {
|
await MainActor.run {
|
||||||
deepLinkVideo = video
|
appEnvironment.navigationCoordinator.presenter.present(.downloadOptions(video, streams: streams, captions: captions))
|
||||||
deepLinkStreams = streams
|
|
||||||
deepLinkCaptions = captions
|
|
||||||
showingDeepLinkDownloadSheet = true
|
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
// Fall back to open on error
|
// Fall back to open on error
|
||||||
@@ -720,10 +697,7 @@ struct YatteeApp: App {
|
|||||||
let video = DirectMediaHelper.createVideo(from: url, probe: probe)
|
let video = DirectMediaHelper.createVideo(from: url, probe: probe)
|
||||||
let stream = DirectMediaHelper.createStream(from: url, probe: probe)
|
let stream = DirectMediaHelper.createStream(from: url, probe: probe)
|
||||||
await MainActor.run {
|
await MainActor.run {
|
||||||
deepLinkVideo = video
|
appEnvironment.navigationCoordinator.presenter.present(.downloadOptions(video, streams: [stream], captions: []))
|
||||||
deepLinkStreams = [stream]
|
|
||||||
deepLinkCaptions = []
|
|
||||||
showingDeepLinkDownloadSheet = true
|
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -739,10 +713,7 @@ struct YatteeApp: App {
|
|||||||
.extractURL(url, instance: instance)
|
.extractURL(url, instance: instance)
|
||||||
|
|
||||||
await MainActor.run {
|
await MainActor.run {
|
||||||
deepLinkVideo = video
|
appEnvironment.navigationCoordinator.presenter.present(.downloadOptions(video, streams: streams, captions: captions))
|
||||||
deepLinkStreams = streams
|
|
||||||
deepLinkCaptions = captions
|
|
||||||
showingDeepLinkDownloadSheet = true
|
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
// Fall back to open on error
|
// Fall back to open on error
|
||||||
|
|||||||
Reference in New Issue
Block a user