Browse Source

Merge pull request #45 from wix/androidBottomTabs

Add support for bottom tabs in Android
Guy Carmeli 8 years ago
parent
commit
753406a028

+ 1
- 0
android/app/build.gradle View File

@@ -35,6 +35,7 @@ repositories {
35 35
 
36 36
 dependencies {
37 37
     compile fileTree(dir: "libs", include: ["*.jar"])
38
+    compile "com.aurelhubert:ahbottomnavigation:1.2.3"
38 39
     compile "com.android.support:appcompat-v7:23.0.1"
39 40
     compile 'com.android.support:design:23.1.1'
40 41
     compile "com.facebook.react:react-native:+"  // From node_modules

+ 1
- 0
android/app/src/main/AndroidManifest.xml View File

@@ -3,6 +3,7 @@
3 3
 
4 4
     <application>
5 5
         <activity android:name="com.reactnativenavigation.activities.TabActivity" />
6
+        <activity android:name="com.reactnativenavigation.activities.BottomTabActivity" />
6 7
         <activity android:name="com.reactnativenavigation.activities.SingleScreenActivity" />
7 8
     </application>
8 9
 

+ 1
- 0
android/app/src/main/java/com/reactnativenavigation/activities/BaseReactActivity.java View File

@@ -135,6 +135,7 @@ public abstract class BaseReactActivity extends AppCompatActivity implements Def
135 135
     @Override
136 136
     protected void onCreate(Bundle savedInstanceState) {
137 137
         super.onCreate(savedInstanceState);
138
+        ContextProvider.setActivityContext(this);
138 139
         mReactInstanceManager = createReactInstanceManager();
139 140
         handleOnCreate();
140 141
     }

+ 182
- 0
android/app/src/main/java/com/reactnativenavigation/activities/BottomTabActivity.java View File

@@ -0,0 +1,182 @@
1
+package com.reactnativenavigation.activities;
2
+
3
+import android.graphics.Color;
4
+import android.graphics.drawable.Drawable;
5
+import android.os.AsyncTask;
6
+import android.os.Bundle;
7
+import android.view.Menu;
8
+import android.widget.FrameLayout;
9
+
10
+import com.aurelhubert.ahbottomnavigation.AHBottomNavigation;
11
+import com.aurelhubert.ahbottomnavigation.AHBottomNavigationItem;
12
+import com.reactnativenavigation.R;
13
+import com.reactnativenavigation.core.RctManager;
14
+import com.reactnativenavigation.core.objects.Screen;
15
+import com.reactnativenavigation.views.RnnToolBar;
16
+import com.reactnativenavigation.views.ScreenStack;
17
+
18
+import java.util.ArrayList;
19
+import java.util.HashMap;
20
+import java.util.Map;
21
+
22
+import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
23
+
24
+/**
25
+ * Created by guyc on 02/04/16.
26
+ */
27
+public class BottomTabActivity extends BaseReactActivity implements AHBottomNavigation.OnTabSelectedListener {
28
+    public static final String EXTRA_SCREENS = "extraScreens";
29
+
30
+    private static final String TAB_STYLE_BUTTON_COLOR = "tabBarButtonColor";
31
+    private static final String TAB_STYLE_SELECTED_COLOR = "tabBarSelectedButtonColor";
32
+    private static final String TAB_STYLE_BAR_BG_COLOR = "tabBarBackgroundColor";
33
+    private static final String TAB_STYLE_INACTIVE_TITLES = "tabShowInactiveTitles";
34
+
35
+    private static int DEFAULT_TAB_BAR_BG_COLOR = 0xFFFFFFFF;
36
+    private static int DEFAULT_TAB_BUTTON_COLOR = Color.GRAY;
37
+    private static int DEFAULT_TAB_SELECTED_COLOR = 0xFF0000FF;
38
+    private static boolean DEFAULT_TAB_INACTIVE_TITLES = true;
39
+
40
+    private AHBottomNavigation mBottomNavigation;
41
+    private FrameLayout mContentFrame;
42
+    private ArrayList<ScreenStack> mScreenStacks;
43
+    private int mCurrentStackPosition = 0;
44
+
45
+    @Override
46
+    protected void handleOnCreate() {
47
+        mReactInstanceManager = RctManager.getInstance().getReactInstanceManager();
48
+
49
+        setContentView(R.layout.bottom_tab_activity);
50
+        mToolbar = (RnnToolBar) findViewById(R.id.toolbar);
51
+        mBottomNavigation = (AHBottomNavigation) findViewById(R.id.bottom_tab_bar);
52
+        mContentFrame = (FrameLayout) findViewById(R.id.contentFrame);
53
+
54
+        ArrayList<Screen> screens = (ArrayList<Screen>) getIntent().getSerializableExtra(EXTRA_SCREENS);
55
+        mBottomNavigation.setForceTint(true);
56
+        setupToolbar(screens);
57
+        setupTabs(getIntent().getExtras());
58
+        setupPages(screens);
59
+    }
60
+
61
+    private void setupPages(ArrayList<Screen> screens) {
62
+        new SetupTabsTask(this, screens).execute();
63
+    }
64
+
65
+    private void setupToolbar(ArrayList<Screen> screens) {
66
+        Screen initialScreen = screens.get(0);
67
+        setNavigationStyle(initialScreen);
68
+        mToolbar.setScreens(screens);
69
+        mToolbar.setTitle(initialScreen.title);
70
+        setSupportActionBar(mToolbar);
71
+    }
72
+
73
+    @Override
74
+    public void setNavigationStyle(Screen screen) {
75
+        super.setNavigationStyle(screen);
76
+        mToolbar.setTitle(screen.title);
77
+    }
78
+
79
+    private void setupTabs(Bundle style) {
80
+
81
+        mBottomNavigation.setForceTitlesDisplay(style.getBoolean(TAB_STYLE_INACTIVE_TITLES, DEFAULT_TAB_INACTIVE_TITLES));
82
+        mBottomNavigation.setForceTint(true);
83
+        mBottomNavigation.setDefaultBackgroundColor(getColor(style, TAB_STYLE_BAR_BG_COLOR, DEFAULT_TAB_BAR_BG_COLOR));
84
+        mBottomNavigation.setInactiveColor(getColor(style, TAB_STYLE_BUTTON_COLOR, DEFAULT_TAB_BUTTON_COLOR));
85
+        mBottomNavigation.setAccentColor(getColor(style, TAB_STYLE_SELECTED_COLOR, DEFAULT_TAB_SELECTED_COLOR));
86
+    }
87
+
88
+    private static int getColor(Bundle bundle, String key, int defaultColor) {
89
+        if (bundle.containsKey(key)) {
90
+            return Color.parseColor(bundle.getString(key));
91
+        }
92
+        else {
93
+            return defaultColor;
94
+        }
95
+    }
96
+
97
+    @Override
98
+    public boolean onCreateOptionsMenu(Menu menu) {
99
+        boolean ret = super.onCreateOptionsMenu(menu);
100
+        mToolbar.handleOnCreateOptionsMenuAsync();
101
+        return ret;
102
+    }
103
+
104
+    @Override
105
+    public void push(Screen screen) {
106
+        super.push(screen);
107
+        mScreenStacks.get(mCurrentStackPosition).push(screen);
108
+    }
109
+
110
+    @Override
111
+    public Screen pop(String navigatorId) {
112
+        super.pop(navigatorId);
113
+        Screen screen = mScreenStacks.get(mCurrentStackPosition).pop();
114
+        setNavigationStyle(screen);
115
+        return screen;
116
+    }
117
+
118
+    @Override
119
+    protected Screen getCurrentScreen() {
120
+        return mScreenStacks.get(mCurrentStackPosition).peek();
121
+    }
122
+
123
+    @Override
124
+    protected String getCurrentNavigatorId() {
125
+        return mScreenStacks.get(mCurrentStackPosition).peek().navigatorId;
126
+    }
127
+
128
+    @Override
129
+    public int getScreenStackSize() {
130
+        return mScreenStacks.get(mCurrentStackPosition).getStackSize();
131
+    }
132
+
133
+    @Override
134
+    public void onTabSelected(int position, boolean wasSelected) {
135
+        if (wasSelected) {
136
+            return;
137
+        }
138
+        mContentFrame.removeAllViews();
139
+        mContentFrame.addView(mScreenStacks.get(position), new FrameLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
140
+        mCurrentStackPosition = position;
141
+        setNavigationStyle(mScreenStacks.get(mCurrentStackPosition).peek());
142
+    }
143
+
144
+    private static class SetupTabsTask extends AsyncTask<Void, Void, Map<Screen, Drawable>> {
145
+        private BottomTabActivity mActivity;
146
+        private ArrayList<Screen> mScreens;
147
+
148
+        public SetupTabsTask(BottomTabActivity context, ArrayList<Screen> screens) {
149
+            mActivity = context;
150
+            mScreens = screens;
151
+        }
152
+
153
+        @Override
154
+        protected Map<Screen, Drawable> doInBackground(Void... params) {
155
+            Map<Screen, Drawable> icons = new HashMap<>();
156
+            for (Screen screen : mScreens) {
157
+                if (screen.icon != null) {
158
+                    icons.put(screen, screen.getIcon(this.mActivity));
159
+                }
160
+            }
161
+            return icons;
162
+        }
163
+
164
+        @Override
165
+        protected void onPostExecute(Map<Screen, Drawable> icons) {
166
+            mActivity.setTabsWithIcons(mScreens, icons);
167
+        }
168
+    }
169
+
170
+    private void setTabsWithIcons(ArrayList<Screen> screens, Map<Screen, Drawable> icons) {
171
+        mScreenStacks = new ArrayList<>();
172
+        for(Screen screen: screens) {
173
+            ScreenStack stack = new ScreenStack(this);
174
+            stack.push(screen);
175
+            mScreenStacks.add(stack);
176
+            AHBottomNavigationItem item = new AHBottomNavigationItem(screen.label, icons.get(screen), Color.GRAY);
177
+            mBottomNavigation.addItem(item);
178
+            mBottomNavigation.setOnTabSelectedListener(this);
179
+        }
180
+        this.onTabSelected(0, false);
181
+    }
182
+}

+ 1
- 0
android/app/src/main/java/com/reactnativenavigation/activities/TabActivity.java View File

@@ -42,6 +42,7 @@ public class TabActivity extends BaseReactActivity {
42 42
         setNavigationStyle(initialScreen);
43 43
         mToolbar.setScreens(screens);
44 44
         mToolbar.setTitle(initialScreen.title);
45
+        mToolbar.setupToolbarButtonsAsync(initialScreen);
45 46
         setSupportActionBar(mToolbar);
46 47
     }
47 48
 

+ 2
- 44
android/app/src/main/java/com/reactnativenavigation/core/objects/Button.java View File

@@ -10,6 +10,7 @@ import android.view.MenuItem;
10 10
 
11 11
 import com.facebook.react.bridge.ReadableMap;
12 12
 import com.reactnativenavigation.BuildConfig;
13
+import com.reactnativenavigation.utils.IconUtils;
13 14
 import com.reactnativenavigation.utils.ResourceDrawableIdHelper;
14 15
 
15 16
 import java.io.Serializable;
@@ -24,13 +25,10 @@ import java.util.concurrent.atomic.AtomicInteger;
24 25
 public class Button extends JsonObject implements Serializable {
25 26
     private static final long serialVersionUID = -570145217281069067L;
26 27
 
27
-    public static final String LOCAL_RESOURCE_URI_SCHEME = "res";
28 28
     private static final String KEY_ID = "id";
29 29
     private static final String KEY_TITLE = "title";
30 30
     private static final String KEY_ICON = "icon";
31 31
 
32
-    private static ResourceDrawableIdHelper sResDrawableIdHelper = new ResourceDrawableIdHelper();
33
-
34 32
     public String id;
35 33
     public String title;
36 34
     private String mIconSource;
@@ -49,47 +47,7 @@ public class Button extends JsonObject implements Serializable {
49 47
     }
50 48
 
51 49
     public Drawable getIcon(Context ctx) {
52
-        if (mIconSource == null) {
53
-            return null;
54
-        }
55
-
56
-        try {
57
-            Drawable icon;
58
-            Uri iconUri = getIconUri(ctx);
59
-
60
-            if (LOCAL_RESOURCE_URI_SCHEME.equals(iconUri.getScheme())) {
61
-                icon = sResDrawableIdHelper.getResourceDrawable(ctx, mIconSource);
62
-            } else {
63
-                URL url = new URL(iconUri.toString());
64
-                Bitmap bitmap = BitmapFactory.decodeStream(url.openStream());
65
-                icon = new BitmapDrawable(bitmap);
66
-            }
67
-            return icon;
68
-        } catch (Exception e) {
69
-            if (BuildConfig.DEBUG) {
70
-                e.printStackTrace();
71
-            }
72
-        }
73
-        return null;
74
-    }
75
-
76
-    private Uri getIconUri(Context context) {
77
-        Uri ret = null;
78
-        if (mIconSource != null) {
79
-            try {
80
-                ret = Uri.parse(mIconSource);
81
-                // Verify scheme is set, so that relative uri (used by static resources) are not handled.
82
-                if (ret.getScheme() == null) {
83
-                    ret = null;
84
-                }
85
-            } catch (Exception e) {
86
-                // Ignore malformed uri, then attempt to extract resource ID.
87
-            }
88
-            if (ret == null) {
89
-                ret = sResDrawableIdHelper.getResourceDrawableUri(context, mIconSource);
90
-            }
91
-        }
92
-        return ret;
50
+       return IconUtils.getIcon(ctx, mIconSource);
93 51
     }
94 52
 
95 53
     public int getItemId() {

+ 10
- 3
android/app/src/main/java/com/reactnativenavigation/core/objects/Screen.java View File

@@ -1,5 +1,7 @@
1 1
 package com.reactnativenavigation.core.objects;
2 2
 
3
+import android.content.Context;
4
+import android.graphics.drawable.Drawable;
3 5
 import android.support.annotation.ColorInt;
4 6
 import android.support.annotation.NonNull;
5 7
 import android.support.annotation.Nullable;
@@ -7,6 +9,7 @@ import android.support.annotation.Nullable;
7 9
 import com.facebook.react.bridge.ReadableArray;
8 10
 import com.facebook.react.bridge.ReadableMap;
9 11
 import com.facebook.react.bridge.ReadableNativeMap;
12
+import com.reactnativenavigation.utils.IconUtils;
10 13
 
11 14
 import java.io.Serializable;
12 15
 import java.util.ArrayList;
@@ -37,7 +40,7 @@ public class Screen extends JsonObject implements Serializable {
37 40
     private static final String KEY_TAB_NORMAL_TEXT_COLOR = "tabNormalTextColor";
38 41
     private static final String KEY_TAB_SELECTED_TEXT_COLOR = "tabSelectedTextColor";
39 42
     private static final String KEY_TAB_INDICATOR_COLOR = "tabIndicatorColor";
40
-    public static final String KEY_PROPS = "passProps";
43
+    private static final String KEY_PROPS = "passProps";
41 44
 
42 45
     public final String title;
43 46
     public final String label;
@@ -45,7 +48,7 @@ public class Screen extends JsonObject implements Serializable {
45 48
     public final String screenInstanceId;
46 49
     public final String navigatorId;
47 50
     public final String navigatorEventId;
48
-    public final int icon;
51
+    public final String icon;
49 52
     public final ArrayList<Button> buttons;
50 53
     public HashMap<String, Object> passedProps = new HashMap<>();
51 54
 
@@ -71,7 +74,7 @@ public class Screen extends JsonObject implements Serializable {
71 74
         screenInstanceId = getString(screen, KEY_SCREEN_INSTANCE_ID);
72 75
         navigatorId = getString(screen, KEY_NAVIGATOR_ID);
73 76
         navigatorEventId = getString(screen, KEY_NAVIGATOR_EVENT_ID);
74
-        icon = getInt(screen, KEY_ICON);
77
+        icon = getString(screen, KEY_ICON);
75 78
         if(screen.hasKey(KEY_PROPS)) {
76 79
             passedProps = ((ReadableNativeMap) screen.getMap(KEY_PROPS)).toHashMap();
77 80
         }
@@ -90,6 +93,10 @@ public class Screen extends JsonObject implements Serializable {
90 93
         return ret;
91 94
     }
92 95
 
96
+    public Drawable getIcon(Context ctx) {
97
+        return IconUtils.getIcon(ctx, icon);
98
+    }
99
+
93 100
     public void setToolbarStyle(ReadableMap screen) {
94 101
         ReadableMap style = getMap(screen, KEY_TOOL_BAR_STYLE);
95 102
         if (style != null) {

+ 9
- 4
android/app/src/main/java/com/reactnativenavigation/modules/RctActivityModule.java View File

@@ -9,12 +9,14 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule;
9 9
 import com.facebook.react.bridge.ReactMethod;
10 10
 import com.facebook.react.bridge.ReadableArray;
11 11
 import com.facebook.react.bridge.ReadableMap;
12
+import com.facebook.react.bridge.ReadableNativeMap;
12 13
 import com.reactnativenavigation.activities.BaseReactActivity;
14
+import com.reactnativenavigation.activities.BottomTabActivity;
13 15
 import com.reactnativenavigation.activities.SingleScreenActivity;
14
-import com.reactnativenavigation.activities.TabActivity;
15 16
 import com.reactnativenavigation.controllers.ModalController;
16 17
 import com.reactnativenavigation.core.objects.Screen;
17 18
 import com.reactnativenavigation.modal.RnnModal;
19
+import com.reactnativenavigation.utils.BridgeUtils;
18 20
 import com.reactnativenavigation.utils.ContextProvider;
19 21
 
20 22
 import java.util.ArrayList;
@@ -35,14 +37,17 @@ public class RctActivityModule extends ReactContextBaseJavaModule {
35 37
     }
36 38
 
37 39
     @ReactMethod
38
-    public void startTabBasedApp(ReadableArray screens) {
40
+    public void startTabBasedApp(ReadableArray screens, ReadableMap style) {
39 41
         Activity context = ContextProvider.getActivityContext();
40 42
         if (context != null && !context.isFinishing()) {
41
-            Intent intent = new Intent(context, TabActivity.class);
43
+            Intent intent = new Intent(context, BottomTabActivity.class);
42 44
             intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
43 45
 
44 46
             Bundle extras = new Bundle();
45
-            extras.putSerializable(TabActivity.EXTRA_SCREENS, createScreens(screens));
47
+            extras.putSerializable(BottomTabActivity.EXTRA_SCREENS, createScreens(screens));
48
+            if (style != null) {
49
+                BridgeUtils.addMapToBundle(((ReadableNativeMap) style).toHashMap(), extras);
50
+            }
46 51
             intent.putExtras(extras);
47 52
             
48 53
             context.startActivity(intent);

+ 65
- 0
android/app/src/main/java/com/reactnativenavigation/utils/IconUtils.java View File

@@ -0,0 +1,65 @@
1
+package com.reactnativenavigation.utils;
2
+
3
+import android.content.Context;
4
+import android.graphics.Bitmap;
5
+import android.graphics.BitmapFactory;
6
+import android.graphics.drawable.BitmapDrawable;
7
+import android.graphics.drawable.Drawable;
8
+import android.net.Uri;
9
+
10
+import com.reactnativenavigation.BuildConfig;
11
+
12
+import java.net.URL;
13
+
14
+/**
15
+ * Created by yedidyak on 29/05/2016.
16
+ */
17
+public class IconUtils {
18
+    public static final String LOCAL_RESOURCE_URI_SCHEME = "res";
19
+    private static ResourceDrawableIdHelper sResDrawableIdHelper = new ResourceDrawableIdHelper();
20
+
21
+    public static Drawable getIcon(Context ctx, String iconSource) {
22
+        if (iconSource == null) {
23
+            return null;
24
+        }
25
+
26
+        try {
27
+            Drawable icon;
28
+            Uri iconUri = getIconUri(ctx, iconSource);
29
+
30
+            if (LOCAL_RESOURCE_URI_SCHEME.equals(iconUri.getScheme())) {
31
+                icon = sResDrawableIdHelper.getResourceDrawable(ctx, iconSource);
32
+            } else {
33
+                URL url = new URL(iconUri.toString());
34
+                Bitmap bitmap = BitmapFactory.decodeStream(url.openStream());
35
+                icon = new BitmapDrawable(bitmap);
36
+            }
37
+            return icon;
38
+        } catch (Exception e) {
39
+            if (BuildConfig.DEBUG) {
40
+                e.printStackTrace();
41
+            }
42
+        }
43
+        return null;
44
+    }
45
+
46
+    private static Uri getIconUri(Context context, String iconSource) {
47
+        Uri ret = null;
48
+        if (iconSource != null) {
49
+            try {
50
+                ret = Uri.parse(iconSource);
51
+                // Verify scheme is set, so that relative uri (used by static resources) are not handled.
52
+                if (ret.getScheme() == null) {
53
+                    ret = null;
54
+                }
55
+            } catch (Exception e) {
56
+                // Ignore malformed uri, then attempt to extract resource ID.
57
+            }
58
+            if (ret == null) {
59
+                ret = sResDrawableIdHelper.getResourceDrawableUri(context, iconSource);
60
+            }
61
+        }
62
+        return ret;
63
+    }
64
+
65
+}

+ 9
- 0
android/app/src/main/java/com/reactnativenavigation/views/RnnToolBar.java View File

@@ -164,6 +164,15 @@ public class RnnToolBar extends Toolbar {
164 164
 
165 165
             Menu menu = ((BaseReactActivity) context).getMenu();
166 166
 
167
+            if (menu == null) {
168
+                RnnToolBar toolBar = mToolbarWR.get();
169
+                if (toolBar != null) {
170
+                    toolBar.mSetupToolbarTask = null;
171
+                }
172
+                mToolbarWR.clear();
173
+                return;
174
+            }
175
+
167 176
             // Remove prev screen buttons
168 177
             for (Button btn : mOldButtons) {
169 178
                 menu.removeItem(btn.getItemId());

+ 33
- 0
android/app/src/main/res/layout/bottom_tab_activity.xml View File

@@ -0,0 +1,33 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
+    xmlns:tools="http://schemas.android.com/tools"
4
+    xmlns:app="http://schemas.android.com/apk/res-auto"
5
+    android:orientation="vertical"
6
+    android:layout_width="match_parent"
7
+    android:layout_height="match_parent"
8
+    tools:context=".activities.TabActivity">
9
+
10
+    <android.support.design.widget.AppBarLayout
11
+        android:id="@+id/appbar"
12
+        android:layout_width="match_parent"
13
+        android:layout_height="wrap_content"
14
+        android:fitsSystemWindows="true">
15
+        <com.reactnativenavigation.views.RnnToolBar
16
+            android:id="@+id/toolbar"
17
+            android:layout_width="match_parent"
18
+            android:layout_height="?attr/actionBarSize"
19
+            app:layout_scrollFlags="scroll|enterAlways"/>
20
+    </android.support.design.widget.AppBarLayout>
21
+
22
+    <FrameLayout
23
+        android:id="@+id/contentFrame"
24
+        android:layout_width="match_parent"
25
+        android:layout_height="0dp"
26
+        android:layout_weight="1"/>
27
+
28
+    <com.aurelhubert.ahbottomnavigation.AHBottomNavigation
29
+        android:id="@+id/bottom_tab_bar"
30
+        android:layout_width="match_parent"
31
+        android:layout_height="wrap_content"/>
32
+
33
+</LinearLayout>

+ 0
- 6
example-redux/src/screens/FirstTabScreen.js View File

@@ -37,12 +37,6 @@ class FirstTabScreen extends Component {
37 37
     ]
38 38
   };
39 39
 
40
-  static propTypes = {
41
-    str: PropTypes.string.isRequired,
42
-    obj: PropTypes.object.isRequired,
43
-    num: PropTypes.number.isRequired
44
-  };
45
-
46 40
   constructor(props) {
47 41
     super(props);
48 42
     // if you want to listen on navigator events, set this up

+ 0
- 6
example-redux/src/screens/SecondTabScreen.js View File

@@ -19,12 +19,6 @@ class SecondTabScreen extends Component {
19 19
     navBarTranslucent: true
20 20
   };
21 21
 
22
-  static propTypes = {
23
-    str: PropTypes.string.isRequired,
24
-    obj: PropTypes.object.isRequired,
25
-    num: PropTypes.number.isRequired
26
-  };
27
-
28 22
   constructor(props) {
29 23
     super(props);
30 24
     this.buttonsCounter = 0;

+ 7
- 1
src/platformSpecific.android.js View File

@@ -35,9 +35,15 @@ function startTabBasedApp(params) {
35 35
     addNavigatorParams(tab, null, idx);
36 36
     addNavigatorButtons(tab);
37 37
     addNavigationStyleParams(tab);
38
+    if (tab.icon) {
39
+      const icon = resolveAssetSource(tab.icon);
40
+      if (icon) {
41
+        tab.icon = icon.uri;
42
+      }
43
+    }
38 44
   });
39 45
 
40
-  RctActivity.startTabBasedApp(params.tabs);
46
+  RctActivity.startTabBasedApp(params.tabs, params.tabsStyle);
41 47
 }
42 48
 
43 49
 function navigatorPush(navigator, params) {