NavigationStack | This is how SwiftUI's navigation should've been since day one!

Поделиться
HTML-код
  • Опубликовано: 15 сен 2024
  • In this video, we will explore the difference between the old NavigationView vs NavigationStack announced at #WWDC22, and why this new API is astronomically better than the previous one.
    ------
    Demos showed in the video:
    * Custom back button: gist.github.co...
    * popToRoot(): gist.github.co...
    * Override Navigation: gist.github.co...
    * NavigationPath: gist.github.co...
    ------
    Resources:
    * developer.appl...)
    * developer.appl...
    * developer.appl...
    * developer.appl...
    * Pointfree's navigation alternative: github.com/poi...
    ------
    Videos related:
    * State and Binding: • SwiftUI's lifecycle, @...
    * any Keyword: • "any" Keyword and Exis...
    * where clauses: • Generics in Swift: Whe...
    * Lazy Grids: • How to replicate Apple...
    -----
    Contact:
    / swiftandtips
    / swiftandtips
    / swiftandtips
    Finally, ask me for a video you would like to see next 😄!
    Credits:
    - Music by Wataboi from pixabay.com/
    - Video edited with Final Cut Pro

Комментарии • 46

  • @ColeDano
    @ColeDano 2 года назад +2

    Thanks Pete!
    This is what I’ve been wondering since I started learning Swift. Layouts are so simple, yet any navigation beyond the most becomes a convoluted mess.
    This is big enough that the backwards compatibility starts to matter to me as well. Being an Indy, I might just adopt this anyway as navigation is critical to what I’m cooking up.

  • @jujdu
    @jujdu 2 года назад +5

    Can't even imagine when we will be using this approach... Now we have iOS 14 in our project and I think we will have using it for the next 2-3 years (or even more) before we change it to only iOS 15, even not iOS 16. Because iOS 14 with SwiftUI it's kinda iOS 10-11 with UIKit some years ago.
    Apple's interfaces are pretty nice, but it's stupid that we can't use it for so long time. And more, even we can use it, it's anyway super high level API and we still can't do all stuff we need.

    • @swiftandtips
      @swiftandtips  2 года назад

      I know 😥, but I think the community will get inspiration of this approach to build a custom version in the meantime.

  • @RatherBeCancelledThanHandled
    @RatherBeCancelledThanHandled Год назад +1

    I thumbed this up because the image with the banana and the wacky sound was uhhhmazin

  • @officialspaceefrain
    @officialspaceefrain Год назад +1

    Tomato is a fruit 🥸. Great video btw. Love the edits. Keep it up !

    • @swiftandtips
      @swiftandtips  Год назад +2

      CHANGE MY MIND 🍅! Just kidding, thanks for clarifying 😂!
      And thanks for your support 😊

  • @rgenericson5361
    @rgenericson5361 Год назад

    Congrats for presenting by far, the best explanation on RUclips!

  • @tehLilaQ
    @tehLilaQ Год назад

    Godsend! Finally!

  • @andrejkling3886
    @andrejkling3886 2 года назад +1

    Thank you…

  • @anasalhalabi1051
    @anasalhalabi1051 2 года назад

    you are amazing Please continue

  • @FeminDharamshi
    @FeminDharamshi Год назад +1

    What do you use to make your videos? The slides/presentation?

  • @Ogrutsov
    @Ogrutsov Год назад

    Thanks for your video!
    How to make swipe back gesture if you hide or make custom navigation back button?
    Should I write custom gesture for that?

    • @swiftandtips
      @swiftandtips  Год назад

      Great question, Yes! You will have to do your own implementation 😅

  • @fakingitpod
    @fakingitpod 7 месяцев назад

    love it

  • @andrewduncanpoole
    @andrewduncanpoole 2 года назад

    Thank you fro these insights - it is definitely a good thing that Apple are improving the code making it more efficient and to the point. Is Navigationstack backward compatible for earlier versions of MacOS? The code won't run while on MacOS12.5 even with #if available(MacOS 13*)....

    • @swiftandtips
      @swiftandtips  2 года назад +1

      Hi Andrew, I’m sorry but it’s not backward compatible (yet). You can only use it on iOS16 and macOS Ventura and above. I hope this could be available for older OSs, but I don’t think they will do it. There isn’t backward compatibility for @StateObject on iOS 13, which is even more important than this.

    • @andrewduncanpoole
      @andrewduncanpoole 2 года назад +1

      @@swiftandtips Thank you for getting back to me. I will only really be able to implement this in October when Ventura is released - so will have to hold onto the existing convoluted code till then.

  • @aqibos
    @aqibos Год назад

    How do you get a reference to the NavigationPath in another view, say a child view that was appended already?

    • @swiftandtips
      @swiftandtips  Год назад

      What would you like to do with that?

    • @aqibos
      @aqibos Год назад

      @@swiftandtips append to the navigation path in the child view. I ended figuring it out by adding it as an environment object.

    • @swiftandtips
      @swiftandtips  Год назад

      @@aqibos Cool, can you share the code with us? Just to have a better context of what you did. Thanks!

  • @dewigesrek5651
    @dewigesrek5651 2 года назад

    this os why i still stick my fingers in uikit. it’s mature and stable enough. look at this, ios 15+ only. imagine having to do if #available and put separate logic for 2 different ios version

    • @dewigesrek5651
      @dewigesrek5651 2 года назад

      apple could’ve made it available for ios 13+ but no

    • @swiftandtips
      @swiftandtips  2 года назад

      I agree with you, this would be better for iOS 13+, but at the same time, building a Framework that basically all the ecosystem can use is hard. I mean, I guess they may evaluate backward compatibility to see the impact on legacy OSs, but who knows 🤷🏻‍♂️

  • @fakingitpod
    @fakingitpod 7 месяцев назад

    wow

  • @marlhex6280
    @marlhex6280 Год назад

    where's the best quality source to learn real SwiftUI data handling?

    • @swiftandtips
      @swiftandtips  Год назад

      Hi @marlhex6280, What do you mean by real data handling?

    • @marlhex6280
      @marlhex6280 Год назад

      @@swiftandtips, thanks for the question. I mean passing views around 1 navigationStack, business logic architecture, and I think URLSession or Alamofire is now like old school as UIKit, Highly functional, but new companies will want async-await. I know SwiftUI needs to mature a little bit for us to catch up so they stop deprecating important stuff as NavigationView to NavigationStacks, and one final question, styling, I was implementing a picker on .segmented and trying to find a way to add colours to each segment it's just a little bit difficult to find at first glance if I add the modifiers in each bracket looks like it ignores the code, like when we apply cornerRadius it needs a specific order

    • @marlhex6280
      @marlhex6280 Год назад

      @@swiftandtips I've found this video from a friend that works at Meta ruclips.net/video/3pIXMwvJLZs/видео.html&ab_channel=AppStuff

  • @dugrut1325
    @dugrut1325 Год назад

    ... I'm still wondering! ???

  • @johncitrowske9922
    @johncitrowske9922 Год назад

    The sfx are very loud lol

    • @swiftandtips
      @swiftandtips  Год назад +1

      I fixed that in later episodes 😅

  • @oliver_lauritsen_oa
    @oliver_lauritsen_oa 2 года назад +5

    New navigation method sounds good but apple is just trash nothing is backwards compatible and it means if you want to make use of the new version you must update to newest iOS and swift it’s not like on android where most things is backwards compatible down to android 5 a nearly 10 year old version 😡

  • @indiekiduk
    @indiekiduk Год назад

    It's great they are trying but this attempt is totally useless since a navigation value can't be a binding.

    • @swiftandtips
      @swiftandtips  Год назад

      Hi @indiekiduk, Can you elaborate this?

    • @indiekiduk
      @indiekiduk Год назад

      NavigationLink(value: $fruit) navigationDestination(for: Binding.self) Instance method 'navigationDestination(for:destination:)' requires that 'Binding' conform to 'Hashable'

  • @CrisCozy
    @CrisCozy Год назад

    Way less code 🎉