|
@@ -1,5 +1,9 @@
|
1
|
1
|
# Layout Types
|
2
|
2
|
|
|
3
|
+The possibilities of the RNN layout API are wide open in terms of what you can construct with it: stacks, tabs and drawers in many combinations.
|
|
4
|
+
|
|
5
|
+You can compose arbitrary native layout hierarchies (although some weird edge cases may not be possible or produce errors). In such cases, open an issue so that we either fix it or warn in dev time.
|
|
6
|
+
|
3
|
7
|
## component
|
4
|
8
|
|
5
|
9
|
Component layout holds a single react component.
|
|
@@ -18,7 +22,7 @@ const component = {
|
18
|
22
|
## stack
|
19
|
23
|
|
20
|
24
|
Support children layouts of any kind.
|
21
|
|
-When initialized with more than one screen, the last screen will be presented at the top of the stack.
|
|
25
|
+A stack can be initialised with more then one screen, in which case the last screen will be presented at the top of the stack.
|
22
|
26
|
|
23
|
27
|
```js
|
24
|
28
|
const stack = {
|
|
@@ -30,9 +34,7 @@ const stack = {
|
30
|
34
|
component: {}
|
31
|
35
|
}
|
32
|
36
|
],
|
33
|
|
- options: {
|
34
|
|
-
|
35
|
|
- }
|
|
37
|
+ options: {}
|
36
|
38
|
}
|
37
|
39
|
```
|
38
|
40
|
|
|
@@ -42,22 +44,29 @@ const stack = {
|
42
|
44
|
const bottomTabs = {
|
43
|
45
|
children: [
|
44
|
46
|
{
|
45
|
|
- stack: {}
|
|
47
|
+ stack: {
|
|
48
|
+ children: [],
|
|
49
|
+ options: {
|
|
50
|
+ bottomTab: {
|
|
51
|
+ title: 'Tab 1',
|
|
52
|
+ icon: require('../images/one.png')
|
|
53
|
+ }
|
|
54
|
+ }
|
|
55
|
+ }
|
46
|
56
|
},
|
47
|
57
|
{
|
48
|
58
|
component: {
|
49
|
|
- name: 'tab1',
|
|
59
|
+ name: 'secondTabScreen',
|
50
|
60
|
options: {
|
51
|
61
|
bottomTab: {
|
52
|
|
- icon: require('icon')
|
|
62
|
+ title: 'Tab 2',
|
|
63
|
+ icon: require('../images/two.png')
|
53
|
64
|
}
|
54
|
65
|
}
|
55
|
66
|
}
|
56
|
67
|
}
|
57
|
68
|
],
|
58
|
|
- options: {
|
59
|
|
-
|
60
|
|
- }
|
|
69
|
+ options: {}
|
61
|
70
|
}
|
62
|
71
|
```
|
63
|
72
|
|
|
@@ -101,4 +110,103 @@ const splitView = {
|
101
|
110
|
maxWidth: 300, // Maximum width of master view
|
102
|
111
|
},
|
103
|
112
|
}
|
104
|
|
-```
|
|
113
|
+```
|
|
114
|
+
|
|
115
|
+# Layout Examples
|
|
116
|
+
|
|
117
|
+## Single page app with two side menus:
|
|
118
|
+
|
|
119
|
+```js
|
|
120
|
+Navigation.setRoot({
|
|
121
|
+ root: {
|
|
122
|
+ sideMenu: {
|
|
123
|
+ left: {
|
|
124
|
+ component: {
|
|
125
|
+ name: 'navigation.playground.TextScreen',
|
|
126
|
+ passProps: {
|
|
127
|
+ text: 'This is a left side menu screen'
|
|
128
|
+ }
|
|
129
|
+ }
|
|
130
|
+ },
|
|
131
|
+ center: {
|
|
132
|
+ component: {
|
|
133
|
+ name: 'navigation.playground.WelcomeScreen'
|
|
134
|
+ },
|
|
135
|
+ },
|
|
136
|
+ right: {
|
|
137
|
+ component: {
|
|
138
|
+ name: 'navigation.playground.TextScreen',
|
|
139
|
+ passProps: {
|
|
140
|
+ text: 'This is a right side menu screen'
|
|
141
|
+ }
|
|
142
|
+ }
|
|
143
|
+ }
|
|
144
|
+ }
|
|
145
|
+ }
|
|
146
|
+});
|
|
147
|
+```
|
|
148
|
+
|
|
149
|
+## Tab based app (with passProps example):
|
|
150
|
+
|
|
151
|
+```js
|
|
152
|
+Navigation.setRoot({
|
|
153
|
+ root: {
|
|
154
|
+ bottomTabs: {
|
|
155
|
+ children: [
|
|
156
|
+ {
|
|
157
|
+ component: {
|
|
158
|
+ name: 'navigation.playground.TextScreen',
|
|
159
|
+ passProps: {
|
|
160
|
+ text: 'This is tab 1',
|
|
161
|
+ myFunction: () => 'Hello from a function!',
|
|
162
|
+ },
|
|
163
|
+ },
|
|
164
|
+ },
|
|
165
|
+ {
|
|
166
|
+ component: {
|
|
167
|
+ name: 'navigation.playground.TextScreen',
|
|
168
|
+ passProps: {
|
|
169
|
+ text: 'This is tab 2',
|
|
170
|
+ },
|
|
171
|
+ },
|
|
172
|
+ },
|
|
173
|
+ ],
|
|
174
|
+ },
|
|
175
|
+ }
|
|
176
|
+});
|
|
177
|
+```
|
|
178
|
+
|
|
179
|
+## Stack based app (with options example, initialised with 2 screens):
|
|
180
|
+
|
|
181
|
+```js
|
|
182
|
+Navigation.setRoot({
|
|
183
|
+ root: {
|
|
184
|
+ stack: {
|
|
185
|
+ options: {
|
|
186
|
+ topBar: {
|
|
187
|
+ hidden: true
|
|
188
|
+ }
|
|
189
|
+ },
|
|
190
|
+ children: [
|
|
191
|
+ {
|
|
192
|
+ component: {
|
|
193
|
+ name: 'navigation.playground.TextScreen',
|
|
194
|
+ passProps: {
|
|
195
|
+ text: 'This is tab 1',
|
|
196
|
+ myFunction: () => 'Hello from a function!',
|
|
197
|
+ }
|
|
198
|
+ }
|
|
199
|
+ },
|
|
200
|
+ {
|
|
201
|
+ component: {
|
|
202
|
+ name: 'navigation.playground.TextScreen',
|
|
203
|
+ passProps: {
|
|
204
|
+ text: 'This is tab 2',
|
|
205
|
+ }
|
|
206
|
+ }
|
|
207
|
+ }
|
|
208
|
+ ]
|
|
209
|
+ }
|
|
210
|
+ }
|
|
211
|
+});
|
|
212
|
+```
|