|
1 | 1 | import SwiftUI |
2 | 2 |
|
3 | | -extension View { |
4 | | - /// Presents a modal view that covers as much of the screen as possible using the store you |
5 | | - /// provide as a data source for the sheet's content. |
6 | | - /// |
7 | | - /// > This is a Composable Architecture-friendly version of SwiftUI's `fullScreenCover` view |
8 | | - /// > modifier. |
9 | | - /// |
10 | | - /// - Parameters: |
11 | | - /// - store: A store that is focused on ``PresentationState`` and ``PresentationAction`` for |
12 | | - /// a modal. When `store`'s state is non-`nil`, the system passes a store of unwrapped `State` |
13 | | - /// and `Action` to the modifier's closure. You use this store to power the content in a sheet |
14 | | - /// you create that the system displays to the user. If `store`'s state is `nil`-ed out, the |
15 | | - /// system dismisses the currently displayed sheet. |
16 | | - /// - onDismiss: The closure to execute when dismissing the modal view. |
17 | | - /// - content: A closure returning the content of the modal view. |
18 | | - @available(iOS 14, tvOS 14, watchOS 7, *) |
19 | | - @available(macOS, unavailable) |
20 | | - public func fullScreenCover<State, Action, Content: View>( |
21 | | - store: Store<PresentationState<State>, PresentationAction<Action>>, |
22 | | - onDismiss: (() -> Void)? = nil, |
23 | | - @ViewBuilder content: @escaping (_ store: Store<State, Action>) -> Content |
24 | | - ) -> some View { |
25 | | - self.presentation(store: store) { `self`, $item, destination in |
26 | | - self.fullScreenCover(item: $item, onDismiss: onDismiss) { _ in |
27 | | - destination(content) |
| 3 | +#if !os(macOS) |
| 4 | + extension View { |
| 5 | + /// Presents a modal view that covers as much of the screen as possible using the store you |
| 6 | + /// provide as a data source for the sheet's content. |
| 7 | + /// |
| 8 | + /// > This is a Composable Architecture-friendly version of SwiftUI's `fullScreenCover` view |
| 9 | + /// > modifier. |
| 10 | + /// |
| 11 | + /// - Parameters: |
| 12 | + /// - store: A store that is focused on ``PresentationState`` and ``PresentationAction`` for |
| 13 | + /// a modal. When `store`'s state is non-`nil`, the system passes a store of unwrapped `State` |
| 14 | + /// and `Action` to the modifier's closure. You use this store to power the content in a sheet |
| 15 | + /// you create that the system displays to the user. If `store`'s state is `nil`-ed out, the |
| 16 | + /// system dismisses the currently displayed sheet. |
| 17 | + /// - onDismiss: The closure to execute when dismissing the modal view. |
| 18 | + /// - content: A closure returning the content of the modal view. |
| 19 | + @available(iOS 14, tvOS 14, watchOS 7, *) |
| 20 | + @available(macOS, unavailable) |
| 21 | + public func fullScreenCover<State, Action, Content: View>( |
| 22 | + store: Store<PresentationState<State>, PresentationAction<Action>>, |
| 23 | + onDismiss: (() -> Void)? = nil, |
| 24 | + @ViewBuilder content: @escaping (_ store: Store<State, Action>) -> Content |
| 25 | + ) -> some View { |
| 26 | + self.presentation(store: store) { `self`, $item, destination in |
| 27 | + self.fullScreenCover(item: $item, onDismiss: onDismiss) { _ in |
| 28 | + destination(content) |
| 29 | + } |
28 | 30 | } |
29 | 31 | } |
30 | | - } |
31 | | - |
32 | | - /// Presents a modal view that covers as much of the screen as possible using the store you |
33 | | - /// provide as a data source for the sheet's content. |
34 | | - /// |
35 | | - /// > This is a Composable Architecture-friendly version of SwiftUI's `fullScreenCover` view |
36 | | - /// > modifier. |
37 | | - /// |
38 | | - /// - Parameters: |
39 | | - /// - store: A store that is focused on ``PresentationState`` and ``PresentationAction`` for |
40 | | - /// a modal. When `store`'s state is non-`nil`, the system passes a store of unwrapped `State` |
41 | | - /// and `Action` to the modifier's closure. You use this store to power the content in a sheet |
42 | | - /// you create that the system displays to the user. If `store`'s state is `nil`-ed out, the |
43 | | - /// system dismisses the currently displayed sheet. |
44 | | - /// - toDestinationState: A transformation to extract modal state from the presentation state. |
45 | | - /// - fromDestinationAction: A transformation to embed modal actions into the presentation |
46 | | - /// action. |
47 | | - /// - onDismiss: The closure to execute when dismissing the modal view. |
48 | | - /// - content: A closure returning the content of the modal view. |
49 | | - @available(iOS 14, tvOS 14, watchOS 7, *) |
50 | | - @available(macOS, unavailable) |
51 | | - public func fullScreenCover<State, Action, DestinationState, DestinationAction, Content: View>( |
52 | | - store: Store<PresentationState<State>, PresentationAction<Action>>, |
53 | | - state toDestinationState: @escaping (_ state: State) -> DestinationState?, |
54 | | - action fromDestinationAction: @escaping (_ destinationAction: DestinationAction) -> Action, |
55 | | - onDismiss: (() -> Void)? = nil, |
56 | | - @ViewBuilder content: @escaping (_ store: Store<DestinationState, DestinationAction>) -> Content |
57 | | - ) -> some View { |
58 | | - self.presentation( |
59 | | - store: store, state: toDestinationState, action: fromDestinationAction |
60 | | - ) { `self`, $item, destination in |
61 | | - self.fullScreenCover(item: $item, onDismiss: onDismiss) { _ in |
62 | | - destination(content) |
| 32 | + |
| 33 | + /// Presents a modal view that covers as much of the screen as possible using the store you |
| 34 | + /// provide as a data source for the sheet's content. |
| 35 | + /// |
| 36 | + /// > This is a Composable Architecture-friendly version of SwiftUI's `fullScreenCover` view |
| 37 | + /// > modifier. |
| 38 | + /// |
| 39 | + /// - Parameters: |
| 40 | + /// - store: A store that is focused on ``PresentationState`` and ``PresentationAction`` for |
| 41 | + /// a modal. When `store`'s state is non-`nil`, the system passes a store of unwrapped `State` |
| 42 | + /// and `Action` to the modifier's closure. You use this store to power the content in a sheet |
| 43 | + /// you create that the system displays to the user. If `store`'s state is `nil`-ed out, the |
| 44 | + /// system dismisses the currently displayed sheet. |
| 45 | + /// - toDestinationState: A transformation to extract modal state from the presentation state. |
| 46 | + /// - fromDestinationAction: A transformation to embed modal actions into the presentation |
| 47 | + /// action. |
| 48 | + /// - onDismiss: The closure to execute when dismissing the modal view. |
| 49 | + /// - content: A closure returning the content of the modal view. |
| 50 | + @available(iOS 14, tvOS 14, watchOS 7, *) |
| 51 | + @available(macOS, unavailable) |
| 52 | + public func fullScreenCover<State, Action, DestinationState, DestinationAction, Content: View>( |
| 53 | + store: Store<PresentationState<State>, PresentationAction<Action>>, |
| 54 | + state toDestinationState: @escaping (_ state: State) -> DestinationState?, |
| 55 | + action fromDestinationAction: @escaping (_ destinationAction: DestinationAction) -> Action, |
| 56 | + onDismiss: (() -> Void)? = nil, |
| 57 | + @ViewBuilder content: @escaping (_ store: Store<DestinationState, DestinationAction>) -> Content |
| 58 | + ) -> some View { |
| 59 | + self.presentation( |
| 60 | + store: store, state: toDestinationState, action: fromDestinationAction |
| 61 | + ) { `self`, $item, destination in |
| 62 | + self.fullScreenCover(item: $item, onDismiss: onDismiss) { _ in |
| 63 | + destination(content) |
| 64 | + } |
63 | 65 | } |
64 | 66 | } |
65 | 67 | } |
66 | | -} |
| 68 | +#endif |
0 commit comments