Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unreleased

- changed: (iOS) `SimpleTextInput` back chevron replaced with "Cancel" button
- added: New Kado OTC provider integration.
- changed: Improved EdgeCrashEvent reporting with additional metadata, tags, and name/message information.
- changed: Integrate `installSurvey` endpoint for post-install survey options
Expand Down
40 changes: 23 additions & 17 deletions src/__tests__/modals/__snapshots__/WalletListModal.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ exports[`WalletListModal should render with loading props 1`] = `
style={
{
"flexGrow": 1,
"flexShrink": 1,
}
}
>
Expand Down Expand Up @@ -161,11 +162,26 @@ exports[`WalletListModal should render with loading props 1`] = `
</Text>
</View>
<View
style={
marginRemProps={
{
"flexDirection": "row",
"aroundRem": 0.5,
}
}
style={
[
{
"marginBottom": 11,
"marginLeft": 11,
"marginRight": 11,
"marginTop": 11,
},
{
"alignItems": "center",
"flexDirection": "row",
"justifyContent": "center",
},
]
}
>
<View
accessibilityState={
Expand All @@ -189,11 +205,6 @@ exports[`WalletListModal should render with loading props 1`] = `
}
}
focusable={true}
marginRemProps={
{
"aroundRem": 0.5,
}
}
onClick={[Function]}
onResponderGrant={[Function]}
onResponderMove={[Function]}
Expand All @@ -208,18 +219,13 @@ exports[`WalletListModal should render with loading props 1`] = `
}
style={
[
{
"marginBottom": 11,
"marginLeft": 11,
"marginRight": 11,
"marginTop": 11,
},
{
"alignItems": "center",
"borderRadius": 2247,
"borderWidth": 1,
"flexDirection": "row",
"flexGrow": 1,
"flexShrink": 1,
"paddingHorizontal": 22,
"paddingVertical": 17,
},
Expand Down Expand Up @@ -308,7 +314,7 @@ exports[`WalletListModal should render with loading props 1`] = `
<View
size={
{
"value": undefined,
"value": 0,
}
}
style={
Expand All @@ -318,8 +324,8 @@ exports[`WalletListModal should render with loading props 1`] = `
"aspectRatio": 1,
},
{
"opacity": undefined,
"width": undefined,
"opacity": 0,
"width": 0,
},
]
}
Expand All @@ -329,7 +335,7 @@ exports[`WalletListModal should render with loading props 1`] = `
{
"color": "#FFFFFF",
"fontFamily": "Material Icons",
"fontSize": 22,
"fontSize": 0,
"fontStyle": "normal",
"fontWeight": "normal",
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,11 +294,27 @@ exports[`CreateWalletSelectCrypto should render with loading props 1`] = `
</View>
</View>
<View
style={
marginRemProps={
{
"flexDirection": "row",
"horizontalRem": 1,
"verticalRem": 0.5,
}
}
style={
[
{
"marginBottom": 11,
"marginLeft": 22,
"marginRight": 22,
"marginTop": 11,
},
{
"alignItems": "center",
"flexDirection": "row",
"justifyContent": "center",
},
]
}
>
<View
accessibilityState={
Expand All @@ -322,12 +338,6 @@ exports[`CreateWalletSelectCrypto should render with loading props 1`] = `
}
}
focusable={true}
marginRemProps={
{
"horizontalRem": 1,
"verticalRem": 0.5,
}
}
onClick={[Function]}
onResponderGrant={[Function]}
onResponderMove={[Function]}
Expand All @@ -342,18 +352,13 @@ exports[`CreateWalletSelectCrypto should render with loading props 1`] = `
}
style={
[
{
"marginBottom": 11,
"marginLeft": 22,
"marginRight": 22,
"marginTop": 11,
},
{
"alignItems": "center",
"borderRadius": 2247,
"borderWidth": 1,
"flexDirection": "row",
"flexGrow": 1,
"flexShrink": 1,
"paddingHorizontal": 22,
"paddingVertical": 17,
},
Expand Down Expand Up @@ -442,7 +447,7 @@ exports[`CreateWalletSelectCrypto should render with loading props 1`] = `
<View
size={
{
"value": undefined,
"value": 0,
}
}
style={
Expand All @@ -452,8 +457,8 @@ exports[`CreateWalletSelectCrypto should render with loading props 1`] = `
"aspectRatio": 1,
},
{
"opacity": undefined,
"width": undefined,
"opacity": 0,
"width": 0,
},
]
}
Expand All @@ -463,7 +468,7 @@ exports[`CreateWalletSelectCrypto should render with loading props 1`] = `
{
"color": "#FFFFFF",
"fontFamily": "Material Icons",
"fontSize": 22,
"fontSize": 0,
"fontStyle": "normal",
"fontWeight": "normal",
}
Expand Down
3 changes: 2 additions & 1 deletion src/components/modals/WalletListModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,8 @@ export function WalletListModal(props: Props) {

const getStyles = cacheStyles((theme: Theme) => ({
header: {
flexGrow: 1
flexGrow: 1,
flexShrink: 1
},
bankMargin: {
flex: 1,
Expand Down
86 changes: 65 additions & 21 deletions src/components/themed/SimpleTextInput.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react'
import { useMemo } from 'react'
import { TextInput, TouchableOpacity, View } from 'react-native'
import { Platform, Text, TextInput, TouchableOpacity, View } from 'react-native'
import Animated, {
interpolate,
interpolateColor,
Expand All @@ -15,6 +15,7 @@ import Animated, {

import { useHandler } from '../../hooks/useHandler'
import { MarginRemProps, useMarginRemStyle } from '../../hooks/useMarginRemStyle'
import { lstrings } from '../../locales/strings'
import { EdgeTouchableWithoutFeedback } from '../common/EdgeTouchableWithoutFeedback'
import { styled, styledWithRef } from '../hoc/styled'
import { AnimatedIconComponent, ChevronBackAnimated, CloseIconAnimated } from '../icons/ThemedIcons'
Expand Down Expand Up @@ -111,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 @@ -172,7 +174,7 @@ export const SimpleTextInput = React.forwardRef<SimpleTextInputRef, SimpleTextIn
if (onSubmitEditing != null) onSubmitEditing()
})

const backIconSize = useDerivedValue(() => 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 All @@ -186,9 +188,9 @@ export const SimpleTextInput = React.forwardRef<SimpleTextInputRef, SimpleTextIn
}, [disabled, isFocused, theme.textInputPlaceholderColor, theme.textInputPlaceholderColorDisabled, theme.textInputPlaceholderColorFocused])

return (
<ContainerView>
<ContainerView marginRemProps={marginRemProps}>
<EdgeTouchableWithoutFeedback accessible={false} testID={testID} onPress={() => focus()}>
<InputContainerView disableAnimation={disableAnimation} focusAnimation={focusAnimation} scale={scale} marginRemProps={marginRemProps}>
<InputContainerView disableAnimation={disableAnimation} focusAnimation={focusAnimation} scale={scale}>
<SideContainer size={leftIconSize}>{Icon == null ? null : <Icon color={iconColor} size={leftIconSize} />}</SideContainer>
<TouchableOpacity hitSlop={theme.rem(0.75)} accessible onPress={handleDonePress} testID={`${testID}.doneButton`}>
<SideContainer size={backIconSize}>
Expand Down Expand Up @@ -234,20 +236,38 @@ export const SimpleTextInput = React.forwardRef<SimpleTextInputRef, SimpleTextIn
</TouchContainer>
</InputContainerView>
</EdgeTouchableWithoutFeedback>
{isIos && isFocused && (
<TouchContainer hitSlop={theme.rem(0.75)} accessible onPress={handleDonePress} testID={`${testID}.cancelButton`}>
<CancelButton>
<CancelText numberOfLines={1} ellipsizeMode="clip">
{lstrings.string_cancel_cap}
</CancelText>
</CancelButton>
</TouchContainer>
)}
</ContainerView>
)
})

const ContainerView = styled(View)({
flexDirection: 'row'
const ContainerView = styled(View)<{
marginRemProps: MarginRemProps
}>(theme => ({ marginRemProps }) => {
const marginRemStyle = useMarginRemStyle(marginRemProps)
return [
marginRemStyle,
{
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'center'
}
]
})

const InputContainerView = styled(Animated.View)<{
disableAnimation: SharedValue<number>
focusAnimation: SharedValue<number>
scale: SharedValue<number>
marginRemProps: MarginRemProps
}>(theme => ({ disableAnimation, focusAnimation, scale, marginRemProps }) => {
}>(theme => ({ disableAnimation, focusAnimation, scale }) => {
const interpolateInputBackgroundColor = useAnimatedColorInterpolateFn(
theme.textInputBackgroundColor,
theme.textInputBackgroundColorFocused,
Expand All @@ -258,29 +278,31 @@ const InputContainerView = styled(Animated.View)<{
theme.textInputBorderColorFocused,
theme.textInputBorderColorDisabled
)
const marginRemStyle = useMarginRemStyle(marginRemProps)

return [
marginRemStyle,
{
alignItems: 'center',
borderWidth: theme.textInputBorderWidth,
borderRadius: theme.rem(theme.textInputBorderRadius),
flexDirection: 'row',
flexGrow: 1,
flexShrink: 1,
paddingHorizontal: theme.rem(1),
paddingVertical: theme.rem(0.75)
},
useAnimatedStyle(() => ({
backgroundColor: interpolateInputBackgroundColor(focusAnimation, disableAnimation),
borderColor: interpolateOutlineColor(focusAnimation, disableAnimation),
opacity: interpolate(scale.value, [1, 0.5], [1, 0]),
transform: [
{
scale: interpolate(scale.value, [1, 0], [1, 0.75])
}
]
}))
useAnimatedStyle(() => {
'worklet'
return {
backgroundColor: interpolateInputBackgroundColor(focusAnimation, disableAnimation),
borderColor: interpolateOutlineColor(focusAnimation, disableAnimation),
opacity: interpolate(scale.value, [1, 0.5], [1, 0]),
transform: [
{
scale: interpolate(scale.value, [1, 0], [1, 0.75])
}
]
}
})
]
})

Expand Down Expand Up @@ -324,11 +346,33 @@ const InputField = styledWithRef(AnimatedTextInput)<{
})

const TouchContainer = styled(TouchableOpacity)(theme => ({
// Increase tappable area with padding, while net 0 with negative margin to visually appear as if 0 margins/padding
// Increase tappable area with padding, while net 0 with negative margin to
// visually appear as if 0 margins/padding
padding: theme.rem(1),
margin: -theme.rem(1)
}))

const CancelButton = styled(View)(theme => () => {
return {
alignItems: 'center',
justifyContent: 'center',
marginLeft: theme.rem(0.5)
}
})

const CancelText = styled(Text)(theme => {
return {
color: theme.textInputIconColorFocused,
fontFamily: theme.fontFaceDefault,
fontSize: theme.rem(1),
includeFontPadding: false,
textAlign: 'center',
whiteSpace: 'nowrap',
marginHorizontal: theme.rem(0.5),
flexShrink: 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove minWidth in favor of margins.

}
})

function useAnimatedColorInterpolateFn(fromColor: string, toColor: string, disabledColor: string) {
const interpolateFn = useMemo(() => {
return (focusValue: SharedValue<number>, disabledValue: SharedValue<number>) => {
Expand Down
Loading