Skip to content

Commit

Permalink
fix: fixed problems with animation of icon in expo-vector-icons 14
Browse files Browse the repository at this point in the history
  • Loading branch information
RichardLindhout committed Jan 7, 2025
1 parent a512951 commit 4ee5b4f
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 37 deletions.
Binary file modified .yarn/install-state.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"dependencies": {
"@expo/metro-runtime": "~4.0.0",
"@expo/vector-icons": "^13.0.0",
"@expo/vector-icons": "^14.0.4",
"expo": "~52.0.23",
"expo-build-properties": "~0.13.1",
"expo-status-bar": "~2.0.0",
Expand Down
27 changes: 2 additions & 25 deletions src/MaterialCommunityIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { StyleSheet, Animated } from 'react-native';
import { Animated } from 'react-native';

let MaterialCommunityIcons: any;

Expand Down Expand Up @@ -39,27 +39,4 @@ try {
};
}

const defaultIcon = ({ name, color, size, style, ...rest }: any) => (
<MaterialCommunityIcons
selectable={false}
name={name}
color={color}
size={size}
style={[
{
lineHeight: size,
},
styles.icon,
style,
]}
{...rest}
/>
);

const styles = StyleSheet.create({
icon: {
backgroundColor: 'transparent',
},
});

export default defaultIcon;
export default MaterialCommunityIcons;
32 changes: 24 additions & 8 deletions src/TabsHeaderItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,30 @@ export default function TabsHeaderItem({
iconPosition !== 'top' && styles.marginRight,
]}
>
<MaterialCommunityIcon
selectable={false}
accessibilityElementsHidden={true}
importantForAccessibility="no"
name={tab.props.icon || ''}
style={{ color: color, opacity }}
size={24}
/>
{/*<AnimatedText style={{ color, opacity }}>BB</AnimatedText>*/}
{tab.props.icon ? (
Platform.OS === 'android' ? (
<Animated.View style={{ opacity }}>
<MaterialCommunityIcon
selectable={false}
accessibilityElementsHidden={true}
importantForAccessibility="no"
name={tab.props.icon}
color={textColor}
size={24}
/>
</Animated.View>
) : (
<MaterialCommunityIcon
selectable={false}
accessibilityElementsHidden={true}
importantForAccessibility="no"
name={tab.props.icon}
style={{ color, opacity }}
size={24}
/>
)
) : null}
</View>
) : null}
{badgeIsFilled ? (
Expand Down
2 changes: 1 addition & 1 deletion src/internal.native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function useAnimatedText({
color:
childrenA.length <= 1
? activeColor
: positionWithOffset.interpolate({
: positionWithOffset!.interpolate({
inputRange: inputRange,
outputRange: childrenA.map((_, i) =>
i === tabIndex ? activeColor : textColor
Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2272,7 +2272,7 @@ __metadata:
languageName: node
linkType: hard

"@expo/vector-icons@npm:^14.0.0":
"@expo/vector-icons@npm:^14.0.0, @expo/vector-icons@npm:^14.0.4":
version: 14.0.4
resolution: "@expo/vector-icons@npm:14.0.4"
dependencies:
Expand Down Expand Up @@ -11914,7 +11914,7 @@ __metadata:
dependencies:
"@babel/core": ^7.20.0
"@expo/metro-runtime": ~4.0.0
"@expo/vector-icons": ^13.0.0
"@expo/vector-icons": ^14.0.4
expo: ~52.0.23
expo-build-properties: ~0.13.1
expo-status-bar: ~2.0.0
Expand Down

0 comments on commit 4ee5b4f

Please sign in to comment.