Skip to content
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
5 changes: 5 additions & 0 deletions .changeset/stupid-plants-laugh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"live-mobile": minor
---

CurrencyIcon simplification and cache bug fix
2 changes: 1 addition & 1 deletion apps/ledger-live-mobile/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 36176158
versionName "3.97.1"
versionName "3.98.0"
resValue "string", "build_config_package", "com.ledger.live"
testBuildType System.getProperty('testBuildType', 'debug')
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
Expand Down
2 changes: 1 addition & 1 deletion apps/ledger-live-mobile/src/components/AccountCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const AccountCard = ({
style={style}
{...props}
>
<CurrencyIcon currency={currency} disabled={disabled} size={iconSize} circle />
<CurrencyIcon currency={currency} disabled={disabled} size={iconSize} />
<Flex flexGrow={1} flexShrink={1} marginLeft={4} flexDirection="row" alignItems="center">
<Flex minWidth={20} flexShrink={1}>
<Text
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ function AssetCentricGraphCard({
>
<Animated.View style={[BalanceOpacity]}>
<Flex alignItems="center">
<CurrencyIcon size={32} currency={currency} circle />
<CurrencyIcon size={32} currency={currency} />
<Flex alignItems="center">
<Flex>
{!balanceHistory ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const AssetRowLayout = ({
/>
)}
<Flex flexDirection="row" pt={topLink ? 0 : 6} pb={bottomLink ? 0 : 6} alignItems="center">
<CurrencyIcon currency={currency} size={40} circle />
<CurrencyIcon currency={currency} size={40} />
<Flex flex={1} justifyContent="center" ml={4}>
<Flex mb={1} flexDirection="row" justifyContent="space-between">
<Flex flexGrow={1} flexShrink={1} flexDirection="row" alignItems="center">
Expand Down
61 changes: 19 additions & 42 deletions apps/ledger-live-mobile/src/components/CurrencyIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React, { useMemo, memo } from "react";
import React, { memo } from "react";
import { Currency } from "@ledgerhq/types-cryptoassets";
import { Flex, ensureContrast } from "@ledgerhq/native-ui";
import { Flex } from "@ledgerhq/native-ui";
import styled, { useTheme } from "styled-components/native";
import { getCurrencyColor } from "~/helpers/getCurrencyColor";
import { CryptoIcon } from "@ledgerhq/native-ui/pre-ldls";
import { getValidCryptoIconSizeNative } from "@ledgerhq/live-common/helpers/cryptoIconSize";

Expand All @@ -12,32 +11,15 @@ const DefaultWrapper = styled(Flex)<{ disabled?: boolean }>`
opacity: ${p => (p.disabled ? 0.6 : 1)};
`;

const CircleWrapper = styled(Flex)<{ disabled?: boolean }>`
border-radius: 9999px;
border: 1px solid transparent;
background: ${p => p.color};
height: ${p => p.size}px;
width: ${p => p.size}px;
align-items: center;
justify-content: center;
opacity: ${p => (p.disabled ? 0.6 : 1)};
`;

type Props = {
currency: Currency;
size: number;
bg?: string;
circle?: boolean;
disabled?: boolean;
hideNetwork?: boolean;
};

const CurrencyIcon = ({ size, currency, circle, bg, disabled, hideNetwork }: Props) => {
const CurrencyIcon = ({ size, currency, disabled, hideNetwork }: Props) => {
const { colors } = useTheme();
const bgColor = useMemo(
() => ensureContrast(getCurrencyColor(currency), colors.constant.white),
[colors, currency],
);
const validIconSize = getValidCryptoIconSizeNative(size);

if (currency.type === "FiatCurrency") {
Expand All @@ -46,29 +28,24 @@ const CurrencyIcon = ({ size, currency, circle, bg, disabled, hideNetwork }: Pro

const ledgerId = currency.id;
const ticker = currency.ticker;
const network = hideNetwork
? undefined
: currency.type === "TokenCurrency"
? currency.parentCurrency.id
: undefined;

const cryptoIconElement = (
<CryptoIcon
ledgerId={ledgerId}
ticker={ticker}
size={validIconSize}
backgroundColor={colors.background.main}
{...(network && { network })}
/>
);

if (circle) {
return (
<CircleWrapper size={size} color={bg || bgColor} disabled={disabled}>
{cryptoIconElement}
</CircleWrapper>
const cryptoIconElement =
!hideNetwork && currency.type === "TokenCurrency" ? (
<CryptoIcon
ledgerId={ledgerId}
ticker={ticker}
size={validIconSize}
backgroundColor={colors.background.main}
network={currency.parentCurrency.id}
/>
) : (
<CryptoIcon
ledgerId={ledgerId}
ticker={ticker}
size={validIconSize}
backgroundColor={colors.background.main}
/>
);
}

if (disabled) {
return <DefaultWrapper disabled={disabled}>{cryptoIconElement}</DefaultWrapper>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default function DelegationDrawer({
left={
icon || (
<Circle size={iconWidth} bg={rgba(color, 0.2)}>
<CurrencyIcon size={iconWidth / 2} currency={currency} bg={"rgba(0,0,0,0)"} />
<CurrencyIcon size={iconWidth / 2} currency={currency} />
</Circle>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ function ZeroBalanceDisabledModalContent({
currencyTicker: actionCurrency?.ticker,
actionName: action.label,
})}
Icon={<CurrencyIcon size={48} currency={actionCurrency as Currency} circle />}
Icon={<CurrencyIcon size={48} currency={actionCurrency as Currency} />}
>
<Flex mx={16} flexDirection={"row"}>
<Button onPress={goToBuy} type="main" size={"large"} outline flex={1} mr={3}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function SummaryFromSection({ token }: Readonly<Props>) {
data={
<View style={styles.container}>
<View style={styles.currencyIcon}>
<CurrencyIcon size={16} currency={token} circle />
<CurrencyIcon size={16} currency={token} />
</View>
<LText numberOfLines={1} style={styles.text}>
{token.name}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import QRCode from "react-native-qrcode-svg";
import { Trans } from "react-i18next";
import type { Account, TokenAccount } from "@ledgerhq/types-live";
import { getMainAccount, getAccountCurrency } from "@ledgerhq/live-common/account/index";
import { getCurrencyColor } from "@ledgerhq/live-common/currencies/color";
import { CompositeScreenProps } from "@react-navigation/native";
import styled, { useTheme } from "styled-components/native";
import { Box, Flex, Text } from "@ledgerhq/native-ui";
Expand Down Expand Up @@ -109,12 +108,7 @@ export default function ReceiveConfirmation({ route }: Props) {
bg="constant.white"
position="absolute"
>
<CurrencyIcon
currency={currency}
bg={getCurrencyColor(currency) || colors.constant.black}
size={48}
circle
/>
<CurrencyIcon currency={currency} size={48} />
</Flex>
</Flex>
<Text
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default function NominationDrawer({
left={
icon || (
<Circle size={iconWidth} bg={rgba(color, 0.2)}>
<CurrencyIcon size={iconWidth / 2} currency={currency} bg={"rgba(0,0,0,0)"} />
<CurrencyIcon size={iconWidth / 2} currency={currency} />
</Circle>
)
}
Expand Down
14 changes: 0 additions & 14 deletions apps/ledger-live-mobile/src/helpers/getCurrencyColor.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const View: React.FC<ViewProps> = ({
<Text numberOfLines={1} variant="body" color="neutral.c70" flexShrink={1}>
{formattedAddress}
</Text>
<CurrencyIcon currency={currency} size={20} circle hideNetwork />
<CurrencyIcon currency={currency} size={20} hideNetwork />
</Flex>
</Flex>
{!hideBalanceInfo && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const AssetItem: React.FC<AssetItemProps> = ({ asset, balance }) => {

return (
<>
<CurrencyIcon currency={currency} size={40} circle />
<CurrencyIcon currency={currency} size={40} />
<Flex flex={1} flexShrink={1} testID={`assetItem-${currency.name}`}>
<Text
numberOfLines={1}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function DistributionCard({ item: { currency, amount, distribution } }: Props) {
<Container onPress={navigateToAccounts}>
<Flex flexDirection="row">
<IconContainer>
<CurrencyIcon currency={currency} size={35} circle />
<CurrencyIcon currency={currency} size={35} />
</IconContainer>
<CoinInfoContainer>
<CurrencyRow>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
getMainAccount,
getAccountCurrency,
} from "@ledgerhq/live-common/account/index";
import { getCurrencyColor } from "@ledgerhq/live-common/currencies/color";
import FeatureToggle from "@ledgerhq/live-common/featureFlags/FeatureToggle";
import { useTheme } from "styled-components/native";
import { Flex, Text, IconsLegacy, Button, Box, BannerCard, Icons } from "@ledgerhq/native-ui";
Expand Down Expand Up @@ -379,12 +378,7 @@ function ReceiveConfirmationInner({ navigation, route, account, parentAccount }:
bg="constant.white"
position="absolute"
>
<CurrencyIcon
currency={currency}
bg={getCurrencyColor(currency) || colors.constant.black}
size={48}
circle
/>
<CurrencyIcon currency={currency} size={48} />
</Flex>
</Flex>
<Text
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const TokenContextualModal = ({
preventBackdropClick={false}
Icon={
showingContextMenu ? (
<CurrencyIcon size={48} currency={getAccountCurrency(account)} circle />
<CurrencyIcon size={48} currency={getAccountCurrency(account)} />
) : undefined
}
title={showingContextMenu ? account.token.name : undefined}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export const GenerateMockAccountSelectScreen = () => {
checked={checkedCurrencies[id]}
label={
<Flex flexDirection="row" alignItems="center" pt={2}>
<CurrencyIcon circle size={32} currency={currency} />
<CurrencyIcon size={32} currency={currency} />
<Text style={{ marginLeft: 5 }}>{name}</Text>
</Flex>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ function SignSummary({
</LText>
<View style={styles.headerContainer}>
<View style={styles.headerIconContainer}>
<CurrencyIcon size={18} currency={mainAccount.currency} circle />
<CurrencyIcon size={18} currency={mainAccount.currency} />
</View>
<LText semiBold secondary numberOfLines={1}>
{maybeAccountName}
Expand Down
2 changes: 1 addition & 1 deletion apps/web-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@codemirror/view": "^6.28.2",
"@ledgerhq/coin-framework": "workspace:^",
"@ledgerhq/cryptoassets": "workspace:^",
"@ledgerhq/crypto-icons": "1.3.0",
"@ledgerhq/crypto-icons": "catalog:",
"@ledgerhq/domain-service": "workspace:^",
"@ledgerhq/errors": "workspace:^",
"@ledgerhq/hw-app-eth": "workspace:^",
Expand Down
2 changes: 1 addition & 1 deletion libs/ui/packages/native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"storybook-generate": "sb-rn-get-stories"
},
"dependencies": {
"@ledgerhq/crypto-icons": "1.3.0",
"@ledgerhq/crypto-icons": "catalog:",
"@ledgerhq/icons-ui": "workspace:^",
"@ledgerhq/ui-shared": "workspace:^",
"color": "^4.0.0",
Expand Down
2 changes: 1 addition & 1 deletion libs/ui/packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"unimported": "unimported"
},
"dependencies": {
"@ledgerhq/crypto-icons": "1.3.0",
"@ledgerhq/crypto-icons": "catalog:",
"@ledgerhq/icons-ui": "workspace:^",
"@ledgerhq/ui-shared": "workspace:^",
"@tanstack/react-virtual": "3.13.6",
Expand Down
25 changes: 14 additions & 11 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading