Skip to content

Commit

Permalink
Complete redesigns for approval flow (#1558)
Browse files Browse the repository at this point in the history
* Confirm: Use TransactionReviewFeeCard, add primaryCurrency prop, add ETH transaction fee, move renderIfGasEstimationReady to TransactionReviewFeeCard, remove adjust transaction fee button, pass props to TransactionReviewFeeCard

* CustomGas: Implement redesign. Still need to modify styling of individual gas selectors

* snapshot update

* Approve: Use Modal in place of Action Modal, use updated CustomGas

* Confirm: fix, change props.transactionState to state.transaction (merge conflict recovery)

* snapshot update

* Approve: add in ActionModal styles, use ActionModal

* Use ActionModal

* Remove transaction direction

* Add onRequestClose

* Add host and network under website icon

* Use TransactionHeader component

* Use AccountInfoCard

* Add black to text in AccountInfoCard

* Remove up/down arrow icon

* Update: styles

* Update networkFee

* Update: translation text

* Update: sync up with PR and update translations

* Add TransactionReivewDetailsCard

* Include getMethodData

* Rename onViewDetails -> toggleViewDetails

* Adjust styles

* Remove commented code

* Update: tests

* Update: TransactionReviewDetailsCard styles

* Update: Move customGas and editPermission out from Modals

* Update: remove now redundant infos

* Remove comments

* Remove padding

* Fix eslint issues

* Adjust location of KeyboardAwareScrollView for renderEditPermission

* Fix transition when opening network fee

* Update: Create translation for "Total"

* Update: secureIcon

* Update: remove padding

* Update: Add ConnectHeader component

* Update: Make ConnectHeader props isRequired

* Update: move view into RenderCustomGas method

* Add activeTabUrl so we get https and secure icon

* Update: display network fee in fiat when selected

* Update: Add save button to network fee

* Update: Add Set button for editPermission

* Update: tests

* Fix hitTest issue with network fee

* Update: Display currencySymbol

* Update: round fiat price to two decimals

* Update: fallback to  just to be safe

* Update: Add getActiveTabUrl method

Co-authored-by: Etienne Dusseault <[email protected]>
  • Loading branch information
rickycodes and EtDu authored Jun 24, 2020
1 parent 4c1258f commit af69702
Show file tree
Hide file tree
Showing 11 changed files with 532 additions and 452 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ exports[`AccountInfoCard should render correctly 1`] = `
numberOfLines={1}
style={
Object {
"color": "#000000",
"fontFamily": "CircularStd-Medium",
"fontSize": 16,
"fontWeight": "600",
Expand All @@ -59,6 +60,7 @@ exports[`AccountInfoCard should render correctly 1`] = `
numberOfLines={1}
style={
Object {
"color": "#000000",
"flexGrow": 1,
"fontFamily": "CircularStd-Medium",
"fontSize": 16,
Expand All @@ -76,6 +78,7 @@ exports[`AccountInfoCard should render correctly 1`] = `
style={
Object {
"alignSelf": "flex-start",
"color": "#000000",
"fontFamily": "CircularStd-Medium",
"fontSize": 14,
"fontWeight": "100",
Expand Down
9 changes: 6 additions & 3 deletions app/components/UI/AccountInfoCard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,20 @@ const styles = StyleSheet.create({
maxWidth: Device.isMediumDevice() ? '35%' : '45%',
...fontStyles.bold,
fontSize: 16,
marginRight: 2
marginRight: 2,
color: colors.black
},
accountAddress: {
flexGrow: 1,
...fontStyles.bold,
fontSize: 16
fontSize: 16,
color: colors.black
},
balanceText: {
...fontStyles.thin,
fontSize: 14,
alignSelf: 'flex-start'
alignSelf: 'flex-start',
color: colors.black
}
});

Expand Down
47 changes: 47 additions & 0 deletions app/components/UI/ConnectHeader/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import React, { Component } from 'react';
import { View, StyleSheet, Text, TouchableOpacity } from 'react-native';
import PropTypes from 'prop-types';
import IonicIcon from 'react-native-vector-icons/Ionicons';
import { colors, fontStyles } from '../../../styles/common';

const styles = StyleSheet.create({
header: {
width: '100%',
position: 'relative',
paddingBottom: 20
},
title: {
...fontStyles.bold,
color: colors.black,
fontSize: 14,
textAlign: 'center',
paddingVertical: 12
},
back: {
position: 'absolute',
zIndex: 1,
paddingVertical: 10,
paddingRight: 10
}
});

class ConnectHeader extends Component {
static propTypes = {
action: PropTypes.func.isRequired,
title: PropTypes.string.isRequired
};

render() {
const { title, action } = this.props;
return (
<View style={styles.header}>
<TouchableOpacity style={styles.back} onPress={action}>
<IonicIcon name={'ios-arrow-back'} size={24} color={colors.black} />
</TouchableOpacity>
<Text style={styles.title}>{title}</Text>
</View>
);
}
}

export default ConnectHeader;
13 changes: 7 additions & 6 deletions app/components/UI/TransactionHeader/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,13 @@ class TransactionHeader extends PureComponent {
*/
renderSecureIcon = () => {
const { url } = this.props.currentPageInformation;
const secureIcon =
getUrlObj(url).protocol === 'https:' ? (
<FontAwesome name={'lock'} size={15} style={styles.secureIcon} />
) : (
<FontAwesome name={'warning'} size={15} style={styles.secureIcon} />
);
const secureIcon = (
<FontAwesome
name={getUrlObj(url).protocol === 'https:' ? 'lock' : 'warning'}
size={15}
style={styles.secureIcon}
/>
);
return secureIcon;
};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
import React, { Component } from 'react';

import { StyleSheet, Text, View, TouchableOpacity } from 'react-native';
import { colors, fontStyles } from '../../../../styles/common';
import PropTypes from 'prop-types';
import IonicIcon from 'react-native-vector-icons/Ionicons';
import { strings } from '../../../../../locales/i18n';
import Feather from 'react-native-vector-icons/Feather';
import ConnectHeader from '../../../UI/ConnectHeader';

const styles = StyleSheet.create({
uppercase: {
textTransform: 'capitalize'
},
viewData: {
borderWidth: 1,
borderColor: colors.grey200,
borderRadius: 10,
padding: 16,
marginTop: 20
},
viewDataRow: {
display: 'flex',
flexDirection: 'row',
flexWrap: 'wrap'
},
viewDataTitle: {
...fontStyles.bold,
color: colors.black,
fontSize: 14
},
viewDataText: {
marginTop: 20
},
viewDataArrow: {
marginLeft: 'auto'
},
transactionDetails: {
borderWidth: 1,
borderColor: colors.grey200,
borderRadius: 10,
padding: 16
},
transactionDetailsRow: {
display: 'flex',
flexDirection: 'row',
flexWrap: 'wrap',
paddingVertical: 4
},
transactionDetailsTextLeft: {
...fontStyles.thin,
color: colors.black,
fontSize: 14
},
transactionDetailsTextRight: {
...fontStyles.bold,
color: colors.black,
fontSize: 14,
textAlign: 'right',
flexDirection: 'row',
marginLeft: 'auto'
},
section: {
minWidth: '100%',
width: '100%'
},
copyIcon: {
marginLeft: 1,
marginTop: 2
},
address: {
...fontStyles.bold,
color: colors.blue
}
});

export default class TransactionReviewDetailsCard extends Component {
static propTypes = {
toggleViewDetails: PropTypes.func,
copyContractAddress: PropTypes.func,
toggleViewData: PropTypes.func,
address: PropTypes.string,
host: PropTypes.string,
allowance: PropTypes.string,
tokenSymbol: PropTypes.string,
data: PropTypes.string,
displayViewData: PropTypes.bool,
method: PropTypes.string
};

render() {
const {
toggleViewDetails,
toggleViewData,
copyContractAddress,
address,
host,
allowance,
tokenSymbol,
data,
method,
displayViewData
} = this.props;

return (
<>
<View style={styles.section}>
<ConnectHeader
action={toggleViewDetails}
title={strings('spend_limit_edition.transaction_details')}
/>
<View style={styles.transactionDetails}>
<View style={styles.transactionDetailsRow}>
<Text style={styles.transactionDetailsTextLeft}>
{strings('spend_limit_edition.site_url')}
</Text>
<Text style={styles.transactionDetailsTextRight}>{host}</Text>
</View>
<View style={styles.transactionDetailsRow}>
<Text style={styles.transactionDetailsTextLeft}>
{strings('spend_limit_edition.contract_address')}
</Text>
<View style={styles.transactionDetailsTextRight}>
<Text style={styles.address}>{address}</Text>
<Feather
name="copy"
size={16}
color={colors.blue}
style={styles.copyIcon}
onPress={copyContractAddress}
/>
</View>
</View>
<View style={styles.transactionDetailsRow}>
<Text style={styles.transactionDetailsTextLeft}>
{strings('spend_limit_edition.allowance')}
</Text>
<Text style={styles.transactionDetailsTextRight}>
{allowance} {tokenSymbol}
</Text>
</View>
</View>
<View style={styles.viewData}>
<TouchableOpacity style={styles.viewDataRow} onPress={toggleViewData}>
<Text style={styles.viewDataTitle}>{strings('spend_limit_edition.view_data')}</Text>
<View style={styles.viewDataArrow}>
<IonicIcon
name={`ios-arrow-${displayViewData ? 'up' : 'down'}`}
size={16}
color={colors.grey500}
/>
</View>
</TouchableOpacity>
{displayViewData ? (
<>
<Text style={[styles.viewDataText, styles.uppercase]}>
{strings('spend_limit_edition.function')}: {method}
</Text>
<Text style={styles.viewDataText}>{data}</Text>
</>
) : null}
</View>
</View>
</>
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ exports[`Approve should render correctly 1`] = `
}
}
accountsLength={1}
contractBalances={
Object {
"0x2": "0",
}
}
activeTabUrl="https://metamask.github.io/test-dapp/"
conversionRate={100}
currentCurrency="USD"
identities={
Expand All @@ -24,6 +20,7 @@ exports[`Approve should render correctly 1`] = `
},
}
}
primaryCurrency="Fiat"
setTransactionObject={[Function]}
showAlert={[Function]}
ticker="ETH"
Expand Down
Loading

0 comments on commit af69702

Please sign in to comment.