diff --git a/Sources/InfiniteNavigation/Helper/View+Environments.swift b/Sources/InfiniteNavigation/Helper/View+Environments.swift index d359a62..14a521b 100644 --- a/Sources/InfiniteNavigation/Helper/View+Environments.swift +++ b/Sources/InfiniteNavigation/Helper/View+Environments.swift @@ -1,7 +1,7 @@ import SwiftUI extension View { - func apply(environments: Environments) -> AnyView { + func apply(environments: [Environment]) -> AnyView { var result: any View = self environments.forEach { result = (result.environmentObject($0) as any View) } return result.toAnyView() diff --git a/Sources/InfiniteNavigation/InfiniteNavContainer.swift b/Sources/InfiniteNavigation/InfiniteNavContainer.swift index cc5261b..51cd1c2 100644 --- a/Sources/InfiniteNavigation/InfiniteNavContainer.swift +++ b/Sources/InfiniteNavigation/InfiniteNavContainer.swift @@ -8,7 +8,7 @@ internal struct Sheet: Identifiable { let source: () -> any View } -public typealias Environments = [any ObservableObject] +public typealias Environment = any ObservableObject @available(iOS 16.0, *) public struct InfiniteNavContainer: View { @@ -18,14 +18,14 @@ public struct InfiniteNavContainer: View { private let navAction: NavDestinationPublisher private let viewBuilder: NavDestinationBuilder - private let environments: Environments + private let environments: [Environment] @State private var stack: [Sheet] init( initialStack: [Destination] = [], navAction: NavDestinationPublisher, - environments: Environments = [], + environments: [Environment] = [], viewBuilder: @escaping NavDestinationBuilder, root: @escaping () -> Root ) { diff --git a/Sources/InfiniteNavigation/InfiniteNavigation.swift b/Sources/InfiniteNavigation/InfiniteNavigation.swift index 2a850d8..c4968ad 100644 --- a/Sources/InfiniteNavigation/InfiniteNavigation.swift +++ b/Sources/InfiniteNavigation/InfiniteNavigation.swift @@ -7,7 +7,7 @@ public struct InfiniteNavigation { public static func create( initialStack: [Destination] = [], navAction: AnyPublisher, Never>, - environments: any ObservableObject..., + environments: Environment..., viewBuilder: @escaping (Destination) -> some View, @ViewBuilder root: @escaping () -> Root ) -> some View { @@ -24,7 +24,7 @@ public struct InfiniteNavigation { public static func create( initialStack: [Destination] = [], navAction: AnyPublisher, Never>, - environments: Environments = [], + environments: [Environment] = [], viewBuilder: @escaping (Destination) -> some View, @ViewBuilder root: @escaping () -> Root ) -> some View { diff --git a/Sources/InfiniteNavigation/LegacyInfiniteNavContainer.swift b/Sources/InfiniteNavigation/LegacyInfiniteNavContainer.swift index a7be2d2..d5eac1c 100644 --- a/Sources/InfiniteNavigation/LegacyInfiniteNavContainer.swift +++ b/Sources/InfiniteNavigation/LegacyInfiniteNavContainer.swift @@ -17,7 +17,7 @@ public struct LegacyInfiniteNavContainer: UIViewContro internal init( initialStack: [View] = [], navAction: NavDestinationPublisher, - environments: Environments = [], + environments: [Environment] = [], viewBuilder: @escaping NavDestinationBuilder, root: @escaping () -> Root ) { @@ -50,11 +50,11 @@ public struct LegacyInfiniteNavContainer: UIViewContro var resolver: Resolver? - private let environments: Environments + private let environments: [Environment] private let viewBuilder: NavDestinationBuilder private var navSubscription: AnyCancellable? - init(navAction: NavDestinationPublisher, environments: Environments, viewBuilder: @escaping NavDestinationBuilder) { + init(navAction: NavDestinationPublisher, environments: [Environment], viewBuilder: @escaping NavDestinationBuilder) { self.environments = environments self.viewBuilder = viewBuilder