-
Notifications
You must be signed in to change notification settings - Fork 369
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
[Wallet] Gold screen redesign #3764
Conversation
015c7e5
to
16f2765
Compare
2cfecda
to
4c6a287
Compare
Codecov Report
|
5442940
to
f67f9c4
Compare
@@ -27,7 +27,7 @@ export enum BtnSizes { | |||
export interface ButtonProps { | |||
onPress: () => void | |||
style?: StyleProp<ViewStyle> | |||
text: string | |||
text: string | JSX.Element |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is needed, when we show inside the button text.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's preferable to use React.ReactNode
https://stackoverflow.com/questions/58123398/when-to-use-jsx-element-vs-reactnode-vs-reactelement
@@ -67,6 +67,12 @@ const fontStyles = StyleSheet.create({ | |||
center: { | |||
textAlign: 'center', | |||
}, | |||
mediumNumber: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not in the Design Kit, but we use it more than twice on Gold Screen - I figure we could use it the future. Cc @coreycelo
18212d9
to
247fb45
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks awesome!! 👍 🎉
I've suggested a couple of small changes.
<SafeAreaView style={styles.container}> | ||
<View style={styles.paddedContainer}> | ||
<ScrollView> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For fullscreen views, it's nicer to put <SafeAreaView>
inside the <ScrollView>
so when scrolling up and down the content is not clipped before the bottom/top of the screen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would content overlap with the bar in the bottom on iPhone X in this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes but that's what is preferred visually, the difference is that there's some padding at the bottom so you can still fully view all the content from the scrollview without overlap.
alignItems: 'center' as 'center', | ||
}, | ||
headerTitleAlign: 'center', | ||
headerTitleAlign: 'center' as 'center', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😅
@@ -27,7 +27,7 @@ export enum BtnSizes { | |||
export interface ButtonProps { | |||
onPress: () => void | |||
style?: StyleProp<ViewStyle> | |||
text: string | |||
text: string | JSX.Element |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's preferable to use React.ReactNode
https://stackoverflow.com/questions/58123398/when-to-use-jsx-element-vs-reactnode-vs-reactelement
function getStyleForWrapper( | ||
size: BtnSizes | undefined, | ||
style: StyleProp<ViewStyle> | ||
): StyleProp<ViewStyle> { | ||
return [{ flexDirection: size === BtnSizes.FULL ? 'column' : 'row' }, style] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't need to be addressed in the PR but I think the current BtnSize
API is limiting.
In another PR I needed a button having both FULL
(full width) and SMALL
(40pt height) behaviors.
I don't have a proposition right now but wanted to raise this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I was thinking about this as well to split this into two verticals: font size and horizontal filling. And started to think that this is needed, when I saw your workaround on this, when you were needed full width with small font size.
import colors from '@celo/react-components/styles/colors.v2' | ||
import fontStyles from '@celo/react-components/styles/fonts.v2' | ||
import * as React from 'react' | ||
import { StyleSheet, Text, View } from 'react-native' | ||
|
||
interface Props { | ||
text: string | ||
} | ||
|
||
function SectionHead({ text }: Props) { | ||
return ( | ||
<View style={style.container}> | ||
<Text style={style.text}>{text}</Text> | ||
</View> | ||
) | ||
} | ||
|
||
const style = StyleSheet.create({ | ||
container: { | ||
paddingTop: 20, | ||
paddingBottom: 8, | ||
paddingHorizontal: 16, | ||
}, | ||
text: { | ||
...fontStyles.h2, | ||
color: colors.dark, | ||
}, | ||
}) | ||
|
||
export default SectionHead |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated SectionHeadNew
in a previous master that's already been merged:
https://github.com/celo-org/celo-monorepo/blob/ee5242cb59ef61a35718d76c8dc2447d0c71c7a0/packages/react-components/components/SectionHeadNew.tsx
We can use that one now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the Gold tab they have a different styling, so I will rename to SectionHeadGold.tsx
for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh ok, all good then 👍
// TODO: find a way on how to show local exchangeRate without this hack | ||
const exchangeRateAmount = { | ||
value: localAmount.exchangeRate, | ||
currencyCode: CURRENCIES[CURRENCY_ENUM.DOLLAR].code, | ||
localAmount: { | ||
value: localAmount.exchangeRate, | ||
exchangeRate: localAmount.exchangeRate, | ||
currencyCode: localAmount.currencyCode, | ||
}, | ||
} | ||
|
||
return ( | ||
<Touchable onPress={onPress}> | ||
<View style={styles.container}> | ||
<View style={styles.firstRow}> | ||
<View style={styles.desc}> | ||
<Text style={styles.txMode}> | ||
{isSellGoldTx ? t('feedItemGoldSold') : t('feedItemGoldPurchased')} | ||
</Text> | ||
<> | ||
<Text style={styles.exchangeRate}> @ </Text> | ||
<CurrencyDisplay | ||
amount={exchangeRateAmount} | ||
hideSymbol={false} | ||
hideCode={true} | ||
showLocalAmount={true} | ||
style={styles.exchangeRate} | ||
/> | ||
</> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're only interested in displaying a specific value and not doing conversions, it looks like you can simplify to this:
const localAmount = (isSellGoldTx ? makerAmount : takerAmount).localAmount!
const exchangeRateAmount = {
value: localAmount.exchangeRate,
currencyCode: localAmount.currencyCode,
localAmount: null
}
// Then
<CurrencyDisplay
amount={exchangeRateAmount}
hideSymbol={false}
hideCode={true}
showLocalAmount={false}
style={styles.exchangeRate}
/>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately this would not work with currency symbols. See here:
https://github.com/celo-org/celo-monorepo/blob/337d28c94e418afea2d6ec05f5a7930916fc8371/packages/mobile/src/components/CurrencyDisplay.tsx#L151-L155
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should decouple conversion and representation inside CurrencyDisplay
, but that is for a different PR :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah 😢, I intended to merge LocalCurrency and CURRENCIES to avoid this kind of mess.
All good then 👍
d94fead
to
ad69b6e
Compare
ad69b6e
to
79f9fca
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
@@ -59,9 +59,10 @@ export const emptyHeader: StackNavigationOptions = { | |||
headerShown: true, | |||
headerTitleStyle: [styles.headerTitle, componentStyles.screenHeader], | |||
headerTitleContainerStyle: { | |||
alignItems: 'center', | |||
alignItems: 'center' as 'center', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw since this is now typed as StackNavigationOptions
the as 'center'
should be no longer needed
Description
This PR implements Celo Gold redesigned screens with some exceptions:
blockchain-api
and de-hardcode other fees in Wallet codebase).Other changes
Button
logic withBtnSize.FULL
a bit, so it's not needed to add manually styles every time we want a full width button.Button
logic, so it acceptsstring | Element
(needed when we use inside the button text)Tested
Android
Related issues
Backwards compatibility
Yes
Screenshots