Posts

Post not yet marked as solved
5 Replies
164 Views
I am targeting iOS17 and using @Observable. I have an array of items, and I want to present a sheet when the array is greater than zero. My @Observable looks like this: @Observable class BStoreOO { var items: [Int] = [] var showBS: Bool { items.isEmpty } func updateItems(newItems: [Int]) { self.items = newItems } } When this array gets added to, from another view, I would like to present a sheet/popover. Inside my ContentView I have a @State `... that uses that @Observable struct ContentView: View { @State var bStore = BStoreOO() Further down in my View, how should I toggle this view on the basis of the observed array not being empty? I have tried a number of ways. Some error, some don't, but none present the sheet! For example: .popover(isPresented: bStore.showBS) { PopoverContent() } Gives the error "Cannot convert value of type 'Bool' to expected argument type 'Binding'" If I add a State like this: @State private var isShowingBS = false and then add this: .onChange(of: bStore.items) { self.isShowingBS = self.bStore.items.count > 0 } I don't get errors but nothing is presented. What is the correct way to bind the presentation of the sheet to whether the observed items array is empty or not?
Posted Last updated
.
Post not yet marked as solved
7 Replies
2.6k Views
The iOS Simulator is incredibly useful for debugging. However, once a PWA has been saved to Home screen it is no longer possible to inspect in via Safari Web Inspector. Will this be addressed?
Posted Last updated
.
Post marked as solved
6 Replies
3.8k Views
I have read more blog posts than I care to recall and I am still unclear: is there a simple way to determine the geometry of a clicked Button?I'm looking for the equivalent to `Element.getBoundingClientRect()`in JavaScript???I get get the width of a clicked SwiftUI button by creating a UILabel and measuring:let labelWidth = label.intrinsicContentSize.width return labelWidthBut even that feels hacky.I'm looking to do something like this (pseudo code) where geometry.x gives me the x position of the Button:GeometryReader { geometry in return Button(action: { self.xPos = geometry.x}) { HStack { Text("Sausages") } } }??
Posted Last updated
.
Post marked as solved
1 Replies
576 Views
I've followed the documentation for making a symbol set here: https://developer.apple.com/documentation/xcode/creating_custom_symbol_images_for_your_appAnd also the docs on configuring: https://developer.apple.com/documentation/uikit/uiimage/configuring_and_displaying_symbol_images_in_your_uiHowever, nothing covers what the syntax is to actually include one of these in a view. For example, given an asset in Assets.xcassets called "sausages" what should the correct syntax be on line 5?:Text("Sausages") .font(.title) .tabItem { VStack { Image(systemName: "sausages") Text("sausages") } }Or does this have to be done with standard Swift?
Posted Last updated
.
Post not yet marked as solved
1 Replies
984 Views
As per https://github.com/w3c/csswg-drafts/issues/2732I would like to know if there is intent to expose the values of env() values to JavaScript?These values have been in iOS devices for nearly two years now and other than UA sniffing combined with screen measurement we don't have any means at our disposal to read in the values in JavaScript.Is there any progress on exposing these values to script?
Posted Last updated
.