Reload the List with updated data from API | SwiftUI Crypto App #16

preview_player
Показать описание
Now that our app is coming together, you probably noticed that we don't have a way to reload the data. This of course is a very important feature because we don't want the user to have to close and re-open the app every time they want updated data. In this video we will add a very simple loading button that the user can click to reload the data.

Unfortunately, SwiftUI doesn't have a "pull-to-refresh" feature just yet. So instead of hacking one together, we are just going to use a basic icon. However, we will enhance the user experience a little bit by adding animation and haptics when the user clicks it!

*** UPDATE:

Apple officially announced a "pull-to refresh" feature coming to SwiftUI at WWDC 2021! I will not be updating the implementation in this video, but I will be covering this new feature in a bootcamp video coming soon.

*** LINKS:

🤙 WELCOME BACK 🤙

Рекомендации по теме
Комментарии
Автор

Great video as usual Nick! The pull down functionality is now available by adding .refreshable { print("do your magic!") } to the List.

TF
Автор

So far I've somehow managed to keep up and follow, but now I think my brain is going to explode :)

oldschool
Автор

Great series Nick, really learning a lot about how to structure a modern iOS app. Incidently, in iOS 15 there is now a .refreshable() modifier for List which enables pull to refresh!!!!

iaincaldwell
Автор

Coming together very smoothly. With all the iOS updates the next courses are gonna shorter I recon. Super excited for the rest. Can't thank you enough.

Benbbr
Автор

I remember WWDC2021 mentioned this new feature! It now seems to be a modifier of List

Nick-gjgz
Автор

Nick, great tutorial! I noticed you can get a divide by zero error if the previousValue is 0. I added a check that portfolioCoins is not empty in mapGlobalMarketData func.

granito
Автор

Sweet, I was hoping you would take advantage and make some videos of the new SwiftUI features coming. Not too many streamers will be on top of that. (Referencing the comment about the up coming bootcamp.)

sols.
Автор

somehow shows an error at the portfolioValue by a warning as "Invalid redeclaration of "portfolioValue" and cannot figure out what it does mean.

msmhshs
Автор

If you are reading this, please leave a like, many views and not so many likes, mmm.. creating this content takes time and effort, all of us came here looking for knowledge, learn to be thankful as well ;)

Julio-cuhd
Автор

thanks nick for this tutorial, it would be awesome if you can create a discord channel

disclosure
Автор

Unfortunately, this tutorial doesn't mention the limit of HTTP requests,
because if you use the reload button frequently, you will get HTTP error 429 (too many requests).
This is a BUG of a new feature. (Reload Button)

paulmax
Автор

One suggestion:
- Mapping for currentHoldingsValue can be even more shorter with keypath:

let portfolioValue =

btw: this course is awesome

miljanangelovik
welcome to shbcf.ru