ソースを参照

Added styling options for navigation components

Navigation views such as ToolBar, StatusBar, NavigationBar can now be
customized through a static JSON defined in each screen component.

Styling options introduced in this commit:

 - ToolBar color
 - StatusBar color
 - NavigationBar color
 - Buttons tint color
 - Title color
 - Tab normal text color
 - Tab Selected text color
 - Selected tab inidicator color
Guy Carmeli 8 年 前
コミット
eda60276cf

+ 22
- 1
android/app/src/main/java/com/reactnativenavigation/activities/BaseReactActivity.java ファイルの表示

@@ -29,6 +29,7 @@ import com.reactnativenavigation.core.objects.Button;
29 29
 import com.reactnativenavigation.core.objects.Screen;
30 30
 import com.reactnativenavigation.packages.RnnPackage;
31 31
 import com.reactnativenavigation.utils.ContextProvider;
32
+import com.reactnativenavigation.utils.SdkSupports;
32 33
 import com.reactnativenavigation.views.RnnToolBar;
33 34
 
34 35
 import java.util.Arrays;
@@ -169,6 +170,26 @@ public abstract class BaseReactActivity extends AppCompatActivity implements Def
169 170
         setContentView(mReactRootView);
170 171
     }
171 172
 
173
+    public void setNavigationColors(Screen screen) {
174
+        if (screen.toolBarColor != null) {
175
+            mToolbar.setBackgroundColor(screen.toolBarColor);
176
+        }
177
+
178
+        if (screen.titleColor != null) {
179
+            mToolbar.setTitleTextColor(screen.titleColor);
180
+        }
181
+
182
+        if (SdkSupports.lollipop()) {
183
+            if (screen.statusBarColor != null) {
184
+                getWindow().setStatusBarColor(screen.statusBarColor);
185
+            }
186
+
187
+            if (screen.navigationBarColor != null) {
188
+                getWindow().setNavigationBarColor(screen.navigationBarColor);
189
+            }
190
+        }
191
+    }
192
+
172 193
     @Override
173 194
     protected void onResume() {
174 195
         super.onResume();
@@ -209,7 +230,7 @@ public abstract class BaseReactActivity extends AppCompatActivity implements Def
209 230
         if (mToolbar != null &&
210 231
             getCurrentNavigatorId().equals(screen.navigatorId) &&
211 232
             getScreenStackSize() >= 1) {
212
-            mToolbar.showBackButton();
233
+            mToolbar.showBackButton(screen);
213 234
         }
214 235
     }
215 236
 

+ 6
- 6
android/app/src/main/java/com/reactnativenavigation/activities/SingleScreenActivity.java ファイルの表示

@@ -1,11 +1,11 @@
1 1
 package com.reactnativenavigation.activities;
2 2
 
3
-import android.support.v7.widget.Toolbar;
4 3
 import android.widget.FrameLayout;
5 4
 
6 5
 import com.reactnativenavigation.R;
7 6
 import com.reactnativenavigation.core.RctManager;
8 7
 import com.reactnativenavigation.core.objects.Screen;
8
+import com.reactnativenavigation.views.RnnToolBar;
9 9
 import com.reactnativenavigation.views.ScreenStack;
10 10
 
