Selaa lähdekoodia

Initial commit for PlatformSpecific.android.js

This class handles all Android specific logic. Currently only startTabBasedApp is implemented,
but in the future all interactions with the UI will go here.
Guy Carmeli 8 vuotta sitten
vanhempi
commit
e7f24f174b
2 muutettua tiedostoa jossa 36 lisäystä ja 4 poistoa
  1. 7
    4
      src/Navigation.js
  2. 29
    0
      src/platformSpecific.android.js

+ 7
- 4
src/Navigation.js Näytä tiedosto

@@ -10,8 +10,11 @@ function registerScreen(screenID, generator) {
10 10
 }
11 11
 
12 12
 function registerComponent(screenID, generator, store = undefined, Provider = undefined) {
13
-  if (store && Provider) return _registerComponentRedux(screenID, generator, store, Provider);
14
-  else return _registerComponentNoRedux(screenID, generator);
13
+  if (store && Provider) {
14
+    return _registerComponentRedux(screenID, generator, store, Provider);
15
+  } else {
16
+    return _registerComponentNoRedux(screenID, generator);
17
+  }
15 18
 }
16 19
 
17 20
 function _registerComponentNoRedux(screenID, generator) {
@@ -26,7 +29,7 @@ function _registerComponentNoRedux(screenID, generator) {
26 29
         );
27 30
       }
28 31
     };
29
-  }
32
+  };
30 33
   registerScreen(screenID, generatorWrapper);
31 34
   return generatorWrapper;
32 35
 }
@@ -45,7 +48,7 @@ function _registerComponentRedux(screenID, generator, store, Provider) {
45 48
         );
46 49
       }
47 50
     };
48
-  }
51
+  };
49 52
   registerScreen(screenID, generatorWrapper);
50 53
   return generatorWrapper;
51 54
 }

+ 29
- 0
src/platformSpecific.android.js Näytä tiedosto

@@ -0,0 +1,29 @@
1
+import Navigation from './Navigation';
2
+
3
+import {
4
+  RctActivity
5
+} from 'react-native-controllers';
6
+
7
+function startSingleScreenApp(params) {
8
+  const screen = params.screen;
9
+  if (!screen.screen) {
10
+    console.error('startSingleScreenApp(params): screen must include a screen property');
11
+    return;
12
+  }
13
+
14
+  console.warn('startSingleScreenApp not implemented yet');
15
+}
16
+
17
+function startTabBasedApp(params) {
18
+  if (!params.tabs) {
19
+    console.error('startTabBasedApp(params): params.tabs is required');
20
+    return;
21
+  }
22
+
23
+  RctActivity.startTabBasedApp(params.tabs);
24
+}
25
+
26
+export default {
27
+  startSingleScreenApp,
28
+  startTabBasedApp
29
+}