Undo a backward move when using NavigationStack

When I navigate backward (like swiping the view from the left), I want to be able to drag it back from the right to move to that previous view. Sort of like an undo stack.
I asked this question on StackOverflow and the solution there works, but doesn't feel "native": I want the full dragging-of-the-view effect just like in the native navigation.
Is it possible to use NavigationStack or other existing views to solve that?

pexavc,

Funnily enough. I actually just did this. But I’m essentially holding a stack of view builders that represents the navigation stack view. Popping the view after applying a custom drag gesture view modifier to replicate the animation you’re requesting.

There are some interesting repos that involve custom solutions around this problem.

github.com/matteopuc/swiftui-navigation-stack

For starters.

But, essentially I just opted out of using the built in navigations. Unless it’s SplitView for macOS

lazyvar,
@lazyvar@programming.dev avatar

Nothing better than what was discussed on SO comes to mind, at least nothing that would give you that native smooth feel.

It will definitely require a decent amount of custom work.

Closest example I can think of was Apollo, I believe @christianselig was contemplating writing up a blogpost on how he did it, but I’m unsure if he got around to doing it yet (and it’ll likely be in UIKit).

  • All
  • Subscribed
  • Moderated
  • Favorites
  • swiftui@lemmy.world
  • GTA5RPClips
  • DreamBathrooms
  • thenastyranch
  • magazineikmin
  • tacticalgear
  • cubers
  • Youngstown
  • mdbf
  • slotface
  • rosin
  • osvaldo12
  • ngwrru68w68
  • kavyap
  • InstantRegret
  • JUstTest
  • everett
  • Durango
  • cisconetworking
  • khanakhh
  • ethstaker
  • tester
  • anitta
  • Leos
  • normalnudes
  • modclub
  • megavids
  • provamag3
  • lostlight
  • All magazines