diff --git a/src/App.js b/src/App.js
index 445d56016..7c9bccbc2 100644
--- a/src/App.js
+++ b/src/App.js
@@ -18,6 +18,7 @@ import Receive from './components/Receive'
import Share from './components/Share'
import ShareLink from './components/ShareLink'
import Balance from "./components/Balance";
+import SimpleBalance from "./components/SimpleBalance";
import Receipt from "./components/Receipt";
import MainCard from './components/MainCard';
import History from './components/History';
@@ -158,18 +159,19 @@ export default class App extends Component {
// NOTE: This function is for _displaying_ a currency value to a user. It
// adds a currency unit to the beginning or end of the number!
- currencyDisplay = amount => {
+ currencyDisplay = (amount, toParts) => {
// NOTE: For some reason, this function seems to take very long.
- const { exchangeRate } = this.state
- const locale = localStorage.getItem('i18nextLng')
+ const { exchangeRate } = this.state;
+ const locale = localStorage.getItem('i18nextLng');
const symbol = localStorage.getItem('currency') || Object.keys(exchangeRate)[0];
const convertedAmount = this.fromDollars(amount);
- return new Intl.NumberFormat(locale, {
+ const formatter = new Intl.NumberFormat(locale, {
style: 'currency',
currency: symbol,
- maximumFractionDigits: 2
- }).format(convertedAmount)
+ maximumFractionDigits: 2
+ });
+ return toParts ? formatter.formatToParts(convertedAmount) : formatter.format(convertedAmount);
}
// `fromDollars` and `toDollars` is used to convert floats from one currency
@@ -249,7 +251,6 @@ export default class App extends Component {
})
}
componentDidMount(){
-
document.body.style.backgroundColor = mainStyle.backgroundColor
this.detectContext()
@@ -333,7 +334,7 @@ export default class App extends Component {
}
this.setState({mainnetweb3,daiContract,bridgeContract})
}
-
+
componentWillUnmount() {
clearInterval(interval)
clearInterval(intervalLong)
@@ -720,6 +721,10 @@ export default class App extends Component {
}
}
render() {
+ const expertMode = localStorage.getItem("expertMode") === "true"
+ // Right now "expertMode" is enabled by default. To disable it by default, remove the following line.
+ || localStorage.getItem("expertMode") === null;
+
let {
web3, account, gwei, block, avgBlockTime, etherscan, balance, metaAccount, burnMetaAccount, view, alert, send
} = this.state;
@@ -825,6 +830,7 @@ export default class App extends Component {
buttonStyle={buttonStyle}
changeView={this.changeView}
isVendor={this.state.isVendor&&this.state.isVendor.isAllowed}
+ expertMode={expertMode}
/>
)
@@ -847,7 +853,7 @@ export default class App extends Component {
return (
-
{defaultBalanceDisplay}
@@ -889,10 +895,10 @@ export default class App extends Component {
-
{extraTokens}
+ {expertMode ? (<>
@@ -963,6 +970,12 @@ export default class App extends Component {
amount={parseFloat(this.state.ethBalance) * parseFloat(this.state.ethprice)}
address={account}
currencyDisplay={this.currencyDisplay}/>
+ >) : (
+
+ )}
{/* eslint-disable-next-line jsx-a11y/accessible-emoji */}
💀 This product is currently in early alpha. Use at your own risk! 💀
diff --git a/src/components/Advanced.js b/src/components/Advanced.js
index e0451bf43..f4448e6cb 100644
--- a/src/components/Advanced.js
+++ b/src/components/Advanced.js
@@ -8,6 +8,8 @@ import {
Text,
Select,
Flex,
+ Box,
+ Checkbox
} from 'rimble-ui'
import { PrimaryButton, BorderButton } from '../components/Buttons'
import getConfig from '../config'
@@ -21,13 +23,17 @@ export default class Advanced extends React.Component {
privateKeyQr:false,
seedPhraseHidden:true,
privateKeyHidden:true,
- currency: ''
+ currency: '',
+ expertMode:false
}
}
componentDidMount() {
let currency = localStorage.getItem('currency')
- this.setState({ currency })
+ const expertMode = localStorage.getItem("expertMode") === "true"
+ // Right now "expertMode" is enabled by default. To disable it by default, remove the following line.
+ || localStorage.getItem("expertMode") === null;
+ this.setState({ currency, expertMode })
}
updateCurrency = e => {
@@ -36,9 +42,15 @@ export default class Advanced extends React.Component {
localStorage.setItem('currency', value)
}
+ updateAdvancedBalance= e => {
+ let { checked } = e.target
+ this.setState({ expertMode: checked })
+ localStorage.setItem('expertMode', checked)
+ }
+
render(){
let {isVendor, balance, privateKey, changeAlert, changeView, setPossibleNewPrivateKey} = this.props
- let { currency } = this.state
+ let { currency, expertMode } = this.state
let url = window.location.protocol+"//"+window.location.hostname
if(window.location.port&&window.location.port!==80&&window.location.port!==443){
@@ -146,34 +158,36 @@ export default class Advanced extends React.Component {
return (
-
- {i18n.t('currency.label')}
-
-
-
-
Learn More
-
-
-
-
+
{privateKey && !isVendor &&
diff --git a/src/components/Balance.js b/src/components/Balance.js
index aa7021ff4..19e8eaecd 100644
--- a/src/components/Balance.js
+++ b/src/components/Balance.js
@@ -2,6 +2,9 @@ import React from 'react';
import { Flex, Text, Image } from "rimble-ui";
export default ({icon, text, amount, currencyDisplay}) => {
+ const expertMode = localStorage.getItem("expertMode") === "true"
+ // Right now "expertMode" is enabled by default. To disable it by default, remove the following line.
+ || localStorage.getItem("expertMode") === null;
let opacity = 1
@@ -11,15 +14,21 @@ export default ({icon, text, amount, currencyDisplay}) => {
return (
+ {expertMode ? (
{text}
+ ) : (
+
+ Your balance
+
+ )}
-
+
{/* NOTE: Sometimes the exchangeRate to fiat wasn't loaded yet and hence
* amount can become NaN. In this case, we simply pass 0 to
* currencyDisplay.*/}
diff --git a/src/components/MoreButtons.js b/src/components/MoreButtons.js
index e5826c8e1..03fb7af9d 100644
--- a/src/components/MoreButtons.js
+++ b/src/components/MoreButtons.js
@@ -6,6 +6,7 @@ import { BorderButton } from "./Buttons";
export default ({
isVendor,
changeView,
+ expertMode
}) => {
let exchangeButton;
@@ -41,7 +42,7 @@ export default ({
return (
-
+
{
@@ -54,7 +55,7 @@ export default ({
- {exchangeButton}
+ {isVendor || expertMode ? {exchangeButton} : null}
);
};
diff --git a/src/components/SimpleBalance.js b/src/components/SimpleBalance.js
new file mode 100644
index 000000000..9dddedbf2
--- /dev/null
+++ b/src/components/SimpleBalance.js
@@ -0,0 +1,69 @@
+import React from "react";
+import styled from "styled-components";
+import { Text } from "rimble-ui";
+
+// Here are all the classes that can be used to style the balance.
+// Some of them are not in use now, but are listed for clarity.
+
+const StyledBalance = styled.div`
+ text-align: center;
+ padding: 20px 0;
+
+ color: var(--primary);
+
+ .otherAssets {
+ color: var(--dark-text);
+ }
+
+ span {
+ font-size: 200%;
+ }
+
+ .integer {
+ font-size: 400%;
+ }
+
+ .group {
+ }
+
+ .decimal {
+ }
+
+ .fraction {
+ }
+
+ .literal {
+ }
+
+ .currency {
+ font-size: 100%;
+ }
+`;
+
+export default ({ mainAmount, otherAmounts, currencyDisplay }) => {
+ if (isNaN(mainAmount) || typeof mainAmount === "undefined") {
+ mainAmount = 0.0;
+ }
+
+ const otherAssetsTotal = Object.values(otherAmounts).reduce(
+ (acc, curr) => acc + parseInt(curr, 10),
+ 0
+ );
+ const parts = currencyDisplay(mainAmount, true);
+
+ return (
+ <>
+
+ {parts.map(({ type, value }) => (
+ {value}
+ ))}
+ {otherAssetsTotal > 0 && (
+
+ +{currencyDisplay(otherAssetsTotal)} in other assets
+
+ )}
+
+
+ >
+ );
+};