Skip to content

Commit

Permalink
Fix macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
Šimon Šesták committed Aug 12, 2024
1 parent 38d1d8a commit 472f6aa
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Sources/FuturedArchitecture/Architecture/Coordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ public extension Coordinator {
Task { @MainActor in
self.modalCover = .init(destination: destination, style: .sheet)
}
#if !os(macOS)
case .fullscreenCover:
Task { @MainActor in
self.modalCover = .init(destination: destination, style: .fullscreenCover)
}
#endif
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public struct NavigationStackFlow<Coordinator: NavigationStackCoordinator, Conte
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:))
.sheet(item: sheetBinding, onDismiss: coordinator.onModalDismiss, content: coordinator.scene(for:))
}
#else
public var body: some View {
Expand All @@ -34,11 +34,13 @@ public struct NavigationStackFlow<Coordinator: NavigationStackCoordinator, Conte
}
}

#if !os(macOS)
private var fullscreenCoverBinding: Binding<Coordinator.Destination?> {
.init {
coordinator.modalCover?.style == .fullscreenCover ? coordinator.modalCover?.destination : nil
} set: { destination in
coordinator.modalCover = destination.map { .init(destination: $0, style: .fullscreenCover) }
}
}
#endif
}
4 changes: 3 additions & 1 deletion Sources/FuturedArchitecture/Architecture/TabViewFlow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public struct TabViewFlow<Coordinator: TabCoordinator, Content: View>: View {
TabView(selection: $coordinator.selectedTab) {
content()
}
.sheet(item: $coordinator.sheet, onDismiss: coordinator.onSheetDismiss, content: coordinator.scene(for:))
.sheet(item: sheetBinding, onDismiss: coordinator.onModalDismiss, content: coordinator.scene(for:))
}
#else
public var body: some View {
Expand All @@ -34,11 +34,13 @@ public struct TabViewFlow<Coordinator: TabCoordinator, Content: View>: View {
}
}

#if !os(macOS)
private var fullscreenCoverBinding: Binding<Coordinator.Destination?> {
.init {
coordinator.modalCover?.style == .fullscreenCover ? coordinator.modalCover?.destination : nil
} set: { destination in
coordinator.modalCover = destination.map { .init(destination: $0, style: .fullscreenCover) }
}
}
#endif
}
2 changes: 2 additions & 0 deletions Sources/FuturedHelpers/Helpers/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import SwiftUI

#if !os(macOS)
protocol AppSceneDelegate: AnyObject, UIWindowSceneDelegate, ObservableObject {
var delegate: SceneDelegate? { get set }
}
Expand Down Expand Up @@ -40,3 +41,4 @@ extension View {
modifier(SceneDelegateWrapperViewModifier<T>(delegate: sceneDelegate))
}
}
#endif

0 comments on commit 472f6aa

Please sign in to comment.