-
Notifications
You must be signed in to change notification settings - Fork 934
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Innei <tukon479@gmail.com>
- Loading branch information
Showing
20 changed files
with
375 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { cn, toScientificNotation } from "@follow/utils" | ||
import { Text } from "react-native" | ||
|
||
export const Balance = ({ | ||
children, | ||
|
||
className, | ||
precision = 2, | ||
}: { | ||
/** The token balance in wei. */ | ||
children: bigint | ||
|
||
className?: string | ||
precision?: number | ||
}) => { | ||
const n = BigInt(children || 0n) | ||
const formatted = format(n, { digits: precision, trailingZeros: true }) | ||
|
||
return <Text className={cn("tabular-nums", className)}>{formatted}</Text> | ||
} | ||
|
||
function format( | ||
value: bigint, | ||
options: | ||
| number | ||
| { | ||
digits?: number | ||
compact?: boolean | ||
trailingZeros?: boolean | ||
locale?: string | ||
decimalsRounding?: "ROUND_HALF" | "ROUND_UP" | "ROUND_DOWN" | ||
signDisplay?: "auto" | "always" | "exceptZero" | "negative" | "never" | ||
} = {}, | ||
): string { | ||
// Normalize options | ||
const opts = typeof options === "number" ? { digits: options } : options | ||
const { | ||
digits, | ||
compact = false, | ||
trailingZeros = false, | ||
locale = "en-US", | ||
|
||
signDisplay = "auto", | ||
} = opts | ||
|
||
// Convert bigint to number for formatting | ||
const num = Number(value) / 1e18 // Assuming 18 decimals (wei to ether conversion) | ||
|
||
if (compact) { | ||
return new Intl.NumberFormat(locale, { | ||
notation: "compact", | ||
maximumFractionDigits: digits, | ||
minimumFractionDigits: trailingZeros ? digits : 0, | ||
signDisplay, | ||
}).format(num) | ||
} | ||
|
||
// For very large or small numbers, use scientific notation | ||
if (Math.abs(num) > 1e9 || (Math.abs(num) < 1e-9 && num !== 0)) { | ||
return toScientificNotation(num.toString(), 10) | ||
} | ||
|
||
return new Intl.NumberFormat(locale, { | ||
maximumFractionDigits: digits, | ||
minimumFractionDigits: trailingZeros ? digits : 0, | ||
signDisplay, | ||
useGrouping: true, | ||
}).format(num) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import * as React from "react" | ||
import Svg, { Path } from "react-native-svg" | ||
|
||
interface UserAdd2CuteFiIconProps { | ||
width?: number | ||
height?: number | ||
color?: string | ||
} | ||
|
||
export const UserAdd2CuteFiIcon = ({ | ||
width = 24, | ||
height = 24, | ||
color = "#10161F", | ||
}: UserAdd2CuteFiIconProps) => { | ||
return ( | ||
<Svg width={width} height={height} fill="none" viewBox="0 0 24 24"> | ||
<Path fill="#fff" fillOpacity={0.01} d="M24 0v24H0V0z" /> | ||
<Path | ||
fill={color} | ||
d="M6 7a5 5 0 1 1 10 0A5 5 0 0 1 6 7M4.822 14.672C6.425 13.694 8.605 13 11 13c.447 0 .887.024 1.316.07a1 1 0 0 1 .72 1.557A5.968 5.968 0 0 0 12 18c0 .92.207 1.79.575 2.567a1 1 0 0 1-.89 1.428c-.226.003-.455.005-.685.005-2.229 0-4.335-.14-5.913-.558-.785-.208-1.524-.506-2.084-.956C2.41 20.01 2 19.345 2 18.5c0-.787.358-1.523.844-2.139.494-.625 1.177-1.2 1.978-1.69M18 14a1 1 0 0 1 1 1v2h2a1 1 0 1 1 0 2h-2v2a1 1 0 1 1-2 0v-2h-2a1 1 0 1 1 0-2h2v-2a1 1 0 0 1 1-1" | ||
/> | ||
</Svg> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import * as React from "react" | ||
import Svg, { Path } from "react-native-svg" | ||
|
||
interface Wallet2CuteFiIconProps { | ||
width?: number | ||
height?: number | ||
color?: string | ||
} | ||
|
||
export const Wallet2CuteFiIcon = ({ | ||
width = 24, | ||
height = 24, | ||
color = "#10161F", | ||
}: Wallet2CuteFiIconProps) => { | ||
return ( | ||
<Svg width={width} height={height} fill="none" viewBox="0 0 24 24"> | ||
<Path fill="#fff" fillOpacity={0.01} d="M24 0v24H0V0z" /> | ||
<Path | ||
fill={color} | ||
fillRule="evenodd" | ||
d="M9.06 4.647a.31.31 0 0 0-.06.069c0 .01.008.086.137.231.14.157.375.335.702.504.66.342 1.503.549 2.161.549.658 0 1.502-.207 2.161-.549.327-.169.561-.347.702-.504.129-.145.136-.22.137-.231a.309.309 0 0 0-.06-.069c-.106-.094-.31-.213-.639-.325C13.647 4.102 12.765 4 12 4c-.765 0-1.647.101-2.301.322-.33.112-.533.23-.638.325m6.63 2.214c.242-.17.469-.363.663-.58.353-.395.647-.925.647-1.567 0-.666-.317-1.188-.723-1.553-.386-.348-.872-.577-1.336-.733C14.01 2.113 12.892 2 12 2c-.892 0-2.01.113-2.941.428-.464.156-.95.385-1.336.733C7.317 3.526 7 4.048 7 4.714c0 .642.294 1.172.647 1.566.194.218.42.411.663.581C5.325 8.284 3 11.335 3 15c0 2.556 1.02 4.386 2.766 5.525C7.441 21.617 9.67 22 12 22s4.56-.383 6.234-1.475C19.98 19.386 21 17.555 21 15c0-3.665-2.325-6.716-5.31-8.139m-4.296 4.192a1 1 0 1 0-1.788.894L10.132 13H10a1 1 0 1 0 0 2h1v.5h-1a1 1 0 1 0 0 2h1v.5a1 1 0 1 0 2 0v-.5h1a1 1 0 1 0 0-2h-1V15h1a1 1 0 1 0 0-2h-.132l.526-1.053a1 1 0 1 0-1.788-.894L12 12.263z" | ||
clipRule="evenodd" | ||
/> | ||
</Svg> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.