-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Sig request design fixed #1493
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 f291c0a
SignatureRequest: remove account information from top, proptypes, pro…
EtDu 15f02a5
SignatureRequest: change signing message to 'Sign this message?', mak…
EtDu 7912c03
remove keyboard aware scroll view
EtDu 8ddde9d
Add AccountInfoCard component to SignatureRequest
EtDu c59ae57
AccountInfoCard: implement proper styling
EtDu b551336
AccountInfoCard: use renderShortAddress, fix styles, use conversionRa…
EtDu 19031f5
ActionView: add isSigning prop, disables scroll when true, SignatureR…
EtDu d8be5a9
AccountInfoCard: remove top level view
EtDu 24f54ca
SignatureRequest: apply styles & layout, add website + arrow icons
EtDu 36b1ff9
Signing components: update styling, rename informationRow --> informa…
EtDu 72f868f
remove message style
EtDu ac7f421
TypedSign: put back message style, add messageWrapper style, ensure d…
EtDu 2765e4e
AccountInfoCard: add snapshot test
EtDu 71c61f5
update snapshots
EtDu ce57e18
styling of 'sign this message'
EtDu 8371934
update snapshot
EtDu ff0da31
update snapshot
EtDu 2823612
SignatureRequest: Always render arrow if children coming from TypedSign
EtDu 15cb5d0
SignatureRequest: change to regular component with state to show expa…
EtDu f23031d
fix dapp icon style, fix render inf loop
EtDu df050ff
remove textwrap for typed sign. Now renders properly for V1, V3 & V4
EtDu 092cc1c
AccountInfoCard: fix paddings, identicon style, use widths instead of…
EtDu d0bf963
TypedSign: use width instead of flex
EtDu 829fa86
SignatureRequest: remove website icon wrapper, fix arrow positioning,…
EtDu 07490dd
temp disable warning to match style, ensure message fits within box
EtDu c1844a8
PersonalSign: create message wrapper, ensure message fits within box
EtDu 7bdb194
Message & Personal Sign: use ellipses mode for text wrapper, drop mes…
EtDu a19f1c5
SignatureRequest: remove shouldRenderArrow, add shouldRenderArrow prop
EtDu 9d22c00
MessageSign: change to stateful component, add renderArrow state, dec…
EtDu b8929f4
PersonalSign: change to stateful component, add renderArrow state, de…
EtDu b49b4a1
TypedSign: shouldRenderArrow always passes down as true. Will never b…
EtDu c414b92
SignatureRequest: change back to pure component, change handleMessage…
EtDu 76e7f4b
change handleMessageTap to toggleExpandedMessage
EtDu 0d8d42a
TypedSign: implement message expansion and retraction
EtDu 883ea26
modify message, add message_from
EtDu a72665e
new ExpandedMessage component, rendered by typed, personal & regular …
EtDu ed2b81d
TypedSign: use ExpandedMessage component
EtDu 2ca88f5
ExpandedMessage: test
EtDu f7fb3bd
SignatureRequest: add renderArrow prop, make box not expandable if false
EtDu f532db7
MessageSign: implement message expanding and retracting
EtDu 42be920
PersonalSign: implement message expand & retract
EtDu 90af65c
ExpandedMessage: add mock fns, update all snapshots
EtDu a17503a
ActionView: get rid of top border
EtDu 3bec8f9
new button styles
EtDu 1863b06
signing components: ensure a top left and right rounded border
EtDu 699a7db
change Cancel & Sign to lowercase
EtDu 13ef7ea
snapshot update
EtDu 313c9c7
adjust style for android
EtDu 0452644
use unique button style for signing components, fix percentage in sty…
EtDu 54b4d73
change isSigning prop to noScroll
EtDu b824ee2
snapshot update
EtDu a744966
update more snapshots
EtDu a83dfb9
Signing components: revert to pure component
EtDu f5d04c6
AccountInfoCard: use weiToFiat & hexToBn helpers to display fiat valu…
EtDu 3622643
Signing components: shift renderRootView() contents into render()
EtDu b86f0a3
update snapshot
EtDu 4bb66a1
AccountInfoCard, SignatureRequest: fix paddings per design
EtDu ddae54b
AccountInfoCard: remove bottom margin
EtDu 1fd0325
TransactionHeader: remove margins, use padding
EtDu 2c42733
MessageSign: larger min height, showWarning prop
EtDu 8606302
WarningMessage: use flexstart alignment for bell icon
EtDu da252e3
locales: change eth_sign_warning
EtDu e7d0a83
WarningMessage: add object as secondary prop type for warning message
EtDu ad736b3
SignatureRequest: use WarningMessage component, fix paddings, use ren…
EtDu a0632fa
snapshot update yo
EtDu 90f36fc
SignatureRequest: move AccountInfoCard ontop of message children
EtDu f4151e8
snapshot update
EtDu 51a92dd
AccountInfoCard: remove width
EtDu ff31dd2
ActionView: remove no scroll - small devices
EtDu 9e3b7d5
Signing Components: remove root style, move to SignatureRequest
EtDu a91d9d7
SignatureRequest: remove style redundancies, add in root style
EtDu 86d0a5d
SignatureRequest: fix height of modal based on screen height
EtDu 779ea0b
ExpandedMessage: fix styling, move scrollview to signing components r…
EtDu 3ad345b
ExpandedMessage: Put the scroll back
EtDu 1ce7ea5
PersonalSign: remove expandedMessage text wrapper
EtDu b4494bb
SignatureRequest: fix up styling, add more overhead (reduced from sig…
EtDu 2da4466
Signing components: reduce view hierarchy, move to SignatureRequest
EtDu 198a13b
Locales: add Read more to signature_request
EtDu 8309a82
AccountInfoCard: add operation prop, if operation is signing, only di…
EtDu 5da1156
TypedSign: add shouldTruncateMessage & truncateMessage in state
EtDu 9fece60
PersonalSign: remove console log
EtDu ee3c131
Signing components: change renderArrow to truncateMessage
EtDu 3cad9ca
Nav/Main: add showExpandedMessage to state, add toggleExpandedMessage…
EtDu d91c1e7
Signing Components: move showExpandedMessage out of state, move out t…
EtDu 745a1be
TypedSign: create different messageWrapper height for iOS & Android, …
EtDu 2c90d80
ExpandedMessage: fix scrollview
EtDu d8da92d
snapshot update
EtDu 82e9ef2
AccountInfoCard: use getTicker
EtDu fb30fb5
Signing components: change margin bottom from 5 to 4
EtDu 96ab1b3
Device: new getMediumDevice, SignatureRequest: use getMediumDevice
EtDu ae84182
ActionView, styledButtonStyles: add cancel button style for signing c…
EtDu abe67bd
snapshot update
EtDu 4deab30
SignatureRequest: fix the domain logo not being a circle
EtDu c63c7fa
update snapshot
EtDu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
app/components/UI/AccountInfoCard/__snapshots__/index.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
(< 0.00001 eth) | ||
</Text> | ||
</View> | ||
</View> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 theonRequestClose
prop for this very purpose. Since we're using a wrapped version of the nativeModal
, it'sonBackButtonPress
. Since the Modal is at the top of the view hierarchy for signing operations, I wasn't sure how else to implement this.