diff --git a/README.md b/README.md index 3c3f904a..9f34c5a7 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,8 @@ Every `CopilotStep` must have these props: 1. **name**: A unique name for the walkthrough step. 2. **order**: A positive number indicating the order of the step in the entire walkthrough. 3. **text**: The text shown as the description for the step. +4. **imageSource(optional)**: Image to be shown on the tooltip of walkthrough step. +5. **extraComponent(optional)**: Any other custom React component or React element to be shown in the tooltip of walkthrough step. In order to start the tutorial, you can call the `start` prop function in the root component that is injected by `copilot`: diff --git a/src/components/ConnectedCopilotStep.js b/src/components/ConnectedCopilotStep.js index ba12c13c..017511fe 100644 --- a/src/components/ConnectedCopilotStep.js +++ b/src/components/ConnectedCopilotStep.js @@ -7,6 +7,8 @@ type Props = { name: string, text: string, order: number, + imageSource: string, + extraComponent: React$Element, _copilot: CopilotContext, children: React$Element }; @@ -17,6 +19,8 @@ class ConnectedCopilotStep extends Component { name: this.props.name, text: this.props.text, order: this.props.order, + imageSource: this.props.imageSource, + extraComponent: this.props.extraComponent, target: this, wrapper: this.wrapper, }); diff --git a/src/components/Tooltip.js b/src/components/Tooltip.js index 94c2a7fa..eed192ad 100644 --- a/src/components/Tooltip.js +++ b/src/components/Tooltip.js @@ -1,6 +1,6 @@ // @flow import React from 'react'; -import { View, Text, TouchableOpacity } from 'react-native'; +import { View, Text, Image, TouchableOpacity } from 'react-native'; import Button from './Button'; @@ -24,37 +24,45 @@ const Tooltip = ({ handlePrev, handleStop, currentStep, -}: Props) => ( - - - {currentStep.text} +}: Props) => { + return ( + + + {currentStep.extraComponent} + + + + + + {currentStep.text} + + + { + !isLastStep ? + + + + : null + } + { + !isFirstStep ? + + + + : null + } + { + !isLastStep ? + + + : + + + + } + - - { - !isLastStep ? - - - - : null - } - { - !isFirstStep ? - - - - : null - } - { - !isLastStep ? - - - : - - - - } - - -); + ) +}; export default Tooltip; diff --git a/src/components/style.js b/src/components/style.js index ce9fdfcd..a31cdbc7 100644 --- a/src/components/style.js +++ b/src/components/style.js @@ -32,6 +32,16 @@ export default StyleSheet.create({ }, tooltipText: { + }, + extraComponentContainer: { + flex: 1, + justifyContent: 'center', + alignItems: 'center', + }, + imageContainer: { + flex: 1, + justifyContent: 'center', + alignItems: 'center', }, tooltipContainer: { flex: 1,