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

Nested fragment ScreenSwitcher #12

Closed
DomiBlaze opened this issue May 4, 2018 · 1 comment
Closed

Nested fragment ScreenSwitcher #12

DomiBlaze opened this issue May 4, 2018 · 1 comment

Comments

@DomiBlaze
Copy link

DomiBlaze commented May 4, 2018

Is it possible to implement nested FragmentScreenSwitcher?
One of my fragments(let's call it HostFragment) has a bottom navigation implemented, and I want to use switchTo to switch betweed child fragments of HostFragment.
Furthermore, I have AnotherHostFragment with different set of fragments.
I want to solve this problem without additional activities, in a single activity app setup.

Thank you in advance

@aartikov
Copy link
Owner

aartikov commented May 5, 2018

You can extend FragmentScreenSwitcher to delegate switching of inner fragments to additional screen switchers. Like that:

public interface ScreenSwitcherProvider {
	ScreenSwitcher getScreenSwitcher();
}
public class MainScreenSwitcher extends FragmentScreenSwitcher {

	// constructors are ommited
	
	@Override
	public void switchTo(Screen screen, @Nullable AnimationData animationData) throws NavigationException {
		if (isInner(screen)) {
			ScreenSwitcher screenSwitcher = ((ScreenSwitcherProvider) getCurrentFragment()).getScreenSwitcher();
			screenSwitcher.switchTo(screen, animationData);
		} else {
			super.switchTo(screen, animationData);
		}
	}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants