react-native-copilot
Version:
Make an interactive step by step tour guide for you react-native app
63 lines (56 loc) • 1.43 kB
JavaScript
// @flow
import React from 'react';
import { View, Text, TouchableOpacity } from 'react-native';
import Button from './Button';
import styles from './style';
import type { Step } from '../types';
type Props = {
isFirstStep: boolean,
isLastStep: boolean,
handleNext: func,
handlePrev: func,
handleStop: func,
currentStep: Step,
labels: Object,
};
const Tooltip = ({
isFirstStep,
isLastStep,
handleNext,
handlePrev,
handleStop,
currentStep,
labels,
}: Props) => (
<View>
<View style={styles.tooltipContainer}>
<Text testID="stepDescription" style={styles.tooltipText}>{currentStep.text}</Text>
</View>
<View style={[styles.bottomBar]}>
{
!isLastStep ?
<TouchableOpacity onPress={handleStop}>
<Button>{labels.skip || 'Skip'}</Button>
</TouchableOpacity>
: null
}
{
!isFirstStep ?
<TouchableOpacity onPress={handlePrev}>
<Button>{labels.previous || 'Previous'}</Button>
</TouchableOpacity>
: null
}
{
!isLastStep ?
<TouchableOpacity onPress={handleNext}>
<Button>{labels.next || 'Next'}</Button>
</TouchableOpacity> :
<TouchableOpacity onPress={handleStop}>
<Button>{labels.finish || 'Finish'}</Button>
</TouchableOpacity>
}
</View>
</View>
);
export default Tooltip;