Closed jamolkhon closed 5 years ago
I'd have to see the design to tell you something concrete (and I know that's not as easy to just show off 🤔 ) but as simple-stack
handles the management of navigation state in the form of a list, technically what you do in the handleStateChange
method is totally up to you -- you are not confined to the FragmentStateChanger nor the DefaultViewStateChanger.
The real trickery is the handling of [], [A,B,C]
type of state changes, for example after process death or configuration changes. Because the views are destroyed and recreated by Android on configuration change, so if it needs to be "see-through", then in that case you'd have to restore the active screens in order after such recreation. Which you can, because you know exactly that [A,B,C]
screens should be showing. So in such scenario, you would remove views only if its key is not in the stateChange.newKeys
I think this scenario is actually easier with simple-stack
than it would be with any other navigation library available.
This is how a typical see-through screen looks.
I can imagine this as a [MapKey, MenuKey]
, just gotta make sure you add the MapKey
to the screen it's in the new keys even if it's not the top (and not yet on the screen).
Did that answer your question?
Yes, it did. The solution was surprisingly easy. I just removed FragmentTransaction.detach calls then added a FragmentTransaction.add call for non-top keys as you suggested. Thanks for the help!
(make sure to add
fragments only if they are !isAdded
😉 )
Happy to hear!
Sorry, couldn't come up with a better title.
Having screens A and B where B has transparent background. Will A be (partially) seen when B is the topmost screen?
If not what is the best way to accomplish this? I've started working on a new project where almost half of the screens should be or look like dialogs.