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

feat(earn-info): keep token icon and name on the same line #6222

Merged
merged 5 commits into from
Nov 13, 2024
Merged
Changes from 3 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
24 changes: 18 additions & 6 deletions src/earn/poolInfoScreen/EarnPoolInfoScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,12 @@ function TitleSection({
}) {
return (
<View testID="TitleSection" onLayout={onLayout} style={styles.titleContainer}>
<TokenIcons tokensInfo={tokensInfo} />
<Text style={styles.title}>{title}</Text>
<View style={styles.titleTokenContainer}>
<View style={styles.titleTokenIconContainer}>
Copy link
Contributor

Choose a reason for hiding this comment

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

for my understanding, what's the purpose of this extra wrapper View?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Wrapped the token icon in an extra view to shrink it down; otherwise, it'll take up the whole line.

Copy link
Contributor

@satish-ravi satish-ravi Nov 13, 2024

Choose a reason for hiding this comment

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

ok, seems like having flexShrink: 1 does not really make a difference? and just the wrapper View without style should suffice, so maybe we can drop the style?

<TokenIcons tokensInfo={tokensInfo} />
</View>
<Text style={styles.title}>{title}</Text>
</View>
<View style={styles.subtitleContainer}>
<Text style={styles.subtitleLabel}>
<Trans i18nKey="earnFlow.poolInfoScreen.chainName" values={{ networkName }}>
Expand Down Expand Up @@ -212,7 +216,6 @@ export default function EarnPoolInfoScreen({ route, navigation }: Props) {
}, [allPositionsWithBalance])

const onPressWithdraw = () => {
// TODO(tomm): once act-1385 is merge use the bottom sheet button presses
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is covered by the event EarnEvents.earn_select_withdraw_type.

AppAnalytics.track(EarnEvents.earn_pool_info_tap_withdraw, {
poolId: positionId,
providerId: appId,
Expand Down Expand Up @@ -266,8 +269,8 @@ export default function EarnPoolInfoScreen({ route, navigation }: Props) {
navigation,
title: <HeaderTitleSection earnPosition={pool} tokensInfo={tokensInfo} />,
scrollPosition,
startFadeInPosition: titleHeight - titleHeight * 0.33,
animationDistance: titleHeight * 0.33,
startFadeInPosition: titleHeight - titleHeight * 0.9,
animationDistance: titleHeight * 0.66,
Copy link
Contributor

Choose a reason for hiding this comment

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

can we document these magic numbers? And any reason why they are changing to different values, when compared to the existing one where both were 0.33

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These are the values I found when testing locally that rendered the title in the header best. Moving to a single line for the token icon and title means we want a higher fade-in position and a lower animation distance. Alternatively, we could move the chain name and protocol name out of the header and compute the title height better, but that was a bigger change.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added a comment and simplified a bit in e08941d.

})

return (
Expand Down Expand Up @@ -522,7 +525,7 @@ const styles = StyleSheet.create({
flex: 1,
},
scrollContainer: {
padding: Spacing.Thick24,
paddingHorizontal: Spacing.Thick24,
...(Platform.OS === 'android' && {
minHeight: variables.height,
}),
Expand All @@ -542,6 +545,15 @@ const styles = StyleSheet.create({
titleContainer: {
gap: Spacing.Smallest8,
},
titleTokenContainer: {
flex: 1,
flexDirection: 'row',
alignItems: 'flex-start',
gap: Spacing.Smallest8,
},
titleTokenIconContainer: {
flexShrink: 1,
},
subtitleContainer: {
flex: 1,
flexDirection: 'row',
Expand Down
Loading