Skip to content

Commit

Permalink
Merge pull request #47485 from bernhardoj/fix/47381-blue-outline-is-v…
Browse files Browse the repository at this point in the history
…ery-light

Fix blue outline is almost not visible in tab bar button
  • Loading branch information
flodnv authored Aug 16, 2024
2 parents cf897a0 + e2874ef commit 5d09846
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions src/components/TabSelector/TabSelectorItem.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import React from 'react';
import {Animated, StyleSheet} from 'react-native';
import React, {useState} from 'react';
import {Animated} from 'react-native';
import PressableWithFeedback from '@components/Pressable/PressableWithFeedback';
import useThemeStyles from '@hooks/useThemeStyles';
import CONST from '@src/CONST';
import type IconAsset from '@src/types/utils/IconAsset';
import TabIcon from './TabIcon';
import TabLabel from './TabLabel';

const AnimatedPressableWithFeedback = Animated.createAnimatedComponent(PressableWithFeedback);

type TabSelectorItemProps = {
/** Function to call when onPress */
onPress?: () => void;
Expand All @@ -32,29 +34,29 @@ type TabSelectorItemProps = {

function TabSelectorItem({icon, title = '', onPress = () => {}, backgroundColor = '', activeOpacity = 0, inactiveOpacity = 1, isActive = false}: TabSelectorItemProps) {
const styles = useThemeStyles();
const [isHovered, setIsHovered] = useState(false);

return (
<PressableWithFeedback
<AnimatedPressableWithFeedback
accessibilityLabel={title}
style={[styles.tabSelectorButton]}
style={[styles.tabSelectorButton, styles.tabBackground(isHovered, isActive, backgroundColor)]}
wrapperStyle={[styles.flex1]}
onPress={onPress}
onHoverIn={() => setIsHovered(true)}
onHoverOut={() => setIsHovered(false)}
role={CONST.ROLE.BUTTON}
>
{({hovered}) => (
<Animated.View style={[styles.tabSelectorButton, StyleSheet.absoluteFill, styles.tabBackground(hovered, isActive, backgroundColor)]}>
<TabIcon
icon={icon}
activeOpacity={styles.tabOpacity(hovered, isActive, activeOpacity, inactiveOpacity).opacity}
inactiveOpacity={styles.tabOpacity(hovered, isActive, inactiveOpacity, activeOpacity).opacity}
/>
<TabLabel
title={title}
activeOpacity={styles.tabOpacity(hovered, isActive, activeOpacity, inactiveOpacity).opacity}
inactiveOpacity={styles.tabOpacity(hovered, isActive, inactiveOpacity, activeOpacity).opacity}
/>
</Animated.View>
)}
</PressableWithFeedback>
<TabIcon
icon={icon}
activeOpacity={styles.tabOpacity(isHovered, isActive, activeOpacity, inactiveOpacity).opacity}
inactiveOpacity={styles.tabOpacity(isHovered, isActive, inactiveOpacity, activeOpacity).opacity}
/>
<TabLabel
title={title}
activeOpacity={styles.tabOpacity(isHovered, isActive, activeOpacity, inactiveOpacity).opacity}
inactiveOpacity={styles.tabOpacity(isHovered, isActive, inactiveOpacity, activeOpacity).opacity}
/>
</AnimatedPressableWithFeedback>
);
}

Expand Down

0 comments on commit 5d09846

Please sign in to comment.