Post

Replies

Boosts

Views

Activity

Loading View on API call
I have a Loading view saying "Please wait" that I want to be presented until the data from the API comes back. However, self.showLoading = false is executed even before store.getHomeItems() is finished. How can I do it ? struct HomeView: View {   @State var showLoading = false ... if (self.showLoading == true) { LoadingView() } else { //my content } ... ScrollView { //my scroll content } .onAppear { self.showLoading = true       DispatchQueue.main.async {          store.getHomeItems()       } self.showloading = false ... } I also dont know if I can call Dispatch on my HomeView, since my API layer has also an another DispatchQueue. URLSession.shared.dataTask(with: url) { (data, _, _) in       guard let data = data else { return }               let myItems = try! JSONDecoder().decode([ItemModel].self, from: data)      DispatchQueue.main.asyncAfter(deadline: .now() + 10) {         completion(myItems)       }        }     .resume() Thank you
2
0
1.6k
Nov ’21
Picker without NavigationView
I have a picker on my view but it's not selectable unless I replace my VStack for a NavigationView. However I cant have a NavigationView on this page, otherwise it brakes other parts. What's the solution for that ? Thx VStack { Picker }
4
0
2.0k
Dec ’21
Call 2o API after finishing 1st one
I have a button that when pressed should call an API which return an ID. Then having this ID, I will call a 2nd API. Button(action: { var id = self.callApi1() self.callApi2(id) }) { Text("Start") } How can I call the Api2 JUST when the Api1 was finished and returned its value ? Thank you
3
0
550
Dec ’21
TabBar Transitions
I have a TabBar with 3 items: Home ScrollView Products NavigationView Users NavigationView When clicking on the tabBar buttons, I will go back to the related view. However, at the point where I had left. I would like to every time I move to a different tab, it starts fresh like 1st time. a) If it's a scrollview, after coming back to the tab I would like the view scrolled to the top. b) If it's a navigationView, after coming back to the tab, I would like to scroll to the top and move to the Navigation root list. How can I do it. Thx folks
0
0
370
Dec ’21
Loading View on API call
I have a Loading view saying "Please wait" that I want to be presented until the data from the API comes back. However, self.showLoading = false is executed even before store.getHomeItems() is finished. How can I do it ? struct HomeView: View {   @State var showLoading = false ... if (self.showLoading == true) { LoadingView() } else { //my content } ... ScrollView { //my scroll content } .onAppear { self.showLoading = true       DispatchQueue.main.async {          store.getHomeItems()       } self.showloading = false ... } I also dont know if I can call Dispatch on my HomeView, since my API layer has also an another DispatchQueue. URLSession.shared.dataTask(with: url) { (data, _, _) in       guard let data = data else { return }               let myItems = try! JSONDecoder().decode([ItemModel].self, from: data)      DispatchQueue.main.asyncAfter(deadline: .now() + 10) {         completion(myItems)       }        }     .resume() Thank you
Replies
2
Boosts
0
Views
1.6k
Activity
Nov ’21
Picker without NavigationView
I have a picker on my view but it's not selectable unless I replace my VStack for a NavigationView. However I cant have a NavigationView on this page, otherwise it brakes other parts. What's the solution for that ? Thx VStack { Picker }
Replies
4
Boosts
0
Views
2.0k
Activity
Dec ’21
Call 2o API after finishing 1st one
I have a button that when pressed should call an API which return an ID. Then having this ID, I will call a 2nd API. Button(action: { var id = self.callApi1() self.callApi2(id) }) { Text("Start") } How can I call the Api2 JUST when the Api1 was finished and returned its value ? Thank you
Replies
3
Boosts
0
Views
550
Activity
Dec ’21
TabBar Transitions
I have a TabBar with 3 items: Home ScrollView Products NavigationView Users NavigationView When clicking on the tabBar buttons, I will go back to the related view. However, at the point where I had left. I would like to every time I move to a different tab, it starts fresh like 1st time. a) If it's a scrollview, after coming back to the tab I would like the view scrolled to the top. b) If it's a navigationView, after coming back to the tab, I would like to scroll to the top and move to the Navigation root list. How can I do it. Thx folks
Replies
0
Boosts
0
Views
370
Activity
Dec ’21