1
0
mirror of https://github.com/yattee/yattee.git synced 2025-04-28 07:50:33 +05:30

Fix sheets and covers on iOS 14

This commit is contained in:
Arkadiusz Fal 2021-11-30 23:58:11 +01:00
parent 5ef89ac9f4
commit b5ffa5b267
3 changed files with 78 additions and 57 deletions

View File

@ -24,7 +24,7 @@ struct ContentView: View {
#endif #endif
var body: some View { var body: some View {
Section { Group {
#if os(iOS) #if os(iOS)
if horizontalSizeClass == .compact { if horizontalSizeClass == .compact {
AppTabNavigation() AppTabNavigation()
@ -49,55 +49,66 @@ struct ContentView: View {
.environmentObject(subscriptions) .environmentObject(subscriptions)
.environmentObject(thumbnailsModel) .environmentObject(thumbnailsModel)
.sheet(isPresented: $navigation.presentingWelcomeScreen) { // iOS 14 has problem with multiple sheets in one view
WelcomeScreen() // but it's ok when it's in background
.environmentObject(accounts) .background(
.environmentObject(navigation) EmptyView().sheet(isPresented: $navigation.presentingWelcomeScreen) {
} WelcomeScreen()
.environmentObject(accounts)
.environmentObject(navigation)
}
)
#if os(iOS) #if os(iOS)
.fullScreenCover(isPresented: $player.presentingPlayer) { .background(
VideoPlayerView() EmptyView().fullScreenCover(isPresented: $player.presentingPlayer) {
.environmentObject(accounts) videoPlayer
.environmentObject(instances) }
.environmentObject(navigation) )
.environmentObject(player)
.environmentObject(playlists)
.environmentObject(subscriptions)
.environmentObject(thumbnailsModel)
}
#elseif os(macOS) #elseif os(macOS)
.sheet(isPresented: $player.presentingPlayer) { .background(
VideoPlayerView() EmptyView().sheet(isPresented: $player.presentingPlayer) {
.frame(minWidth: 900, minHeight: 800) videoPlayer
.environmentObject(accounts) .frame(minWidth: 900, minHeight: 800)
.environmentObject(instances) }
.environmentObject(navigation) )
.environmentObject(player)
.environmentObject(playlists)
.environmentObject(subscriptions)
.environmentObject(thumbnailsModel)
}
#endif #endif
#if !os(tvOS) #if !os(tvOS)
.handlesExternalEvents(preferring: Set(["*"]), allowing: Set(["*"])) .handlesExternalEvents(preferring: Set(["*"]), allowing: Set(["*"]))
.onOpenURL(perform: handleOpenedURL) .onOpenURL(perform: handleOpenedURL)
.sheet(isPresented: $navigation.presentingAddToPlaylist) { .background(
AddToPlaylistView(video: navigation.videoToAddToPlaylist) EmptyView().sheet(isPresented: $navigation.presentingAddToPlaylist) {
.environmentObject(playlists) AddToPlaylistView(video: navigation.videoToAddToPlaylist)
} .environmentObject(playlists)
.sheet(isPresented: $navigation.presentingPlaylistForm) { }
PlaylistFormView(playlist: $navigation.editedPlaylist) )
.environmentObject(accounts) .background(
.environmentObject(playlists) EmptyView().sheet(isPresented: $navigation.presentingPlaylistForm) {
} PlaylistFormView(playlist: $navigation.editedPlaylist)
.sheet(isPresented: $navigation.presentingSettings, onDismiss: openWelcomeScreenIfAccountEmpty) { .environmentObject(accounts)
SettingsView() .environmentObject(playlists)
.environmentObject(accounts) }
.environmentObject(instances) )
} .background(
EmptyView().sheet(isPresented: $navigation.presentingSettings, onDismiss: openWelcomeScreenIfAccountEmpty) {
SettingsView()
.environmentObject(accounts)
.environmentObject(instances)
}
)
#endif #endif
} }
private var videoPlayer: some View {
VideoPlayerView()
.environmentObject(accounts)
.environmentObject(instances)
.environmentObject(navigation)
.environmentObject(player)
.environmentObject(playlists)
.environmentObject(subscriptions)
.environmentObject(thumbnailsModel)
}
func configure() { func configure() {
SiestaLog.Category.enabled = .common SiestaLog.Category.enabled = .common
SDImageCodersManager.shared.addCoder(SDImageWebPCoder.shared) SDImageCodersManager.shared.addCoder(SDImageWebPCoder.shared)

View File

@ -318,17 +318,21 @@ struct VideoDetails: View {
.foregroundColor(.secondary) .foregroundColor(.secondary)
} }
} }
.sheet(isPresented: $presentingAddToPlaylist) { .background(
if let video = video { EmptyView().sheet(isPresented: $presentingAddToPlaylist) {
AddToPlaylistView(video: video) if let video = video {
AddToPlaylistView(video: video)
}
} }
} )
#if os(iOS) #if os(iOS)
.sheet(isPresented: $presentingShareSheet) { .background(
if let shareURL = shareURL { EmptyView().sheet(isPresented: $presentingShareSheet) {
ShareSheet(activityItems: [shareURL]) if let shareURL = shareURL {
ShareSheet(activityItems: [shareURL])
}
} }
} )
#endif #endif
} }

View File

@ -58,14 +58,20 @@ struct PlaylistsView: View {
.environmentObject(accounts) .environmentObject(accounts)
} }
#else #else
.sheet(isPresented: $showingNewPlaylist, onDismiss: selectCreatedPlaylist) { .background(
PlaylistFormView(playlist: $createdPlaylist) EmptyView()
.environmentObject(accounts) .sheet(isPresented: $showingNewPlaylist, onDismiss: selectCreatedPlaylist) {
} PlaylistFormView(playlist: $createdPlaylist)
.sheet(isPresented: $showingEditPlaylist, onDismiss: selectEditedPlaylist) { .environmentObject(accounts)
PlaylistFormView(playlist: $editedPlaylist) }
.environmentObject(accounts) )
} .background(
EmptyView()
.sheet(isPresented: $showingEditPlaylist, onDismiss: selectEditedPlaylist) {
PlaylistFormView(playlist: $editedPlaylist)
.environmentObject(accounts)
}
)
#endif #endif
.toolbar { .toolbar {
ToolbarItemGroup { ToolbarItemGroup {