diff options
author | Paul Frazee <pfrazee@gmail.com> | 2023-05-17 12:30:54 -0500 |
---|---|---|
committer | Paul Frazee <pfrazee@gmail.com> | 2023-05-17 12:30:54 -0500 |
commit | 7aa1d9010e26da14a843efab0389386144cc978a (patch) | |
tree | 31ac7916fd7e1045bce0a078d67cc1164cc2e42f /src/view/com/util/forms/Button.tsx | |
parent | 52c72d65326c2df6ada7547103c18ed41b51ebda (diff) | |
parent | 0ca096138a690f036828c49f9e95cf394b1a4339 (diff) | |
download | voidsky-7aa1d9010e26da14a843efab0389386144cc978a.tar.zst |
Merge branch 'main' into custom-algos
Diffstat (limited to 'src/view/com/util/forms/Button.tsx')
-rw-r--r-- | src/view/com/util/forms/Button.tsx | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/view/com/util/forms/Button.tsx b/src/view/com/util/forms/Button.tsx index 1c9b1cf51..6a5f19f99 100644 --- a/src/view/com/util/forms/Button.tsx +++ b/src/view/com/util/forms/Button.tsx @@ -38,6 +38,7 @@ export function Button({ accessibilityLabel, accessibilityHint, accessibilityLabelledBy, + onAccessibilityEscape, }: React.PropsWithChildren<{ type?: ButtonType label?: string @@ -48,6 +49,7 @@ export function Button({ accessibilityLabel?: string accessibilityHint?: string accessibilityLabelledBy?: string + onAccessibilityEscape?: () => void }>) { const theme = useTheme() const typeOuterStyle = choose<ViewStyle, Record<ButtonType, ViewStyle>>( @@ -126,6 +128,7 @@ export function Button({ }, }, ) + const onPressWrapped = React.useCallback( (event: Event) => { event.stopPropagation() @@ -134,15 +137,30 @@ export function Button({ }, [onPress], ) + + const getStyle = React.useCallback( + state => { + const arr = [typeOuterStyle, styles.outer, style] + if (state.pressed) { + arr.push({opacity: 0.6}) + } else if (state.hovered) { + arr.push({opacity: 0.8}) + } + return arr + }, + [typeOuterStyle, style], + ) + return ( <Pressable - style={[typeOuterStyle, styles.outer, style]} + style={getStyle} onPress={onPressWrapped} testID={testID} accessibilityRole="button" accessibilityLabel={accessibilityLabel} accessibilityHint={accessibilityHint} - accessibilityLabelledBy={accessibilityLabelledBy}> + accessibilityLabelledBy={accessibilityLabelledBy} + onAccessibilityEscape={onAccessibilityEscape}> {label ? ( <Text type="button" style={[typeLabelStyle, labelStyle]}> {label} |