-
Notifications
You must be signed in to change notification settings - Fork 96
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
fix(earn-cards): handle large font sizes #6308
base: main
Are you sure you want to change the base?
Changes from all commits
44eff03
3190c94
6641bbe
0aa4ffa
3b2fca2
a9c1b76
2aaf470
fd54594
97010ed
d695764
3a367bf
e4f7b69
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,21 +32,19 @@ function EarningItemLineItem({ earnItem }: { earnItem: EarningItem }) { | |
|
||
return ( | ||
<View testID="EarningItemLineItem" style={styles.cardLineContainer}> | ||
<View style={styles.cardLineLabel}> | ||
<View style={styles.flexLabel}> | ||
<Text numberOfLines={1} style={styles.depositAndEarningsCardLabelText}> | ||
{earnItem.label} | ||
</Text> | ||
</View> | ||
<View style={styles.flexShrink}> | ||
<Text style={styles.depositAndEarningsCardValueText}> | ||
{t('earnFlow.poolInfoScreen.lineItemAmountDisplay', { | ||
localCurrencySymbol, | ||
localCurrencyAmount: formatValueToDisplay(amountInLocalCurrency), | ||
cryptoAmount: formatValueToDisplay(new BigNumber(earnItem.amount)), | ||
cryptoSymbol: tokenInfo?.symbol, | ||
})} | ||
</Text> | ||
</View> | ||
<Text style={styles.depositAndEarningsCardValueText}> | ||
{t('earnFlow.poolInfoScreen.lineItemAmountDisplay', { | ||
localCurrencySymbol, | ||
localCurrencyAmount: formatValueToDisplay(amountInLocalCurrency), | ||
cryptoAmount: formatValueToDisplay(new BigNumber(earnItem.amount)), | ||
cryptoSymbol: tokenInfo?.symbol, | ||
})} | ||
</Text> | ||
</View> | ||
) | ||
} | ||
|
@@ -126,6 +124,7 @@ export function DepositAndEarningsCard({ | |
label={t('earnFlow.poolInfoScreen.totalDepositAndEarnings')} | ||
labelStyle={styles.cardTitleText} | ||
testID={'DepositInfoIcon'} | ||
numberOfLines={1} | ||
/> | ||
<View> | ||
<Text style={styles.depositAndEarningCardTitleText}> | ||
|
@@ -139,7 +138,7 @@ export function DepositAndEarningsCard({ | |
|
||
<View style={styles.depositAndEarningCardSubtitleContainer}> | ||
<View style={styles.cardLineContainer}> | ||
<View style={styles.cardLineLabel}> | ||
<View style={styles.flexLabel}> | ||
{cantSeparateCompoundedInterest ? ( | ||
<Text style={styles.depositAndEarningsCardLabelText}> | ||
{t('earnFlow.poolInfoScreen.depositAndEarnings')} | ||
|
@@ -150,16 +149,14 @@ export function DepositAndEarningsCard({ | |
</Text> | ||
)} | ||
</View> | ||
<View style={styles.flexShrink}> | ||
<Text style={styles.depositAndEarningsCardValueText}> | ||
{t('earnFlow.poolInfoScreen.lineItemAmountDisplay', { | ||
localCurrencySymbol, | ||
localCurrencyAmount: formatValueToDisplay(totalDepositBalanceInLocalCurrency), | ||
cryptoAmount: formatValueToDisplay(totalDepositBalanceInCrypto), | ||
cryptoSymbol: depositTokenInfo?.symbol, | ||
})} | ||
</Text> | ||
</View> | ||
<Text style={styles.depositAndEarningsCardValueText}> | ||
{t('earnFlow.poolInfoScreen.lineItemAmountDisplay', { | ||
localCurrencySymbol, | ||
localCurrencyAmount: formatValueToDisplay(totalDepositBalanceInLocalCurrency), | ||
cryptoAmount: formatValueToDisplay(totalDepositBalanceInCrypto), | ||
cryptoSymbol: depositTokenInfo?.symbol, | ||
})} | ||
</Text> | ||
</View> | ||
{earningItems.map((item, index) => ( | ||
<EarningItemLineItem key={index} earnItem={item} /> | ||
|
@@ -186,15 +183,15 @@ export function YieldCard({ | |
return ( | ||
<View style={styles.card} testID="YieldCard"> | ||
<View style={styles.cardLineContainer}> | ||
<View style={styles.cardLineLabel}> | ||
<View style={styles.flexLabel}> | ||
<LabelWithInfo | ||
onPress={onInfoIconPress} | ||
label={t('earnFlow.poolInfoScreen.yieldRate')} | ||
labelStyle={styles.cardTitleText} | ||
labelStyle={styles.lineLabel} | ||
testID="YieldRateInfoIcon" | ||
/> | ||
</View> | ||
<Text style={styles.cardTitleText}> | ||
<Text style={styles.lineValue}> | ||
{yieldRateSum > 0.00005 | ||
? t('earnFlow.poolInfoScreen.ratePercent', { rate: yieldRateSum.toFixed(2) }) | ||
: '--'} | ||
|
@@ -206,19 +203,17 @@ export function YieldCard({ | |
const tokenInfo = tokensInfo.filter((token) => token.tokenId === rate.tokenId) | ||
return ( | ||
<View style={styles.cardLineContainer} key={index}> | ||
<View style={styles.cardLineLabel}> | ||
<View style={styles.flexLabel}> | ||
<View style={styles.yieldRateLabelContainer}> | ||
<Text numberOfLines={1} style={styles.cardLabelText}> | ||
{rate.label} | ||
</Text> | ||
<Text style={styles.cardLabelText}>{rate.label}</Text> | ||
<TokenIcons | ||
tokensInfo={tokenInfo} | ||
size={IconSize.XXSMALL} | ||
showNetworkIcon={false} | ||
/> | ||
</View> | ||
</View> | ||
<Text style={styles.cardLabelText}> | ||
<Text style={styles.cardValueText}> | ||
{t('earnFlow.poolInfoScreen.ratePercent', { rate: rate.percentage.toFixed(2) })} | ||
</Text> | ||
</View> | ||
|
@@ -240,15 +235,15 @@ export function DailyYieldRateCard({ | |
return ( | ||
<View style={styles.card} testID="DailyYieldRateCard"> | ||
<View style={styles.cardLineContainer}> | ||
<View style={styles.cardLineLabel}> | ||
<View style={styles.flexLabel}> | ||
<LabelWithInfo | ||
onPress={onInfoIconPress} | ||
label={t('earnFlow.poolInfoScreen.dailyYieldRate')} | ||
labelStyle={styles.cardTitleText} | ||
labelStyle={styles.lineLabel} | ||
testID="DailyYieldRateInfoIcon" | ||
/> | ||
</View> | ||
<Text style={styles.cardTitleText}> | ||
<Text style={styles.lineValue}> | ||
{t('earnFlow.poolInfoScreen.ratePercent', { rate: dailyYieldRate.toFixed(4) })} | ||
</Text> | ||
</View> | ||
|
@@ -274,15 +269,15 @@ export function TvlCard({ | |
return ( | ||
<View style={styles.card} testID="TvlCard"> | ||
<View style={styles.cardLineContainer}> | ||
<View style={styles.cardLineLabel}> | ||
<View style={styles.flexLabel}> | ||
<LabelWithInfo | ||
onPress={onInfoIconPress} | ||
label={t('earnFlow.poolInfoScreen.tvl')} | ||
labelStyle={styles.cardTitleText} | ||
labelStyle={styles.lineLabel} | ||
testID="TvlInfoIcon" | ||
/> | ||
</View> | ||
<Text style={styles.cardTitleText}>{tvlString}</Text> | ||
<Text style={styles.lineValue}>{tvlString}</Text> | ||
</View> | ||
</View> | ||
) | ||
|
@@ -304,23 +299,23 @@ export function AgeCard({ | |
return ( | ||
<View style={styles.card} testID="AgeCard"> | ||
<View style={styles.cardLineContainer}> | ||
<View style={styles.cardLineLabel}> | ||
<View style={styles.flexLabel}> | ||
<LabelWithInfo | ||
onPress={onInfoIconPress} | ||
label={t('earnFlow.poolInfoScreen.ageOfPool')} | ||
labelStyle={styles.cardTitleText} | ||
labelStyle={styles.lineLabel} | ||
testID="AgeInfoIcon" | ||
/> | ||
</View> | ||
<Text style={styles.cardTitleText}>{formattedDuration(dateInterval)}</Text> | ||
<Text style={styles.lineValue}>{formattedDuration(dateInterval)}</Text> | ||
</View> | ||
</View> | ||
) | ||
} | ||
|
||
export const styles = StyleSheet.create({ | ||
flexShrink: { | ||
flexShrink: 1, | ||
flexLabel: { | ||
flex: 1.2, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why the non-standard flex value here? Is this to make up for the lack of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is just for spacing, as having the columns of flex 1 and 1 values appear a bit cramped and gives a bit too much room to the labels; it is the same as flex: 6 to 5, with an 11 column 11-column layout. |
||
}, | ||
card: { | ||
padding: Spacing.Regular16, | ||
|
@@ -334,20 +329,35 @@ export const styles = StyleSheet.create({ | |
flexDirection: 'row', | ||
justifyContent: 'space-between', | ||
}, | ||
cardLineLabel: { | ||
paddingRight: 20, // Prevents Icon from being cut off on long labels | ||
}, | ||
yieldRateLabelContainer: { | ||
flexDirection: 'row', | ||
gap: Spacing.Tiny4, | ||
}, | ||
lineLabel: { | ||
...typeScale.labelSemiBoldMedium, | ||
color: Colors.black, | ||
textAlign: 'left', | ||
}, | ||
lineValue: { | ||
...typeScale.labelSemiBoldMedium, | ||
color: Colors.black, | ||
textAlign: 'right', | ||
flex: 1, | ||
}, | ||
cardTitleText: { | ||
...typeScale.labelSemiBoldMedium, | ||
color: Colors.black, | ||
}, | ||
cardLabelText: { | ||
...typeScale.bodyMedium, | ||
color: Colors.gray3, | ||
textAlign: 'left', | ||
}, | ||
cardValueText: { | ||
...typeScale.bodyMedium, | ||
color: Colors.black, | ||
textAlign: 'right', | ||
flex: 1, | ||
}, | ||
depositAndEarningCard: { | ||
backgroundColor: Colors.gray1, | ||
|
@@ -381,5 +391,6 @@ export const styles = StyleSheet.create({ | |
color: Colors.black, | ||
flexWrap: 'wrap', | ||
textAlign: 'right', | ||
flex: 1, | ||
}, | ||
}) |
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 wonder if it's better to have
1
orundefined
as the defaultThere 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.
When I tried to set the default to 1 I ran into an issue where setting it to undefined wasn't overriding the default value. I can try setting the default to undefined and see how that works.