Post

Replies

Boosts

Views

Activity

Reply to isPresented: on the basis of an observed object not being empty?
Imagine a shopping app. And when you add an item(s) to your basket from a child view (say there is a quantity plus/minus button), you want to bring up the cart as a popover. The user might dismiss the cart from within the cart/popover, but equally, the user might take the item back out of the cart from the child view page, and if there was only one item in the basket, and the user removes it from the ChildView, I would want the cart/popover to dismiss also. So: items in array, show the cart/popover No items in cart, or cart/popover dismissed directly, hide the cart/popover
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Mar ’24
Reply to isPresented: on the basis of an observed object not being empty?
Forgot to add that shouldShowSheet in a function: func shouldShowSheet() -> Binding<Bool> { return .init(get: { return bStore.items.count > 0 }, set: { _ in }) }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Mar ’24
Reply to isPresented: on the basis of an observed object not being empty?
Imagine a shopping app. And when you add an item(s) to your basket from a child view (say there is a quantity plus/minus button), you want to bring up the cart as a popover. The user might dismiss the cart from within the cart/popover, but equally, the user might take the item back out of the cart from the child view page, and if there was only one item in the basket, and the user removes it from the ChildView, I would want the cart/popover to dismiss also. So: items in array, show the cart/popover No items in cart, or cart/popover dismissed directly, hide the cart/popover
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Mar ’24
Reply to isPresented: on the basis of an observed object not being empty?
No, that would just be hiding the cart. There would be some other UI to bring it back if needed. I actually ended up with the problem being solved when someone on another forum suggested using didSet on the items variable, and use that to add the logic to toggle the @State private var isShowingBS = false
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Mar ’24