Browse Source

fix(ui): improve transitions in pay flow

renovate/lint-staged-8.x
Tom Kirkpatrick 6 years ago
parent
commit
44317394cc
No known key found for this signature in database GPG Key ID: 72203A8EC5967EA8
  1. 30
      app/components/Pay/Pay.js

30
app/components/Pay/Pay.js

@ -30,7 +30,7 @@ const ShowHidePayReq = Keyframes.Spring({
small: { height: 48 }, small: { height: 48 },
big: async (next, cancel, ownProps) => { big: async (next, cancel, ownProps) => {
ownProps.context.focusPayReqInput() ownProps.context.focusPayReqInput()
await next({ height: 130 }) await next({ height: 130, immediate: true })
} }
}) })
@ -369,7 +369,7 @@ class Pay extends React.Component {
show && show &&
(styles => ( (styles => (
<animated.div style={styles}> <animated.div style={styles}>
<Box mb={5}> <Box mb={4}>
<Text textAlign="justify"> <Text textAlign="justify">
<FormattedMessage {...messages.description} /> <FormattedMessage {...messages.description} />
</Text> </Text>
@ -530,11 +530,6 @@ class Pay extends React.Component {
setCryptoCurrency setCryptoCurrency
} = this.props } = this.props
// Do not render unless we are on the summary step.
if (currentStep !== 'summary') {
return null
}
const formState = this.formApi.getState() const formState = this.formApi.getState()
let minFee, maxFee let minFee, maxFee
if (routes.length) { if (routes.length) {
@ -542,6 +537,7 @@ class Pay extends React.Component {
maxFee = getMaxFee(routes) maxFee = getMaxFee(routes)
} }
const render = () => {
// convert entered amount to satoshis // convert entered amount to satoshis
if (isOnchain) { if (isOnchain) {
const amountInSatoshis = convert(cryptoCurrency, 'sats', formState.values.amountCrypto) const amountInSatoshis = convert(cryptoCurrency, 'sats', formState.values.amountCrypto)
@ -579,6 +575,20 @@ class Pay extends React.Component {
} }
} }
return (
<Transition
native
items={currentStep === 'summary'}
from={{ opacity: 0, height: 0 }}
enter={{ opacity: 1, height: 'auto' }}
leave={{ opacity: 0, height: 0 }}
initial={{ opacity: 1, height: 'auto' }}
>
{show => show && (styles => <animated.div style={styles}>{render()}</animated.div>)}
</Transition>
)
}
/** /**
* Form renderer. * Form renderer.
*/ */
@ -670,11 +680,17 @@ class Pay extends React.Component {
</Flex> </Flex>
<Box as="section" css={{ flex: 1 }} mb={3}> <Box as="section" css={{ flex: 1 }} mb={3}>
<Box width={1} css={{ position: 'relative' }}>
{this.renderHelpText()} {this.renderHelpText()}
<Box width={1} css={{ position: 'absolute' }}>
{this.renderAddressField()} {this.renderAddressField()}
{this.renderAmountFields()} {this.renderAmountFields()}
</Box>
<Box width={1} css={{ position: 'absolute' }}>
{this.renderSummary()} {this.renderSummary()}
</Box> </Box>
</Box>
</Box>
<Box as="footer" mt="auto"> <Box as="footer" mt="auto">
<ShowHideButtons state={showBack || showSubmit ? 'show' : 'show'}> <ShowHideButtons state={showBack || showSubmit ? 'show' : 'show'}>

Loading…
Cancel
Save