You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+27-24Lines changed: 27 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,7 +37,7 @@ The `<Popover>` is able to handle dynamic content and adapt to screen size chang
37
37
38
38
## <aname="upgrading" />Upgrading from 0.5.x
39
39
40
-
Version 0.6 brought some large changes, increasing efficiency, stability, and flexibility. For React Navigation users, there is a new required prop, `showInPopover`, that you must pass to `PopoverStackNavigator` if you want to specify when to show stack views in a Popover. This replaces `PopoverNavigation.shouldShowInPopover`. See the new [setup](#setup) instructions below for details.
40
+
Version 0.6 brought some large changes, increasing efficiency, stability, and flexibility. For React Navigation users, there is a new prop, `showInPopover`, that you might want to pass to `PopoverStackNavigator` if you want to customize when to show stack views in a Popover. This replaces `PopoverNavigation.shouldShowInPopover`. See the new [setup](#setup) instructions below for details.
41
41
42
42
## <aname="demo"/>Demo App
43
43
@@ -70,7 +70,7 @@ import Popover from 'react-native-popover-view'
70
70
...
71
71
render (
72
72
<Popover
73
-
isVisible={this.state.isVisible}/>
73
+
isVisible={this.state.isVisible}>
74
74
<CustomElement />
75
75
</Popover>
76
76
)
@@ -80,20 +80,23 @@ import Popover from 'react-native-popover-view'
isVisible | bool | No | false | Show/Hide the popover
84
84
fromView | ref | Yes | null | The `ref` of the view that should anchor the popover.
85
85
fromRect | rect | Yes | null | Alternative to `fromView`. Rectangle at which to anchor the popover.
86
86
displayArea | rect | Yes | screen rect | Area where the popover is allowed to be displayed
87
87
placement | string | Yes | 'auto' | How to position the popover - top | bottom | left | right | auto. When 'auto' is specified, it will determine the ideal placement so that the popover is fully visible within `displayArea`.
88
-
onClose | function | Yes | | Callback to be fired when the user taps the popover
88
+
onClose | function | Yes | | Callback to be fired when the user taps outside the popover
89
89
doneClosingCallback | function | Yes | | Callback to be fired when the popover is finished closing (after animation)
90
-
showInModal | bool | Yes | true | Whether the Popover should be encapsulated in the [Modal view from RN](https://facebook.github.io/react-native/docs/modal.html), which allows it to show above all other content, or just be present in the view hierarchy like a normal view.
91
-
showArrow | bool | Yes | true | Whether the arrow that points to the rect (passing in as `fromRect`) is shown. If `fromRect` is null, the arrow will never be shown.
90
+
showInModal | bool | Yes | true | Whether the popover should be encapsulated in the [Modal view from RN](https://facebook.github.io/react-native/docs/modal.html), which allows it to show above all other content, or just be present in the view hierarchy like a normal view.
91
+
showArrow | bool | Yes | true | Whether the arrow that points to the rect (passed in as `fromView` or `fromRect`) is shown. If `fromView` and `fromRect` are null, the arrow will never be shown.
92
+
arrowSize | size | Yes | 16 x 8 | The size of the arrow that points to the rect.
92
93
showBackground | bool | Yes | true | Whether the background behind the popover darkens when the popover is shown.
93
94
94
-
If neither fromRect or fromView are provided, the popover will float in the center of the screen.
95
+
If neither `fromRect` or `fromView` are provided, the popover will float in the center of the screen.
95
96
96
-
rect is an object with the following properties: `{x: number, y: number, width: number, height: number}`. You can create the object yourself, or `import Popover, { Rect } from 'react-native-popover-view` and create a rect by calling `new Rect(x, y, width, height)`.
97
+
`rect` is an object with the following properties: `{x: number, y: number, width: number, height: number}`. You can create the object yourself, or `import Popover, { Rect } from 'react-native-popover-view` and create a rect by calling `new Rect(x, y, width, height)`.
98
+
99
+
Likewise, `size` is an object with the following properties: `{width: number, height: number}`. You can create the object yourself, or `import Popover, { Size } from 'react-native-popover-view` and create a rect by calling `new Size(width, height)`.
97
100
98
101
### <aname="standalone-example"/>Full Example
99
102
```jsx
@@ -123,14 +126,14 @@ class PopoverExample extends Component {
This can also be integrated with react-navigation's StackNavigator, so that on tablets, views higher up in the stack show in a popover instead of a full-screen modal.
169
+
This can also be integrated with react-navigation's StackNavigator, so that on tablets, views higher up in the stack show in a popover instead ofina full-screen modal.
167
170
168
171
### <a name="setup"/>Basic Setup
169
172
170
173
171
174
#### 1) Change `StackNavigator` to `PopoverStackNavigator`
172
175
173
176
`PopoverStackNavigator` is a drop-in replacement for react-navigation's `StackNavigator`. It assumes the first view in your `RouteConfigs` is the base view, and every other view should be shown in a Popover when the `showInPopover` prop is `true` (see step #2).
174
-
You can pass a few (optional) per-screen options through your `RouteConfigs` or globally through your StackNavigatorConfig:
177
+
You can pass a few (optional) per-screen options through your `RouteConfigs` or globally through your `StackNavigatorConfig`:
`placement` | PLACEMENT_OPTIONS | PLACEMENT_OPTIONS.AUTO | Passed through to `Popover`.
179
-
`contentContainerStyle` | number | 380 | The style for the internal view that wraps the `Popover`. (Default {width: 380})
182
+
`contentContainerStyle` | number | {width: 380} | The style for the internal view that wraps the `Popover`.
180
183
`showInModal` | boolean | true | Passed through to `Popover`. If you want to stack multiple `Popover`'s, only the bottom one can be shown in a `Modal` on iOS.
181
184
`showArrow`| boolean |true| Passed through to `Popover`
182
-
`showBackground`| boolean |true| Passed through to `Popover`
185
+
`showBackground`| boolean |true| Passed through to `Popover`
183
186
`arrowSize`| Size |true| Passed through to `Popover`
184
187
185
-
Note that ifyou pass a value through the StackNavigatorConfig, and pass the same option for an individual screen, the value passed for the screen overrides.
188
+
Note: If you pass a value through the `StackNavigatorConfig`, and pass the same option for an individual screen, the value passed for the screen overrides.
186
189
187
190
Example:
188
-
```js
191
+
```jsx
189
192
import Popover, { PopoverStackNavigator } from 'react-native-popover-view';
190
193
191
194
let stack = PopoverStackNavigator({
@@ -224,7 +227,7 @@ let stack = PopoverStackNavigator({
224
227
225
228
By default, views will be shown in a Popover view on tablets, and normally on phones. To override this behavior, you can pass the `showInPopover` prop to the classreturned by `PopoverStackNavigator`:
226
229
227
-
```js
230
+
```jsx
228
231
let Stack = PopoverStackNavigator(...);
229
232
...
230
233
render() {
@@ -387,7 +390,7 @@ let styles = {
387
390
388
391
By default, Popover's will query RN's `SafeAreaView` to get the allowed display area on the device, and then add a 10pt padding around all the edges, and set this as the display area. If you want to inject a custum display area to a specific popover, you can do so either through the `PopoverStackNavigator`'s `RouteConfigs` or through params in the `navigate` call:
389
392
390
-
```js
393
+
```jsx
391
394
let Stack = PopoverStackNavigator({
392
395
View1: {
393
396
screen: 'View1',
@@ -400,7 +403,7 @@ let Stack = PopoverStackNavigator({
400
403
}, options);
401
404
```
402
405
OR
403
-
```js
406
+
```jsx
404
407
this.props.navigation.navigate('View1', {displayArea: new Rect(0, 0, 50,50)});
405
408
```
406
409
@@ -423,11 +426,11 @@ Now, if your app is put into split-screen mode while the popover is still showin
423
426
424
427
## <a name="contributing">Contributing
425
428
426
-
Pull requests are welcome, and if you find that you are having to bend over backwards to make this work for you, feel free to open an issue or PR! Of course, try to keep the same coding style if possible and I'll try to get back to you as soon as possible.
429
+
Pull requests are welcome; if you find that you are having to bend over backwards to make this work for you, feel free to open an issue or PR! Of course, try to keep the same coding style if possible and I'll try to get back to you as soon as I can.
427
430
428
431
## <a name="credits"/>Credits
429
432
430
-
Original codebase created by Jean Regisser <jean.regisser@gmail.com> (https://github.com/jeanregisser) as [react-native-popover](https://github.com/jeanregisser/react-native-popover), which has been abandoned
433
+
Original codebase created by Jean Regisser <jean.regisser@gmail.com> (https://github.com/jeanregisser) as [react-native-popover](https://github.com/jeanregisser/react-native-popover), which has been abandoned.
0 commit comments