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

Transaction Header Component #1487

Merged
merged 39 commits into from
May 5, 2020
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
1ee9b2e
Remove redundant imports, remove redundant styles, comment typo corre…
EtDu Apr 11, 2020
d2d3e2d
added lock and warning icons
EtDu Apr 11, 2020
0e35f8c
removed domain prop
EtDu Apr 11, 2020
ef5866a
new TransactionHeader component, imports, styling, prop types, lock/w…
EtDu Apr 11, 2020
013a3b6
re-generated snapshot for SignatureRequest, created new test for Tran…
EtDu Apr 11, 2020
0ceaae9
network changes based on selected network
EtDu Apr 11, 2020
0cd80cc
update snapshot
EtDu Apr 11, 2020
d5d09d2
update snapshot
EtDu Apr 14, 2020
3032009
remove function, use css for network capitalization
EtDu Apr 14, 2020
b6ca43a
move network status logic to renderNetworkStatusIndicator()
EtDu Apr 14, 2020
5239163
render icon logic moved to renderSecureIcon()
EtDu Apr 14, 2020
c873969
add comments
EtDu Apr 14, 2020
a15db63
update snapshot
EtDu Apr 14, 2020
e6faaee
remove redundant getTrackingParams, use props directly
EtDu Apr 15, 2020
6ffa251
remove png icons from image dir, use react native svg icons (FontAwes…
EtDu Apr 15, 2020
34004dd
TransactionHeader: use 'Ethereum' instead of 'Mainnet'
EtDu Apr 16, 2020
9a4ee8d
Add shortnames to networks util, TransactionHeader: use networks util…
EtDu Apr 17, 2020
935177b
Merge branch 'develop' of github.com:MetaMask/metamask-mobile into tr…
EtDu Apr 17, 2020
b07e684
Remove redundant imports, remove redundant styles, comment typo corre…
EtDu Apr 11, 2020
20dfde2
added lock and warning icons
EtDu Apr 11, 2020
1e7d902
removed domain prop
EtDu Apr 11, 2020
3651f5e
new TransactionHeader component, imports, styling, prop types, lock/w…
EtDu Apr 11, 2020
8fbcb4f
re-generated snapshot for SignatureRequest, created new test for Tran…
EtDu Apr 11, 2020
c2e547f
network changes based on selected network
EtDu Apr 11, 2020
8b60530
update snapshot
EtDu Apr 11, 2020
6bd6855
update snapshot
EtDu Apr 14, 2020
8c4ca78
remove function, use css for network capitalization
EtDu Apr 14, 2020
612be16
move network status logic to renderNetworkStatusIndicator()
EtDu Apr 14, 2020
8bd9f8c
render icon logic moved to renderSecureIcon()
EtDu Apr 14, 2020
66f0b7f
add comments
EtDu Apr 14, 2020
6591da5
update snapshot
EtDu Apr 14, 2020
d5d5bcc
remove redundant getTrackingParams, use props directly
EtDu Apr 15, 2020
08d2243
remove png icons from image dir, use react native svg icons (FontAwes…
EtDu Apr 15, 2020
b623cef
TransactionHeader: use 'Ethereum' instead of 'Mainnet'
EtDu Apr 16, 2020
6e8d98a
Add shortnames to networks util, TransactionHeader: use networks util…
EtDu Apr 17, 2020
b3db4c5
Merge branch 'develop' into transaction-header
EtDu Apr 30, 2020
acb28e7
Merge branch 'transaction-header' of github.com:MetaMask/metamask-mob…
EtDu Apr 30, 2020
035370c
fixed import error
EtDu Apr 30, 2020
c86c12e
Merge branch 'develop' into transaction-header
estebanmino May 5, 2020
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 @@ -109,61 +109,14 @@ exports[`SignatureRequest should render correctly 1`] = `
</Text>
</View>
</View>
<View
style={
<Connect(TransactionHeader)
currentPageInformation={
Object {
"margin": 10,
"title": "title",
"url": "url",
}
}
>
<WebsiteIcon
style={
Object {
"borderRadius": 32,
"height": 64,
"marginTop": 15,
"width": 64,
}
}
title="title"
url="url"
viewStyle={
Object {
"alignItems": "center",
"borderRadius": 10,
"justifyContent": "center",
}
}
/>
<Text
style={
Object {
"color": "#000000",
"fontFamily": "CircularStd-Medium",
"fontSize": 16,
"fontWeight": "600",
"padding": 5,
"textAlign": "center",
}
}
>
title
</Text>
<Text
style={
Object {
"color": "#000000",
"fontFamily": "CircularStd-Medium",
"fontSize": 12,
"fontWeight": "400",
"padding": 5,
"textAlign": "center",
}
}
>
url
</Text>
</View>
/>
<View
style={
Object {
Expand Down
67 changes: 12 additions & 55 deletions app/components/UI/SignatureRequest/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ import { colors, fontStyles, baseStyles } from '../../../styles/common';
import { strings } from '../../../../locales/i18n';
import { connect } from 'react-redux';
import ActionView from '../ActionView';
import TransactionHeader from '../TransactionHeader';
import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view';
import { renderFromWei } from '../../../util/number';
import Identicon from '../Identicon';
import WebsiteIcon from '../WebsiteIcon';
import { renderAccountName } from '../../../util/address';
import Analytics from '../../../core/Analytics';
import ANALYTICS_EVENT_OPTS from '../../../util/analytics';
import { getHost } from '../../../util/browser';

const styles = StyleSheet.create({
wrapper: {
Expand Down Expand Up @@ -66,39 +65,11 @@ const styles = StyleSheet.create({
padding: 5,
textAlign: 'center'
},
domainText: {
...fontStyles.normal,
textAlign: 'center',
fontSize: 12,
padding: 5,
color: colors.black
},
domainTitle: {
...fontStyles.bold,
textAlign: 'center',
fontSize: 16,
padding: 5,
color: colors.black
},
children: {
flex: 1,
borderTopColor: colors.grey200,
borderTopWidth: 1,
height: '100%'
},
domainLogo: {
marginTop: 15,
width: 64,
height: 64,
borderRadius: 32
},
assetLogo: {
alignItems: 'center',
justifyContent: 'center',
borderRadius: 10
},
domainWrapper: {
margin: 10
}
});

Expand Down Expand Up @@ -135,10 +106,6 @@ class SignatureRequest extends PureComponent {
* Content to display above the action buttons
*/
children: PropTypes.node,
/**
* Object containing domain information for the signature request for EIP712
*/
domain: PropTypes.object,
/**
* Object containing current page title and url
*/
Expand All @@ -148,7 +115,7 @@ class SignatureRequest extends PureComponent {
*/
type: PropTypes.string,
/**
* String representing the selected the selected network
* String representing the selected network
*/
networkType: PropTypes.string,
/**
Expand All @@ -157,24 +124,6 @@ class SignatureRequest extends PureComponent {
showWarning: PropTypes.bool
};

renderPageInformation = () => {
const {
domain,
currentPageInformation: { url },
currentPageInformation
} = this.props;
const title = typeof currentPageInformation.title === 'string' ? currentPageInformation.title : getHost(url);
const name = domain && typeof domain.name === 'string';
return (
<View style={styles.domainWrapper}>
<WebsiteIcon style={styles.domainLogo} viewStyle={styles.assetLogo} title={title} url={url} />
<Text style={styles.domainTitle}>{title}</Text>
<Text style={styles.domainText}>{url}</Text>
{!!name && <Text style={styles.domainText}>{name}</Text>}
</View>
);
};

/**
* Calls trackCancelSignature and onCancel callback
*/
Expand Down Expand Up @@ -229,7 +178,15 @@ class SignatureRequest extends PureComponent {
);

render() {
const { children, showWarning, accounts, selectedAddress, identities } = this.props;
const {
children,
showWarning,
accounts,
selectedAddress,
identities,
currentPageInformation,
type
} = this.props;
const balance = renderFromWei(accounts[selectedAddress].balance);
const accountLabel = renderAccountName(selectedAddress, identities);
return (
Expand All @@ -256,7 +213,7 @@ class SignatureRequest extends PureComponent {
</Text>
</View>
</View>
{this.renderPageInformation()}
<TransactionHeader currentPageInformation={currentPageInformation} type={type} />
<View style={styles.signingInformation}>
{showWarning ? (
this.showWarning()
Expand Down
142 changes: 142 additions & 0 deletions app/components/UI/TransactionHeader/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`TransactionHeader should render correctly 1`] = `
<View
style={
Object {
"alignItems": "center",
"justifyContent": "center",
"margin": 10,
}
}
>
<WebsiteIcon
style={
Object {
"borderRadius": 32,
"height": 64,
"marginTop": 15,
"width": 64,
}
}
title="url"
url="url"
viewStyle={
Object {
"alignItems": "center",
"borderRadius": 10,
"justifyContent": "center",
}
}
/>
<View
style={
Object {
"alignItems": "center",
"flexDirection": "row",
"justifyContent": "center",
"marginTop": 10,
}
}
>
<Image
resizeMethod="resize"
resizeMode="contain"
source={
Object {
"testUri": "../../../app/images/warning-icon.png",
}
}
style={
Object {
"height": 15,
"marginBottom": 3,
"marginRight": 5,
"width": 15,
}
}
/>
<Text
style={
Object {
"color": "#000000",
"fontFamily": "CircularStd-Medium",
"fontSize": 14,
"fontWeight": "600",
"textAlign": "center",
}
}
>
url
</Text>
</View>
<View
style={
Object {
"alignItems": "center",
"flexDirection": "row",
"justifyContent": "center",
"marginBottom": 12,
}
}
>
<View
style={
Array [
Object {
"borderRadius": 2.5,
"height": 5,
"width": 5,
},
Object {
"backgroundColor": "green",
},
]
}
/>
<Text
style={
Object {
"color": "#000000",
"fontFamily": "CircularStd-Medium",
"fontSize": 12,
"fontWeight": "400",
"padding": 5,
"textAlign": "center",
}
}
>
Ropsten
</Text>
</View>
<View
style={
Object {
"alignItems": "center",
"flex": 1,
"justifyContent": "center",
}
}
>
<Text
style={
Object {
"borderColor": "#d6d9dc",
"borderRadius": 10,
"borderWidth": 1,
"fontFamily": "CircularStd-Medium",
"fontSize": 10,
"fontWeight": "300",
"height": 20,
"paddingLeft": 6,
"paddingRight": 6,
"paddingTop": 3,
"textAlign": "center",
}
}
>
functionName
</Text>
</View>
</View>
`;
Loading