ソースを参照

api migration

Daniel Zlotin 7 年 前
コミット
bbca8e07dc

+ 2
- 2
lib/ios/RNNLayoutNode.m ファイルの表示

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

+ 1
- 1
lib/ios/RNNRootViewController.m ファイルの表示

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

+ 8
- 8
lib/src/Navigation.js ファイルの表示

@@ -9,9 +9,9 @@ const LayoutTreeCrawler = require('./commands/LayoutTreeCrawler');
9 9
 const PrivateEventsListener = require('./events/PrivateEventsListener');
10 10
 const PublicEventsRegistry = require('./events/PublicEventsRegistry');
11 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 16
 /** @constructor */
17 17
 class Navigation {
@@ -44,12 +44,12 @@ class Navigation {
44 44
    * @param {Root} root
45 45
    */
46 46
   setRoot(params) {
47
-    return this.commands.setRoot(new Root(params));
47
+    return this.commands.setRoot(params);
48 48
   }
49 49
 
50 50
   /**
51 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 54
   setDefaultOptions(options) {
55 55
     this.commands.setDefaultOptions(options);
@@ -58,10 +58,10 @@ class Navigation {
58 58
   /**
59 59
    * Change a containers navigation options
60 60
    * @param {string} containerId The container's id.
61
-   * @param {options:NavigationOptions} options
61
+   * @param {options:Options} options
62 62
    */
63 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,7 +93,7 @@ class Navigation {
93 93
    * @param {Container} container
94 94
    */
95 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 ファイルの表示

@@ -1,5 +1,4 @@
1 1
 const OptionsProcessor = require('./OptionsProcessor');
2
-const Options = require('./../params/options/Options');
3 2
 
4 3
 describe('navigation options', () => {
5 4
   let options;
@@ -93,15 +92,14 @@ describe('navigation options', () => {
93 92
     expect(options.topBar.myOtherValue).toEqual('value');
94 93
   });
95 94
 
96
-  it('processes NavigationOptions jsDoc object', () => {
95
+  it('processes Options object', () => {
97 96
     options.someKeyColor = 'rgb(255, 0, 255)';
98 97
     options.topBar = { textColor: 'red' };
99 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 105
   it('undefined value return undefined ', () => {

lib/src/params/containers/Container.js → lib/src/xparams/containers/Container.js ファイルの表示


lib/src/params/containers/Container.test.js → lib/src/xparams/containers/Container.test.js ファイルの表示


lib/src/params/containers/Root.js → lib/src/xparams/containers/Root.js ファイルの表示


lib/src/params/containers/Root.test.js → lib/src/xparams/containers/Root.test.js ファイルの表示


lib/src/params/containers/SideMenu.js → lib/src/xparams/containers/SideMenu.js ファイルの表示


lib/src/params/containers/SideMenu.test.js → lib/src/xparams/containers/SideMenu.test.js ファイルの表示


lib/src/params/options/BottomTab.js → lib/src/xparams/options/BottomTab.js ファイルの表示


lib/src/params/options/BottomTab.test.js → lib/src/xparams/options/BottomTab.test.js ファイルの表示


lib/src/params/options/BottomTabs.js → lib/src/xparams/options/BottomTabs.js ファイルの表示


lib/src/params/options/BottomTabs.test.js → lib/src/xparams/options/BottomTabs.test.js ファイルの表示


lib/src/params/options/Button.js → lib/src/xparams/options/Button.js ファイルの表示


lib/src/params/options/Button.test.js → lib/src/xparams/options/Button.test.js ファイルの表示


lib/src/params/options/Options.js → lib/src/xparams/options/Options.js ファイルの表示

@@ -3,7 +3,7 @@ const BottomTabs = require('./BottomTabs');
3 3
 const BottomTab = require('./BottomTab');
4 4
 const TopTabs = require('./TopTabs');
5 5
 
6
-class NavigationOptions {
6
+class Options {
7 7
   /**
8 8
    * @property {options:TopBar} [topBar]
9 9
    * @property {options:BottomTabs} [bottomTabs]
@@ -24,4 +24,4 @@ class NavigationOptions {
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 ファイルの表示

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

lib/src/params/options/TopBar.js → lib/src/xparams/options/TopBar.js ファイルの表示


lib/src/params/options/TopBar.test.js → lib/src/xparams/options/TopBar.test.js ファイルの表示


lib/src/params/options/TopTab.js → lib/src/xparams/options/TopTab.js ファイルの表示


lib/src/params/options/TopTab.test.js → lib/src/xparams/options/TopTab.test.js ファイルの表示


lib/src/params/options/TopTabs.js → lib/src/xparams/options/TopTabs.js ファイルの表示


lib/src/params/options/TopTabs.test.js → lib/src/xparams/options/TopTabs.test.js ファイルの表示


+ 8
- 2
playground/src/app.js ファイルの表示

@@ -5,8 +5,14 @@ function start() {
5 5
   registerContainers();
6 6
   Navigation.events().onAppLaunched(() => {
7 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 ファイルの表示

@@ -22,19 +22,23 @@ class CustomTransitionDestination extends Component {
22 22
   }
23 23
   push() {
24 24
     Navigation.push(this.props.containerId, {
25
-      name: 'navigation.playground.OptionsScreen'
25
+      component: {
26
+        name: 'navigation.playground.OptionsScreen'
27
+      }
26 28
     });
27 29
   }
28 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 43
   render() {
40 44
     return (

+ 12
- 10
playground/src/containers/CustomTransitionOrigin.js ファイルの表示

@@ -52,17 +52,19 @@ class CustomTransitionOrigin extends Component {
52 52
   }
53 53
   onClickNavigationIcon() {
54 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 ファイルの表示

@@ -61,7 +61,7 @@ class LifecycleScreen extends Component {
61 61
   }
62 62
 
63 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 67
 module.exports = LifecycleScreen;

+ 6
- 2
playground/src/containers/OptionsScreen.js ファイルの表示

@@ -125,13 +125,17 @@ class OptionsScreen extends Component {
125 125
 
126 126
   onClickScrollViewScreen() {
127 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 134
   onClickCustomTranstition() {
133 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 ファイルの表示

@@ -46,79 +46,113 @@ class WelcomeScreen extends Component {
46 46
 
47 47
   onClickSwitchToTabs() {
48 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 97
   onClickSwitchToSideMenus() {
84 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 99
       sideMenu: {
112 100
         left: {
113
-          container: {
101
+          component: {
114 102
             name: 'navigation.playground.SideMenuScreen',
115 103
             passProps: {
116 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 154
         right: {
121
-          container: {
155
+          component: {
122 156
             name: 'navigation.playground.SideMenuScreen',
123 157
             passProps: {
124 158
               side: 'right'
@@ -131,19 +165,23 @@ class WelcomeScreen extends Component {
131 165
 
132 166
   async onClickPush() {
133 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 174
   onClickLifecycleScreen() {
139 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 182
   async onClickShowModal() {
145 183
     await Navigation.showModal({
146
-      container: {
184
+      component: {
147 185
         name: 'navigation.playground.ModalScreen'
148 186
       }
149 187
     });
@@ -155,7 +193,9 @@ class WelcomeScreen extends Component {
155 193
 
156 194
   onClickPushOptionsScreen() {
157 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,13 +252,17 @@ class WelcomeScreen extends Component {
212 252
 
213 253
   onClickBackHandler() {
214 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 261
   onClickPushOrientationMenuScreen() {
220 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
 }