You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TabView and .sheet seem not to be playing well together on macOS. Anyone else seen this?
I'm writing a macOS application and, once one has selected a context to work in, there are a few different ways to interact with that context. I started out with a UI that's based on tabs, one tab per kind of data that's being modified. I've then written a picker control, to provide a searchable list of items. Click a "pick a person" button should trigger a sheet to pop up, the contents of the sheet being the control, populated with the appropriate list of people. Interestingly, this works in a live preview of the view that contains the button, but doesn't work when that view is inside a TabView. This leads me to think that there's something in SwiftUI that doesn't like this kind of nesting.
Multiple .sheet modifiers on a single view seem not to work properly - not super surprising, but a little disappointing. What's the right way to achieve what I want?
Again, this picker control I've written - provide it a list of items and when one is selected then the picker's ViewStore will send an itemSelected action. Now, if I'm editing a person record, I might want to add children, or partners, or parents. Three different kinds of relationship, but the same kind of entity (a person) being related. Intuitively, there are three buttons: add a parent, add a partner, add a child. But given how long it takes the compiler (longest I've waited is 5 minutes and it has never completed), I'm going to guess that
var body:someView{VStack{...}.sheet(store:self.store.scope(state: \.$destination, action:{.destination($0)}),
state:/EditPerson.Destination.State.selectParent,
action:EditPerson.Destination.Action.selectParent){ store in...}.sheet(store:self.store.scope(state: \.$destination, action:{.destination($0)}),
state:/EditPerson.Destination.State.selectPartner,
action:EditPerson.Destination.Action.selectPartner){ store in...}.sheet(store:self.store.scope(state: \.$destination, action:{.destination($0)}),
state:/EditPerson.Destination.State.selectChild,
action:EditPerson.Destination.Action.selectChild){ store in...}
...is not the right way to do it. So now I'm thinking that I need to encode the relationship type into the Destination state, along with the list of people. Given that I already know the control works (at least, in a preview and when not in a TabView) this might let me move forward on reimagining the UI without tabs. But, it feels kind of dirty. Like, okay, I know that on this particular view, the only sheet I might want to put up is a picker that's populated with people, but that feels overly specific. Is that really how SwiftUI expects us to use sheets? That a given view might only ever want to pop up one kind of sheet?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
TabView
and.sheet
seem not to be playing well together on macOS. Anyone else seen this?I'm writing a macOS application and, once one has selected a context to work in, there are a few different ways to interact with that context. I started out with a UI that's based on tabs, one tab per kind of data that's being modified. I've then written a picker control, to provide a searchable list of items. Click a "pick a person" button should trigger a sheet to pop up, the contents of the sheet being the control, populated with the appropriate list of people. Interestingly, this works in a live preview of the view that contains the button, but doesn't work when that view is inside a
TabView
. This leads me to think that there's something in SwiftUI that doesn't like this kind of nesting.Multiple
.sheet
modifiers on a single view seem not to work properly - not super surprising, but a little disappointing. What's the right way to achieve what I want?Again, this picker control I've written - provide it a list of items and when one is selected then the picker's
ViewStore
will send an itemSelected action. Now, if I'm editing a person record, I might want to add children, or partners, or parents. Three different kinds of relationship, but the same kind of entity (a person) being related. Intuitively, there are three buttons: add a parent, add a partner, add a child. But given how long it takes the compiler (longest I've waited is 5 minutes and it has never completed), I'm going to guess that...is not the right way to do it. So now I'm thinking that I need to encode the relationship type into the Destination state, along with the list of people. Given that I already know the control works (at least, in a preview and when not in a TabView) this might let me move forward on reimagining the UI without tabs. But, it feels kind of dirty. Like, okay, I know that on this particular view, the only sheet I might want to put up is a picker that's populated with people, but that feels overly specific. Is that really how SwiftUI expects us to use sheets? That a given view might only ever want to pop up one kind of sheet?
Beta Was this translation helpful? Give feedback.
All reactions