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

Tokens view #87

Merged
merged 26 commits into from Aug 31, 2018
Merged

Tokens view #87

merged 26 commits into from Aug 31, 2018

Conversation

estebanmino
Copy link
Contributor

@estebanmino estebanmino commented Aug 24, 2018

Description

This pull request adds the ability to handle assets (ERC20), adding manually custom tokens.

Checklist

  • There is a related GitHub issue
  • Tests are included if applicable
  • Any added code is fully documented
  • Get tokens from GABA
  • Add custom tokens

Related #61

WIP

customtoken

Copy link
Contributor

@brunobar79 brunobar79 left a 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"
Copy link
Contributor

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


render() {
return (
<View style={styles.wrapper} testID={'add-asset-screen'}>
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I finally added a scrollview inside this, seems to work fine.

scroll

Copy link
Contributor Author

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

Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor Author

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 ?

Copy link
Contributor

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

export default class AddAsset extends Component {
constructor(props) {
super(props);
this.state = {
Copy link
Contributor

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)

Copy link
Contributor Author

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';
Copy link
Contributor

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 = {
Copy link
Contributor

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

* View that provides ability to add custom assets.
*/
export default class SearchAsset extends Component {
constructor(props) {
Copy link
Contributor

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

};

cancelAddToken = () => {
this.props.navigation.push('Wallet');
Copy link
Contributor

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

/>

<View style={styles.footer}>
<TouchableOpacity style={[styles.buttonCancel, styles.button]} onPress={this.cancelAddToken}>
Copy link
Contributor

Choose a reason for hiding this comment

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

Button

<TouchableOpacity style={[styles.buttonCancel, styles.button]} onPress={this.cancelAddToken}>
<Text>CANCEL</Text>
</TouchableOpacity>
<TouchableOpacity style={[styles.buttonAddToken, styles.button]}>
Copy link
Contributor

Choose a reason for hiding this comment

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

Button

/**
* Main view for the wallet
* Main view for the walletselectedAddress
Copy link
Contributor

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

@brunobar79
Copy link
Contributor

brunobar79 commented Aug 27, 2018

@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.

/**
* Name of the current view
*/
onSubmit: PropTypes.object.function,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

add comments

brunobar79
brunobar79 previously approved these changes Aug 28, 2018
@brunobar79 brunobar79 dismissed their stale review August 28, 2018 01:36

I approved and then I realized that we're still missing the unit tests

Copy link
Contributor

@bitpshr bitpshr left a 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.

decimals: ''
};

static navigationOptions = {
Copy link
Contributor

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?


render() {
return (
<View style={styles.wrapper} testID={'add-asset-screen'}>
Copy link
Contributor

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.

return (
<View style={styles.wrapper} testID={'add-asset-screen'}>
<ScrollableTabView renderTabBar={this.renderTabBar}>
<SearchAsset navigation={this.props.navigation} tabLabel="Search" />
Copy link
Contributor

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;
Copy link
Contributor

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 = {
/**
Copy link
Contributor

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.` });
Copy link
Contributor

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>
Copy link
Contributor

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>
Copy link
Contributor

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'}
Copy link
Contributor

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.

onChangeText={this.onTokenChange}
/>
</ScrollView>
<PageFooter onCancel={this.cancelAddToken} cancelText={'CANCEL'} submitText={'NEXT'} />
Copy link
Contributor

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",
Copy link
Contributor

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?

Copy link
Contributor Author

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).

Copy link
Contributor

@brunobar79 brunobar79 left a 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

Copy link
Contributor

@bitpshr bitpshr left a 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.

@estebanmino estebanmino merged commit 137d74a into master Aug 31, 2018
@estebanmino estebanmino deleted the tokens-view branch August 31, 2018 15:39
@estebanmino estebanmino mentioned this pull request Sep 5, 2018
3 tasks
@brunobar79 brunobar79 mentioned this pull request Nov 19, 2018
sethkfman pushed a commit that referenced this pull request Sep 3, 2021
Bump our `eslint` config dependencies.
rickycodes pushed a commit that referenced this pull request Jan 31, 2022
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants