-
Notifications
You must be signed in to change notification settings - Fork 132
Expand file tree
/
Copy pathGraphEventTooltip.tsx
More file actions
68 lines (63 loc) · 1.66 KB
/
GraphEventTooltip.tsx
File metadata and controls
68 lines (63 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import React from 'react'
import Animated, { FadeIn, FadeOut } from 'react-native-reanimated'
import { Dimensions, Platform, StyleSheet, Text, View } from 'react-native'
import { EventTooltipComponentProps } from '../../../src/LineGraphProps'
export type TransactionEventTooltipProps = EventTooltipComponentProps<{}>
const SCREEN_WIDTH = Dimensions.get('screen').width
const ANIMATION_DURATION = 200
const TOOLTIP_LEFT_OFFSET = 25
const TOOLTIP_RIGHT_OFFSET = 145
export const GraphEventTooltip = ({
eventX,
eventY,
}: TransactionEventTooltipProps) => {
const tooltipPositionStyle = {
left:
eventX > SCREEN_WIDTH / 2
? eventX - TOOLTIP_RIGHT_OFFSET
: eventX + TOOLTIP_LEFT_OFFSET,
top: eventY,
}
return (
<Animated.View
style={[styles.tooltip, tooltipPositionStyle]}
entering={FadeIn.duration(ANIMATION_DURATION)}
exiting={FadeOut.duration(ANIMATION_DURATION)}
>
<View style={styles.content}>
<Text style={styles.textNote}>
Here you can display {'\n'}
any information you {'\n'}
want about the event.
</Text>
</View>
</Animated.View>
)
}
const styles = StyleSheet.create({
tooltip: {
position: 'absolute',
backgroundColor: 'white',
paddingHorizontal: 10,
borderRadius: 20,
// add shadow based on platform
...Platform.select({
ios: {
shadowColor: 'black',
shadowOffset: { width: 0, height: 2 },
shadowOpacity: 0.5,
shadowRadius: 3,
},
android: {
elevation: 3,
},
}),
},
content: {
paddingVertical: 12,
},
textNote: {
color: 'gray',
fontSize: 10,
},
})