Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public Screen pop(String navigatorId) {

protected abstract String getCurrentNavigatorId();

protected abstract Screen getCurrentScreen();
public abstract Screen getCurrentScreen();

public abstract int getScreenStackSize();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ 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);
setNavigationStyle(initialScreen);
}

@Override
Expand Down Expand Up @@ -111,12 +111,12 @@ public void push(Screen screen) {
public Screen pop(String navigatorId) {
super.pop(navigatorId);
Screen screen = mScreenStacks.get(mCurrentStackPosition).pop();
setNavigationStyle(screen);
setNavigationStyle(getCurrentScreen());
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was being called with the screen that was being popped rather than the screen being changed to. Not sure if that was an existing issue or if I've misinterpreted what was going on.

return screen;
}

@Override
protected Screen getCurrentScreen() {
public Screen getCurrentScreen() {
return mScreenStacks.get(mCurrentStackPosition).peek();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ protected void onPause() {
// No need to implement stack interface since this activity is only used to start other
// activities such as TabActivity or SingleScreenActivity.
@Override
protected Screen getCurrentScreen() {
public Screen getCurrentScreen() {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ protected void handleOnCreate() {
}

protected void setupToolbar(Screen screen) {
setNavigationStyle(screen);
mToolbar.setTitle(screen.title);
setSupportActionBar(mToolbar);
setNavigationStyle(screen);
}

@Override
Expand All @@ -52,7 +52,7 @@ public void push(Screen screen) {
public Screen pop(String navigatorId) {
super.pop(navigatorId);
Screen screen = mScreenStack.pop();
setNavigationStyle(screen);
setNavigationStyle(getCurrentScreen());
return screen;
}

Expand All @@ -62,7 +62,7 @@ public String getCurrentNavigatorId() {
}

@Override
protected Screen getCurrentScreen() {
public Screen getCurrentScreen() {
return mScreenStack.peek();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ protected void handleOnCreate() {

private void setupToolbar(ArrayList<Screen> screens) {
Screen initialScreen = screens.get(0);
setNavigationStyle(initialScreen);
mToolbar.setScreens(screens);
mToolbar.setTitle(initialScreen.title);
mToolbar.setupToolbarButtonsAsync(initialScreen);
setSupportActionBar(mToolbar);
setNavigationStyle(initialScreen);
}

@Override
Expand Down Expand Up @@ -77,12 +77,12 @@ public void push(Screen screen) {
public Screen pop(String navigatorId) {
super.pop(navigatorId);
Screen screen = mAdapter.pop(navigatorId);
setNavigationStyle(screen);
setNavigationStyle(getCurrentScreen());
return screen;
}

@Override
protected Screen getCurrentScreen() {
public Screen getCurrentScreen() {
return mAdapter.peek(getCurrentNavigatorId());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,8 @@ protected ReadableMap getMap(ReadableMap map, String key) {
protected Integer getColor(ReadableMap map, String key) {
return map.hasKey(key) ? Color.parseColor(map.getString(key)) : null;
}

protected Boolean getBoolean(ReadableMap map, String key) {
return map.hasKey(key) ? map.getBoolean(key) : null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class Screen extends JsonObject implements Serializable {
private static final String KEY_TOOL_BAR_STYLE = "navigatorStyle";
private static final String KEY_STATUS_BAR_COLOR = "statusBarColor";
private static final String KEY_TOOL_BAR_COLOR = "toolBarColor";
private static final String KEY_TOOL_BAR_HIDDEN = "toolBarHidden";
private static final String KEY_NAVIGATION_BAR_COLOR = "navigationBarColor";
private static final String KEY_BUTTONS_TINT_COLOR = "buttonsTint";
private static final String KEY_TITLE_COLOR = "titleColor";
Expand All @@ -54,6 +55,7 @@ public class Screen extends JsonObject implements Serializable {

// Navigation styling
@Nullable @ColorInt public Integer toolBarColor;
@Nullable public Boolean toolBarHidden;
@Nullable @ColorInt public Integer statusBarColor;
@Nullable @ColorInt public Integer navigationBarColor;
@Nullable @ColorInt public Integer buttonsTintColor;
Expand Down Expand Up @@ -105,6 +107,7 @@ public void setToolbarStyle(ReadableMap screen) {
ReadableMap style = getMap(screen, KEY_TOOL_BAR_STYLE);
if (style != null) {
toolBarColor = getColor(style, KEY_TOOL_BAR_COLOR);
toolBarHidden = getBoolean(style, KEY_TOOL_BAR_HIDDEN);
statusBarColor = getColor(style, KEY_STATUS_BAR_COLOR);
navigationBarColor = getColor(style, KEY_NAVIGATION_BAR_COLOR);
buttonsTintColor = getColor(style, KEY_BUTTONS_TINT_COLOR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,35 @@ public class RnnModal extends Dialog implements DialogInterface.OnDismissListene

private ScreenStack mScreenStack;
private View mContentView;
private Screen mOriginalScreen;
private Screen mScreen;
private RnnToolBar mToolBar;
private BaseReactActivity mContext;

public RnnModal(BaseReactActivity context, Screen screen) {
super(context, R.style.Modal);
mScreen = screen;
mOriginalScreen = context.getCurrentScreen();
mContext = context;
ModalController.getInstance().add(this);
init(context);
}

private void updateToolbar(Screen screen) {
mToolBar.setTitle(screen.title);
mContext.setSupportActionBar(mToolBar);
mToolBar.setStyle(screen);
mToolBar.setupToolbarButtonsAsync(screen);
}

@SuppressLint("InflateParams")
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);
updateToolbar(mScreen);
mScreenStack.push(mScreen, new RctView.OnDisplayedListener() {
@Override
public void onDisplayed() {
Expand Down Expand Up @@ -87,4 +96,17 @@ public void onBackPressed() {
public void onDismiss(DialogInterface dialog) {
ModalController.getInstance().remove();
}

@Override
public void dismiss(){
super.dismiss();
if (mContext != null && !mContext.isFinishing()) {
mContext.runOnUiThread(new Runnable() {
@Override
public void run() {
updateToolbar(mOriginalScreen);
Copy link
Copy Markdown
Contributor Author

@MattDavies MattDavies Jun 2, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed to restore the original toolbar style as it was before the modal was raised.

}
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ public void setStyle(Screen screen) {
} else {
resetTitleTextColor();
}

if (screen.toolBarHidden != null && screen.toolBarHidden) {
hideToolbar();
} else {
showToolbar();
}
}

private void resetBackground() {
Expand All @@ -95,6 +101,20 @@ public void setupToolbarButtonsAsync(Screen oldScreen, Screen newScreen) {
}
}

public void showToolbar() {
ActionBar actionBar = ContextProvider.getActivityContext().getSupportActionBar();
if (actionBar != null) {
actionBar.show();
}
}

public void hideToolbar() {
ActionBar actionBar = ContextProvider.getActivityContext().getSupportActionBar();
if (actionBar != null) {
actionBar.hide();
}
}

@SuppressWarnings({"ConstantConditions"})
public void showBackButton(Screen screen) {
ActionBar actionBar = ContextProvider.getActivityContext().getSupportActionBar();
Expand Down