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 @@ -46,14 +46,13 @@ public class BottomTabActivity extends BaseReactActivity implements AHBottomNavi
protected void handleOnCreate() {
mReactInstanceManager = RctManager.getInstance().getReactInstanceManager();

setContentView(R.layout.bottom_tab_activity);
mToolbar = (RnnToolBar) findViewById(R.id.toolbar);
ArrayList<Screen> screens = (ArrayList<Screen>) getIntent().getSerializableExtra(EXTRA_SCREENS);
showHideToolbar(screens);

mBottomNavigation = (AHBottomNavigation) findViewById(R.id.bottom_tab_bar);
mContentFrame = (FrameLayout) findViewById(R.id.contentFrame);

ArrayList<Screen> screens = (ArrayList<Screen>) getIntent().getSerializableExtra(EXTRA_SCREENS);
mBottomNavigation.setForceTint(true);
setupToolbar(screens);
setupTabs(getIntent().getExtras());
setupPages(screens);
}
Expand All @@ -70,10 +69,23 @@ private void setupToolbar(ArrayList<Screen> screens) {
setSupportActionBar(mToolbar);
}

private void showHideToolbar(ArrayList<Screen> screens) {
Screen initialScreen = screens.get(0);
if (initialScreen.toolBarHidden != null && initialScreen.toolBarHidden) {
setContentView(R.layout.bottom_tab_activity_without_toolbar);
} else {
setContentView(R.layout.bottom_tab_activity);
mToolbar = (RnnToolBar) findViewById(R.id.toolbar);
setupToolbar(screens);
}
}

@Override
public void setNavigationStyle(Screen screen) {
super.setNavigationStyle(screen);
mToolbar.setTitle(screen.title);
if (mToolbar != null) {
mToolbar.setTitle(screen.title);
}
}

private void setupTabs(Bundle style) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,17 @@ public class SingleScreenActivity extends BaseReactActivity {
protected void handleOnCreate() {
mReactInstanceManager = RctManager.getInstance().getReactInstanceManager();

setContentView(R.layout.single_screen_activity);
mToolbar = (RnnToolBar) findViewById(R.id.toolbar);

Screen screen = (Screen) getIntent().getSerializableExtra(EXTRA_SCREEN);
mNavigatorId = screen.navigatorId;
setupToolbar(screen);


if (screen.toolBarHidden != null && screen.toolBarHidden) {
setContentView(R.layout.single_screen_activity_without_toolbar);
} else {
setContentView(R.layout.single_screen_activity);
mToolbar = (RnnToolBar) findViewById(R.id.toolbar);
setupToolbar(screen);
}

mScreenStack = new ScreenStack(this);
FrameLayout contentFrame = (FrameLayout) findViewById(R.id.contentFrame);
contentFrame.addView(mScreenStack);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,16 @@ public class TabActivity extends BaseReactActivity {
protected void handleOnCreate() {
mReactInstanceManager = RctManager.getInstance().getReactInstanceManager();

setContentView(R.layout.tab_activity);
mToolbar = (RnnToolBar) findViewById(R.id.toolbar);
ArrayList<Screen> screens = (ArrayList<Screen>) getIntent().getSerializableExtra(EXTRA_SCREENS);
Screen initialScreen = screens.get(0);
showHideToolbar(initialScreen);

mTabLayout = (RnnTabLayout) findViewById(R.id.tabLayout);
mViewPager = (ViewPager) findViewById(R.id.viewPager);

ArrayList<Screen> screens = (ArrayList<Screen>) getIntent().getSerializableExtra(EXTRA_SCREENS);

setupToolbar(screens);
setupViewPager(screens);
}

private void setupToolbar(ArrayList<Screen> screens) {
Screen initialScreen = screens.get(0);
setNavigationStyle(initialScreen);
Expand All @@ -46,6 +45,17 @@ private void setupToolbar(ArrayList<Screen> screens) {
setSupportActionBar(mToolbar);
}

private void showHideToolbar(Screen screen) {
if (screen.toolBarHidden != null && screen.toolBarHidden) {
setContentView(R.layout.bottom_tab_activity_without_toolbar);
} else {
ArrayList<Screen> screens = (ArrayList<Screen>) getIntent().getSerializableExtra(EXTRA_SCREENS);
setContentView(R.layout.bottom_tab_activity);
mToolbar = (RnnToolBar) findViewById(R.id.toolbar);
setupToolbar(screens);
}
}

@Override
public void setNavigationStyle(Screen screen) {
super.setNavigationStyle(screen);
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 @@ -40,14 +40,20 @@ public RnnModal(BaseReactActivity context, Screen 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);

if (mScreen.toolBarHidden != null && mScreen.toolBarHidden) {
mContentView = LayoutInflater.from(context).inflate(R.layout.modal_layout_without_toolbar, null, false);
} else {
mContentView = LayoutInflater.from(context).inflate(R.layout.modal_layout, null, false);

RnnToolBar toolBar = (RnnToolBar) mContentView.findViewById(R.id.toolbar);
toolBar.setStyle(mScreen);
toolBar.setTitle(mScreen.title);
toolBar.setupToolbarButtonsAsync(mScreen);
}

mScreenStack = (ScreenStack) mContentView.findViewById(R.id.screenStack);

setContentView(mContentView);
toolBar.setStyle(mScreen);
toolBar.setTitle(mScreen.title);
toolBar.setupToolbarButtonsAsync(mScreen);
mScreenStack.push(mScreen, new RctView.OnDisplayedListener() {
@Override
public void onDisplayed() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activities.TabActivity">

<FrameLayout
android:id="@+id/contentFrame"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>

<com.aurelhubert.ahbottomnavigation.AHBottomNavigation
android:id="@+id/bottom_tab_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

</LinearLayout>
13 changes: 13 additions & 0 deletions android/app/src/main/res/layout/modal_layout_without_toolbar.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@android:color/transparent"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">

<com.reactnativenavigation.views.ScreenStack
android:id="@+id/screenStack"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">

<FrameLayout
android:id="@+id/contentFrame"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
15 changes: 15 additions & 0 deletions android/app/src/main/res/layout/tab_activity_without_toolbar.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activities.TabActivity">

<android.support.v4.view.ViewPager
android:id="@+id/viewPager"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>