Browse Source

added layout types doc

yogevbd 6 years ago
parent
commit
37c38673c7
2 changed files with 246 additions and 0 deletions
  1. 81
    0
      docs/docs/layout-types.md
  2. 165
    0
      docs/docs/top-level-api.md

+ 81
- 0
docs/docs/layout-types.md View File

@@ -0,0 +1,81 @@
1
+# Layout Types
2
+
3
+## stack
4
+
5
+Expect children layouts of any kind.\
6
+When initializing with more than one screen last screen will be presented at the top of the stack.
7
+
8
+```js
9
+const stack = {
10
+  children: [
11
+    {
12
+      component: {}
13
+    },
14
+    {
15
+      component: {}
16
+    }
17
+  ],
18
+  options: {
19
+
20
+  }
21
+}
22
+```
23
+
24
+## component
25
+
26
+Component layout holds your react component.
27
+
28
+```js
29
+const component = {
30
+  name: 'Your registered component name',
31
+  options: {},
32
+  passProps: {
33
+    text: 'This text will be available in your component.props'
34
+  }
35
+}
36
+```
37
+
38
+## bottomTabs
39
+
40
+Expect children layouts
41
+
42
+```js
43
+const bottomTabs = {
44
+  children: [
45
+    {
46
+      stack: {}
47
+    },
48
+    {
49
+      component: {
50
+        name: 'tab1',
51
+        options: {
52
+          bottomTab: {
53
+            icon: require('icon')
54
+          }
55
+        }
56
+      }
57
+    }
58
+  ],
59
+  options: {
60
+
61
+  }
62
+}
63
+```
64
+
65
+## sideMenu
66
+
67
+Expect center, left and right layouts
68
+
69
+```js
70
+const sideMenu = {
71
+  left: {
72
+    component: {}
73
+  },
74
+  center: {
75
+    stack: {}
76
+  },
77
+  right: {
78
+    component: {}
79
+  }
80
+}
81
+```

+ 165
- 0
docs/docs/top-level-api.md View File

@@ -0,0 +1,165 @@
1
+# Top Level API Migration
2
+
3
+In order to make navigation API homogenous as much as possible, we provide setRoot function that receives layout of any kind.
4
+See [Layout types](layout-types)
5
+
6
+
7
+## setRoot(layout)
8
+
9
+```js
10
+Navigation.setRoot({
11
+  bottomTabs: {
12
+    children: [{
13
+      stack: {
14
+        children: [{
15
+          component: {
16
+            name: 'example.FirstTabScreen',
17
+            passProps: {
18
+              text: 'This is tab 1'
19
+            }
20
+          }
21
+        }],
22
+        options: {
23
+          bottomTab: {
24
+            title: 'Tab 1',
25
+            icon: require('../images/one.png'),
26
+            testID: 'FIRST_TAB_BAR_BUTTON'
27
+          }
28
+        }
29
+      }
30
+    },
31
+    {
32
+      component: {
33
+        name: 'navigation.playground.TextScreen',
34
+        passProps: {
35
+          text: 'This is tab 2'
36
+        },
37
+        options: {
38
+          bottomTab: {
39
+            title: 'Tab 2',
40
+            icon: require('../images/two.png'),
41
+            testID: 'SECOND_TAB_BAR_BUTTON'
42
+          }
43
+        }
44
+      }
45
+    }]
46
+  }
47
+});
48
+```
49
+
50
+## startSingleScreenApp(params) -> setRoot({stack})
51
+
52
+Change your app root into an app based on a single screen (like the iOS Calendar or Settings app). The screen will receive its own navigation stack with a native nav bar
53
+
54
+```js
55
+Navigation.setRoot({
56
+  stack: {
57
+    children: [{
58
+      component: {
59
+        name: 'example.WelcomeScreen',
60
+        passProps: {
61
+          text: 'stack with one child'
62
+        }
63
+      }
64
+    }],
65
+    options: {
66
+      topBar: {
67
+        title: {
68
+          text: 'Welcome screen'
69
+        }
70
+      }
71
+    }
72
+  }
73
+});
74
+```
75
+
76
+## showModal(params = {}) -> showModal(layout = {})
77
+
78
+Show a screen as a modal.
79
+
80
+```js
81
+Navigation.showModal({
82
+  stack: {
83
+    children: [{
84
+      component: {
85
+        name: 'example.ModalScreen',
86
+        passProps: {
87
+          text: 'stack with one child'
88
+        },
89
+        options: {
90
+          topBar: {
91
+            title: {
92
+              text: 'Modal with stack'
93
+            }
94
+          }
95
+        }
96
+      }
97
+    }]
98
+  }
99
+});
100
+```
101
+
102
+## dismissModal(params = {}) -> dismissModal(componentId)
103
+
104
+Dismiss the current modal.
105
+
106
+```js
107
+Navigation.dismissModal(this.props.componentId);
108
+```
109
+
110
+## dismissAllModals(params = {}) -> dismissAllModals()
111
+
112
+Dismiss all the current modals at the same time.
113
+
114
+```js
115
+Navigation.dismissAllModals();
116
+```
117
+
118
+<!-- ## showLightBox(params = {}) - Use showOverlay
119
+
120
+Show a screen as a lightbox.
121
+
122
+```js
123
+Navigation.showLightBox({
124
+  screen: 'example.LightBoxScreen', // unique ID registered with Navigation.registerScreen
125
+  passProps: {}, // simple serializable object that will pass as props to the lightbox (optional)
126
+  style: {
127
+    backgroundBlur: 'dark', // 'dark' / 'light' / 'xlight' / 'none' - the type of blur on the background
128
+    backgroundColor: '#ff000080', // tint color for the background, you can specify alpha here (optional)
129
+    tapBackgroundToDismiss: true // dismisses LightBox on background taps (optional)
130
+  }
131
+});
132
+``` -->
133
+
134
+<!-- ## dismissLightBox(params = {})
135
+
136
+Dismiss the current lightbox.
137
+
138
+```js
139
+Navigation.dismissLightBox();
140
+``` -->
141
+
142
+<!-- ## handleDeepLink(params = {})
143
+
144
+Trigger a deep link within the app. See [deep links](https://wix.github.io/react-native-navigation/#/deep-links) for more details about how screens can listen for deep link events.
145
+
146
+```js
147
+Navigation.handleDeepLink({
148
+  link: 'link/in/any/format',
149
+  payload: '' // (optional) Extra payload with deep link
150
+});
151
+``` -->
152
+
153
+<!-- ## registerScreen(screenID, generator)
154
+
155
+This is an internal function you probably don't want to use directly. If your screen components extend `Screen` directly (`import { Screen } from 'react-native-navigation'`), you can register them directly with `registerScreen` instead of with `registerComponent`. The main benefit of using `registerComponent` is that it wraps your regular screen component with a `Screen` automatically.
156
+
157
+```js
158
+Navigation.registerScreen('example.AdvancedScreen', () => AdvancedScreen);
159
+```
160
+
161
+## getCurrentlyVisibleScreenId()
162
+
163
+In some cases you might need the id of the currently visible screen. This method returns the unique id of the currently visible screen:
164
+`const visibleScreenInstanceId = await Navigation.getCurrentlyVisibleScreenId()`
165
+In order to have any use of this method, you'd need to map instanceId to screens your self. -->