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

Sig request design fixed #1493

Merged
merged 95 commits into from
May 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
9990027
new folder for AccountInfoCard component, remove signature_request.ti…
EtDu Apr 14, 2020
f291c0a
SignatureRequest: remove account information from top, proptypes, pro…
EtDu Apr 14, 2020
15f02a5
SignatureRequest: change signing message to 'Sign this message?', mak…
EtDu Apr 14, 2020
7912c03
remove keyboard aware scroll view
EtDu Apr 14, 2020
8ddde9d
Add AccountInfoCard component to SignatureRequest
EtDu Apr 14, 2020
c59ae57
AccountInfoCard: implement proper styling
EtDu Apr 14, 2020
b551336
AccountInfoCard: use renderShortAddress, fix styles, use conversionRa…
EtDu Apr 15, 2020
19031f5
ActionView: add isSigning prop, disables scroll when true, SignatureR…
EtDu Apr 15, 2020
d8be5a9
AccountInfoCard: remove top level view
EtDu Apr 15, 2020
24f54ca
SignatureRequest: apply styles & layout, add website + arrow icons
EtDu Apr 15, 2020
36b1ff9
Signing components: update styling, rename informationRow --> informa…
EtDu Apr 15, 2020
72f868f
remove message style
EtDu Apr 16, 2020
ac7f421
TypedSign: put back message style, add messageWrapper style, ensure d…
EtDu Apr 16, 2020
2765e4e
AccountInfoCard: add snapshot test
EtDu Apr 16, 2020
71c61f5
update snapshots
EtDu Apr 16, 2020
ce57e18
styling of 'sign this message'
EtDu Apr 16, 2020
8371934
update snapshot
EtDu Apr 16, 2020
ff0da31
update snapshot
EtDu Apr 16, 2020
2823612
SignatureRequest: Always render arrow if children coming from TypedSign
EtDu Apr 17, 2020
15cb5d0
SignatureRequest: change to regular component with state to show expa…
EtDu Apr 17, 2020
f23031d
fix dapp icon style, fix render inf loop
EtDu Apr 18, 2020
df050ff
remove textwrap for typed sign. Now renders properly for V1, V3 & V4
EtDu Apr 18, 2020
092cc1c
AccountInfoCard: fix paddings, identicon style, use widths instead of…
EtDu Apr 18, 2020
d0bf963
TypedSign: use width instead of flex
EtDu Apr 18, 2020
829fa86
SignatureRequest: remove website icon wrapper, fix arrow positioning,…
EtDu Apr 18, 2020
07490dd
temp disable warning to match style, ensure message fits within box
EtDu Apr 18, 2020
c1844a8
PersonalSign: create message wrapper, ensure message fits within box
EtDu Apr 18, 2020
7bdb194
Message & Personal Sign: use ellipses mode for text wrapper, drop mes…
EtDu Apr 18, 2020
a19f1c5
SignatureRequest: remove shouldRenderArrow, add shouldRenderArrow prop
EtDu Apr 18, 2020
9d22c00
MessageSign: change to stateful component, add renderArrow state, dec…
EtDu Apr 18, 2020
b8929f4
PersonalSign: change to stateful component, add renderArrow state, de…
EtDu Apr 18, 2020
b49b4a1
TypedSign: shouldRenderArrow always passes down as true. Will never b…
EtDu Apr 18, 2020
c414b92
SignatureRequest: change back to pure component, change handleMessage…
EtDu Apr 20, 2020
76e7f4b
change handleMessageTap to toggleExpandedMessage
EtDu Apr 20, 2020
0d8d42a
TypedSign: implement message expansion and retraction
EtDu Apr 20, 2020
883ea26
modify message, add message_from
EtDu Apr 20, 2020
a72665e
new ExpandedMessage component, rendered by typed, personal & regular …
EtDu Apr 20, 2020
ed2b81d
TypedSign: use ExpandedMessage component
EtDu Apr 20, 2020
2ca88f5
ExpandedMessage: test
EtDu Apr 20, 2020
f7fb3bd
SignatureRequest: add renderArrow prop, make box not expandable if false
EtDu Apr 20, 2020
f532db7
MessageSign: implement message expanding and retracting
EtDu Apr 20, 2020
42be920
PersonalSign: implement message expand & retract
EtDu Apr 20, 2020
90af65c
ExpandedMessage: add mock fns, update all snapshots
EtDu Apr 20, 2020
a17503a
ActionView: get rid of top border
EtDu Apr 20, 2020
3bec8f9
new button styles
EtDu Apr 20, 2020
1863b06
signing components: ensure a top left and right rounded border
EtDu Apr 20, 2020
699a7db
change Cancel & Sign to lowercase
EtDu Apr 20, 2020
13ef7ea
snapshot update
EtDu Apr 20, 2020
313c9c7
adjust style for android
EtDu Apr 21, 2020
0452644
use unique button style for signing components, fix percentage in sty…
EtDu Apr 22, 2020
54b4d73
change isSigning prop to noScroll
EtDu Apr 22, 2020
b824ee2
snapshot update
EtDu Apr 22, 2020
a744966
update more snapshots
EtDu Apr 22, 2020
a83dfb9
Signing components: revert to pure component
EtDu Apr 23, 2020
f5d04c6
AccountInfoCard: use weiToFiat & hexToBn helpers to display fiat valu…
EtDu Apr 23, 2020
3622643
Signing components: shift renderRootView() contents into render()
EtDu Apr 23, 2020
b86f0a3
update snapshot
EtDu Apr 23, 2020
4bb66a1
AccountInfoCard, SignatureRequest: fix paddings per design
EtDu Apr 24, 2020
ddae54b
AccountInfoCard: remove bottom margin
EtDu Apr 24, 2020
1fd0325
TransactionHeader: remove margins, use padding
EtDu Apr 24, 2020
2c42733
MessageSign: larger min height, showWarning prop
EtDu Apr 24, 2020
8606302
WarningMessage: use flexstart alignment for bell icon
EtDu Apr 24, 2020
da252e3
locales: change eth_sign_warning
EtDu Apr 24, 2020
e7d0a83
WarningMessage: add object as secondary prop type for warning message
EtDu Apr 24, 2020
ad736b3
SignatureRequest: use WarningMessage component, fix paddings, use ren…
EtDu Apr 24, 2020
a0632fa
snapshot update yo
EtDu Apr 24, 2020
90f36fc
SignatureRequest: move AccountInfoCard ontop of message children
EtDu Apr 27, 2020
f4151e8
snapshot update
EtDu Apr 27, 2020
51a92dd
AccountInfoCard: remove width
EtDu May 2, 2020
ff31dd2
ActionView: remove no scroll - small devices
EtDu May 2, 2020
9e3b7d5
Signing Components: remove root style, move to SignatureRequest
EtDu May 2, 2020
a91d9d7
SignatureRequest: remove style redundancies, add in root style
EtDu May 2, 2020
86d0a5d
SignatureRequest: fix height of modal based on screen height
EtDu May 2, 2020
779ea0b
ExpandedMessage: fix styling, move scrollview to signing components r…
EtDu May 3, 2020
3ad345b
ExpandedMessage: Put the scroll back
EtDu May 3, 2020
1ce7ea5
PersonalSign: remove expandedMessage text wrapper
EtDu May 3, 2020
b4494bb
SignatureRequest: fix up styling, add more overhead (reduced from sig…
EtDu May 4, 2020
2da4466
Signing components: reduce view hierarchy, move to SignatureRequest
EtDu May 4, 2020
198a13b
Locales: add Read more to signature_request
EtDu May 4, 2020
8309a82
AccountInfoCard: add operation prop, if operation is signing, only di…
EtDu May 4, 2020
5da1156
TypedSign: add shouldTruncateMessage & truncateMessage in state
EtDu May 4, 2020
9fece60
PersonalSign: remove console log
EtDu May 4, 2020
ee3c131
Signing components: change renderArrow to truncateMessage
EtDu May 4, 2020
3cad9ca
Nav/Main: add showExpandedMessage to state, add toggleExpandedMessage…
EtDu May 5, 2020
d91c1e7
Signing Components: move showExpandedMessage out of state, move out t…
EtDu May 5, 2020
745a1be
TypedSign: create different messageWrapper height for iOS & Android, …
EtDu May 5, 2020
2c90d80
ExpandedMessage: fix scrollview
EtDu May 5, 2020
d8da92d
snapshot update
EtDu May 5, 2020
82e9ef2
AccountInfoCard: use getTicker
EtDu May 6, 2020
fb30fb5
Signing components: change margin bottom from 5 to 4
EtDu May 6, 2020
96ab1b3
Device: new getMediumDevice, SignatureRequest: use getMediumDevice
EtDu May 6, 2020
ae84182
ActionView, styledButtonStyles: add cancel button style for signing c…
EtDu May 6, 2020
abe67bd
snapshot update
EtDu May 6, 2020
4deab30
SignatureRequest: fix the domain logo not being a circle
EtDu May 7, 2020
c63c7fa
update snapshot
EtDu May 7, 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
24 changes: 21 additions & 3 deletions app/components/Nav/Main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,8 @@ class Main extends PureComponent {
paymentChannelRequest: false,
paymentChannelRequestLoading: false,
paymentChannelRequestCompleted: false,
paymentChannelRequestInfo: {}
paymentChannelRequestInfo: {},
showExpandedMessage: false
};

backgroundMode = false;
Expand Down Expand Up @@ -929,8 +930,19 @@ class Main extends PureComponent {
this.setState({ signMessage: false });
};

toggleExpandedMessage = () => {
this.setState({ showExpandedMessage: !this.state.showExpandedMessage });
};

renderSigningModal = () => {
const { signMessage, signMessageParams, signType, currentPageTitle, currentPageUrl } = this.state;
const {
signMessage,
signMessageParams,
signType,
currentPageTitle,
currentPageUrl,
showExpandedMessage
} = this.state;
return (
<Modal
isVisible={signMessage}
Expand All @@ -941,7 +953,7 @@ class Main extends PureComponent {
animationInTiming={600}
animationOutTiming={600}
onBackdropPress={this.onSignAction}
onBackButtonPress={this.onSignAction}
onBackButtonPress={showExpandedMessage ? this.toggleExpandedMessage : this.onSignAction}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this feels strange to me, having a state variable from /Main to change stuff inside a component. Did you try to use https://reactnative.dev/docs/backhandler to handle the back button on these modals?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but when a Modal is open BackHandler doesn't publish any events. Modal has the onRequestClose prop for this very purpose. Since we're using a wrapped version of the native Modal, it's onBackButtonPress. Since the Modal is at the top of the view hierarchy for signing operations, I wasn't sure how else to implement this.

onSwipeComplete={this.onSignAction}
swipeDirection={'down'}
propagateSwipe
Expand All @@ -952,6 +964,8 @@ class Main extends PureComponent {
onCancel={this.onSignAction}
onConfirm={this.onSignAction}
currentPageInformation={{ title: currentPageTitle, url: currentPageUrl }}
toggleExpandedMessage={this.toggleExpandedMessage}
showExpandedMessage={showExpandedMessage}
/>
)}
{signType === 'typed' && (
Expand All @@ -960,6 +974,8 @@ class Main extends PureComponent {
onCancel={this.onSignAction}
onConfirm={this.onSignAction}
currentPageInformation={{ title: currentPageTitle, url: currentPageUrl }}
toggleExpandedMessage={this.toggleExpandedMessage}
showExpandedMessage={showExpandedMessage}
/>
)}
{signType === 'eth' && (
Expand All @@ -969,6 +985,8 @@ class Main extends PureComponent {
onCancel={this.onSignAction}
onConfirm={this.onSignAction}
currentPageInformation={{ title: currentPageTitle, url: currentPageUrl }}
toggleExpandedMessage={this.toggleExpandedMessage}
showExpandedMessage={showExpandedMessage}
/>
)}
</Modal>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`AccountInfoCard should render correctly 1`] = `
<View
style={
Object {
"borderColor": "#bbc0c5",
"borderRadius": 10,
"borderWidth": 1,
"flexDirection": "row",
"justifyContent": "flex-start",
"padding": 16,
}
}
>
<Component
address="0x0"
customStyle={
Object {
"marginRight": 8,
}
}
diameter={40}
/>
<View
style={
Object {
"alignItems": "flex-start",
"flexDirection": "column",
"flexGrow": 1,
"justifyContent": "center",
}
}
>
<View
style={
Object {
"flexDirection": "row",
"justifyContent": "flex-start",
"width": "100%",
}
}
>
<Text
numberOfLines={1}
style={
Object {
"fontFamily": "CircularStd-Medium",
"fontSize": 16,
"fontWeight": "600",
"marginRight": 2,
"maxWidth": "55%",
}
}
>
0x0...0x0
</Text>
<Text
numberOfLines={1}
style={
Object {
"flexGrow": 1,
"fontFamily": "CircularStd-Medium",
"fontSize": 16,
"fontWeight": "600",
}
}
>
(
0x0...0x0
)
</Text>
</View>
<Text
numberOfLines={1}
style={
Object {
"alignSelf": "flex-start",
"fontFamily": "CircularStd-Medium",
"fontSize": 14,
"fontWeight": "100",
}
}
>
Balance:

0 undefined

(&lt; 0.00001 eth)
</Text>
</View>
</View>
`;
132 changes: 132 additions & 0 deletions app/components/UI/AccountInfoCard/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { StyleSheet, View, Text } from 'react-native';
import { colors, fontStyles } from '../../../styles/common';
import { renderFromWei, weiToFiat, hexToBN } from '../../../util/number';
import Identicon from '../Identicon';
import { strings } from '../../../../locales/i18n';
import { connect } from 'react-redux';
import { renderAccountName, renderShortAddress } from '../../../util/address';
import { getTicker } from '../../../util/transactions';

const styles = StyleSheet.create({
accountInformation: {
flexDirection: 'row',
justifyContent: 'flex-start',
borderWidth: 1,
borderColor: colors.grey200,
borderRadius: 10,
padding: 16
},
identicon: {
marginRight: 8
},
accountInfoRow: {
flexGrow: 1,
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'flex-start'
},
accountNameAndAddress: {
width: '100%',
flexDirection: 'row',
justifyContent: 'flex-start'
},
accountName: {
maxWidth: '55%',
...fontStyles.bold,
fontSize: 16,
marginRight: 2
},
accountAddress: {
flexGrow: 1,
...fontStyles.bold,
fontSize: 16
},
balanceText: {
...fontStyles.thin,
fontSize: 14,
alignSelf: 'flex-start'
}
});

class AccountInfoCard extends PureComponent {
static propTypes = {
/**
* Map of accounts to information objects including balances
*/
accounts: PropTypes.object,
/**
* List of accounts from the PreferencesController
*/
identities: PropTypes.object,
/**
* A string that represents the selected address
*/
selectedAddress: PropTypes.string,
/**
* A number that specifies the ETH/USD conversion rate
*/
conversionRate: PropTypes.number,
/**
* The selected currency
*/
currentCurrency: PropTypes.string,
/**
* Declares the operation being performed i.e. 'signing'
*/
operation: PropTypes.string,
/**
* Current selected ticker
*/
ticker: PropTypes.string
};

render() {
const {
accounts,
selectedAddress,
identities,
conversionRate,
currentCurrency,
operation,
ticker
} = this.props;
const weiBalance = hexToBN(accounts[selectedAddress].balance);
const balance = `(${renderFromWei(weiBalance)} ${getTicker(ticker)})`;
const accountLabel = renderAccountName(selectedAddress, identities);
const address = renderShortAddress(selectedAddress);
const dollarBalance = weiToFiat(weiBalance, conversionRate, currentCurrency);
return (
<View style={styles.accountInformation}>
<Identicon address={selectedAddress} diameter={40} customStyle={styles.identicon} />
<View style={styles.accountInfoRow}>
<View style={styles.accountNameAndAddress}>
<Text numberOfLines={1} style={styles.accountName}>
{accountLabel}
</Text>
<Text numberOfLines={1} style={styles.accountAddress}>
({address})
</Text>
</View>
{operation === 'signing' ? null : (
<Text numberOfLines={1} style={styles.balanceText}>
{strings('signature_request.balance_title')} {dollarBalance} {balance}
</Text>
)}
</View>
</View>
);
}
}

const mapStateToProps = state => ({
accounts: state.engine.backgroundState.AccountTrackerController.accounts,
selectedAddress: state.engine.backgroundState.PreferencesController.selectedAddress,
identities: state.engine.backgroundState.PreferencesController.identities,
conversionRate: state.engine.backgroundState.CurrencyRateController.conversionRate,
currentCurrency: state.engine.backgroundState.CurrencyRateController.currentCurrency,
ticker: state.engine.backgroundState.NetworkController.provider.ticker
});

export default connect(mapStateToProps)(AccountInfoCard);
44 changes: 44 additions & 0 deletions app/components/UI/AccountInfoCard/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import React from 'react';
import { shallow } from 'enzyme';
import configureMockStore from 'redux-mock-store';
import AccountInfoCard from './';

const mockStore = configureMockStore();

describe('AccountInfoCard', () => {
it('should render correctly', () => {
const initialState = {
engine: {
backgroundState: {
AccountTrackerController: {
accounts: {
'0x0': {
balance: 200
}
}
},
PreferencesController: {
selectedAddress: '0x0',
identities: {
address: '0x0',
name: 'Account 1'
}
},
CurrencyRateController: {
conversionRate: 10
},
NetworkController: {
provider: {
ticker: 'eth'
}
}
}
}
};

const wrapper = shallow(<AccountInfoCard />, {
context: { store: mockStore(initialState) }
});
expect(wrapper.dive()).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ exports[`ActionView should render correctly 1`] = `
<View
style={
Object {
"borderTopColor": "#bbc0c5",
"borderTopWidth": 1,
"flex": 0,
"flexDirection": "row",
"paddingHorizontal": 24,
Expand Down
8 changes: 3 additions & 5 deletions app/components/UI/ActionView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ import React from 'react';
import StyledButton from '../StyledButton';
import PropTypes from 'prop-types';
import { Keyboard, StyleSheet, View, ActivityIndicator, TouchableWithoutFeedback } from 'react-native';
import { baseStyles, colors } from '../../../styles/common';
import { baseStyles } from '../../../styles/common';
import { strings } from '../../../../locales/i18n';
import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view';

const styles = StyleSheet.create({
actionContainer: {
borderTopColor: colors.grey200,
borderTopWidth: 1,
flex: 0,
flexDirection: 'row',
paddingVertical: 16,
Expand Down Expand Up @@ -69,7 +67,7 @@ export default function ActionView({
{showCancelButton && (
<StyledButton
testID={cancelTestID}
type={'cancel'}
type={confirmButtonMode === 'sign' ? 'signingCancel' : 'cancel'}
onPress={onCancelPress}
containerStyle={[styles.button, styles.cancel]}
disabled={confirmed}
Expand Down Expand Up @@ -124,7 +122,7 @@ ActionView.propTypes = {
/**
* Type of button to show as the confirm button
*/
confirmButtonMode: PropTypes.oneOf(['normal', 'confirm']),
confirmButtonMode: PropTypes.oneOf(['normal', 'confirm', 'sign']),
/**
* Text to show in the confirm button
*/
Expand Down
Loading