Skip to content

Commit

Permalink
ADD: See currency when tap and hold on balance
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosrdz committed Nov 13, 2023
1 parent 242a6a7 commit 2bc0d28
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
3 changes: 2 additions & 1 deletion blue_modules/storage-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ export const BlueStorageProvider = ({ children }) => {
}, []);

const getPreferredCurrency = async () => {
const item = await getPreferredCurrencyAsyncStorage();
const item = JSON.parse(await getPreferredCurrencyAsyncStorage());
_setPreferredFiatCurrency(item);
return item;
};

const setPreferredFiatCurrency = () => {
Expand Down
12 changes: 9 additions & 3 deletions components/TransactionsNavigationHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import loc, { formatBalance } from '../loc';
import { BlueStorageContext } from '../blue_modules/storage-context';
import ToolTipMenu from './TooltipMenu';
import { BluePrivateBalance } from '../BlueComponents';
import { FiatUnit } from '../models/fiatUnit';

interface TransactionsNavigationHeaderProps {
wallet: AbstractWallet;
Expand Down Expand Up @@ -40,7 +41,7 @@ const TransactionsNavigationHeader: React.FC<TransactionsNavigationHeaderProps>
const [wallet, setWallet] = useState(initialWallet);
const [allowOnchainAddress, setAllowOnchainAddress] = useState(false);

const context = useContext(BlueStorageContext);
const { preferredFiatCurrency, saveToDisk } = useContext(BlueStorageContext);
const menuRef = useRef(null);

const verifyIfWalletAllowsOnchainAddress = useCallback(() => {
Expand Down Expand Up @@ -81,7 +82,7 @@ const TransactionsNavigationHeader: React.FC<TransactionsNavigationHeaderProps>

const updatedWallet = updateWalletVisibility(wallet, !wallet.hideBalance);
setWallet(updatedWallet);
context.saveToDisk();
saveToDisk();
};

const updateWalletWithNewUnit = (w: AbstractWallet, newPreferredUnit: BitcoinUnit) => {
Expand Down Expand Up @@ -155,13 +156,18 @@ const TransactionsNavigationHeader: React.FC<TransactionsNavigationHeaderProps>
})()}
style={styles.chainIcon}
/>

<Text testID="WalletLabel" numberOfLines={1} style={styles.walletLabel}>
{wallet.getLabel()}
</Text>
<ToolTipMenu
onPress={changeWalletBalanceUnit}
ref={menuRef}
title={loc.wallets.balance}
title={`${loc.wallets.balance} (${
wallet.getPreferredBalanceUnit() === BitcoinUnit.LOCAL_CURRENCY
? preferredFiatCurrency.endPointKey ?? FiatUnit.USD
: wallet.getPreferredBalanceUnit()
})`}
onPressMenuItem={onPressMenuItem}
actions={
wallet.hideBalance
Expand Down

0 comments on commit 2bc0d28

Please sign in to comment.