Skip to content

Commit

Permalink
Add feature to handle clicks on Copilot Walkthroughables
Browse files Browse the repository at this point in the history
Fix issue #6 only for view overlays
  • Loading branch information
iamsoorena committed Sep 2, 2018
1 parent 1fbf8fd commit 88bfa78
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions src/components/ViewMask.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// @flow
import React, { Component } from 'react';

import { View, Animated, I18nManager } from 'react-native';
import PropTypes from 'prop-types';
import { View, Animated, I18nManager, TouchableOpacity } from 'react-native';
import styles from './style';

import type { valueXY } from '../types';
import type { CopilotContext, valueXY } from '../types';


const rtl = I18nManager.isRTL;
Expand All @@ -31,6 +31,10 @@ type State = {
};

class ViewMask extends Component<Props, State> {
static contextTypes = {
_copilot: PropTypes.object,
}

state = {
size: new Animated.ValueXY({ x: 0, y: 0 }),
position: new Animated.ValueXY({ x: 0, y: 0 }),
Expand All @@ -42,6 +46,10 @@ class ViewMask extends Component<Props, State> {
}
}

context: {
_copilot: CopilotContext,
}

animate = (size: valueXY = this.props.size, position: valueXY = this.props.position): void => {
if (this.state.animated) {
Animated.parallel([
Expand Down Expand Up @@ -113,6 +121,17 @@ class ViewMask extends Component<Props, State> {
},
]}
/>
<TouchableOpacity
style={{
backgroundColor: 'transparent',
[start]: this.props.position.x,
[end]: (this.props.layout.width - (this.props.size.x + this.props.position.x)),
top: this.props.position.y,
width: this.props.size.x,
height: this.props.size.y,
}}
onPress={this.context._copilot.getCurrentStep().target.props.children.props.onPress || null}
/>
</View>
);
}
Expand Down

0 comments on commit 88bfa78

Please sign in to comment.