Skip to content

Commit

Permalink
fixup! fixup! Implement iOS "Cancel" button
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon-edge committed Nov 29, 2024
1 parent 418a9fe commit fbb4356
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/components/themed/SimpleTextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export const SimpleTextInput = React.forwardRef<SimpleTextInputRef, SimpleTextIn

const hasIcon = Icon != null
const hasValue = value !== ''
const isIos = Platform.OS === 'ios'

const [isFocused, setIsFocused] = React.useState(false)

Expand Down Expand Up @@ -173,7 +174,7 @@ export const SimpleTextInput = React.forwardRef<SimpleTextInputRef, SimpleTextIn
if (onSubmitEditing != null) onSubmitEditing()
})

const backIconSize = useDerivedValue(() => (Platform.OS === 'ios' ? 0 : interpolate(focusAnimation.value, [0, 1], [0, themeRem])))
const backIconSize = useDerivedValue(() => (isIos ? 0 : interpolate(focusAnimation.value, [0, 1], [0, themeRem])))
const leftIconSize = useDerivedValue(() => (hasIcon ? (hasValue ? 0 : interpolate(focusAnimation.value, [0, 1], [themeRem, 0])) : 0))
const rightIconSize = useDerivedValue(() => (hasValue ? themeRem : focusAnimation.value * themeRem))

Expand Down Expand Up @@ -235,7 +236,7 @@ export const SimpleTextInput = React.forwardRef<SimpleTextInputRef, SimpleTextIn
</TouchContainer>
</InputContainerView>
</EdgeTouchableWithoutFeedback>
{Platform.OS === 'ios' && (
{isIos && (
<CancelButton isFocused={isFocused}>
<TouchContainer hitSlop={theme.rem(0.75)} accessible onPress={handleDonePress} testID={`${testID}.cancelButton`}>
<CancelText numberOfLines={1} ellipsizeMode="clip">
Expand All @@ -251,7 +252,8 @@ export const SimpleTextInput = React.forwardRef<SimpleTextInputRef, SimpleTextIn
const ContainerView = styled(View)({
flexDirection: 'row',
alignItems: 'center',
flex: 1
flexGrow: 1,
flexShrink: 1
})

const InputContainerView = styled(Animated.View)<{
Expand Down

0 comments on commit fbb4356

Please sign in to comment.