Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transparent screens #193

Closed
jamolkhon opened this issue Jul 4, 2019 · 6 comments

Comments

Projects
None yet
2 participants
@jamolkhon
Copy link

commented Jul 4, 2019

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.

@Zhuinden

This comment has been minimized.

Copy link
Owner

commented Jul 5, 2019

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.

@jamolkhon

This comment has been minimized.

Copy link
Author

commented Jul 5, 2019

profile-screen-or-dialog

This is how a typical see-through screen looks.

@Zhuinden

This comment has been minimized.

Copy link
Owner

commented Jul 5, 2019

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).

@Zhuinden

This comment has been minimized.

Copy link
Owner

commented Jul 8, 2019

Did that answer your question?

@jamolkhon

This comment has been minimized.

Copy link
Author

commented Jul 8, 2019

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!

@Zhuinden

This comment has been minimized.

Copy link
Owner

commented Jul 8, 2019

(make sure to add fragments only if they are !isAdded 😉 )

Happy to hear!

@Zhuinden Zhuinden closed this Jul 8, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.