Skip to content

Commit 5a219ff

Browse files
committed
Fixing mistake in Readme
1 parent ac33483 commit 5a219ff

File tree

1 file changed

+27
-24
lines changed

1 file changed

+27
-24
lines changed

README.md

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ The `<Popover>` is able to handle dynamic content and adapt to screen size chang
3737

3838
## <a name="upgrading" />Upgrading from 0.5.x
3939

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.
4141

4242
## <a name="demo"/>Demo App
4343

@@ -70,7 +70,7 @@ import Popover from 'react-native-popover-view'
7070
...
7171
render (
7272
<Popover
73-
isVisible={this.state.isVisible} />
73+
isVisible={this.state.isVisible}>
7474
<CustomElement />
7575
</Popover>
7676
)
@@ -80,20 +80,23 @@ import Popover from 'react-native-popover-view'
8080

8181
Prop | Type | Optional | Default | Description
8282
----------------- | -------- | -------- | ----------- | -----------
83-
isVisible | bool | Yes | false | Show/Hide the popover
83+
isVisible | bool | No | false | Show/Hide the popover
8484
fromView | ref | Yes | null | The `ref` of the view that should anchor the popover.
8585
fromRect | rect | Yes | null | Alternative to `fromView`. Rectangle at which to anchor the popover.
8686
displayArea | rect | Yes | screen rect | Area where the popover is allowed to be displayed
8787
placement | string | Yes | 'auto' | How to position the popover - top &#124; bottom &#124; left &#124; right &#124; 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
8989
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.
9293
showBackground | bool | Yes | true | Whether the background behind the popover darkens when the popover is shown.
9394

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.
9596

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)`.
97100

98101
### <a name="standalone-example"/>Full Example
99102
```jsx
@@ -123,14 +126,14 @@ class PopoverExample extends Component {
123126
render() {
124127
return (
125128
<View style={styles.container}>
126-
<TouchableHighlight ref={ref => this.touchable = ref} style={styles.button} onPress={this.showPopover}>
127-
<Text style={styles.buttonText}>Press me</Text>
129+
<TouchableHighlight ref={ref => this.touchable = ref} style={styles.button} onPress={() => this.showPopover()}>
130+
<Text>Press me</Text>
128131
</TouchableHighlight>
129132

130133
<Popover
131134
isVisible={this.state.isVisible}
132135
fromView={this.touchable}
133-
onClose={this.closePopover}>
136+
onClose={() => this.closePopover()}>
134137
<Text>I'm the content of this popover!</Text>
135138
</Popover>
136139
</View>
@@ -153,39 +156,39 @@ var styles = StyleSheet.create({
153156
backgroundColor: '#ccc',
154157
borderColor: '#333',
155158
borderWidth: 1,
156-
},
157-
buttonText: {
158159
}
159160
});
160161
161162
AppRegistry.registerComponent('PopoverExample', () => PopoverExample);
162163
```
163164
165+
---
166+
164167
## <a name="rn"/>Usage with React Navigation
165168
166-
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 of in a full-screen modal.
167170

168171
### <a name="setup"/>Basic Setup
169172

170173

171174
#### 1) Change `StackNavigator` to `PopoverStackNavigator`
172175

173176
`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`:
175178
176179
Option | Type | Default | Description
177180
----------- | ----------------- | ---------------------- | --------------
178181
`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`.
180183
`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.
181184
`showArrow` | boolean | true | Passed through to `Popover`
182-
`showBackground` | boolean | true | Passed through to `Popover`
185+
`showBackground` | boolean | true | Passed through to `Popover`
183186
`arrowSize` | Size | true | Passed through to `Popover`
184187

185-
Note that if you 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.
186189

187190
Example:
188-
```js
191+
```jsx
189192
import Popover, { PopoverStackNavigator } from 'react-native-popover-view';
190193
191194
let stack = PopoverStackNavigator({
@@ -224,7 +227,7 @@ let stack = PopoverStackNavigator({
224227

225228
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 class returned by `PopoverStackNavigator`:
226229

227-
```js
230+
```jsx
228231
let Stack = PopoverStackNavigator(...);
229232
...
230233
render() {
@@ -387,7 +390,7 @@ let styles = {
387390
388391
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:
389392

390-
```js
393+
```jsx
391394
let Stack = PopoverStackNavigator({
392395
View1: {
393396
screen: 'View1',
@@ -400,7 +403,7 @@ let Stack = PopoverStackNavigator({
400403
}, options);
401404
```
402405
OR
403-
```js
406+
```jsx
404407
this.props.navigation.navigate('View1', {displayArea: new Rect(0, 0, 50,50)});
405408
```
406409

@@ -423,11 +426,11 @@ Now, if your app is put into split-screen mode while the popover is still showin
423426

424427
## <a name="contributing">Contributing
425428

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.
427430

428431
## <a name="credits"/>Credits
429432

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.
431434

432435
---
433436

0 commit comments

Comments
 (0)