Browse Source

Throw exception when tab is missing an icon on Android

Guy Carmeli 8 years ago
parent
commit
1bc6eeab40
1 changed files with 14 additions and 6 deletions
  1. 14
    6
      src/platformSpecific.android.js

+ 14
- 6
src/platformSpecific.android.js View File

33
     addNavigatorParams(tab, null, idx);
33
     addNavigatorParams(tab, null, idx);
34
     addNavigatorButtons(tab);
34
     addNavigatorButtons(tab);
35
     addNavigationStyleParams(tab);
35
     addNavigationStyleParams(tab);
36
-    if (tab.icon) {
37
-      const icon = resolveAssetSource(tab.icon);
38
-      if (icon) {
39
-        tab.icon = icon.uri;
40
-      }
41
-    }
36
+    addTabIcon(tab);
42
     tab.passProps = params.passProps;
37
     tab.passProps = params.passProps;
43
   });
38
   });
44
 
39
 
46
   RctActivity.startTabBasedApp(params.tabs, params.tabsStyle, drawer);
41
   RctActivity.startTabBasedApp(params.tabs, params.tabsStyle, drawer);
47
 }
42
 }
48
 
43
 
44
+function addTabIcon(tab) {
45
+  if (tab.icon) {
46
+    const icon = resolveAssetSource(tab.icon);
47
+    if (icon) {
48
+      tab.icon = icon.uri;
49
+    }
50
+  }
51
+
52
+  if (!tab.icon) {
53
+    throw new Error("No icon defined for tab " + tab.screen);
54
+  }
55
+}
56
+
49
 function navigatorPush(navigator, params) {
57
 function navigatorPush(navigator, params) {
50
   addNavigatorParams(params, navigator);
58
   addNavigatorParams(params, navigator);
51
   addNavigatorButtons(params);
59
   addNavigatorButtons(params);