@@ -18,10 +18,10 @@ the rest.
1818
1919## Basics
2020
21- The tools for this style of navigation include the `` PresentationState `` property wrapper ,
22- `` PresentationAction `` , the `` Reducer/ifLet(_:action:destination:fileID:line:)-4f2at `` operator, and
23- a bunch of APIs that mimic SwiftUI's regular tools, such as ` .sheet ` , ` .popover ` , etc., but tuned
24- specifically for the Composable Architecture .
21+ The tools for this style of navigation include the `` Presents() `` macro ,
22+ `` PresentationAction `` , the `` Reducer/ifLet(_:action:destination:fileID:line:)-4f2at `` operator,
23+ and that is all. Once your feature is properly integrated with those tools you can use all of
24+ SwiftUI's normal navigation view modifiers, such as ` sheet(item:) ` , ` popover(item:) ` , etc .
2525
2626The process of integrating two features together for navigation largely consists of 2 steps:
2727integrating the features' domains together and integrating the features' views together. One
@@ -31,7 +31,7 @@ into the parent.
3131
3232For example, suppose you have a list of items and you want to be able to show a sheet to display a
3333form for adding a new item. We can integrate state and actions together by utilizing the
34- `` PresentationState `` and `` PresentationAction `` types :
34+ `` Presents() `` macro and `` PresentationAction `` type :
3535
3636``` swift
3737@Reducer
@@ -214,7 +214,7 @@ struct InventoryFeature {
214214> enums.
215215
216216With that done we can now hold onto a _ single_ piece of optional state in our feature, using the
217- `` PresentationState `` property wrapper , and we hold onto the destination actions using the
217+ `` Presents() `` macro , and we hold onto the destination actions using the
218218`` PresentationAction `` type:
219219
220220``` swift
@@ -382,35 +382,29 @@ project:
382382
383383``` swift
384384extension View {
385- @available (iOS , introduced : 13 , deprecated : 16 )
386- @available (macOS , introduced : 10.15 , deprecated : 13 )
387- @available (tvOS , introduced : 13 , deprecated : 16 )
388- @available (watchOS , introduced : 6 , deprecated : 9 )
385+ @available (iOS , introduced : 16 , deprecated : 17 )
386+ @available (macOS , introduced : 13 , deprecated : 14 )
387+ @available (tvOS , introduced : 16 , deprecated : 17 )
388+ @available (watchOS , introduced : 9 , deprecated : 10 )
389389 @ViewBuilder
390390 func navigationDestinationWrapper <D : Hashable , C : View >(
391391 item : Binding<D? >,
392392 @ViewBuilder destination : @escaping (D) -> C
393393 ) -> some View {
394- if #available (iOS 17 , macOS 14 , tvOS 17 , visionOS 1 , watchOS 10 , * ) {
395- navigationDestination (item : item, destination : destination)
396- } else {
397- navigationDestination (
398- isPresented : Binding (
399- get : { item.wrappedValue != nil },
400- set : { isPresented, transaction in
401- if ! isPresented {
402- item.transaction (transaction).wrappedValue = nil
403- }
404- }
405- )
406- ) {
407- if let item = item.wrappedValue {
408- destination (item)
409- }
394+ navigationDestination (isPresented : item.isPresented ) {
395+ if let item = item.wrappedValue
396+ destination (item)
410397 }
411398 }
412399 }
413400}
401+
402+ fileprivate extension Optional where Wrapped: Hashable {
403+ var isPresented: Bool {
404+ get { self != nil }
405+ set { if ! newValue { self = nil } }
406+ }
407+ }
414408```
415409
416410If you target platforms earlier than iOS 16 , macOS 13 , tvOS 16 and watchOS 9 , then you cannot use
@@ -600,8 +594,9 @@ struct CounterFeature {
600594}
601595```
602596
603- And then let's embed that feature into a parent feature using `` PresentationState `` ,
604- `` PresentationAction `` and `` Reducer/ifLet(_:action:destination:fileID:line:)-4f2at `` :
597+ And then let 's embed that feature into a parent feature using the ``Presents ()`` macro,
598+ ``PresentationAction`` type and ``Reducer/ ifLet (_:action:destination:fileID:line: )-4f2at ``
599+ operator :
605600
606601```swift
607602@Reducer
0 commit comments