import { createBlankStackNavigator } from "react-native-screen-transitions/blank-stack";
import Transition from "react-native-screen-transitions";
import Animated, { interpolate } from "react-native-reanimated";
import { View, Text, TouchableOpacity } from "react-native";
const Stack = createBlankStackNavigator();
function TabBar({ focusedRoute, focusedIndex, routes, progress, navigation }) {
"worklet";
// Hide tab bar when detail screen is active
const opacity = interpolate(
progress,
[0, 0.5, 1],
[1, 0.5, 0]
);
return (
<Animated.View
style={{
position: "absolute",
bottom: 0,
left: 0,
right: 0,
height: 50,
backgroundColor: "#fff",
flexDirection: "row",
borderTopWidth: 1,
borderTopColor: "#eee",
opacity,
}}
>
{routes.map((route, index) => (
<TouchableOpacity
key={route.key}
style={{ flex: 1, justifyContent: "center", alignItems: "center" }}
onPress={() => navigation.navigate(route.name)}
>
<Text
style={{
color: focusedIndex === index ? "#007AFF" : "#999",
fontSize: 12,
}}
>
{route.name}
</Text>
</TouchableOpacity>
))}
</Animated.View>
);
}
function HomeScreen({ navigation }) {
return (
<View style={{ flex: 1, justifyContent: "center", paddingBottom: 50 }}>
<TouchableOpacity onPress={() => navigation.navigate("Detail")}>
<Text>Open Detail</Text>
</TouchableOpacity>
</View>
);
}
function DetailScreen() {
return <View style={{ flex: 1, backgroundColor: "#fff" }} />;
}
export default function App() {
return (
<Stack.Navigator
screenOptions={{ headerShown: false }}
overlay={TabBar}
>
<Stack.Screen name="Home" component={HomeScreen} />
<Stack.Screen
name="Detail"
component={DetailScreen}
options={{
...Transition.Presets.SlideFromBottom(),
gestureEnabled: true,
gestureDirection: "vertical",
}}
/>
</Stack.Navigator>
);
}