Skip to content

Commit 96f6bae

Browse files
author
Anupriy R
committed
Feat: Support image in tooltip
1 parent 493e532 commit 96f6bae

File tree

3 files changed

+44
-32
lines changed

3 files changed

+44
-32
lines changed

src/components/ConnectedCopilotStep.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ type Props = {
77
name: string,
88
text: string,
99
order: number,
10+
imageSource: string,
1011
_copilot: CopilotContext,
1112
children: React$Element
1213
};
@@ -17,6 +18,7 @@ class ConnectedCopilotStep extends Component<Props> {
1718
name: this.props.name,
1819
text: this.props.text,
1920
order: this.props.order,
21+
imageSource: this.props.imageSource,
2022
target: this,
2123
wrapper: this.wrapper,
2224
});

src/components/Tooltip.js

Lines changed: 37 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// @flow
22
import React from 'react';
3-
import { View, Text, TouchableOpacity } from 'react-native';
3+
import { View, Text, Image, TouchableOpacity } from 'react-native';
44

55
import Button from './Button';
66

@@ -24,37 +24,42 @@ const Tooltip = ({
2424
handlePrev,
2525
handleStop,
2626
currentStep,
27-
}: Props) => (
28-
<View>
29-
<View style={styles.tooltipContainer}>
30-
<Text testID="stepDescription" style={styles.tooltipText}>{currentStep.text}</Text>
27+
}: Props) => {
28+
return (
29+
<View>
30+
<View style={styles.imageContainer}>
31+
<Image style={{ flex: 1 }} source={currentStep.imageSource} />
32+
</View>
33+
<View style={styles.tooltipContainer}>
34+
<Text testID="stepDescription" style={styles.tooltipText}>{currentStep.text}</Text>
35+
</View>
36+
<View style={[styles.bottomBar]}>
37+
{
38+
!isLastStep ?
39+
<TouchableOpacity onPress={handleStop}>
40+
<Button>Skip</Button>
41+
</TouchableOpacity>
42+
: null
43+
}
44+
{
45+
!isFirstStep ?
46+
<TouchableOpacity onPress={handlePrev}>
47+
<Button>Previous</Button>
48+
</TouchableOpacity>
49+
: null
50+
}
51+
{
52+
!isLastStep ?
53+
<TouchableOpacity onPress={handleNext}>
54+
<Button>Next</Button>
55+
</TouchableOpacity> :
56+
<TouchableOpacity onPress={handleStop}>
57+
<Button>Finish</Button>
58+
</TouchableOpacity>
59+
}
60+
</View>
3161
</View>
32-
<View style={[styles.bottomBar]}>
33-
{
34-
!isLastStep ?
35-
<TouchableOpacity onPress={handleStop}>
36-
<Button>Skip</Button>
37-
</TouchableOpacity>
38-
: null
39-
}
40-
{
41-
!isFirstStep ?
42-
<TouchableOpacity onPress={handlePrev}>
43-
<Button>Previous</Button>
44-
</TouchableOpacity>
45-
: null
46-
}
47-
{
48-
!isLastStep ?
49-
<TouchableOpacity onPress={handleNext}>
50-
<Button>Next</Button>
51-
</TouchableOpacity> :
52-
<TouchableOpacity onPress={handleStop}>
53-
<Button>Finish</Button>
54-
</TouchableOpacity>
55-
}
56-
</View>
57-
</View>
58-
);
62+
)
63+
};
5964

6065
export default Tooltip;

src/components/style.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ export default StyleSheet.create({
3232
},
3333
tooltipText: {
3434

35+
},
36+
imageContainer: {
37+
flex: 1,
38+
justifyContent: 'center',
39+
alignItems: 'center',
3540
},
3641
tooltipContainer: {
3742
flex: 1,

0 commit comments

Comments
 (0)