Skip to content

Commit 8d3cc66

Browse files
authored
Release v1.6.0 (#32)
* Explicitly do not use native animation driver * Fix pressIn animation only starts after moving * Release v1.6.0 * Update readme on new props with example
1 parent 46697fc commit 8d3cc66

File tree

4 files changed

+18
-9
lines changed

4 files changed

+18
-9
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ const renderCustomPopup = ({ appIconSource, appTitle, timeText, title, body }) =
6767
<View>
6868
<Text>{title}</Text>
6969
<Text>{body}</Text>
70+
<Button title='My button' onPress={() => console.log('Popup button onPress!')} />
7071
</View>
7172
);
7273

@@ -76,7 +77,9 @@ class MyComponent extends React.Component {
7677
<View style={styles.container}>
7778
<NotificationPopup
7879
ref={ref => this.popup = ref}
79-
renderPopupContent={renderCustomPopup} />
80+
renderPopupContent={renderCustomPopup}
81+
shouldChildHandleResponderStart={true}
82+
shouldChildHandleResponderMove={true} />
8083
</View>
8184
);
8285
}
@@ -104,6 +107,8 @@ componentDidMount() {
104107
| Param | Type | Default | Description |
105108
| --- | --- | --- | --- |
106109
| **`renderPopupContent`** | function <br /> `(options?: { appIconSource?: ImageSourcePropType; appTitle?: string; timeText?: string; title?: string;body?: string; }) => React.ReactElement<any>` | null | Render your own custom popup body (Optional) |
110+
| **`shouldChildHandleResponderStart`** | boolean | false | By default, parent popup will prevent bubbling event to child. This should be set to true if you have button inside your custom popup that wants to receive the event. |
111+
| **`shouldChildHandleResponderMove`** | boolean | false | By default, parent popup will prevent bubbling event to child. This should be set to true if you have button inside your custom popup that wants to receive the event. |
107112
108113
### Methods
109114

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-push-notification-popup",
3-
"version": "1.5.0",
3+
"version": "1.6.0",
44
"description": "React Native Push Notification Popup Component",
55
"main": "src/index.js",
66
"types": "./types.d.ts",

src/views/DefaultPopup.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ export default class DefaultPopup extends Component {
4343

4444
static propTypes = {
4545
renderPopupContent: PropTypes.func,
46+
shouldChildHandleResponderStart: PropTypes.bool,
47+
shouldChildHandleResponderMove: PropTypes.bool,
4648
}
4749

4850
constructor(props) {
@@ -74,9 +76,9 @@ export default class DefaultPopup extends Component {
7476
};
7577
this._panResponder = PanResponder.create({
7678
onStartShouldSetPanResponder: (e, gestureState) => true,
77-
// onStartShouldSetPanResponderCapture: (e, gestureState) => false,
79+
onStartShouldSetPanResponderCapture: (e, gestureState) => props.shouldChildHandleResponderStart ? false : true, // Capture child event
7880
onMoveShouldSetPanResponder: (e, gestureState) => true,
79-
// onMoveShouldSetPanResponderCapture: (e, gestureState) => false,
81+
onMoveShouldSetPanResponderCapture: (e, gestureState) => props.shouldChildHandleResponderMove ? false : true, // Capture child event
8082
onPanResponderGrant: this._onPanResponderGrant,
8183
onPanResponderMove: this._onPanResponderMove,
8284
onPanResponderRelease: this._onPanResponderRelease,
@@ -118,7 +120,7 @@ export default class DefaultPopup extends Component {
118120
} else {
119121
// 2. If not leaving screen -> slide back to original position
120122
this.clearTimerIfExist();
121-
Animated.timing(containerDragOffsetY, { toValue: 0, duration: 200, useNativeDriver: true })
123+
Animated.timing(containerDragOffsetY, { toValue: 0, duration: 200, useNativeDriver: false })
122124
.start(({finished}) => {
123125
// Reset a new countdown
124126
this.countdownToSlideOut();
@@ -190,15 +192,15 @@ export default class DefaultPopup extends Component {
190192
// console.log('PressIn!'); // DEBUG
191193
// Show feedback as soon as user press down
192194
const { containerScale } = this.state;
193-
Animated.spring(containerScale, { toValue: 0.95, friction: 8, useNativeDriver: true })
195+
Animated.spring(containerScale, { toValue: 0.95, friction: 8, useNativeDriver: false })
194196
.start();
195197
}
196198

197199
onPressOutFeedback = () => {
198200
// console.log('PressOut!'); // DEBUG
199201
// Show feedback as soon as user press down
200202
const { containerScale } = this.state;
201-
Animated.spring(containerScale, { toValue: 1, friction: 8, useNativeDriver: true })
203+
Animated.spring(containerScale, { toValue: 1, friction: 8, useNativeDriver: false })
202204
.start();
203205
}
204206

@@ -220,7 +222,7 @@ export default class DefaultPopup extends Component {
220222
slideIn = (duration) => {
221223
// Animate "this.state.containerSlideOffsetY"
222224
const { containerSlideOffsetY } = this.state; // Using the new one is fine
223-
Animated.timing(containerSlideOffsetY, { toValue: 1, duration: duration || 400, useNativeDriver: true }) // TODO: customize
225+
Animated.timing(containerSlideOffsetY, { toValue: 1, duration: duration || 400, useNativeDriver: false }) // TODO: customize
224226
.start(({finished}) => {
225227
this.countdownToSlideOut();
226228
});
@@ -237,7 +239,7 @@ export default class DefaultPopup extends Component {
237239
const { containerSlideOffsetY } = this.state;
238240

239241
// Reset animation to 0 && show it && animate
240-
Animated.timing(containerSlideOffsetY, { toValue: 0, duration: duration || 400, useNativeDriver: true }) // TODO: customize
242+
Animated.timing(containerSlideOffsetY, { toValue: 0, duration: duration || 400, useNativeDriver: false }) // TODO: customize
241243
.start(({finished}) => {
242244
// Reset everything and hide the popup
243245
this.setState({ show: false });

types.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ declare module "react-native-push-notification-popup" {
2020

2121
interface PushNotificationPopupProps {
2222
renderPopupContent?: (options: ContentOptionsBase) => ReactElement;
23+
shouldChildHandleResponderStart?: boolean;
24+
shouldChildHandleResponderMove?: boolean;
2325
}
2426

2527
export default class ReactNativePushNotificationPopup extends Component<PushNotificationPopupProps, any> {

0 commit comments

Comments
 (0)