Skip to content

Commit

Permalink
DDW-500 Implement design for native tokens - fixing transaction scree…
Browse files Browse the repository at this point in the history
…n ui issues
  • Loading branch information
DeeJayElly committed Jan 29, 2021
1 parent f441d02 commit 3b2488e
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 6 deletions.
Expand Up @@ -370,7 +370,7 @@ export default class WalletTokenSendConfirmationDialog extends Component<
<div className={styles.amountFeesWrapper}>
<div className={styles.amount}>
{amount}
&nbsp; {currencyUnit}
&nbsp;{currencyUnit}
</div>
</div>
</div>
Expand Down
7 changes: 5 additions & 2 deletions source/renderer/app/components/wallet/WalletTokenSendForm.js
Expand Up @@ -251,11 +251,13 @@ export default class WalletTokenSendForm extends Component<Props, State> {
clearReceiverAddress = () => {
const receiverField = this.form.$('receiver');
receiverField.clear();
receiverField.focus();
};

clearAssetValue = () => {
const assetField = this.form.$('asset');
assetField.clear();
assetField.focus();
};

handleOnReset = () => {
Expand Down Expand Up @@ -624,7 +626,7 @@ export default class WalletTokenSendForm extends Component<Props, State> {
</div>
)}
</div>
{this.isReceiverValid && showReceiverField && (
{this.hasReceiverValue && showReceiverField && (
<>
<div className={styles.fieldsLine} />
<div className={styles.assetInput}>
Expand All @@ -635,7 +637,7 @@ export default class WalletTokenSendForm extends Component<Props, State> {
selectedNativeToken.amount,
false
)}
&nbsp;{selectedNativeToken.currencyUnit}
&nbsp;{selectedNativeToken.ticker}
</div>
)}
<NumericInput
Expand Down Expand Up @@ -690,6 +692,7 @@ export default class WalletTokenSendForm extends Component<Props, State> {
syncingLabel={intl.formatMessage(
messages.syncingWallet
)}
hasNativeTokens
value={selectedWalletId}
getStakePoolById={() => {}}
errorPosition="bottom"
Expand Down
Expand Up @@ -90,7 +90,7 @@
}

.clearReceiverContainer {
bottom: 0.5px;
bottom: 0;
display: flex;
height: 48px;
line-height: 48px;
Expand Down
Expand Up @@ -257,6 +257,7 @@

h2 {
display: flex;
margin-bottom: 10px;
}

.receiverRowItemAddresses {
Expand Down
Expand Up @@ -7,7 +7,7 @@ import { omit } from 'lodash';
import WalletsDropdownOption from './WalletsDropdownOption';
import styles from './WalletsDropdown.scss';

import { formattedWalletAmount } from '../../../utils/formatters';
import { formattedTokenWalletAmount, formattedWalletAmount } from '../../../utils/formatters';
import Wallet from '../../../domains/Wallet';
import StakePool from '../../../domains/StakePool';

Expand Down Expand Up @@ -52,6 +52,7 @@ type WalletOption = {
syncing?: boolean,
syncingLabel?: string,
isHardwareWallet: boolean,
hasNativeTokens?: boolean,
};

export default class WalletsDropdown extends Component<Props> {
Expand Down Expand Up @@ -106,6 +107,7 @@ export default class WalletsDropdown extends Component<Props> {
getStakePoolById,
error,
errorPosition,
hasNativeTokens,
...props
} = this.props;
const walletsData = wallets.map(
Expand All @@ -118,6 +120,7 @@ export default class WalletsDropdown extends Component<Props> {
pendingDelegations,
isRestoring,
isHardwareWallet,
ticker,
}: Wallet) => {
const hasPendingDelegations =
pendingDelegations && pendingDelegations.length > 0;
Expand All @@ -126,7 +129,8 @@ export default class WalletsDropdown extends Component<Props> {
currentStakePoolId = lastDelegationStakePoolId;
}
const delegatedStakePool = getStakePoolById(currentStakePoolId);
const detail = !isRestoring ? formattedWalletAmount(amount) : null;
const formatedAmount = hasNativeTokens ? formattedTokenWalletAmount(amount, ticker) : formattedWalletAmount(amount);
const detail = !isRestoring ? formatedAmount : null;
return {
detail,
syncing: isRestoring,
Expand Down
15 changes: 15 additions & 0 deletions source/renderer/app/utils/formatters.js
Expand Up @@ -30,6 +30,21 @@ export const formattedWalletAmount = (
return formattedAmount.toString();
};

export const formattedTokenWalletAmount = (
amount: BigNumber,
currency: string,
) => {
let formattedAmount = amount.toFormat(DECIMAL_PLACES_IN_ADA);
const { decimalSeparator } = BigNumber.config().FORMAT;
if (decimalSeparator !== '.') {
// Only BigNumber.toFormat() method is applying correct separators.
// Since this method is not used for condensed format (long = false)
// the correct number format has to be applied manually.
formattedAmount = formattedAmount.split('.').join(decimalSeparator);
}
return `${formattedAmount} ${currency}`;
};

// Symbol Name Scientific Notation
// K Thousand 1.00E+03
// M Million 1.00E+06
Expand Down

0 comments on commit 3b2488e

Please sign in to comment.