Skip to content

Commit

Permalink
Remove fullscreenCover support for macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
Šimon Šesták committed Jul 25, 2024
1 parent ae7203e commit 41359ee
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Sources/FuturedArchitecture/Architecture/Coordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@ public protocol Coordinator: ObservableObject {
static func rootView(with instance: Self) -> RootView

var sheet: Destination? { get set }
#if !os(macOS)
var fullscreenCover: Destination? { get set }
#endif
var alertModel: AlertModel? { get set }

@ViewBuilder
func scene(for destination: Destination) -> DestinationViews
func onSheetDismiss()
#if !os(macOS)
func onFullscreenCoverDismiss()
#endif
}

public extension Coordinator {
Expand All @@ -34,6 +38,7 @@ public extension Coordinator {
func onSheetDismiss() {}
}

#if !os(macOS)
public extension Coordinator {
func present(fullscreenCover: Destination) {
Task { @MainActor in
Expand All @@ -49,6 +54,7 @@ public extension Coordinator {

func onFullscreenCoverDismiss() {}
}
#endif

public protocol TabCoordinator: Coordinator {
associatedtype Tab: Hashable
Expand Down
10 changes: 10 additions & 0 deletions Sources/FuturedArchitecture/Architecture/NavigationStackFlow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ public struct NavigationStackFlow<Coordinator: NavigationStackCoordinator, Conte
self.content = content
}

#if os(macOS)
public var body: some View {
NavigationStack(path: $coordinator.path) {
content().navigationDestination(for: Coordinator.Destination.self, destination: coordinator.scene(for:))
}
.sheet(item: $coordinator.sheet, onDismiss: coordinator.onSheetDismiss, content: coordinator.scene(for:))
.defaultAlert(model: $coordinator.alertModel)
}
#else
public var body: some View {
NavigationStack(path: $coordinator.path) {
content().navigationDestination(for: Coordinator.Destination.self, destination: coordinator.scene(for:))
Expand All @@ -17,4 +26,5 @@ public struct NavigationStackFlow<Coordinator: NavigationStackCoordinator, Conte
.fullScreenCover(item: $coordinator.fullscreenCover, onDismiss: coordinator.onFullscreenCoverDismiss, content: coordinator.scene(for:))
.defaultAlert(model: $coordinator.alertModel)
}
#endif
}
10 changes: 10 additions & 0 deletions Sources/FuturedArchitecture/Architecture/TabViewFlow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ public struct TabViewFlow<Coordinator: TabCoordinator, Content: View>: View {
self.content = content
}

#if os(macOS)
public var body: some View {
TabView(selection: $coordinator.selectedTab) {
content()
}
.sheet(item: $coordinator.sheet, onDismiss: coordinator.onSheetDismiss, content: coordinator.scene(for:))
.defaultAlert(model: $coordinator.alertModel)
}
#else
public var body: some View {
TabView(selection: $coordinator.selectedTab) {
content()
Expand All @@ -17,4 +26,5 @@ public struct TabViewFlow<Coordinator: TabCoordinator, Content: View>: View {
.fullScreenCover(item: $coordinator.fullscreenCover, onDismiss: coordinator.onFullscreenCoverDismiss, content: coordinator.scene(for:))
.defaultAlert(model: $coordinator.alertModel)
}
#endif
}

0 comments on commit 41359ee

Please sign in to comment.