-
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added custom ellipsis component
- Loading branch information
Showing
3 changed files
with
55 additions
and
454 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { Octicons } from '@expo/vector-icons' | ||
import { Style } from '@globals' | ||
import { useEffect } from 'react' | ||
import { View } from 'react-native' | ||
import Animated, { | ||
SharedValue, | ||
useAnimatedStyle, | ||
useSharedValue, | ||
withRepeat, | ||
withTiming, | ||
} from 'react-native-reanimated' | ||
|
||
const translateMax = -15 | ||
|
||
type DotProps = { | ||
dx: SharedValue<number> | ||
offset: number | ||
} | ||
|
||
const Dot: React.FC<DotProps> = ({ dx, offset }) => { | ||
const animatedStyle = useAnimatedStyle(() => ({ | ||
transform: [{ translateY: Math.max(Math.sin(dx.value - offset), 0) * translateMax }], | ||
})) | ||
|
||
return ( | ||
<Animated.View style={[animatedStyle]}> | ||
<Octicons name="dot-fill" size={8} color={Style.getColor('primary-text2')} /> | ||
</Animated.View> | ||
) | ||
} | ||
|
||
const AnimatedEllipsis = () => { | ||
const dx = useSharedValue(Math.PI * 2) | ||
|
||
useEffect(() => { | ||
dx.value = withRepeat(withTiming(0, { duration: 1200 }), -1) | ||
}, []) | ||
|
||
return ( | ||
<View | ||
style={{ | ||
flexDirection: 'row', | ||
paddingTop: 20, | ||
paddingBottom: 8, | ||
paddingHorizontal: 12, | ||
columnGap: 8, | ||
}}> | ||
<Dot dx={dx} offset={1.2} /> | ||
<Dot dx={dx} offset={0.6} /> | ||
<Dot dx={dx} offset={0} /> | ||
</View> | ||
) | ||
} | ||
|
||
export default AnimatedEllipsis |
Oops, something went wrong.