From 51033994b42ad21f040dc0b9b778604405150915 Mon Sep 17 00:00:00 2001 From: Cassio Rossi Date: Tue, 21 Jul 2026 21:04:21 +0100 Subject: [PATCH] fix(#315): inject AnalyticsManager into full-player sheets The podcast full player crashed on Mac (Designed for iPad) when opened from the mini player: FullPlayerView and ChaptersView read analytics via @EnvironmentObject, but they are presented in .sheet contexts that do not inherit the root .environmentObject(analytics) on the iOS-app-on-Mac runtime, so the first access trapped with "No ObservableObject of type AnalyticsManager found". iPhone and iPad inherit it, so it only crashed on Mac. Re-inject analytics into both presented sheets, mirroring the existing DeepLinkNewsDetailView pattern: - PodcastMiniPlayerModifier forwards analytics into the FullPlayerView sheet. - FullPlayerView forwards analytics into the nested ChaptersView sheet. Co-Authored-By: Claude --- .../Podcast/Modifiers/PodcastMiniPlayerModifier.swift | 11 +++++++---- .../Sources/Podcast/Views/Player/FullPlayerView.swift | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/MacMagazine/Features/PodcastLibrary/Sources/Podcast/Modifiers/PodcastMiniPlayerModifier.swift b/MacMagazine/Features/PodcastLibrary/Sources/Podcast/Modifiers/PodcastMiniPlayerModifier.swift index 7fd32406..f482fec3 100644 --- a/MacMagazine/Features/PodcastLibrary/Sources/Podcast/Modifiers/PodcastMiniPlayerModifier.swift +++ b/MacMagazine/Features/PodcastLibrary/Sources/Podcast/Modifiers/PodcastMiniPlayerModifier.swift @@ -1,3 +1,4 @@ +import AnalyticsLibrary import FeedLibrary import MacMagazineLibrary import SwiftUI @@ -13,6 +14,7 @@ private struct PodcastMiniPlayerModifier: ViewModifier { @Environment(PodcastPlayerManager.self) private var manager @Environment(\.shouldUseSidebar) private var shouldUseSidebar @Environment(\.colorScheme) private var colorScheme + @EnvironmentObject private var analytics: AnalyticsManager @Namespace private var animation public init() {} @@ -32,7 +34,7 @@ private struct PodcastMiniPlayerModifier: ViewModifier { .padding(.horizontal, 20) .glassEffect(.regular) } - .fullPlayerSheet(manager: manager) + .fullPlayerSheet(manager: manager, analytics: analytics) } else { content .tabBarMinimizeBehavior(.onScrollDown) @@ -45,17 +47,17 @@ private struct PodcastMiniPlayerModifier: ViewModifier { .matchedTransitionSource(id: "MINIPLAYER", in: animation) .padding(.horizontal, 8) } - .fullPlayerSheet(manager: manager) + .fullPlayerSheet(manager: manager, analytics: analytics) } } else { content - .fullPlayerSheet(manager: manager) + .fullPlayerSheet(manager: manager, analytics: analytics) } } } private extension View { - func fullPlayerSheet(manager: PodcastPlayerManager) -> some View { + func fullPlayerSheet(manager: PodcastPlayerManager, analytics: AnalyticsManager) -> some View { self.sheet( isPresented: Binding( get: { manager.isFullscreen }, @@ -67,6 +69,7 @@ private extension View { backgroundGradientStyle: .fourTone ) .presentationDragIndicator(.visible) + .environmentObject(analytics) } } } diff --git a/MacMagazine/Features/PodcastLibrary/Sources/Podcast/Views/Player/FullPlayerView.swift b/MacMagazine/Features/PodcastLibrary/Sources/Podcast/Views/Player/FullPlayerView.swift index 2acb44f9..516b2c20 100644 --- a/MacMagazine/Features/PodcastLibrary/Sources/Podcast/Views/Player/FullPlayerView.swift +++ b/MacMagazine/Features/PodcastLibrary/Sources/Podcast/Views/Player/FullPlayerView.swift @@ -78,6 +78,7 @@ struct FullPlayerView: View { isShowingChapterDialog: $isShowingChapterDialog ) .presentationDragIndicator(.visible) + .environmentObject(analytics) } }