Closed alexwhb closed 3 years ago
There are multiple solutions we either have in this repository, or are currently exploring. One solution we have for sub view controllers is:
public class ScreenAController extends ViewController {
@BindView(R2.id.screen_a_container)
ScreensContainer screensContainer;
private final SubScreenRouter subScreenRouter;
private Subscription subscription;
@Inject
public ScreenAController(final SubScreenRouter subScreenRouter) {
this.subScreenRouter = subScreenRouter;
}
@Override
public void onAttach() {
super.onAttach();
subscription = subScreenRouter
.observeRouteChange()
.observeOn(AndroidSchedulers.mainThread())
.subscribe(onScreenChanged);
subScreenRouter.goTo(new SubScreenA());
}
@Override
public void onDetach() {
super.onDetach();
subscription.unsubscribe();
}
@Override
public int getLayoutId() {
return R.layout.screen_a_view;
}
private Action1<RouteChange> onScreenChanged = new Action1<RouteChange>() {
@Override
public void call(RouteChange routeChange) {
List<Screen> toPath = routeChange.getRoute();
if (!toPath.isEmpty()) {
Screen next = toPath.get(toPath.size() - 1);
}
Keyboard.hideKeyboard(screensContainer);
screensContainer.goTo(routeChange);
}
};
}
This way, you can keep another backstack inside of your screen, similar to a sub view controller.
Thank you for you contribution to this repository.
Closing this contribution as this repository is being archived.
First off thank you guys for building out this framework. From my short experience with it, it's already way more simple than using Fragments/Activities. One thing I've not been able to quite figure out yet is if you can somehow nest screens and give them a different UiContainer, then lose that container when you go to another main screen i.e. scope the sub containers? So instead of switching to a whole new view each time you call router.goTo() you can keep some common elements?
So I have a login form in my app with multiple sub views, each share a common background that should stay fixed, but I'd love to be able to call goTo( new NextScreenName()). Originally I was solving this by having a common Activity and each form view would be it's own fragment. Is this possible with the current framework? Any advice on how to solve this would be greatly appreciated.