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

Points: format large numbers in rank card #5265

Merged
merged 4 commits into from
Dec 14, 2023
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
2 changes: 1 addition & 1 deletion src/languages/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -1253,7 +1253,7 @@
"share_link": "Share Link",
"next_drop": "Next Drop",
"your_rank": "Your Rank",
"out_of_x": "Out of %{totalUsers}",
"of_x": "Of %{totalUsers}",
"referrals": "Referrals",
"streak": "Streak",
"longest_yet": "Longest yet",
Expand Down
88 changes: 52 additions & 36 deletions src/screens/points/components/InfoCard.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { Box, Inline, Stack, Text } from '@/design-system';
import { TextSize } from '@/design-system/components/Text/Text';

export const InfoCard = ({
// onPress,
Expand All @@ -13,43 +14,58 @@ export const InfoCard = ({
title: string;
subtitle: string;
mainText: string;
icon: string;
icon?: string;
accentColor: string;
}) => (
// <ButtonPressAnimation onPress={onPress} overflowMargin={50}>
<Box
padding="20px"
background="surfaceSecondaryElevated"
shadow="12px"
height={{ custom: 98 }}
borderRadius={18}
>
<Stack space="12px">
{/* <Inline space="4px" alignVertical="center"> */}
<Text color="labelSecondary" weight="bold" size="15pt">
{title}
</Text>
{/* <Text color="labelQuaternary" weight="heavy" size="13pt">
}) => {
let mainTextFontSize: TextSize;
if (mainText.length > 10) {
mainTextFontSize = '17pt';
} else if (mainText.length > 9) {
mainTextFontSize = '20pt';
} else {
mainTextFontSize = '22pt';
}

return (
// <ButtonPressAnimation onPress={onPress} overflowMargin={50}>
<Box
padding="20px"
background="surfaceSecondaryElevated"
shadow="12px"
height={{ custom: 98 }}
borderRadius={18}
>
<Stack space="12px">
{/* <Inline space="4px" alignVertical="center"> */}
<Text color="labelSecondary" weight="bold" size="15pt">
{title}
</Text>
{/* <Text color="labelQuaternary" weight="heavy" size="13pt">
􀅵
</Text>
</Inline> */}
<Text color="label" weight="heavy" size="22pt">
{mainText}
</Text>
<Inline space="4px">
<Text
align="center"
weight="heavy"
size="12pt"
color={{ custom: accentColor }}
>
{icon}
</Text>
<Text weight="heavy" size="13pt" color={{ custom: accentColor }}>
{subtitle}
</Text>
</Inline>
</Stack>
</Box>
// </ButtonPressAnimation>
);
<Box height={{ custom: 15 }} justifyContent="flex-end">
<Text color="label" weight="heavy" size={mainTextFontSize}>
{mainText}
</Text>
</Box>
<Inline space="4px">
{icon && (
<Text
align="center"
weight="heavy"
size="12pt"
color={{ custom: accentColor }}
>
{icon}
</Text>
)}
<Text weight="heavy" size="13pt" color={{ custom: accentColor }}>
{subtitle}
</Text>
</Inline>
</Stack>
</Box>
// </ButtonPressAnimation>
);
};
26 changes: 10 additions & 16 deletions src/screens/points/content/PointsContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,15 @@ import MaskedView from '@react-native-masked-view/masked-view';
import BlurredRainbow from '@/assets/blurredRainbow.png';
import Planet from '@/assets/planet.png';
import LinearGradient from 'react-native-linear-gradient';
import { safeAreaInsetValues } from '@/utils';
import { deviceUtils, safeAreaInsetValues } from '@/utils';
import { ButtonPressAnimation } from '@/components/animations';
import { getHeaderHeight } from '@/navigation/SwipeNavigator';
import { addressCopiedToastAtom } from '@/recoil/addressCopiedToastAtom';
import { useRecoilState } from 'recoil';
import * as i18n from '@/languages';
import { usePoints } from '@/resources/points';
import { isNil } from 'lodash';
import {
abbreviateNumber,
getFormattedTimeQuantity,
} from '@/helpers/utilities';
import { getFormattedTimeQuantity } from '@/helpers/utilities';
import { address as formatAddress } from '@/utils/abbreviations';
import { delay } from '@/utils/delay';
import { Toast, ToastPositionContainer } from '@/components/toasts';
Expand Down Expand Up @@ -244,17 +241,14 @@ export default function PointsContent() {
<InfoCard
// onPress={() => {}}
title={i18n.t(i18n.l.points.points.your_rank)}
mainText={`#${
rank >= 1_000_000
? abbreviateNumber(rank, 2)
: rank.toLocaleString('en-US')
}`}
icon="􀉬"
subtitle={i18n.t(i18n.l.points.points.out_of_x, {
totalUsers:
totalUsers >= 1_000_000
? abbreviateNumber(totalUsers, 2)
: totalUsers.toLocaleString('en-US'),
mainText={`#${rank.toLocaleString('en-US')}`}
icon={
totalUsers >= 10_000_000 && deviceUtils.isSmallPhone
? undefined
: '􀉬'
}
subtitle={i18n.t(i18n.l.points.points.of_x, {
totalUsers: totalUsers.toLocaleString('en-US'),
})}
accentColor={green}
/>
Expand Down
Loading