Skip to content

Commit

Permalink
Made a fix to highlight the button border correctly for apple and and…
Browse files Browse the repository at this point in the history
…roid tv
  • Loading branch information
tarunkgarg committed Feb 20, 2024
1 parent 00122b5 commit af02902
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/uikit/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ const Button = ({

const isUppercase = uppercase != null ? uppercase : false;

const underlayColor = isDisabled ? 'colors.grey[200]' : 'black';

const [isFocused, setIsFocused] = useState(false);

if (isUppercase) {
textStyles.push(styles.textUppercase);
pressedTextStyles.push(styles.textUppercase);
Expand Down Expand Up @@ -146,15 +150,27 @@ const Button = ({
// return ButtonMode.Done
return <Icon key="successKey" name="success" color={iconColor} />;
};
const [isFocused, setIsFocused] = useState(false);

const getButtonStyleByState = (): any[] => {
let finalStyle = buttonStyles;
if (isDisabled && isFocused) {
// add tv style
finalStyle.push(Platform.isTV ? styles.tvOSPrimaryButtonPressed : {});
} else if (isFocused) {
finalStyle = pressedButtonStyles;
}
return finalStyle;
};

return Platform.isTV ? (
<TouchableHighlight
onFocus={() => setIsFocused(true)}
onBlur={() => setIsFocused(false)}
onPress={onPress}
style={[isFocused ? pressedButtonStyles : buttonStyles, getStyleBySize(size)]}
style={[getButtonStyleByState(), getStyleBySize(size)]}
disabled={disabled}
testID={testID}
underlayColor={underlayColor}
>
{getButtonByMode({ mode, isPressed: isFocused })}
</TouchableHighlight>
Expand Down

0 comments on commit af02902

Please sign in to comment.