Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paul/fix buy quote #4719

Merged
merged 2 commits into from
Jan 18, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -1326,7 +1326,6 @@ exports[`CryptoExchangeQuoteScreenComponent should render with loading props 1`]
"alignItems": "center",
"flexDirection": "row",
"justifyContent": "center",
"marginVertical": 11,
}
}
>
Expand Down Expand Up @@ -1367,10 +1366,10 @@ exports[`CryptoExchangeQuoteScreenComponent should render with loading props 1`]
"marginRight": 11,
"marginTop": 11,
"opacity": 1,
"paddingBottom": 22,
"paddingLeft": 22,
"paddingRight": 22,
"paddingTop": 22,
"paddingBottom": 11,
"paddingLeft": 11,
"paddingRight": 11,
"paddingTop": 11,
}
}
>
Expand Down
5 changes: 2 additions & 3 deletions src/components/cards/PoweredByCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const PoweredByCard = (props: Props) => {

return (
<View style={styles.cardContainer}>
<CardUi4 paddingRem={1} onPress={onPress}>
<CardUi4 paddingRem={0.5} onPress={onPress}>
<View style={styles.poweredByContainer}>
<FastImage style={styles.poweredByIcon} source={iconSrc} resizeMode="contain" />
<View style={styles.poweredByContainerColumn}>
Expand All @@ -44,8 +44,7 @@ const getStyles = cacheStyles((theme: Theme) => ({
cardContainer: {
alignItems: 'center',
flexDirection: 'row', // Make the card shrink
justifyContent: 'center',
marginVertical: theme.rem(0.5)
justifyContent: 'center'
},
poweredByContainerRow: {
flexDirection: 'row'
Expand Down
22 changes: 22 additions & 0 deletions src/components/scenes/InputTesterScene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ export function InputTesterScene(props: Props) {
const [filledTextInputValue3, setFilledTextInputValue3] = useState<string>('')
const [filledTextInputValue4, setFilledTextInputValue4] = useState<string>('')
const [filledTextInputValue5, setFilledTextInputValue5] = useState<string>('')
const [filledTextInputValue6, setFilledTextInputValue6] = useState<string>('')
const [filledTextInputValue7, setFilledTextInputValue7] = useState<string>('')
const walletId = selectedWallet?.wallet.id ?? ''
const tokenId = selectedWallet?.tokenId ?? null
const exchangedFlipInputRef = React.useRef<ExchangedFlipInputRef>(null)
Expand Down Expand Up @@ -89,6 +91,26 @@ export function InputTesterScene(props: Props) {
<SceneWrapper scroll hasTabs hasHeader={false}>
<SectionView marginRem={1}>
<FilledTextInput
vertical={1}
value={filledTextInputValue6}
onChangeText={setFilledTextInputValue6}
autoFocus={false}
placeholder="Test big text"
textsizeRem={1.5}
maxLength={100}
/>
<FilledTextInput
numeric
vertical={1}
value={filledTextInputValue7}
onChangeText={setFilledTextInputValue7}
autoFocus={false}
placeholder="Test big number"
textsizeRem={1.5}
maxLength={100}
/>
<FilledTextInput
vertical={1}
value={filledTextInputValue}
onChangeText={setFilledTextInputValue}
autoFocus={false}
Expand Down
23 changes: 15 additions & 8 deletions src/components/themed/FilledTextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export interface FilledTextInputProps extends SpaceProps {
showSpinner?: boolean
prefix?: string // Text input is left-left justified with a persistent prefix
suffix?: string // Text input is right-right justified with a persistent suffix
textsizeRem?: number

// Callbacks:
onBlur?: () => void
Expand Down Expand Up @@ -123,6 +124,7 @@ export const FilledTextInput = React.forwardRef<FilledTextInputRef, FilledTextIn
maxLength,
secureTextEntry,
testID,
textsizeRem,
...spaceProps
} = props
const theme = useTheme()
Expand Down Expand Up @@ -217,7 +219,7 @@ export const FilledTextInput = React.forwardRef<FilledTextInputRef, FilledTextIn
<InnerContainer focusValue={focusValue} hasPlaceholder={placeholder != null}>
{placeholder == null ? null : (
<Placeholder shift={focusValue}>
<PlaceholderText disableAnimation={disableAnimation} focusAnimation={focusAnimation} scale={scale} shift={focusValue}>
<PlaceholderText disableAnimation={disableAnimation} focusAnimation={focusAnimation} scale={scale} shift={focusValue} textsizeRem={textsizeRem}>
{placeholder}
</PlaceholderText>
</Placeholder>
Expand All @@ -240,6 +242,7 @@ export const FilledTextInput = React.forwardRef<FilledTextInputRef, FilledTextIn
selectionColor={theme.textInputTextColor}
testID={`${testID}.textInput`}
textAlignVertical="top"
textsizeRem={textsizeRem}
scale={scale}
value={value}
// Callbacks:
Expand Down Expand Up @@ -428,8 +431,10 @@ const PlaceholderText = styled(Animated.Text)<{
focusAnimation: SharedValue<number>
scale: SharedValue<number>
shift: SharedValue<number>
}>(theme => ({ disableAnimation, focusAnimation, scale, shift }) => {
const fontSizeBase = theme.rem(scale.value)
textsizeRem?: number
}>(theme => ({ disableAnimation, focusAnimation, scale, shift, textsizeRem }) => {
const fontSizeBase = theme.rem(textsizeRem ?? scale.value)
const fontSizeScaled = theme.rem(scale.value) * 0.75
const interpolatePlaceholderTextColor = useAnimatedColorInterpolateFn(
theme.textInputPlaceholderColor,
theme.textInputPlaceholderColorFocused,
Expand All @@ -445,7 +450,7 @@ const PlaceholderText = styled(Animated.Text)<{
useAnimatedStyle(() => {
return {
color: interpolatePlaceholderTextColor(focusAnimation, disableAnimation),
fontSize: interpolate(shift.value, [0, 1], [fontSizeBase, 0.75 * fontSizeBase])
fontSize: interpolate(shift.value, [0, 1], [fontSizeBase, fontSizeScaled])
}
})
]
Expand All @@ -455,8 +460,9 @@ const StyledAnimatedTextInput = styledWithRef(AnimatedTextInput)<{
disableAnimation: SharedValue<number>
focusAnimation: SharedValue<number>
scale: SharedValue<number>
}>(theme => ({ disableAnimation, focusAnimation, scale }) => {
const rem = theme.rem(1)
textsizeRem?: number
}>(theme => ({ disableAnimation, focusAnimation, scale, textsizeRem }) => {
const rem = theme.rem(textsizeRem ?? 1)
const interpolateTextColor = useAnimatedColorInterpolateFn(theme.textInputTextColor, theme.textInputTextColorFocused, theme.textInputTextColorDisabled)
// Need 2 pixels of shift given a 16 point rem settings
// This is due to Android rendering a text input vertically lower
Expand Down Expand Up @@ -485,8 +491,9 @@ const StyledNumericInput = styledWithRef(NumericInput)<{
disableAnimation: SharedValue<number>
focusAnimation: SharedValue<number>
scale: SharedValue<number>
}>(theme => ({ disableAnimation, focusAnimation, scale }) => {
const rem = theme.rem(1)
textsizeRem?: number
}>(theme => ({ disableAnimation, focusAnimation, textsizeRem, scale }) => {
const rem = theme.rem(textsizeRem ?? 1)
const interpolateTextColor = useAnimatedColorInterpolateFn(theme.textInputTextColor, theme.textInputTextColorFocused, theme.textInputTextColorDisabled)
// Need 2 pixels of shift given a 16 point rem settings
// This is due to Android rendering a text input vertically lower
Expand Down
149 changes: 78 additions & 71 deletions src/plugins/gui/scenes/FiatPluginEnterAmountScene.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react'
import { useEffect } from 'react'
import { Image, Text, View } from 'react-native'
Copy link
Member Author

Choose a reason for hiding this comment

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

review this in 'hide whitespace' mode for simplicity

import { Image, Text, TextStyle, View } from 'react-native'

import { PoweredByCard } from '../../../components/cards/PoweredByCard'
import { SceneWrapper } from '../../../components/common/SceneWrapper'
Expand All @@ -9,6 +9,7 @@ import { cacheStyles, Theme, useTheme } from '../../../components/services/Theme
import { FilledTextInput } from '../../../components/themed/FilledTextInput'
import { MainButton } from '../../../components/themed/MainButton'
import { SceneHeader } from '../../../components/themed/SceneHeader'
import { SectionView } from '../../../components/ui4/SectionView'
import { useHandler } from '../../../hooks/useHandler'
import { lstrings } from '../../../locales/strings'
import { EdgeSceneProps } from '../../../types/routerTypes'
Expand Down Expand Up @@ -133,82 +134,88 @@ export const FiatPluginEnterAmountScene = React.memo((props: Props) => {
<SceneHeader style={styles.sceneHeader} title={headerTitle} underline withTopMargin>
{headerIcon}
</SceneHeader>
<View style={styles.container}>
<View style={styles.textFields}>
<FilledTextInput
numeric
maxDecimals={2}
autoCorrect={false}
autoFocus
autoCapitalize="none"
keyboardType="decimal-pad"
placeholder={label1}
onChangeText={handleChangeText1}
onSubmitEditing={handleSubmit}
showSpinner={spinner1}
value={value1 ?? '0'}
/>
<FilledTextInput
numeric
maxDecimals={6}
autoCorrect={false}
autoFocus={false}
autoCapitalize="none"
keyboardType="decimal-pad"
placeholder={label2}
onChangeText={handleChangeText2}
onSubmitEditing={handleSubmit}
showSpinner={spinner2}
value={value2 ?? '0'}
/>
<SectionView>
<View style={styles.container}>
<View style={styles.textFields}>
<FilledTextInput
numeric
maxDecimals={2}
autoCorrect={false}
autoFocus
autoCapitalize="none"
keyboardType="decimal-pad"
placeholder={label1}
onChangeText={handleChangeText1}
onSubmitEditing={handleSubmit}
showSpinner={spinner1}
textsizeRem={1.5}
value={value1 ?? '0'}
vertical={0.5}
/>
<FilledTextInput
numeric
maxDecimals={6}
autoCorrect={false}
autoFocus={false}
autoCapitalize="none"
keyboardType="decimal-pad"
placeholder={label2}
onChangeText={handleChangeText2}
onSubmitEditing={handleSubmit}
showSpinner={spinner2}
textsizeRem={1.5}
value={value2 ?? '0'}
vertical={0.5}
/>
</View>
{statusText != null ? <Text style={statusTextStyle}>{statusText.content}</Text> : null}
{poweredBy != null ? <PoweredByCard iconUri={poweredByIconPath} poweredByText={poweredBy.poweredByText} onPress={handlePoweredByPress} /> : null}
<MainButton disabled={spinner1 || spinner2} label={lstrings.string_next_capitalized} marginRem={[0.25, 0]} onPress={handleSubmit} />
</View>
{statusText != null ? <Text style={statusTextStyle}>{statusText.content}</Text> : null}
{poweredBy != null ? <PoweredByCard iconUri={poweredByIconPath} poweredByText={poweredBy.poweredByText} onPress={handlePoweredByPress} /> : null}
<MainButton disabled={spinner1 || spinner2} label={lstrings.string_next_capitalized} marginRem={[1, 0]} type="secondary" onPress={handleSubmit} />
</View>
</SectionView>
</SceneWrapper>
)
})

const getStyles = cacheStyles((theme: Theme) => ({
sceneHeader: {
flexDirection: 'row',
justifyContent: 'flex-start',
alignItems: 'center'
},
container: {
alignItems: 'center',
paddingTop: theme.rem(0.5),
width: '100%'
},
textFields: {
flexDirection: 'column',
minWidth: theme.rem(15),
maxWidth: theme.rem(20)
},
text: {
color: theme.primaryText,
fontFamily: theme.fontFaceMedium,
fontSize: theme.rem(1),
includeFontPadding: false
},
textWarning: {
color: theme.warningText,
const getStyles = cacheStyles((theme: Theme) => {
const textCommon: TextStyle = {
fontFamily: theme.fontFaceMedium,
fontSize: theme.rem(1),
includeFontPadding: false
},
textError: {
color: theme.dangerText,
fontFamily: theme.fontFaceMedium,
fontSize: theme.rem(1),
includeFontPadding: false
},
icon: {
height: theme.rem(1.5),
width: theme.rem(1.5),
marginRight: theme.rem(0.5),
marginLeft: theme.rem(0.5),
resizeMode: 'contain'
}
}))
return {
sceneHeader: {
flexDirection: 'row',
justifyContent: 'flex-start',
alignItems: 'center'
},
container: {
alignItems: 'center',
paddingTop: theme.rem(0.5),
width: '100%'
},
textFields: {
flexDirection: 'column',
width: theme.rem(15)
},
text: {
...textCommon,
color: theme.primaryText
},
textWarning: {
...textCommon,
color: theme.warningText
},
textError: {
...textCommon,
color: theme.dangerText
},
icon: {
height: theme.rem(1.5),
width: theme.rem(1.5),
marginRight: theme.rem(0.5),
marginLeft: theme.rem(0.5),
resizeMode: 'contain'
}
}
})
Loading