11 11
 /**
@@ -15,7 +15,6 @@ public class SingleScreenActivity extends BaseReactActivity {
15 15
 
16 16
     public static final String EXTRA_SCREEN = "extraScreen";
17 17
 
18
-    private Toolbar mToolbar;
19 18
     private ScreenStack mScreenStack;
20 19
     private String mNavigatorId;
21 20
 
@@ -24,11 +23,11 @@ public class SingleScreenActivity extends BaseReactActivity {
24 23
         mReactInstanceManager = RctManager.getInstance().getReactInstanceManager();
25 24
 
26 25
         setContentView(R.layout.single_screen_activity);
27
-        mToolbar = (Toolbar) findViewById(R.id.toolbar);
26
+        mToolbar = (RnnToolBar) findViewById(R.id.toolbar);
28 27
 
29 28
         Screen screen = (Screen) getIntent().getSerializableExtra(EXTRA_SCREEN);
30 29
         mNavigatorId = screen.navigatorId;
31
-        setupToolbar(screen.title);
30
+        setupToolbar(screen);
32 31
 
33 32
         mScreenStack = new ScreenStack(this);
34 33
         FrameLayout contentFrame = (FrameLayout) findViewById(R.id.contentFrame);
@@ -36,8 +35,9 @@ public class SingleScreenActivity extends BaseReactActivity {
36 35
         mScreenStack.push(screen);
37 36
     }
38 37
 
39
-    private void setupToolbar(String title) {
40
-        mToolbar.setTitle(title);
38
+    protected void setupToolbar(Screen screen) {
39
+        setNavigationColors(screen);
40
+        mToolbar.setTitle(screen.title);
41 41
         setSupportActionBar(mToolbar);
42 42
     }
43 43
     

+ 18
- 1
android/app/src/main/java/com/reactnativenavigation/activities/TabActivity.java ファイルの表示

@@ -38,8 +38,25 @@ public class TabActivity extends BaseReactActivity {
38 38
     }
39 39
 
40 40
     private void setupToolbar(ArrayList<Screen> screens) {
41
-        setSupportActionBar(mToolbar);
41
+        setNavigationColors(screens.get(0));
42 42
         mToolbar.setScreens(screens);
43
+        setSupportActionBar(mToolbar);
44
+    }
45
+
46
+    @Override
47
+    public void setNavigationColors(Screen screen) {
48
+        super.setNavigationColors(screen);
49
+        if (screen.toolBarColor != null) {
50
+            mTabLayout.setBackgroundColor(screen.toolBarColor);
51
+        }
52
+
53
+        if (screen.tabNormalTextColor != null && screen.tabSelectedTextColor != null) {
54
+            mTabLayout.setTabTextColors(screen.tabNormalTextColor, screen.tabSelectedTextColor);
55
+        }
56
+
57
+        if (screen.tabIndicatorColor != null) {
58
+            mTabLayout.setSelectedTabIndicatorColor(screen.tabIndicatorColor);
59
+        }
43 60
     }
44 61
 
45 62
     private void setupViewPager(ArrayList<Screen> screens) {

+ 26
- 4
android/app/src/main/java/com/reactnativenavigation/adapters/ViewPagerAdapter.java ファイルの表示

@@ -21,7 +21,7 @@ import java.util.Map;
21 21
 /**
22 22
  * Created by guyc on 02/04/16.
23 23
  */
