-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
animated wallet connector menu button arrow
- Loading branch information
1 parent
6126d7d
commit 22a1e32
Showing
2 changed files
with
51 additions
and
11 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
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,48 @@ | ||
import React, { useEffect, useRef } from 'react'; | ||
import { Animated } from 'react-native'; | ||
import { backIconUri } from './assets'; | ||
import { Colors } from '../../utils/colors'; | ||
|
||
interface RotatingArrowIconProps { | ||
openDropdown: boolean; | ||
} | ||
|
||
export const RotatingArrowIcon = (props: RotatingArrowIconProps) => { | ||
const { openDropdown } = props; | ||
|
||
const rotationAnim = useRef(new Animated.Value(0)).current; | ||
|
||
const rotation = rotationAnim.interpolate({ | ||
inputRange: [0, 1], | ||
outputRange: ['0deg', '-90deg'], | ||
}); | ||
|
||
const startRotation = () => { | ||
Animated.timing(rotationAnim, { | ||
toValue: openDropdown ? 1 : 0, | ||
duration: 50, | ||
useNativeDriver: true, | ||
}).start(); | ||
}; | ||
|
||
useEffect(() => { | ||
startRotation(); | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [openDropdown]); | ||
|
||
return ( | ||
<Animated.Image | ||
source={{ uri: backIconUri }} | ||
resizeMode="contain" | ||
style={[styles.arrowIcon, { transform: [{ rotate: rotation }] }]} | ||
/> | ||
); | ||
}; | ||
|
||
const styles = { | ||
arrowIcon: { | ||
width: 15, | ||
height: 15, | ||
tintColor: Colors.white, | ||
}, | ||
}; |