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

fix: Graph label display currency prices instead of coin #425

Merged
merged 1 commit into from
Dec 23, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,12 @@ export const LineGraph: React.FC<LineGraphProps> = ({

const type = diff >= 0 ? "positive" : "negative";

setTokenState({ diff: Math.abs(percentageDiff), time, type });
setTokenState({
percentageDiff: Math.abs(percentageDiff),
diff: diff * 100,
time,
type,
});
}
setPrices(newPrices);
setLoading(false);
Expand Down
12 changes: 6 additions & 6 deletions packages/fetch-extension/src/pages-new/main/balances/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ export const Balances: React.FC<Props> = observer(({ tokenState }) => {

const changeInDollarsValue =
tokenState.type === "positive"
? (parseFloat(totalNumber) * tokenState.diff) / 100
: -(parseFloat(totalNumber) * tokenState.diff) / 100;
? tokenState.diff / 100
: -tokenState.diff / 100;

const changeInDollarsClass =
tokenState.type === "positive"
Expand Down Expand Up @@ -136,7 +136,7 @@ export const Balances: React.FC<Props> = observer(({ tokenState }) => {
</div>
<div className={style["changeInPer"]}>
( {tokenState.type === "positive" ? "+" : "-"}
{parseFloat(tokenState.diff).toFixed(2)} %)
{parseFloat(tokenState.percentageDiff).toFixed(1)} %)
</div>
<div className={style["day"]}>{tokenState.time}</div>
</div>
Expand All @@ -161,7 +161,7 @@ export const Balances: React.FC<Props> = observer(({ tokenState }) => {
rewards.isFetching ? (
<Skeleton height="21px" />
) : totalPrice ? (
` ${totalPrice.toString()} `
` ${totalPrice.toString()} ${fiatCurrency.toUpperCase()}`
) : (
` ${total
.shrink(true)
Expand All @@ -184,11 +184,11 @@ export const Balances: React.FC<Props> = observer(({ tokenState }) => {
style["changeInDollars"] + " " + changeInDollarsClass
}
>
{changeInDollarsValue.toFixed(4)} {totalDenom}
{changeInDollarsValue.toFixed(4)} {fiatCurrency.toUpperCase()}
</div>
<div className={style["changeInPer"]}>
({tokenState.type === "positive" ? "+" : "-"}
{parseFloat(tokenState.diff).toFixed(2)} %)
{parseFloat(tokenState.percentageDiff).toFixed(1)} %)
</div>
<div className={style["day"]}>{tokenState.time}</div>
</div>
Expand Down
10 changes: 8 additions & 2 deletions packages/mobile/ios/mobile.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1111,7 +1111,10 @@
ONLY_ACTIVE_ARCH = YES;
OTHER_CFLAGS = "$(inherited)";
OTHER_CPLUSPLUSFLAGS = "$(inherited)";
OTHER_LDFLAGS = "$(inherited) ";
OTHER_LDFLAGS = (
"$(inherited)",
" ",
);
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
SDKROOT = iphoneos;
};
Expand Down Expand Up @@ -1186,7 +1189,10 @@
MTL_ENABLE_DEBUG_INFO = NO;
OTHER_CFLAGS = "$(inherited)";
OTHER_CPLUSPLUSFLAGS = "$(inherited)";
OTHER_LDFLAGS = "$(inherited) ";
OTHER_LDFLAGS = (
"$(inherited)",
" ",
);
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
SDKROOT = iphoneos;
SWIFT_COMPILATION_MODE = wholemodule;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ export const LineGraph: FunctionComponent<{
const timestamp = new Date().getTime();

tokenState = {
diff: Math.abs(percentageDiff),
percentageDiff: Math.abs(percentageDiff),
diff: diff * 100,
time: getTimeLabel(),
timestamp,
type,
Expand Down
19 changes: 13 additions & 6 deletions packages/mobile/src/screens/home/account-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ export const AccountSection: FunctionComponent<{
);
const changeInDollarsValue =
tokenState.type === "positive"
? (parseFloat(totalNumber) * tokenState.diff) / 100
: -(parseFloat(totalNumber) * tokenState.diff) / 100;
? tokenState.diff / 100
: -tokenState.diff / 100;

const accountOrChainChanged =
activityStore.getAddress !== account.bech32Address ||
Expand Down Expand Up @@ -418,10 +418,17 @@ export const AccountSection: FunctionComponent<{
) as ViewStyle
}
>
{tokenState.type === "positive" && "+"}
{changeInDollarsValue.toFixed(4)} {totalDenom}(
{tokenState.type === "positive" ? "+" : "-"}
{parseFloat(tokenState.diff).toFixed(2)} %)
{`${
tokenState.type === "positive" ? "+" : ""
}${changeInDollarsValue.toFixed(
4
)} ${priceStore.defaultVsCurrency.toUpperCase()} (${
tokenState.type === "positive" ? "+" : "-"
}${
Number.isNaN(parseFloat(tokenState.percentageDiff))
? "0"
: parseFloat(tokenState.percentageDiff).toFixed(1)
} %)`}
</Text>
<Text
style={
Expand Down
1 change: 1 addition & 0 deletions packages/mobile/src/screens/home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const HomeScreen: FunctionComponent = observer(() => {
useStore();

const [tokenState, setTokenState] = useState({
percentageDiff: 0,
diff: 0,
time: "TODAY",
type: "positive",
Expand Down
Loading