Skip to content

Commit

Permalink
chore: sync with rainbow
Browse files Browse the repository at this point in the history
  • Loading branch information
osdnk committed Mar 12, 2021
1 parent 52c8b2f commit 4eb0d28
Show file tree
Hide file tree
Showing 7 changed files with 205 additions and 192 deletions.
17 changes: 2 additions & 15 deletions src/charts/linear/ChartDot.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,10 @@
import React, { useContext } from 'react';
// eslint-disable-next-line import/no-unresolved
import Animated, { useAnimatedStyle } from 'react-native-reanimated';
import Animated from 'react-native-reanimated';
import ChartContext from '../../helpers/ChartContext';
import withReanimatedFallback from '../../helpers/withReanimatedFallback';

function ChartDot({ style, size = 10, ...props }) {
const { dotScale, positionX, positionY } = useContext(ChartContext);
const dotStyle = useAnimatedStyle(
() => ({
opacity: dotScale.value,
transform: [
{ translateX: positionX.value },
{ translateY: positionY.value + 10 }, // TODO temporary fix for clipped chart
{ scale: dotScale.value },
],
}),
undefined,
'dotStyle'
);
const { dotStyle } = useContext(ChartContext);

return (
<Animated.View
Expand Down
25 changes: 8 additions & 17 deletions src/charts/linear/ChartLabels.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { TextInput } from 'react-native';
import Animated, {
useAnimatedStyle,
useDerivedValue,
// eslint-disable-next-line import/no-unresolved
} from 'react-native-reanimated';
import ChartContext from '../../helpers/ChartContext';

Expand All @@ -12,22 +11,14 @@ const AnimatedTextInput = Animated.createAnimatedComponent(TextInput);
function ChartLabelFactory(style) {
return function ChartLabel({ format, ...props }) {
const { [style]: val = 0 } = useContext(ChartContext);
const formattedValue = useDerivedValue(
() => {
return format ? format(val.value) : val.value;
},
undefined,
style + 'formattedValue'
);
const textProps = useAnimatedStyle(
() => {
return {
text: formattedValue.value,
};
},
undefined,
style + 'textProps'
);
const formattedValue = useDerivedValue(() => {
return format ? format(val.value) : val.value;
}, []);
const textProps = useAnimatedStyle(() => {
return {
text: formattedValue.value,
};
}, []);
return (
<AnimatedTextInput
{...props}
Expand Down
Loading

0 comments on commit 4eb0d28

Please sign in to comment.