forked from LedgerHQ/ledger-live-common
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreactNative.ts
28 lines (25 loc) · 839 Bytes
/
reactNative.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import * as icons from "./data/icons/reactNative";
import * as flags from "./data/flags/reactNative";
import type { CryptoCurrency, TokenCurrency } from "./types";
type Icon = React.ComponentType<{
size: number;
color: string;
}>;
function getIconId({ ticker }: CryptoCurrency | TokenCurrency) {
let id = ticker.toLowerCase();
if (!isNaN(parseInt(id.charAt(0), 10))) id = `_${id}`; // fix variable name leading with a numerical value
return id;
}
export function getCryptoCurrencyIcon(
currency: CryptoCurrency
): Icon | null | undefined {
return icons[getIconId(currency)];
}
export function getTokenCurrencyIcon(
token: TokenCurrency
): Icon | null | undefined {
return icons[getIconId(token)];
}
export function getFlag(countryCode: string): Icon | undefined {
return flags[`${countryCode.toLowerCase()}Flag`];
}