Skip to content

Commit 88bfa78

Browse files
committed
Add feature to handle clicks on Copilot Walkthroughables
Fix issue #6 only for view overlays
1 parent 1fbf8fd commit 88bfa78

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

src/components/ViewMask.js

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// @flow
22
import React, { Component } from 'react';
3-
4-
import { View, Animated, I18nManager } from 'react-native';
3+
import PropTypes from 'prop-types';
4+
import { View, Animated, I18nManager, TouchableOpacity } from 'react-native';
55
import styles from './style';
66

7-
import type { valueXY } from '../types';
7+
import type { CopilotContext, valueXY } from '../types';
88

99

1010
const rtl = I18nManager.isRTL;
@@ -31,6 +31,10 @@ type State = {
3131
};
3232

3333
class ViewMask extends Component<Props, State> {
34+
static contextTypes = {
35+
_copilot: PropTypes.object,
36+
}
37+
3438
state = {
3539
size: new Animated.ValueXY({ x: 0, y: 0 }),
3640
position: new Animated.ValueXY({ x: 0, y: 0 }),
@@ -42,6 +46,10 @@ class ViewMask extends Component<Props, State> {
4246
}
4347
}
4448

49+
context: {
50+
_copilot: CopilotContext,
51+
}
52+
4553
animate = (size: valueXY = this.props.size, position: valueXY = this.props.position): void => {
4654
if (this.state.animated) {
4755
Animated.parallel([
@@ -113,6 +121,17 @@ class ViewMask extends Component<Props, State> {
113121
},
114122
]}
115123
/>
124+
<TouchableOpacity
125+
style={{
126+
backgroundColor: 'transparent',
127+
[start]: this.props.position.x,
128+
[end]: (this.props.layout.width - (this.props.size.x + this.props.position.x)),
129+
top: this.props.position.y,
130+
width: this.props.size.x,
131+
height: this.props.size.y,
132+
}}
133+
onPress={this.context._copilot.getCurrentStep().target.props.children.props.onPress || null}
134+
/>
116135
</View>
117136
);
118137
}

0 commit comments

Comments
 (0)