-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Add support for hiding the Toolbar on Android #52
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,10 +64,9 @@ private void setupPages(ArrayList<Screen> screens) { | |
|
|
||
| private void setupToolbar(ArrayList<Screen> screens) { | ||
| Screen initialScreen = screens.get(0); | ||
| setNavigationStyle(initialScreen); | ||
| mToolbar.setScreens(screens); | ||
| mToolbar.setTitle(initialScreen.title); | ||
| setSupportActionBar(mToolbar); | ||
| mToolbar.updateToolbar(initialScreen); | ||
| setNavigationStyle(initialScreen); | ||
| } | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This had to be at the bottom to ensure the action bar was set before applying styles (else you can't show/hide). |
||
|
|
||
| @Override | ||
|
|
@@ -104,14 +103,15 @@ public boolean onCreateOptionsMenu(Menu menu) { | |
| @Override | ||
| public void push(Screen screen) { | ||
| super.push(screen); | ||
| setNavigationStyle(screen); | ||
| mScreenStacks.get(mCurrentStackPosition).push(screen); | ||
| } | ||
|
|
||
| @Override | ||
| public Screen pop(String navigatorId) { | ||
| super.pop(navigatorId); | ||
| Screen screen = mScreenStacks.get(mCurrentStackPosition).pop(); | ||
| setNavigationStyle(screen); | ||
| setNavigationStyle(getCurrentScreen()); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When popping it was applying the style of the screen that had just been popped rather than the new screen. |
||
| return screen; | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,6 +29,7 @@ public class RnnModal extends Dialog implements DialogInterface.OnDismissListene | |
| private ScreenStack mScreenStack; | ||
| private View mContentView; | ||
| private Screen mScreen; | ||
| private RnnToolBar mToolBar; | ||
|
|
||
| public RnnModal(BaseReactActivity context, Screen screen) { | ||
| super(context, R.style.Modal); | ||
|
|
@@ -41,13 +42,10 @@ public RnnModal(BaseReactActivity context, Screen screen) { | |
| private void init(final Context context) { | ||
| requestWindowFeature(Window.FEATURE_NO_TITLE); | ||
| mContentView = LayoutInflater.from(context).inflate(R.layout.modal_layout, null, false); | ||
| RnnToolBar toolBar = (RnnToolBar) mContentView.findViewById(R.id.toolbar); | ||
| mToolBar = (RnnToolBar) mContentView.findViewById(R.id.toolbar); | ||
| mScreenStack = (ScreenStack) mContentView.findViewById(R.id.screenStack); | ||
|
|
||
| setContentView(mContentView); | ||
| toolBar.setStyle(mScreen); | ||
| toolBar.setTitle(mScreen.title); | ||
| toolBar.setupToolbarButtonsAsync(mScreen); | ||
| mToolBar.updateToolbar(mScreen); | ||
| mScreenStack.push(mScreen, new RctView.OnDisplayedListener() { | ||
| @Override | ||
| public void onDisplayed() { | ||
|
|
@@ -67,10 +65,17 @@ public void onDisplayed() { | |
|
|
||
| public void push(Screen screen) { | ||
| mScreenStack.push(screen); | ||
| mToolBar.updateToolbar(mScreen); | ||
| } | ||
|
|
||
| public Screen pop() { | ||
| return mScreenStack.pop(); | ||
| if (mScreenStack.getStackSize() > 1) { | ||
| return mScreenStack.pop(); | ||
| } else { | ||
| ModalController.getInstance().remove(); | ||
| super.onBackPressed(); | ||
| return null; | ||
| } | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When pop was called on the only remaining screen on a modal it didn't appear to be clearing the modal out properly. |
||
| } | ||
|
|
||
| @Override | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still sets window styles so I left it there even though there's now a slight duplication. Lets look at that in another PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, we'll address that in a separate PR. I'll merge soon. Thanks for the contribution Matt 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Welcome! Great library, it's making a huge difference to some of my apps compared to the official nav. I'll keep jumping in where I can to fill gaps.