Skip to content

Commit

Permalink
feat: added custom ellipsis component
Browse files Browse the repository at this point in the history
  • Loading branch information
Vali-98 committed Nov 22, 2024
1 parent def8664 commit c3d8f72
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 454 deletions.
55 changes: 55 additions & 0 deletions app/components/AnimatedEllipsis.tsx
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
Loading

0 comments on commit c3d8f72

Please sign in to comment.