-
-
Notifications
You must be signed in to change notification settings - Fork 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
Tokens view #87
Tokens view #87
Conversation
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.
Honestly I'm impressed with the quality and speed that you made this. 🥇
I've added a few of comments mostly about the code style or some RN specifics, but otherwise looks great!
It would be great if you can add unit tests for this new components (not e2e yet because I didn't set it up for android)
@@ -25,7 +25,7 @@ | |||
android:name=".MainActivity" | |||
android:label="@string/app_name" | |||
android:configChanges="keyboard|keyboardHidden|orientation|screenSize" | |||
android:windowSoftInputMode="adjustResize" | |||
android:windowSoftInputMode="adjustResize|stateUnspecified|adjustPan" |
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.
I don't think you need this if you wrap the main view in a scrollview instead of a view
app/components/AddAsset/index.js
Outdated
|
||
render() { | ||
return ( | ||
<View style={styles.wrapper} testID={'add-asset-screen'}> |
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.
if you change this one for a scroll view you should be able to undo the changes you did on the manifest
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.
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.
unless my idea was different
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.
Don't we also need to make this View
a ScrollView
as well as @brunobar79 suggested? That way both AddAsset
and AddCustomAsset
can scroll properly.
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.
there is a ScrollView
inside it, now I changed it for ActionView
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.
sorry I didn't change this for ActionView
, it's only a View
as you said. What do you think @brunobar79 ?
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.
You added the scrollviews internally on each tab. That's ok with me
app/components/AddAsset/index.js
Outdated
export default class AddAsset extends Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = { |
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.
move the state out of the constructor and remove the constructor (See other components)
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.
I'll try it
@@ -0,0 +1,166 @@ | |||
import React, { Component } from 'react'; | |||
import { Text, TextInput, View, StyleSheet, TouchableOpacity } from 'react-native'; |
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.
Try to avoid using TouchableOpacity and use Button from 'react-native-button'. The main reason is that for android Buttons should be TouchableNativeFeedback. The button components renders the right one depending on the OS.
export default class AddCustomAsset extends Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = { |
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.
Same, move state out and remove the constructor
app/components/SearchAsset/index.js
Outdated
* View that provides ability to add custom assets. | ||
*/ | ||
export default class SearchAsset extends Component { | ||
constructor(props) { |
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.
same comment about removing constructor
app/components/SearchAsset/index.js
Outdated
}; | ||
|
||
cancelAddToken = () => { | ||
this.props.navigation.push('Wallet'); |
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.
same as before. pop or goBack
app/components/SearchAsset/index.js
Outdated
/> | ||
|
||
<View style={styles.footer}> | ||
<TouchableOpacity style={[styles.buttonCancel, styles.button]} onPress={this.cancelAddToken}> |
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.
Button
app/components/SearchAsset/index.js
Outdated
<TouchableOpacity style={[styles.buttonCancel, styles.button]} onPress={this.cancelAddToken}> | ||
<Text>CANCEL</Text> | ||
</TouchableOpacity> | ||
<TouchableOpacity style={[styles.buttonAddToken, styles.button]}> |
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.
Button
app/components/Wallet/index.js
Outdated
/** | ||
* Main view for the wallet | ||
* Main view for the walletselectedAddress |
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.
walletselectedAddress is not a thing
@estebanmino Now that I see the gif, Do you think you can validate the fields on the onBlur event? That way we don't show an error while you're still typing. |
app/components/PageFooter/index.js
Outdated
/** | ||
* Name of the current view | ||
*/ | ||
onSubmit: PropTypes.object.function, |
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.
add comments
I approved and then I realized that we're still missing the unit tests
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 code looks great and this is a very strong first PR against this project. Really great work. The code quality is top-notch, existing patterns were followed, and things work and work well.
I left a lot of nit-picky comments only to be thorough and to help you quickly identify what should be fixed. Every comment is minor, so don't let the number of comments discourage you. This is great stuff. Also, some general comments:
- All components should at least have a snapshot test.
- Any component that shows text should have a class applied with at least a
fontStyle
so the correct font family is applied. This includes inputs,<Text>
components, etc. - We should create a ticket to finish the remainder of token adding, like searching for tokens.
app/components/AddAsset/index.js
Outdated
decimals: '' | ||
}; | ||
|
||
static navigationOptions = { |
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.
Nit: Can we put static properties above non-static properties like state
?
app/components/AddAsset/index.js
Outdated
|
||
render() { | ||
return ( | ||
<View style={styles.wrapper} testID={'add-asset-screen'}> |
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.
Don't we also need to make this View
a ScrollView
as well as @brunobar79 suggested? That way both AddAsset
and AddCustomAsset
can scroll properly.
app/components/AddAsset/index.js
Outdated
return ( | ||
<View style={styles.wrapper} testID={'add-asset-screen'}> | ||
<ScrollableTabView renderTabBar={this.renderTabBar}> | ||
<SearchAsset navigation={this.props.navigation} tabLabel="Search" /> |
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.
Since renders are so expensive on React Native, it's important to keep them as optimal as possible. You can destructure props
to save indirection of touching this.props.<some_prop>
each time. For example, you could do const { navigation } = this.props;
then use navigation
directly without additional lookups to this
and props
.
It's a good idea to destructure as often as possible.
import { colors, fontStyles } from '../../styles/common'; | ||
import Engine from '../../core/Engine'; | ||
import PropTypes from 'prop-types'; | ||
const isValidAddress = require('ethereumjs-util').isValidAddress; |
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.
You can change this to import { isValidAddress } from 'ethereumjs-util';
to stay consistent, it will still work.
}; | ||
|
||
static propTypes = { | ||
/** |
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 documentation formatting is off. It should be:
/**
* navigation object required to push new views
*/
let validated = true; | ||
const decimals = this.state.decimals; | ||
if (decimals.length === 0) { | ||
this.setState({ warningDecimals: `Token precision can't be empty.` }); |
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 string should use i18n.
return ( | ||
<View style={styles.wrapper} testID={'add-custom-token-screen'}> | ||
<ScrollView contentContainerStyle={styles.scrollViewWrapper}> | ||
<Text>Token Address</Text> |
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 should mix in a fontStyle
so it gets the correct font family. It should also use i18n.
/> | ||
<Text style={styles.warningText}>{this.state.warningAddress}</Text> | ||
|
||
<Text>Token Symbol</Text> |
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 should mix in a fontStyle
so it gets the correct font family. It should also use i18n.
<PageFooter | ||
onCancel={this.cancelAddToken} | ||
onSubmit={this.addToken} | ||
cancelText={'CANCEL'} |
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 (and submit below) should use i18n.
app/components/SearchAsset/index.js
Outdated
onChangeText={this.onTokenChange} | ||
/> | ||
</ScrollView> | ||
<PageFooter onCancel={this.cancelAddToken} cancelText={'CANCEL'} submitText={'NEXT'} /> |
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.
These button texts should use i18n.
locales/en.json
Outdated
@@ -37,6 +37,25 @@ | |||
"no_tokens": "You don't have any tokens!", | |||
"add_collectibles": "ADD COLLECTIBLES" | |||
}, | |||
"addAsset": { | |||
"title": "Add Asset", | |||
"search_token": "Search", |
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.
Can you put this one and the one below all uppercase?
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.
also titles? I saw other titles as Wallet and Transfer that are in the same format (lower case).
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.
👍 After the last round of comments
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.
Looks great! Very strong work.
Bump our `eslint` config dependencies.
* wallet get tokens from gaba * wallet add custom token view * fix animate footer above keyboard on android * wallet add asset scrollable search and custom token * wallet adding custom tokens * wallet add custom token validation * fix add asset touchable margin for many assets on list * wallet components delete constructors * wallet navigation pop for go back * wallet add custom token validate by input * wallet add custom token placeholders * wallet tokens using navigation goBack and validations onBlur * wallet using button instead of TouchableOpacity * wallet page footer component * wallet views android working with adjust resize * wallet tokens updating when added custom token * Update GABA version * wallet add custom token update tests * wallet add tokens consolidation * wallet add tokens update snapshots * wallet add tokens more consolidation * wallet add tokens consolidation * wallet add asset testIDs and localization update * wallet add asset style formatting
Description
This pull request adds the ability to handle assets (ERC20), adding manually custom tokens.
Checklist
Related #61
WIP