I am using SF symbols on my TabBar but even though I use the stroke version, it inserts the fill one.
ProductsListView()
.tabItem {
Image(systemName: "book")
Text("Products")
}
However, the image that shows up when I run the application in the book.fill
Why this could be happening?
Thx
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
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
I have a view which goes to my Store, gets data from an API and bringing back to the view.
var productId = 123
@ObservedObject var productStore = ProductStore()
init() {
productStore.getById(productId: self.productid)
}
The object from ProductStore is coming back but when I try to use it:
Text(self.productStore.product!.title)
I get: Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value
Why this is happening if the object doesnt have nil values ?
I am trying to present a decimal variable containing the value of 66.67. So I am trying to do:
Text("\(myVariable, specifier: "%.2f")")
//Instance method 'appendinterpolation(_:specifier) requires that Decimal conform to _formtSpecifiable
Text("\(myVariable, specifier: "%.2f")" as String)
//I receive extra argument specifier in call
How can I fix it ?
Thx
I have an array with 10 different categories.
So I create NavigationLink for each of them, calling MyListView and passing data about the category.
NavigationView {
List(categories) { category in
NavigationLink(destination:
MyListView(category: category)
)
{
CategoryRow(category: category)
}
}
}
So when I click in one of these 10 categories, I will call MyListView. Inside MyListView I have a call to the API bringing a lot of information about the chosen category.
The problem here is, even before clicking in any category, MyListView is being called and the API is called for all the 10 categories.
I only want to call MyListView and the API inside it, after selecting the category.
Whats the problem here ?
Thx
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
I have set in my info.plist file, the background and image I want for my launch screen.
The image is 200px x 200px and for some reason, when the launch screen happens, the image gets stretched, not keeping the original size.
How can I fix it ?
Thank you
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
}