Browse Source

[Docs] Sidemenu & stack (#5473)

Improved stack and Sidemenu docs
DamarXCV 5 years ago
parent
commit
968a46f32b
1 changed files with 112 additions and 1 deletions
  1. 112
    1
      docs/docs/layout-types.md

+ 112
- 1
docs/docs/layout-types.md View File

@@ -38,6 +38,84 @@ const stack = {
38 38
 }
39 39
 ```
40 40
 
41
+### api
42
+### TopBar buttons
43
+#### Android:
44
+* LeftButtons just support one button 
45
+* RightButtons support three visable buttons, more getting replaced with a menu button 
46
+```js
47
+options: {
48
+  topBar: {
49
+    visible: true,
50
+    leftButtons: [
51
+      {
52
+        id: 'back',
53
+        icon: {
54
+          uri: 'back',
55
+        },
56
+      },
57
+    ],
58
+    rightButtons: [
59
+      {
60
+        id: 'search',
61
+        icon: {
62
+          uri: 'search',
63
+        },
64
+      },
65
+    ],
66
+  },
67
+},
68
+```
69
+### Customizations
70
+#### Custom TopBar Title
71
+It's possible to set a custom topBar title to implement a searchbar for example.
72
+```js
73
+options: {
74
+  topBar: {
75
+    visible: true,
76
+    title: {
77
+      component: {
78
+        id: 'app.Search.SearchInput',
79
+        name: 'app.Search.SearchInput', // required
80
+        alignment: 'center', // 'center' or 'fill'
81
+        passProps: {
82
+
83
+        },
84
+      },
85
+    },
86
+  },
87
+},
88
+```
89
+
90
+### Back button
91
+Push a ModalStack which requires a back button on the first screen.
92
+```js
93
+options: {
94
+  topBar: {
95
+    visible: true,
96
+    leftButtons: [
97
+      {
98
+        id: 'back',
99
+        icon: {
100
+          uri: 'back',
101
+        },
102
+      },
103
+    ],
104
+  },
105
+},
106
+```
107
+Catch the button press event inside the ModalScreen.
108
+
109
+```js
110
+navigationButtonPressed = ({ buttonId }) => {
111
+  const { componentId } = this.props;
112
+  if (buttonId === 'back') {
113
+    Navigation.dismissModal(componentId);
114
+  }
115
+}
116
+```
117
+
118
+
41 119
 ## bottomTabs
42 120
 
43 121
 ```js
@@ -168,7 +246,8 @@ Navigation.mergeOptions('SecondScreenId', {
168 246
 
169 247
 ## sideMenu
170 248
 
171
-Expect center, left and right layouts. center: { stack: ... } is required to have a topBar in center screen of a sideMenu app.
249
+This layout allows to implement sidemenus, which can be opened by swiping from one side towards the other side.
250
+`left` and `right` are optional and contain the components, which gets rendered for the sidemenus. `center` is **required** and contains the main application, which **requires** to have a topBar aka `stack`.
172 251
 
173 252
 ```js
174 253
 const sideMenu = {
@@ -189,6 +268,38 @@ const sideMenu = {
189 268
 }
190 269
 ```
191 270
 
271
+### Opening the menu programmatically
272
+The  most common usecase is to open the sidemenus by pressing a [burger button in the topBar](https://wix.github.io/react-native-navigation/#/docs/layout-types?id=adding-a-hamburger-button). To achive this listen on the press event of the burger button and open the sidemenu by calling `Navigation.mergeOptions()` with `visible: true` for the sidemenu.
273
+```js
274
+navigationButtonPressed = ({ buttonId }) => {
275
+  const { componentId } = this.props;
276
+
277
+  if (buttonId === 'sideMenu') {
278
+    Navigation.mergeOptions(componentId, {
279
+      sideMenu: {
280
+        left: {
281
+          visible: true,
282
+        },
283
+      },
284
+    });
285
+  }
286
+}
287
+```
288
+
289
+### Adding a hamburger button
290
+For more information on how to add icons read [this article about react-native-vector-icons](https://wix.github.io/react-native-navigation/#/docs/third-party?id=react-native-vector-icons) or [this article about custom tab icons](https://wix.github.io/react-native-navigation/#/docs/styling?id=custom-tab-icons).
291
+
292
+```js
293
+leftButtons: [
294
+  {
295
+    id: 'sideMenu',
296
+    icon: {
297
+      uri: 'menu',
298
+    },
299
+  },
300
+],
301
+```
302
+
192 303
 ## splitView (iOS only)
193 304
 
194 305
 Master and Detail based layout.