NavigationBackport icon indicating copy to clipboard operation
NavigationBackport copied to clipboard

Any chance of some backport love for the `isPresented` overload of `navigationDestination`?

Open kielgillard opened this issue 3 years ago • 2 comments

From the SwiftUI interface (documentation link):

    /// Associates a destination view with a binding that can be used to push
    /// the view onto a ``NavigationStack``.
    ///
    /// In general, favor binding a path to a navigation stack for programmatic
    /// navigation. Add this view modifer to a view inside a ``NavigationStack``
    /// to programmatically push a single view onto the stack. This is useful
    /// for building components that can push an associated view. For example,
    /// you can present a `ColorDetail` view for a particular color:
    ///
    ///     @State private var showDetails = false
    ///     var favoriteColor: Color
    ///
    ///     NavigationStack {
    ///         VStack {
    ///             Circle()
    ///                 .fill(favoriteColor)
    ///             Button("Show details") {
    ///                 showDetails = true
    ///             }
    ///         }
    ///         .navigationDestination(isPresented: $showDetails) {
    ///             ColorDetail(color: favoriteColor)
    ///         }
    ///         .navigationTitle("My Favorite Color")
    ///     }
    ///
    /// Do not put a navigation destination modifier inside a "lazy" container,
    /// like ``List`` or ``LazyVStack``. These containers create child views
    /// only when needed to render on screen. Add the navigation destination
    /// modifier outside these containers so that the navigation stack can
    /// always see the destination.
    ///
    /// - Parameters:
    ///   - isPresented: A binding to a Boolean value that indicates whether
    ///     `destination` is currently presented.
    ///   - destination: A view to present.
    public func navigationDestination<V>(isPresented: Binding<Bool>, @ViewBuilder destination: () -> V) -> some View where V : View

kielgillard avatar Sep 06 '22 03:09 kielgillard

I'd offer to do a PR but I feel I'm a bit out of my depth here.

kielgillard avatar Sep 06 '22 03:09 kielgillard

Thanks for raising this issue @kielgillard - this API had completely escaped my notice! When I have a chance, I'll see if it can be accommodated in NavigationBackport.

johnpatrickmorgan avatar Sep 20 '22 22:09 johnpatrickmorgan

+1 for this :D

zeusent avatar Nov 25 '22 15:11 zeusent

I finally spent some time on this and have made good progress, so I'll try to merge it in soon.

johnpatrickmorgan avatar Nov 26 '22 00:11 johnpatrickmorgan

+1

thunderball1 avatar Nov 28 '22 19:11 thunderball1

It took a while but I've added support for this in v0.7.0. Please let me know if you find any issues with it.

johnpatrickmorgan avatar Dec 06 '22 23:12 johnpatrickmorgan