-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHeader.tsx
More file actions
59 lines (55 loc) · 1.32 KB
/
Copy pathHeader.tsx
File metadata and controls
59 lines (55 loc) · 1.32 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
import React from "react";
import { Dimensions, StyleSheet, Text, View } from "react-native";
import Animated, {
interpolate,
useDerivedValue,
} from "react-native-reanimated";
import { ReText } from "react-native-redash";
const { width } = Dimensions.get("window");
type Props = {
y: Animated.SharedValue<number>;
x: Animated.SharedValue<number>;
minMaxTime: { minTime: number; maxTime: number };
};
export const Header = ({ y, x, minMaxTime }: Props) => {
const price = useDerivedValue(() => {
const p = interpolate(y.value, [200, 0], [0, 300]);
return `$ ${p.toLocaleString()}`;
});
const date = useDerivedValue(() => {
const d = interpolate(
x.value,
[20, 335],
[minMaxTime.minTime, minMaxTime.maxTime]
);
return `${new Date(d).toUTCString()}`;
});
return (
<View style={styles.container}>
<View style={styles.values}>
<View>
<Text style={styles.label}>HKD</Text>
<ReText text={price}></ReText>
<ReText text={date}></ReText>
</View>
</View>
</View>
);
};
const styles = StyleSheet.create({
container: {
padding: 16,
},
values: {
marginTop: 16,
flexDirection: "row",
justifyContent: "space-between",
},
value: {
fontWeight: "500",
fontSize: 24,
},
label: {
fontSize: 18,
},
});