screens/FeedsScreen.js - FloatingWriteButton
<FloatingWriteButton hidden={hidden} />
components/FloatingWriteButton.js
import {useNavigation} from '@react-navigation/native'; import React, {useEffect, useRef} from 'react'; import {Platform, Pressable, StyleSheet, Animated} from 'react-native'; import Icon from 'react-native-vector-icons/MaterialIcons'; function ({hidden}) { const navigation (); const () => { navigation. ('Write'); }; const animation = useRef(new Animated.Value(0)).current; useEffect(() => { Animated.timing(animation, { toValue: hidden ? 1 : 0, useNativeDriver: true, }).start(); }, [animation, hidden]); return ( <Animated.View style={[ styles.wrapper, { transform: [ { translateY: animation.interpolate({ inputRange: [0, 1], outputRange: [0, 88], }), }, ], opacity: animation.interpolate({ inputRange: [0, 1], outputRange: [1, 0], }), }, ]}> <Pressable style={({pressed}) => [ styles.button, Platform.OS === 'ios' && { opacity: pressed ? 0.6 : 1, }, ]} android_ripple={{color: 'white'}} onPress={onPress}> <Icon name="add" size={24} style={styles.icon} /> </Pressable> </Animated.View> ); } ( )