Browse Source

api migration

Daniel Zlotin 7 years ago
parent
commit
bbca8e07dc

+ 2
- 2
lib/ios/RNNLayoutNode.m View File

15
 
15
 
16
 -(BOOL)isContainer
16
 -(BOOL)isContainer
17
 {
17
 {
18
-	return [self.type isEqualToString:@"Container"];
18
+	return [self.type isEqualToString:@"Component"];
19
 }
19
 }
20
 -(BOOL)isContainerStack
20
 -(BOOL)isContainerStack
21
 {
21
 {
22
-	return [self.type isEqualToString:@"ContainerStack"];
22
+	return [self.type isEqualToString:@"Stack"];
23
 }
23
 }
24
 -(BOOL)isTabs
24
 -(BOOL)isTabs
25
 {
25
 {

+ 1
- 1
lib/ios/RNNRootViewController.m View File

45
 }
45
 }
46
 
46
 
47
 -(BOOL)isCustomTransitioned {
47
 -(BOOL)isCustomTransitioned {
48
-	return self.animator;
48
+	return self.animator != nil;
49
 }
49
 }
50
 
50
 
51
 - (BOOL)prefersStatusBarHidden {
51
 - (BOOL)prefersStatusBarHidden {

+ 8
- 8
lib/src/Navigation.js View File

9
 const PrivateEventsListener = require('./events/PrivateEventsListener');
9
 const PrivateEventsListener = require('./events/PrivateEventsListener');
10
 const PublicEventsRegistry = require('./events/PublicEventsRegistry');
10
 const PublicEventsRegistry = require('./events/PublicEventsRegistry');
11
 const Element = require('./adapters/Element');
11
 const Element = require('./adapters/Element');
12
-const Root = require('./params/containers/Root');
13
-const Container = require('./params/containers/Container');
14
-const NavigationOptions = require('./params/options/NavigationOptions');
12
+// const Root = require('./params/containers/Root');
13
+// const Container = require('./params/containers/Container');
14
+// const Options = require('./params/options/Options');
15
 
15
 
16
 /** @constructor */
16
 /** @constructor */
17
 class Navigation {
17
 class Navigation {
44
    * @param {Root} root
44
    * @param {Root} root
45
    */
45
    */
46
   setRoot(params) {
46
   setRoot(params) {
47
-    return this.commands.setRoot(new Root(params));
47
+    return this.commands.setRoot(params);
48
   }
48
   }
49
 
49
 
50
   /**
50
   /**
51
    * Set default options to all screens. Useful for declaring a consistent style across the app.
51
    * Set default options to all screens. Useful for declaring a consistent style across the app.
52
-   * @param {options:NavigationOptions} options
52
+   * @param {options:Options} options
53
    */
53
    */
54
   setDefaultOptions(options) {
54
   setDefaultOptions(options) {
55
     this.commands.setDefaultOptions(options);
55
     this.commands.setDefaultOptions(options);
58
   /**
58
   /**
59
    * Change a containers navigation options
59
    * Change a containers navigation options
60
    * @param {string} containerId The container's id.
60
    * @param {string} containerId The container's id.
61
-   * @param {options:NavigationOptions} options
61
+   * @param {options:Options} options
62
    */
62
    */
63
   setOptions(containerId, options) {
63
   setOptions(containerId, options) {
64
-    this.commands.setOptions(containerId, new NavigationOptions(options));
64
+    this.commands.setOptions(containerId, options);
65
   }
65
   }
66
 
66
 
67
   /**
67
   /**
93
    * @param {Container} container
93
    * @param {Container} container
94
    */
94
    */
95
   push(containerId, container) {
95
   push(containerId, container) {
96
-    return this.commands.push(containerId, new Container(container));
96
+    return this.commands.push(containerId, container);
97
   }
97
   }
98
 
98
 
99
   /**
99
   /**

+ 3
- 5
lib/src/commands/OptionsProcessor.test.js View File

1
 const OptionsProcessor = require('./OptionsProcessor');
1
 const OptionsProcessor = require('./OptionsProcessor');
2
-const Options = require('./../params/options/Options');
3
 
2
 
4
 describe('navigation options', () => {
3
 describe('navigation options', () => {
5
   let options;
4
   let options;
93
     expect(options.topBar.myOtherValue).toEqual('value');
92
     expect(options.topBar.myOtherValue).toEqual('value');
94
   });
93
   });
95
 
94
 
96
-  it('processes NavigationOptions jsDoc object', () => {
95
+  it('processes Options object', () => {
97
     options.someKeyColor = 'rgb(255, 0, 255)';
96
     options.someKeyColor = 'rgb(255, 0, 255)';
98
     options.topBar = { textColor: 'red' };
97
     options.topBar = { textColor: 'red' };
99
     options.topBar.innerMostObj = { anotherColor: 'yellow' };
98
     options.topBar.innerMostObj = { anotherColor: 'yellow' };
100
-    const optionsObj = new Options(options);
101
 
99
 
102
-    OptionsProcessor.processOptions(optionsObj);
100
+    OptionsProcessor.processOptions({ o: options });
103
 
101
 
104
-    expect(optionsObj.topBar.textColor).toEqual(0xffff0000);
102
+    expect(options.topBar.textColor).toEqual(0xffff0000);
105
   });
103
   });
106
 
104
 
107
   it('undefined value return undefined ', () => {
105
   it('undefined value return undefined ', () => {

lib/src/params/containers/Container.js → lib/src/xparams/containers/Container.js View File


lib/src/params/containers/Container.test.js → lib/src/xparams/containers/Container.test.js View File


lib/src/params/containers/Root.js → lib/src/xparams/containers/Root.js View File


lib/src/params/containers/Root.test.js → lib/src/xparams/containers/Root.test.js View File


lib/src/params/containers/SideMenu.js → lib/src/xparams/containers/SideMenu.js View File


lib/src/params/containers/SideMenu.test.js → lib/src/xparams/containers/SideMenu.test.js View File


lib/src/params/options/BottomTab.js → lib/src/xparams/options/BottomTab.js View File


lib/src/params/options/BottomTab.test.js → lib/src/xparams/options/BottomTab.test.js View File


lib/src/params/options/BottomTabs.js → lib/src/xparams/options/BottomTabs.js View File


lib/src/params/options/BottomTabs.test.js → lib/src/xparams/options/BottomTabs.test.js View File


lib/src/params/options/Button.js → lib/src/xparams/options/Button.js View File


lib/src/params/options/Button.test.js → lib/src/xparams/options/Button.test.js View File


lib/src/params/options/Options.js → lib/src/xparams/options/Options.js View File

3
 const BottomTab = require('./BottomTab');
3
 const BottomTab = require('./BottomTab');
4
 const TopTabs = require('./TopTabs');
4
 const TopTabs = require('./TopTabs');
5
 
5
 
6
-class NavigationOptions {
6
+class Options {
7
   /**
7
   /**
8
    * @property {options:TopBar} [topBar]
8
    * @property {options:TopBar} [topBar]
9
    * @property {options:BottomTabs} [bottomTabs]
9
    * @property {options:BottomTabs} [bottomTabs]
24
   }
24
   }
25
 }
25
 }
26
 
26
 
27
-module.exports = NavigationOptions;
27
+module.exports = Options;

lib/src/params/options/Options.test.js → lib/src/xparams/options/Options.test.js View File

1
-const NavigationOptions = require('./Options');
1
+const Options = require('./Options');
2
 const BottomTabs = require('./BottomTabs');
2
 const BottomTabs = require('./BottomTabs');
3
 const TopBar = require('./TopBar');
3
 const TopBar = require('./TopBar');
4
 const BottomTab = require('./BottomTab');
4
 const BottomTab = require('./BottomTab');
19
   topTabs: TOP_TABS
19
   topTabs: TOP_TABS
20
 };
20
 };
21
 
21
 
22
-describe('NavigationOptions', () => {
22
+describe('Options', () => {
23
   it('parses options correctly', () => {
23
   it('parses options correctly', () => {
24
-    const uut = new NavigationOptions(NAVIGATION_OPTIONS);
24
+    const uut = new Options(NAVIGATION_OPTIONS);
25
     expect(uut.bottomTabs).toBeInstanceOf(BottomTabs);
25
     expect(uut.bottomTabs).toBeInstanceOf(BottomTabs);
26
     expect(uut.topBar).toBeInstanceOf(TopBar);
26
     expect(uut.topBar).toBeInstanceOf(TopBar);
27
     expect(uut.bottomTab).toBeInstanceOf(BottomTab);
27
     expect(uut.bottomTab).toBeInstanceOf(BottomTab);

lib/src/params/options/TopBar.js → lib/src/xparams/options/TopBar.js View File


lib/src/params/options/TopBar.test.js → lib/src/xparams/options/TopBar.test.js View File


lib/src/params/options/TopTab.js → lib/src/xparams/options/TopTab.js View File


lib/src/params/options/TopTab.test.js → lib/src/xparams/options/TopTab.test.js View File


lib/src/params/options/TopTabs.js → lib/src/xparams/options/TopTabs.js View File


lib/src/params/options/TopTabs.test.js → lib/src/xparams/options/TopTabs.test.js View File


+ 8
- 2
playground/src/app.js View File

5
   registerContainers();
5
   registerContainers();
6
   Navigation.events().onAppLaunched(() => {
6
   Navigation.events().onAppLaunched(() => {
7
     Navigation.setRoot({
7
     Navigation.setRoot({
8
-      container: {
9
-        name: 'navigation.playground.WelcomeScreen'
8
+      stack: {
9
+        children: [
10
+          {
11
+            component: {
12
+              name: 'navigation.playground.WelcomeScreen'
13
+            }
14
+          }
15
+        ]
10
       }
16
       }
11
     });
17
     });
12
   });
18
   });

+ 14
- 10
playground/src/containers/CustomTransitionDestination.js View File

22
   }
22
   }
23
   push() {
23
   push() {
24
     Navigation.push(this.props.containerId, {
24
     Navigation.push(this.props.containerId, {
25
-      name: 'navigation.playground.OptionsScreen'
25
+      component: {
26
+        name: 'navigation.playground.OptionsScreen'
27
+      }
26
     });
28
     });
27
   }
29
   }
28
   pop() {
30
   pop() {
29
-    Navigation.pop(this.props.containerId, { customTransition: {
30
-      animations: [{ type: 'sharedElement', fromId: 'title2', toId: 'title1', startDelay: 0, springVelocity: 0.2, duration: 0.5 },
31
-            { type: 'sharedElement', toId: 'image1', fromId: 'customDestinationImage', startDelay: 0, springVelocity: 0.2, duration: 0.5 },
32
-            { type: 'sharedElement', toId: 'image2', fromId: 'customDestinationImage2', startDelay: 0, duration: 0.8 },
33
-            { fromId: 'image4', startY: 50, startX: 50, startAlpha: 0, startDelay: 0, duration: 0.8, springVelocity: 0.5 },
34
-            { fromId: 'customDestinationParagraph', endY: 50, endX: 50, endAlpha: 0, startAlpha: 1, startDelay: 0, duration: 0.8 }
35
-      ],
36
-      duration: 0.8
37
-    } });
31
+    Navigation.pop(this.props.containerId, {
32
+      customTransition: {
33
+        animations: [{ type: 'sharedElement', fromId: 'title2', toId: 'title1', startDelay: 0, springVelocity: 0.2, duration: 0.5 },
34
+        { type: 'sharedElement', toId: 'image1', fromId: 'customDestinationImage', startDelay: 0, springVelocity: 0.2, duration: 0.5 },
35
+        { type: 'sharedElement', toId: 'image2', fromId: 'customDestinationImage2', startDelay: 0, duration: 0.8 },
36
+        { fromId: 'image4', startY: 50, startX: 50, startAlpha: 0, startDelay: 0, duration: 0.8, springVelocity: 0.5 },
37
+        { fromId: 'customDestinationParagraph', endY: 50, endX: 50, endAlpha: 0, startAlpha: 1, startDelay: 0, duration: 0.8 }
38
+        ],
39
+        duration: 0.8
40
+      }
41
+    });
38
   }
42
   }
39
   render() {
43
   render() {
40
     return (
44
     return (

+ 12
- 10
playground/src/containers/CustomTransitionOrigin.js View File

52
   }
52
   }
53
   onClickNavigationIcon() {
53
   onClickNavigationIcon() {
54
     Navigation.push(this.props.containerId, {
54
     Navigation.push(this.props.containerId, {
55
-      name: 'navigation.playground.CustomTransitionDestination',
56
-      customTransition: {
57
-        animations: [
58
-              { type: 'sharedElement', fromId: 'title1', toId: 'title2', startDelay: 0, springVelocity: 0.2, duration: 0.5 },
59
-              { type: 'sharedElement', fromId: 'image1', toId: 'customDestinationImage', startDelay: 0, springVelocity: 0.9, springDamping: 0.9, duration: 0.8, interactivePop: true },
60
-              { type: 'sharedElement', fromId: 'image2', toId: 'customDestinationImage2', startDelay: 0, duration: 0.8 },
61
-              { fromId: 'image4', endY: 50, endX: 50, endAlpha: 0, startDelay: 0, duration: 0.8, springVelocity: 0.5 },
62
-              { fromId: 'customDestinationParagraph', startY: 50, startAlpha: 0, endAlpha: 1, startDelay: 0, duration: 0.8 }
55
+      component: {
56
+        name: 'navigation.playground.CustomTransitionDestination',
57
+        customTransition: {
58
+          animations: [
59
+            { type: 'sharedElement', fromId: 'title1', toId: 'title2', startDelay: 0, springVelocity: 0.2, duration: 0.5 },
60
+            { type: 'sharedElement', fromId: 'image1', toId: 'customDestinationImage', startDelay: 0, springVelocity: 0.9, springDamping: 0.9, duration: 0.8, interactivePop: true },
61
+            { type: 'sharedElement', fromId: 'image2', toId: 'customDestinationImage2', startDelay: 0, duration: 0.8 },
62
+            { fromId: 'image4', endY: 50, endX: 50, endAlpha: 0, startDelay: 0, duration: 0.8, springVelocity: 0.5 },
63
+            { fromId: 'customDestinationParagraph', startY: 50, startAlpha: 0, endAlpha: 1, startDelay: 0, duration: 0.8 }
63
 
64
 
64
-        ],
65
-        duration: 0.8
65
+          ],
66
+          duration: 0.8
67
+        }
66
       }
68
       }
67
     });
69
     });
68
   }
70
   }

+ 1
- 1
playground/src/containers/LifecycleScreen.js View File

61
   }
61
   }
62
 
62
 
63
   onClickPush() {
63
   onClickPush() {
64
-    Navigation.push(this.props.containerId, { name: 'navigation.playground.TextScreen' });
64
+    Navigation.push(this.props.containerId, { component: { name: 'navigation.playground.TextScreen' } });
65
   }
65
   }
66
 }
66
 }
67
 module.exports = LifecycleScreen;
67
 module.exports = LifecycleScreen;

+ 6
- 2
playground/src/containers/OptionsScreen.js View File

125
 
125
 
126
   onClickScrollViewScreen() {
126
   onClickScrollViewScreen() {
127
     Navigation.push(this.props.containerId, {
127
     Navigation.push(this.props.containerId, {
128
-      name: 'navigation.playground.ScrollViewScreen'
128
+      component: {
129
+        name: 'navigation.playground.ScrollViewScreen'
130
+      }
129
     });
131
     });
130
   }
132
   }
131
 
133
 
132
   onClickCustomTranstition() {
134
   onClickCustomTranstition() {
133
     Navigation.push(this.props.containerId, {
135
     Navigation.push(this.props.containerId, {
134
-      name: 'navigation.playground.CustomTransitionOrigin'
136
+      component: {
137
+        name: 'navigation.playground.CustomTransitionOrigin'
138
+      }
135
     });
139
     });
136
   }
140
   }
137
 
141
 

+ 106
- 62
playground/src/containers/WelcomeScreen.js View File

46
 
46
 
47
   onClickSwitchToTabs() {
47
   onClickSwitchToTabs() {
48
     Navigation.setRoot({
48
     Navigation.setRoot({
49
-      bottomTabs: [
50
-        {
51
-          container: {
52
-            name: 'navigation.playground.TextScreen',
53
-            passProps: {
54
-              text: 'This is tab 1',
55
-              myFunction: () => 'Hello from a function!'
56
-            },
57
-            options: {
58
-              bottomTab: {
59
-                title: 'Tab 1',
60
-                testID: testIDs.FIRST_TAB_BAR_BUTTON
61
-              }
49
+      bottomTabs: {
50
+        children: [
51
+          {
52
+            stack: {
53
+              children: [
54
+                {
55
+                  component: {
56
+                    name: 'navigation.playground.TextScreen',
57
+                    passProps: {
58
+                      text: 'This is tab 1',
59
+                      myFunction: () => 'Hello from a function!'
60
+                    },
61
+                    options: {
62
+                      bottomTab: {
63
+                        title: 'Tab 1',
64
+                        testID: testIDs.FIRST_TAB_BAR_BUTTON
65
+                      }
66
+                    }
67
+                  }
68
+                }
69
+              ]
62
             }
70
             }
63
-          }
64
-        },
65
-        {
66
-          container: {
67
-            name: 'navigation.playground.TextScreen',
68
-            passProps: {
69
-              text: 'This is tab 2'
70
-            },
71
-            options: {
72
-              bottomTab: {
73
-                title: 'Tab 2',
74
-                testID: testIDs.SECOND_TAB_BAR_BUTTON
75
-              }
71
+          },
72
+          {
73
+            stack: {
74
+              children: [
75
+                {
76
+                  component: {
77
+                    name: 'navigation.playground.TextScreen',
78
+                    passProps: {
79
+                      text: 'This is tab 2'
80
+                    },
81
+                    options: {
82
+                      bottomTab: {
83
+                        title: 'Tab 2',
84
+                        testID: testIDs.SECOND_TAB_BAR_BUTTON
85
+                      }
86
+                    }
87
+                  }
88
+                }
89
+              ]
76
             }
90
             }
77
           }
91
           }
78
-        }
79
-      ]
92
+        ]
93
+      }
80
     });
94
     });
81
   }
95
   }
82
 
96
 
83
   onClickSwitchToSideMenus() {
97
   onClickSwitchToSideMenus() {
84
     Navigation.setRoot({
98
     Navigation.setRoot({
85
-      bottomTabs: [
86
-        {
87
-          container: {
88
-            name: 'navigation.playground.TextScreen',
89
-            passProps: {
90
-              text: 'This is a side menu center screen tab 1'
91
-            }
92
-          }
93
-        },
94
-        {
95
-          container: {
96
-            name: 'navigation.playground.TextScreen',
97
-            passProps: {
98
-              text: 'This is a side menu center screen tab 2'
99
-            }
100
-          }
101
-        },
102
-        {
103
-          container: {
104
-            name: 'navigation.playground.TextScreen',
105
-            passProps: {
106
-              text: 'This is a side menu center screen tab 3'
107
-            }
108
-          }
109
-        }
110
-      ],
111
       sideMenu: {
99
       sideMenu: {
112
         left: {
100
         left: {
113
-          container: {
101
+          component: {
114
             name: 'navigation.playground.SideMenuScreen',
102
             name: 'navigation.playground.SideMenuScreen',
115
             passProps: {
103
             passProps: {
116
               side: 'left'
104
               side: 'left'
117
             }
105
             }
118
           }
106
           }
119
         },
107
         },
108
+        center: {
109
+          bottomTabs: [
110
+            {
111
+              stack: {
112
+                children: [
113
+                  {
114
+                    component: {
115
+                      name: 'navigation.playground.TextScreen',
116
+                      passProps: {
117
+                        text: 'This is a side menu center screen tab 1'
118
+                      }
119
+                    }
120
+                  }
121
+                ]
122
+              }
123
+            },
124
+            {
125
+              stack: {
126
+                children: [
127
+                  {
128
+                    component: {
129
+                      name: 'navigation.playground.TextScreen',
130
+                      passProps: {
131
+                        text: 'This is a side menu center screen tab 2'
132
+                      }
133
+                    }
134
+                  }
135
+                ]
136
+              }
137
+            },
138
+            {
139
+              stack: {
140
+                children: [
141
+                  {
142
+                    component: {
143
+                      name: 'navigation.playground.TextScreen',
144
+                      passProps: {
145
+                        text: 'This is a side menu center screen tab 3'
146
+                      }
147
+                    }
148
+                  }
149
+                ]
150
+              }
151
+            }
152
+          ]
153
+        },
120
         right: {
154
         right: {
121
-          container: {
155
+          component: {
122
             name: 'navigation.playground.SideMenuScreen',
156
             name: 'navigation.playground.SideMenuScreen',
123
             passProps: {
157
             passProps: {
124
               side: 'right'
158
               side: 'right'
131
 
165
 
132
   async onClickPush() {
166
   async onClickPush() {
133
     await Navigation.push(this.props.containerId, {
167
     await Navigation.push(this.props.containerId, {
134
-      name: 'navigation.playground.PushedScreen'
168
+      component: {
169
+        name: 'navigation.playground.PushedScreen'
170
+      }
135
     });
171
     });
136
   }
172
   }
137
 
173
 
138
   onClickLifecycleScreen() {
174
   onClickLifecycleScreen() {
139
     Navigation.push(this.props.containerId, {
175
     Navigation.push(this.props.containerId, {
140
-      name: 'navigation.playground.LifecycleScreen'
176
+      component: {
177
+        name: 'navigation.playground.LifecycleScreen'
178
+      }
141
     });
179
     });
142
   }
180
   }
143
 
181
 
144
   async onClickShowModal() {
182
   async onClickShowModal() {
145
     await Navigation.showModal({
183
     await Navigation.showModal({
146
-      container: {
184
+      component: {
147
         name: 'navigation.playground.ModalScreen'
185
         name: 'navigation.playground.ModalScreen'
148
       }
186
       }
149
     });
187
     });
155
 
193
 
156
   onClickPushOptionsScreen() {
194
   onClickPushOptionsScreen() {
157
     Navigation.push(this.props.containerId, {
195
     Navigation.push(this.props.containerId, {
158
-      name: 'navigation.playground.OptionsScreen'
196
+      component: {
197
+        name: 'navigation.playground.OptionsScreen'
198
+      }
159
     });
199
     });
160
   }
200
   }
161
 
201
 
212
 
252
 
213
   onClickBackHandler() {
253
   onClickBackHandler() {
214
     Navigation.push(this.props.containerId, {
254
     Navigation.push(this.props.containerId, {
215
-      name: 'navigation.playground.BackHandlerScreen'
255
+      component: {
256
+        name: 'navigation.playground.BackHandlerScreen'
257
+      }
216
     });
258
     });
217
   }
259
   }
218
 
260
 
219
   onClickPushOrientationMenuScreen() {
261
   onClickPushOrientationMenuScreen() {
220
     Navigation.push(this.props.containerId, {
262
     Navigation.push(this.props.containerId, {
221
-      name: 'navigation.playground.OrientationSelectScreen'
263
+      component: {
264
+        name: 'navigation.playground.OrientationSelectScreen'
265
+      }
222
     });
266
     });
223
   }
267
   }
224
 }
268
 }