From 58332300301283baf5a81ddae642a94b481607d8 Mon Sep 17 00:00:00 2001 From: Anatolii <36547799+SAnatoliiS@users.noreply.github.com> Date: Tue, 18 Apr 2023 23:28:40 +0400 Subject: [PATCH] Remove decimal grouping. (#1753) --- casts/numbers/src/Numbers/UIAnimatedNumber.tsx | 16 ++-------------- casts/numbers/src/Numbers/UIStaticNumber.tsx | 6 ++---- .../numbers/src/Numbers/localizedNumberFormat.ts | 12 +----------- 3 files changed, 5 insertions(+), 29 deletions(-) diff --git a/casts/numbers/src/Numbers/UIAnimatedNumber.tsx b/casts/numbers/src/Numbers/UIAnimatedNumber.tsx index f3bae9ad3..b8dfcb06b 100644 --- a/casts/numbers/src/Numbers/UIAnimatedNumber.tsx +++ b/casts/numbers/src/Numbers/UIAnimatedNumber.tsx @@ -48,8 +48,7 @@ export function UIAnimatedNumber({ const diff = React.useRef(new BigNumber(0)); const progress = useSharedValue(0); - const { decimal: decimalSeparator, grouping: integerGroupChar } = - uiLocalized.localeInfo.numbers; + const { grouping: integerGroupChar } = uiLocalized.localeInfo.numbers; const decimalDigitCount = React.useMemo(() => { return getDecimalPartDigitCount(value, decimalAspect); @@ -60,7 +59,6 @@ export function UIAnimatedNumber({ value, decimalAspect, decimalDigitCount, - decimalSeparator, integerGroupChar, showPositiveSign, ), @@ -74,7 +72,6 @@ export function UIAnimatedNumber({ valueHolder.current, decimalAspect, decimalDigitCount, - decimalSeparator, integerGroupChar, showPositiveSign, ); @@ -89,7 +86,6 @@ export function UIAnimatedNumber({ formatted, decimalAspect, decimalDigitCount, - decimalSeparator, integerGroupChar, showPositiveSign, ], @@ -121,19 +117,11 @@ export function UIAnimatedNumber({ newValue, decimalAspect, decimalDigitCount, - decimalSeparator, integerGroupChar, showPositiveSign, ); }, - [ - formatted, - decimalAspect, - decimalDigitCount, - decimalSeparator, - integerGroupChar, - showPositiveSign, - ], + [formatted, decimalAspect, decimalDigitCount, integerGroupChar, showPositiveSign], ); useAnimatedReaction( diff --git a/casts/numbers/src/Numbers/UIStaticNumber.tsx b/casts/numbers/src/Numbers/UIStaticNumber.tsx index 8b2ae5350..0a83bf26e 100644 --- a/casts/numbers/src/Numbers/UIStaticNumber.tsx +++ b/casts/numbers/src/Numbers/UIStaticNumber.tsx @@ -40,8 +40,7 @@ export function UIStaticNumber({ showPositiveSign, }: UINumberGeneralProps & UINumberAppearance & { sign?: React.ReactNode; signBeforeNumber?: boolean }) { - const { decimal: decimalSeparator, grouping: integerGroupChar } = - uiLocalized.localeInfo.numbers; + const { grouping: integerGroupChar } = uiLocalized.localeInfo.numbers; const formatted = React.useMemo(() => { const decimalDigitCount = getDecimalPartDigitCount(value, decimalAspect); @@ -49,11 +48,10 @@ export function UIStaticNumber({ value, decimalAspect, decimalDigitCount, - decimalSeparator, integerGroupChar, showPositiveSign, ); - }, [value, decimalAspect, decimalSeparator, integerGroupChar, showPositiveSign]); + }, [value, decimalAspect, integerGroupChar, showPositiveSign]); /** * A dirty hack to respect default font scale setting of `Text`, diff --git a/casts/numbers/src/Numbers/localizedNumberFormat.ts b/casts/numbers/src/Numbers/localizedNumberFormat.ts index 13ecf2f94..7e257a662 100644 --- a/casts/numbers/src/Numbers/localizedNumberFormat.ts +++ b/casts/numbers/src/Numbers/localizedNumberFormat.ts @@ -36,8 +36,6 @@ enum Rounding { // TODO: move it to uiLocalized! // @inline const INTEGER_GROUP_SIZE = 3; -// @inline -const DECIMAL_GROUP_SIZE = 3; function getIntegerSign(integer: BigNumber, showPositiveSign?: boolean) { 'worklet'; @@ -56,7 +54,6 @@ function getIntegerSign(integer: BigNumber, showPositiveSign?: boolean) { export function formatNumber( value: BigNumber, decimalDigitCount: number, - decimalSeparator: string, integerGroupChar: string, showPositiveSign?: boolean, ) { @@ -74,11 +71,7 @@ export function formatNumber( // if it's negative it would be `-0,` or `-0.` const decimal = value.minus(integer); const decimalFormatted = decimal - .toFormat(decimalDigitCount, Rounding.RoundDown, { - decimalSeparator, - fractionGroupSize: DECIMAL_GROUP_SIZE, - fractionGroupSeparator: ' ', - }) + .toFormat(decimalDigitCount, Rounding.RoundDown) .slice(decimal.lt(0) ? 2 : 1); return { @@ -91,7 +84,6 @@ export function formatNumber( * @param value number to format * @param decimalAspect predefined aspects how to format number * @param decimalDigitCount count of digits in decimal part of the number - * @param decimalSeparator localized separator from user's device * @param integerGroupChar localized char for group from user's device * @returns formatter number as string */ @@ -99,7 +91,6 @@ export function localizedNumberFormat( value: BigNumber, decimalAspect: UINumberDecimalAspect, decimalDigitCount: number, - decimalSeparator: string, integerGroupChar: string, showPositiveSign: boolean | undefined, ) { @@ -108,7 +99,6 @@ export function localizedNumberFormat( const { integer: integerFormatted, decimal: decimalFormatted } = formatNumber( value, decimalDigitCount, - decimalSeparator, integerGroupChar, showPositiveSign, );