-
-
Notifications
You must be signed in to change notification settings - Fork 412
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add onPress support in the middle of steps #71
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
// @flow | ||
import React, { Component } from 'react'; | ||
|
||
import { View, Animated } 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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm still concerned about changing the direction dynamically. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if RN's |
||
const start = rtl ? 'right' : 'left'; | ||
const end = rtl ? 'left' : 'right'; | ||
|
||
type Props = { | ||
size: valueXY, | ||
|
@@ -26,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 }), | ||
|
@@ -37,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([ | ||
|
@@ -78,23 +91,23 @@ class ViewMask extends Component<Props, State> { | |
style={[ | ||
styles.overlayRectangle, | ||
{ | ||
right: leftOverlayRight, | ||
[end]: leftOverlayRight, | ||
}]} | ||
/> | ||
<Animated.View | ||
style={[ | ||
styles.overlayRectangle, | ||
{ | ||
left: rightOverlayLeft, | ||
[start]: rightOverlayLeft, | ||
}]} | ||
/> | ||
<Animated.View | ||
style={[ | ||
styles.overlayRectangle, | ||
{ | ||
top: bottomOverlayTopBoundary, | ||
left: verticalOverlayLeftBoundary, | ||
right: verticalOverlayRightBoundary, | ||
[start]: verticalOverlayLeftBoundary, | ||
[end]: verticalOverlayRightBoundary, | ||
}, | ||
]} | ||
/> | ||
|
@@ -103,11 +116,22 @@ class ViewMask extends Component<Props, State> { | |
styles.overlayRectangle, | ||
{ | ||
bottom: topOverlayBottomBoundary, | ||
left: verticalOverlayLeftBoundary, | ||
right: verticalOverlayRightBoundary, | ||
[start]: verticalOverlayLeftBoundary, | ||
[end]: verticalOverlayRightBoundary, | ||
}, | ||
]} | ||
/> | ||
<TouchableOpacity | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we just not render |
||
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> | ||
); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason it is named "edge case"?