24
-public class ViewPagerAdapter extends PagerAdapter implements TabLayout.OnTabSelectedListener {
24
+public class ViewPagerAdapter extends PagerAdapter implements TabLayout.OnTabSelectedListener, ViewPager.OnPageChangeListener {
25 25
 
26 26
     private static final String EVENT_ON_TAB_SELECTED = "OnTabSelected";
27 27
 
@@ -30,7 +30,7 @@ public class ViewPagerAdapter extends PagerAdapter implements TabLayout.OnTabSel
30 30
     private final ArrayList<ScreenStack> mScreenStacks;
31 31
     private final ArrayList<String> mNavigatorIds;
32 32
     private final Map<String, ScreenStack> mStackByNavigatorId;
33
-
33
+    private int mCurrentPage = 0;
34 34
 
35 35
     public ViewPagerAdapter(BaseReactActivity context, ViewPager viewPager, RnnToolBar toolbar,
36 36
                             ArrayList<Screen> screens) {
@@ -50,12 +50,17 @@ public class ViewPagerAdapter extends PagerAdapter implements TabLayout.OnTabSel
50 50
 
51 51
     public void push(Screen screen) {
52 52
         ScreenStack stack = mStackByNavigatorId.get(screen.navigatorId);
53
+        Screen prevScreen = mScreenStacks.get(mCurrentPage).peek();
54
+        mToolbar.setupToolbarButtonsAsync(prevScreen, screen);
53 55
         stack.push(screen);
54 56
     }
55 57
 
56 58
     public Screen pop(String navigatorId) {
57 59
         ScreenStack stack = mStackByNavigatorId.get(navigatorId);
58
-        return stack != null ? stack.pop() : null;
60
+        Screen oldScreen =  stack != null ? stack.pop() : null;
61
+        Screen newScreen = stack.peek();
62
+        mToolbar.setupToolbarButtonsAsync(oldScreen, newScreen);
63
+        return oldScreen;
59 64
     }
60 65
 
61 66
     public Screen peek(String navigatorId) {
@@ -96,7 +101,9 @@ public class ViewPagerAdapter extends PagerAdapter implements TabLayout.OnTabSel
96 101
         int position = tab.getPosition();
97 102
         mViewPager.setCurrentItem(position);
98 103
 
99
-        mToolbar.setupToolbarButtonsAsync(mScreenStacks.get(position).peek());
104
+        Screen prevScreen = mScreenStacks.get(mCurrentPage).peek();
105
+        Screen newScreen = mScreenStacks.get(position).peek();
106
+        mToolbar.setupToolbarButtonsAsync(prevScreen, newScreen);
100 107
 
101 108
         // Send tab selected event
102 109
         WritableMap params = Arguments.createMap();
@@ -121,4 +128,19 @@ public class ViewPagerAdapter extends PagerAdapter implements TabLayout.OnTabSel
121 128
     public int getStackSizeForNavigatorId(String activeNavigatorID) {
122 129
         return mStackByNavigatorId.get(activeNavigatorID).getStackSize();
123 130
     }
131
+
132
+    @Override
133
+    public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
134
+
135
+    }
136
+
137
+    @Override
138
+    public void onPageSelected(int position) {
139
+        mCurrentPage = position;
140
+    }
141
+
142
+    @Override
143
+    public void onPageScrollStateChanged(int state) {
144
+
145
+    }
124 146
 }

+ 2
- 2
android/app/src/main/java/com/reactnativenavigation/core/objects/Button.java ファイルの表示

@@ -35,8 +35,8 @@ public class Button extends JsonObject implements Serializable {
35 35
     public String title;
36 36
     private String mIconSource;
37 37
 
38
-    private static AtomicInteger sAtomicIdGenerator = new AtomicInteger();
39
-    private static Map<String, Integer> sStringToNumericId = new HashMap<>();
38
+    private static final AtomicInteger sAtomicIdGenerator = new AtomicInteger();
39
+    private static final Map<String, Integer> sStringToNumericId = new HashMap<>();
40 40
 
41 41
     public Button(ReadableMap button) {
42 42
         id = getString(button, KEY_ID);

+ 10
- 0
android/app/src/main/java/com/reactnativenavigation/core/objects/JsonObject.java ファイルの表示

@@ -1,5 +1,7 @@
1 1
 package com.reactnativenavigation.core.objects;
2 2
 
3
+import android.graphics.Color;
4
+
3 5
 import com.facebook.react.bridge.ReadableMap;
4 6
 
5 7
 /**
@@ -18,4 +20,12 @@ public class JsonObject {
18 20
     protected int getInt(ReadableMap map, String key) {
19 21
         return map.hasKey(key) ? map.getInt(key) : -1;
20 22
     }
23
+
24
+    protected ReadableMap getMap(ReadableMap map, String key) {
25
+        return map.hasKey(key) ? map.getMap(key) : null;
26
+    }
27
+
28
+    protected Integer getColor(ReadableMap map, String key) {
29
+        return map.hasKey(key) ? Color.parseColor(map.getString(key)) : null;
30
+    }
21 31
 }

+ 49
- 1
android/app/src/main/java/com/reactnativenavigation/core/objects/Screen.java ファイルの表示

@@ -1,10 +1,15 @@
1 1
 package com.reactnativenavigation.core.objects;
2 2
 
3
+import android.support.annotation.ColorInt;
4
+import android.support.annotation.NonNull;
5
+import android.support.annotation.Nullable;
6
+
3 7
 import com.facebook.react.bridge.ReadableArray;
4 8
 import com.facebook.react.bridge.ReadableMap;
5 9
 
6 10
 import java.io.Serializable;
7 11
 import java.util.ArrayList;
12
+import java.util.Collections;
8 13
 import java.util.List;
9 14
 
10 15
 /**
@@ -20,6 +25,15 @@ public class Screen extends JsonObject implements Serializable {
20 25
     public static final String KEY_NAVIGATOR_EVENT_ID = "navigatorEventID";
21 26
     private static final String KEY_ICON = "icon";
22 27
     private static final String KEY_RIGHT_BUTTONS = "rightButtons";
28
+    private static final String KEY_TOOL_BAR_STYLE = "navigatorStyle";
29
+    private static final String KEY_STATUS_BAR_COLOR = "statusBarColor";
30
+    private static final String KEY_TOOL_BAR_COLOR = "toolBarColor";
31
+    private static final String KEY_NAVIGATION_BAR_COLOR = "navigationBarColor";
32
+    private static final String KEY_BUTTONS_TINT_COLOR = "buttonsTint";
33
+    private static final String KEY_TITLE_COLOR = "titleColor";
34
+    private static final String KEY_TAB_NORMAL_TEXT_COLOR = "tabNormalTextColor";
35
+    private static final String KEY_TAB_SELECTED_TEXT_COLOR = "tabSelectedTextColor";
36
+    private static final String KEY_TAB_INDICATOR_COLOR = "tabIndicatorColor";
23 37
 
24 38
     public String title;
25 39
     public String screenId;
@@ -27,7 +41,22 @@ public class Screen extends JsonObject implements Serializable {
27 41
     public String navigatorId;
28 42
     public String navigatorEventId;
29 43
     public int icon;
30
-    public List<Button> buttons;
44
+    public ArrayList<Button> buttons;
45
+
46
+    // Navigation styling
47
+    @Nullable @ColorInt public Integer toolBarColor;
48
+    @Nullable @ColorInt public Integer statusBarColor;
49
+    @Nullable @ColorInt public Integer navigationBarColor;
50
+    @Nullable @ColorInt public Integer buttonsTintColor;
51
+    @Nullable @ColorInt public Integer titleColor;
52
+    @Nullable @ColorInt public Integer tabNormalTextColor;
53
+    @Nullable @ColorInt public Integer tabSelectedTextColor;
54
+    @Nullable @ColorInt public Integer tabIndicatorColor;
55
+
56
+    @NonNull
57
+    public List<Button> getButtons() {
58
+        return buttons == null ? Collections.EMPTY_LIST : buttons;
59
+    }
31 60
 
32 61
     public Screen(ReadableMap screen) {
33 62
         title = getString(screen, KEY_TITLE);
@@ -37,6 +66,11 @@ public class Screen extends JsonObject implements Serializable {
37 66
         navigatorEventId = getString(screen, KEY_NAVIGATOR_EVENT_ID);
38 67
         icon = getInt(screen, KEY_ICON);
39 68
 
69
+        setButtons(screen);
70
+        setToolbarStyle(screen);
71
+    }
72
+
73
+    private void setButtons(ReadableMap screen) {
40 74
         if (screen.hasKey(KEY_RIGHT_BUTTONS)) {
41 75
             buttons = new ArrayList<>();
42 76
             ReadableArray rightButtons = screen.getArray(KEY_RIGHT_BUTTONS);
@@ -45,4 +79,18 @@ public class Screen extends JsonObject implements Serializable {
45 79
             }
46 80
         }
47 81
     }
82
+
83
+    public void setToolbarStyle(ReadableMap screen) {
84
+        ReadableMap style = getMap(screen, KEY_TOOL_BAR_STYLE);
85
+        if (style != null) {
86
+            toolBarColor = getColor(style, KEY_TOOL_BAR_COLOR);
87
+            statusBarColor = getColor(style, KEY_STATUS_BAR_COLOR);
88
+            navigationBarColor = getColor(style, KEY_NAVIGATION_BAR_COLOR);
89
+            buttonsTintColor = getColor(style, KEY_BUTTONS_TINT_COLOR);
90
+            titleColor = getColor(style, KEY_TITLE_COLOR);
91
+            tabNormalTextColor = getColor(style, KEY_TAB_NORMAL_TEXT_COLOR);
92
+            tabSelectedTextColor = getColor(style, KEY_TAB_SELECTED_TEXT_COLOR);
93
+            tabIndicatorColor = getColor(style, KEY_TAB_INDICATOR_COLOR);
94
+        }
95
+    }
48 96
 }

+ 16
- 0
android/app/src/main/java/com/reactnativenavigation/utils/ImageUtils.java ファイルの表示

@@ -0,0 +1,16 @@
1
+package com.reactnativenavigation.utils;
2
+
3
+import android.graphics.PorterDuff;
4
+import android.graphics.PorterDuffColorFilter;
5
+import android.graphics.drawable.Drawable;
6
+
7
+/**
8
+ * Created by guyc on 23/04/16.
9
+ */
10
+public class ImageUtils {
11
+
12
+    public static void tint(Drawable drawable, int tint) {
13
+        drawable.setColorFilter(new PorterDuffColorFilter(tint, PorterDuff.Mode.SRC_IN));
14
+    }
15
+
16
+}

+ 13
- 0
android/app/src/main/java/com/reactnativenavigation/utils/SdkSupports.java ファイルの表示

@@ -0,0 +1,13 @@
1
+package com.reactnativenavigation.utils;
2
+
3
+import android.os.Build;
4
+
5
+/**
6
+ * Created by guyc on 23/04/16.
7
+ */
8
+public class SdkSupports {
9
+
10
+    public static boolean lollipop() {
11
+        return Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;
12
+    }
13
+}

+ 49
- 16
android/app/src/main/java/com/reactnativenavigation/views/RnnToolBar.java ファイルの表示

@@ -1,17 +1,23 @@
1 1
 package com.reactnativenavigation.views;
2 2
 
3
+import android.annotation.SuppressLint;
3 4
 import android.content.Context;
5
+import android.content.res.Resources;
4 6
 import android.graphics.drawable.Drawable;
5 7
 import android.os.AsyncTask;
8
+import android.support.v4.content.res.ResourcesCompat;
9
+import android.support.v7.app.ActionBar;
6 10
 import android.support.v7.widget.Toolbar;
7 11
 import android.util.AttributeSet;
8 12
 import android.view.Menu;
9 13
 import android.view.MenuItem;
10 14
 
15
+import com.reactnativenavigation.R;
11 16
 import com.reactnativenavigation.activities.BaseReactActivity;
12 17
 import com.reactnativenavigation.core.objects.Button;
13 18
 import com.reactnativenavigation.core.objects.Screen;
14 19
 import com.reactnativenavigation.utils.ContextProvider;
20
+import com.reactnativenavigation.utils.ImageUtils;
15 21
 
16 22
 import java.lang.ref.WeakReference;
17 23
 import java.util.Collections;
@@ -44,18 +50,34 @@ public class RnnToolBar extends Toolbar {
44 50
     }
45 51
 
46 52
     public void handleOnCreateOptionsMenuAsync() {
47
-        setupToolbarButtonsAsync(mScreens.get(0));
53
+        setupToolbarButtonsAsync(null, mScreens.get(0));
48 54
     }
49 55
 
50
-    public void setupToolbarButtonsAsync(Screen screen) {
56
+    public void setupToolbarButtonsAsync(Screen oldScreen, Screen newScreen) {
51 57
         if (mSetupToolbarTask == null) {
52
-            mSetupToolbarTask = new SetupToolbarButtonsTask(this, screen).execute();
58
+            mSetupToolbarTask = new SetupToolbarButtonsTask(this, oldScreen, newScreen).execute();
53 59
         }
54 60
     }
55 61
 
56 62
     @SuppressWarnings({"ConstantConditions"})
57
-    public void showBackButton() {
58
-        ContextProvider.getActivityContext().getSupportActionBar().setDisplayHomeAsUpEnabled(true);
63
+    @SuppressLint("PrivateResource")
64
+    public void showBackButton(Screen screen) {
65
+        ActionBar actionBar = ContextProvider.getActivityContext().getSupportActionBar();
66
+
67
+        Resources resources = getResources();
68
+        final Drawable backButton;
69
+        if (screen.buttonsTintColor != null) {
70
+            backButton = ResourcesCompat.getDrawable(resources,
71
+                    R.drawable.abc_ic_ab_back_mtrl_am_alpha,
72
+                    null);
73
+            ImageUtils.tint(backButton, screen.buttonsTintColor);
74
+        } else {
75
+            backButton = ResourcesCompat.getDrawable(resources,
76
+                    R.drawable.abc_ic_ab_back_mtrl_am_alpha,
77
+                    ContextProvider.getActivityContext().getTheme());
78
+        }
79
+        actionBar.setHomeAsUpIndicator(backButton);
80
+        actionBar.setDisplayHomeAsUpEnabled(true);
59 81
     }
60 82
 
61 83
     @SuppressWarnings({"ConstantConditions"})
@@ -64,12 +86,16 @@ public class RnnToolBar extends Toolbar {
64 86
     }
65 87
 
66 88
     private static class SetupToolbarButtonsTask extends AsyncTask<Void, Void, Map<String, Drawable>> {
67
-        private final List<Button> mButtons;
89
+        private final List<Button> mOldButtons;
90
+        private final List<Button> mNewButtons;
68 91
         private final WeakReference<RnnToolBar> mToolbarWR;
92
+        private final Integer mTintColor;
69 93
 
70
-        public SetupToolbarButtonsTask(RnnToolBar toolBar, Screen newScreen) {
94
+        public SetupToolbarButtonsTask(RnnToolBar toolBar, Screen oldScreen, Screen newScreen) {
71 95
             mToolbarWR = new WeakReference<>(toolBar);
72
-            mButtons = newScreen.buttons == null ? Collections.EMPTY_LIST : newScreen.buttons;
96
+            mOldButtons = oldScreen == null ? Collections.EMPTY_LIST : oldScreen.getButtons();
97
+            mNewButtons = newScreen.getButtons();
98
+            mTintColor = newScreen.buttonsTintColor;
73 99
         }
74 100
 
75 101
         @Override
@@ -80,7 +106,7 @@ public class RnnToolBar extends Toolbar {
80 106
             }
81 107
 
82 108
             Map<String, Drawable> icons = new HashMap<>();
83
-            for (Button button : mButtons) {
109
+            for (Button button : mNewButtons) {
84 110
                 if (button.hasIcon()) {
85 111
                     icons.put(button.id, button.getIcon(context));
86 112
                 }
@@ -97,24 +123,31 @@ public class RnnToolBar extends Toolbar {
97 123
 
98 124
             Menu menu = ((BaseReactActivity) context).getMenu();
99 125
 
126
+            // Remove prev screen buttons
127
+            for (Button btn : mOldButtons) {
128
+                menu.removeItem(btn.getItemId());
129
+            }
130
+
100 131
             // Add new screen buttons
101 132
             int i;
102
-            for (i = 0; i < mButtons.size(); i++) {
103
-                Button button = mButtons.get(i);
133
+            for (i = 0; i < mNewButtons.size(); i++) {
134
+                Button button = mNewButtons.get(i);
104 135
                 MenuItem item = menu.add(Menu.NONE, button.getItemId(), i, button.title);
105 136
                 if (icons.containsKey(button.id)) {
106 137
                     Drawable icon = icons.get(button.id);
138
+                    if (mTintColor != null) {
139
+                        ImageUtils.tint(icon, mTintColor);
140
+                    }
107 141
                     item.setIcon(icon).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
108 142
                 }
109 143
             }
110 144
 
111
-            // Remove prev screen buttons
112
-            for (int j = i; j < menu.size(); j++) {
113
-                menu.removeItem(j);
114
-            }
115
-
116 145
             RnnToolBar toolBar = mToolbarWR.get();
117 146
             if (toolBar != null) {
147
+                if (mTintColor != null) {
148
+                    ImageUtils.tint(toolBar.getOverflowIcon(), mTintColor);
149
+                }
150
+
118 151
                 toolBar.mSetupToolbarTask = null;
119 152
                 mToolbarWR.clear();
120 153
             }

+ 1
- 1
android/app/src/main/res/layout/single_screen_activity.xml ファイルの表示

@@ -10,7 +10,7 @@
10 10
         android:layout_width="match_parent"
11 11
         android:layout_height="wrap_content"
12 12
         android:fitsSystemWindows="true">
13
-        <android.support.v7.widget.Toolbar
13
+        <com.reactnativenavigation.views.RnnToolBar
14 14
             android:id="@+id/toolbar"
15 15
             android:layout_width="match_parent"
16 16
             android:layout_height="?attr/actionBarSize"

+ 11
- 0
example-redux/src/screens/FirstTabScreen.js ファイルの表示

@@ -12,6 +12,17 @@ import * as counterActions from '../reducers/counter/actions';
12 12
 
13 13
 // this is a traditional React component connected to the redux store
14 14
 class FirstTabScreen extends Component {
15
+  static navigatorStyle = {
16
+    statusBarColor: '#303F9F',
17
+    toolBarColor: '#3F51B5',
18
+    navigationBarColor: '#303F9F',
19
+    buttonsTint: '#FFFFFF',
20
+    titleColor: '#FFFFFF',
21
+    tabSelectedTextColor: '#FFA000',
22
+    tabNormalTextColor: '#FFC107',
23
+    tabIndicatorColor: '#FFA000'
24
+  };
25
+
15 26
   static navigatorButtons = {
16 27
     rightButtons: [
17 28
       {

+ 12
- 1
example-redux/src/screens/PushedScreen.js ファイルの表示

@@ -12,6 +12,17 @@ import * as counterActions from '../reducers/counter/actions';
12 12
 
13 13
 // this is a traditional React component connected to the redux store
14 14
 class PushedScreen extends Component {
15
+  static navigatorStyle = {
16
+    statusBarColor: '#303F9F',
17
+    toolBarColor: '#3F51B5',
18
+    navigationBarColor: '#303F9F',
19
+    buttonsTint: '#FFFFFF',
20
+    titleColor: '#FFFFFF',
21
+    tabSelectedTextColor: '#FFA000',
22
+    tabNormalTextColor: '#FFC107',
23
+    tabIndicatorColor: '#FF4081'
24
+  };
25
+
15 26
   constructor(props) {
16 27
     super(props);
17 28
     this.bgColor = this.getRandomColor();
@@ -70,7 +81,7 @@ const styles = StyleSheet.create({
70 81
     textAlign: 'center',
71 82
     fontSize: 18,
72 83
     marginBottom: 10,
73
-    marginTop:10,
84
+    marginTop:10
74 85
   },
75 86
   button: {
76 87
     textAlign: 'center',

+ 8
- 0
src/platformSpecific.android.js ファイルの表示

@@ -21,6 +21,7 @@ function startSingleScreenApp(params) {
21 21
 
22 22
   addNavigatorParams(screen);
23 23
   addNavigatorButtons(screen);
24
+  addToolbarStyleParams(screen);
24 25
   RctActivity.startSingleScreenApp(screen);
25 26
 }
26 27
 
@@ -33,6 +34,7 @@ function startTabBasedApp(params) {
33 34
   params.tabs.forEach(function (tab, idx) {
34 35
     addNavigatorParams(tab, null, idx)
35 36
     addNavigatorButtons(tab);
37
+    addToolbarStyleParams(tab);
36 38
   });
37 39
 
38 40
   RctActivity.startTabBasedApp(params.tabs);
@@ -41,6 +43,7 @@ function startTabBasedApp(params) {
41 43
 function navigatorPush(navigator, params) {
42 44
   addNavigatorParams(params, navigator)
43 45
   addNavigatorButtons(params);
46
+  addToolbarStyleParams(params);
44 47
   RctActivity.navigatorPush(params);
45 48
 }
46 49
 
@@ -71,6 +74,11 @@ function addNavigatorButtons(screen) {
71 74
   }
72 75
 }
73 76
 
77
+function addToolbarStyleParams(screen) {
78
+  const Screen = Navigation.getRegisteredScreen(screen.screen);
79
+  screen.navigatorStyle = Screen.navigatorStyle;
80
+}
81
+
74 82
 export default {
75 83
   startSingleScreenApp,
76 84
   startTabBasedApp,