Skip to content

Commit b7541da

Browse files
committed
fix: fixes the sharp curvy tab scaling issues while active
1 parent 1c56a13 commit b7541da

5 files changed

Lines changed: 14 additions & 33 deletions

File tree

example/app/(tabs)/_layout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Ionicons } from "@expo/vector-icons";
22
import { Tabs } from "expo-router";
33
import React from "react";
4-
// import { ExpandBarTab } from "react-native-floating-tab";
4+
import { ElevatedTab, ExpandBarTab, RollingBallTab, SharpCurvyTab, SlideBarTab } from "react-native-floating-tab";
55

66
import { Colors } from "@/constants/Colors";
77
import { useColorScheme } from "@/hooks/useColorScheme";
@@ -18,7 +18,7 @@ export default function TabLayout() {
1818
initialRouteName="index"
1919
backBehavior="history"
2020
// tabBar={props => <RollingBallTab {...props} />}
21-
// tabBar={props => <SharpCurvyTab {...props} />}
21+
tabBar={props => <SharpCurvyTab {...props} />}
2222
// tabBar={props => <SlideBarTab {...props} />}
2323
// tabBar={props => <ElevatedTab {...props} />}
2424
// tabBar={props => <ExpandBarTab {...props} />}

example/metro.config.js

Lines changed: 0 additions & 27 deletions
This file was deleted.

example/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"react": "18.2.0",
3131
"react-dom": "18.2.0",
3232
"react-native": "0.74.5",
33+
"react-native-floating-tab": "^1.0.20-beta.1",
3334
"react-native-gesture-handler": "~2.16.1",
3435
"react-native-reanimated": "~3.10.1",
3536
"react-native-safe-area-context": "4.10.5",

example/yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7053,6 +7053,11 @@ react-is@^17.0.1:
70537053
resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0"
70547054
integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==
70557055

7056+
react-native-floating-tab@^1.0.20-beta.1:
7057+
version "1.0.20-beta.1"
7058+
resolved "https://registry.yarnpkg.com/react-native-floating-tab/-/react-native-floating-tab-1.0.20-beta.1.tgz#9d8fbe99bb047876615739f74c78dd443d673e8c"
7059+
integrity sha512-sO0raa1HANIlNrFbwE1Ix/VY8g/u2GcjoS3KIGc/ljQE7oWpSl3U3nf3q2qv4rECP51OSbhhf+W0UXnQDW3nHg==
7060+
70567061
react-native-gesture-handler@~2.16.1:
70577062
version "2.16.2"
70587063
resolved "https://registry.yarnpkg.com/react-native-gesture-handler/-/react-native-gesture-handler-2.16.2.tgz#032bd2a07334292d7f6cff1dc9d1ec928f72e26d"

src/components/SharpCurvyTab/SharpCurvyTabButton.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,17 @@ const AnimatedTouchableOpacity = Animated.createAnimatedComponent(TouchableOpaci
1010

1111
export const SharpCurvyTabButton: React.FC<TTabBarButton> = ({ isFocused, label, routeName, color, icon, routes, colors, fontSize, ...props }) => {
1212
const animatedStyles = useAnimatedStyle(() => {
13+
const scale = withSpring(isFocused ? 1.4 : 1, springConfig);
14+
1315
const backgroundColor = withSpring(isFocused ? colors.focusColor : "transparent", springConfig);
1416

1517
return {
1618
backgroundColor,
17-
transform: [{ translateY: withSpring(isFocused ? -35 : 0) }],
19+
20+
transform: [isFocused ? { translateY: withSpring(-35) } : { translateY: withSpring(0) }, { scale }],
1821
};
1922
}, [isFocused]);
23+
2024
//TODO: Work in progress
2125
// const shouldCurveFirstItem = useMemo(() => {
2226
// const index = routes.findIndex(route => route.name === routeName);
@@ -51,9 +55,7 @@ export const SharpCurvyTabButton: React.FC<TTabBarButton> = ({ isFocused, label,
5155
colors={colors}
5256
/>
5357
)}
54-
<Animated.View style={[{ transform: [{ scale: withSpring(isFocused ? 1.4 : 1, springConfig) }] }, animatedStyles, styles.iconWrapper]}>
55-
{icon}
56-
</Animated.View>
58+
<Animated.View style={[animatedStyles, styles.iconWrapper]}>{icon}</Animated.View>
5759

5860
<Text
5961
style={{

0 commit comments

Comments
 (0)