Skip to content

Commit

Permalink
Merge pull request #216 from ChainSafeSystems/cf-205-navigationFunctions
Browse files Browse the repository at this point in the history
Closes #205 - all navigate functions are relevant to their action
  • Loading branch information
GregTheGreek committed Oct 2, 2018
2 parents 924db28 + 2909b84 commit b691b65
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 201 deletions.
4 changes: 0 additions & 4 deletions src/navigation/stack/navigationStack.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import GeneratePassphrase from '../../screens/setup/create/GeneratePassphrase';
import ConfirmPassphrase from '../../screens/setup/create/ConfirmPassphrase';
import CreateWalletNameRecovered from '../../screens/setup/recover/CreateWalletName';
import RecoverWallet from '../../screens/setup/recover/RecoverWallet';
import EnableTokens from '../../screens/setup/crypto/EnableTokens';
import mainBucketNavigation from './mainBucketStack';
import addContact from '../../screens/main/menu/contacts/add/AddContact';
import contacts from '../../screens/main/menu/contacts/index';
Expand Down Expand Up @@ -47,9 +46,6 @@ const navigator = StackNavigator({
recoverWallet: {
screen: RecoverWallet,
},
enableTokens: {
screen: EnableTokens,
},
mainStack: {
screen: mainBucketNavigation,
},
Expand Down
11 changes: 4 additions & 7 deletions src/screens/main/menu/contacts/SelectedContact.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,31 +40,28 @@ class ContactAddresses extends Component {
}
this.props.getQRCodeData(address);
this.props.saveDataForCoinSend(address);
const navigateToCreateOrRestore = NavigationActions.navigate({
const navigateToTokenFunctionality = NavigationActions.navigate({
routeName: 'TokenFunctionality',
});
this.props.navigation.dispatch(navigateToCreateOrRestore);
this.props.navigation.dispatch(navigateToTokenFunctionality);
};

navigateToEditContact = () => {
const navigateToCreateOrRestore = NavigationActions.navigate({
const navigateToEditContact = NavigationActions.navigate({
routeName: 'editContact',
params: { contact: this.props.contact },
});
this.props.navigation.dispatch(navigateToCreateOrRestore);
this.props.navigation.dispatch(navigateToEditContact);
};

renderRow(address) {
const contactInfo = this.props.contact.images;
let url;

for (const key in contactInfo) {
if (contactInfo.hasOwnProperty(key)) {

if (key == Object.keys(address)[0]) {
url = contactInfo[key];
}

}
}

Expand Down
14 changes: 1 addition & 13 deletions src/screens/main/menu/contacts/add/AddContact.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,7 @@ class AddContact extends Component {
this.props.tokens.map((token) => { return newcontactAddress[token.title] = '' ;});
this.setState({ contactAddress: newcontactAddress });
}

/**
* This Method is used to update the contact name in the global
* and local state variable when ever the contactName inputfield changes.
* @param {String} name
*/
// renderName(name) {
// this.setState({ contactName: name });
// const contact = { name };
// this.props.addingContact(contact);
// this.props.saveAddContactInputs(this.state.contactName, this.state.contactAddress, this.state.tokenImages);
// }


navigate = () => {
this.props.saveAddContactInputs(this.state.contactName, this.state.contactAddress, this.state.tokenImages);
this.props.qrScannerInvoker('Contacts');
Expand Down
4 changes: 2 additions & 2 deletions src/screens/main/menu/settings/BackupPhrase.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import LinearButton from '../../../../components/LinearGradient/LinearButton'
import RF from "react-native-responsive-fontsize"

const navigate = () => {
const navigateToPassphrase = NavigationActions.reset({
const navigateToMenu = NavigationActions.reset({
index: 0,
actions: [NavigationActions.navigate({ routeName: 'Drawer' })]
});
this.props.navigation.dispatch(navigateToPassphrase);
this.props.navigation.dispatch(navigateToMenu);
};

/**
Expand Down
4 changes: 2 additions & 2 deletions src/screens/main/tokens/add/Coins.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ class Coins extends Component {
* Allows you to navigate to the navigation drawer
*/
navigate = () => {
const navigateToPassphrase = NavigationActions.reset({
const navigateToMain= NavigationActions.reset({
index: 0,
actions: [NavigationActions.navigate({ routeName: 'portfolioScreen' })],
});
this.props.navigation.dispatch(navigateToPassphrase);
this.props.navigation.dispatch(navigateToMain);
};

render() {
Expand Down
4 changes: 2 additions & 2 deletions src/screens/main/tokens/add/Tokens.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ class Coins extends Component {
* Allows you to navigate to the navigation drawer
*/
navigate = () => {
const navigateToPassphrase = NavigationActions.reset({
const navigateToMain = NavigationActions.reset({
index: 0,
actions: [NavigationActions.navigate({ routeName: 'portfolioScreen' })],
});
this.props.navigation.dispatch(navigateToPassphrase);
this.props.navigation.dispatch(navigateToMain);
};

handleChangeText(input) {
Expand Down
4 changes: 2 additions & 2 deletions src/screens/setup/create/ConfirmPassphrase.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ class ConfirmPassphrase extends Component {
* Method is used to navigate to the "enableTokens" screen.
*/
navigate = () => {
const navigateToEnableTokens = NavigationActions.navigate({
const navigateToMain = NavigationActions.navigate({
routeName: 'mainStack',
});
this.props.navigation.dispatch(navigateToEnableTokens);
this.props.navigation.dispatch(navigateToMain);
};

/**
Expand Down
4 changes: 2 additions & 2 deletions src/screens/setup/create/GeneratePassphrase.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import RF from "react-native-responsive-fontsize"
class GeneratePassphrase extends Component {

navigate = () => {
const navigateToEnableTokens = NavigationActions.navigate({
const navigateToConfirmPassphrase = NavigationActions.navigate({
routeName: 'confirmPassphrase',
params: { wallet: this.props.navigation.state.wallet },
});
this.props.navigation.dispatch(navigateToEnableTokens);
this.props.navigation.dispatch(navigateToConfirmPassphrase);
};

render() {
Expand Down
157 changes: 0 additions & 157 deletions src/screens/setup/crypto/EnableTokens.js

This file was deleted.

8 changes: 4 additions & 4 deletions src/screens/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@ class CreateOrRestore extends Component {
* user decides to create a new wallet
*/
navigateCreate = () => {
const navigateToWalletName = NavigationActions.navigate({
const navigateToCreate = NavigationActions.navigate({
routeName: 'createWalletName',
});
this.props.navigation.dispatch(navigateToWalletName);
this.props.navigation.dispatch(navigateToCreate);
};

/**
* Method is used to navigate to the "createWalletNameRecovered" if and only if the
* user decides to recover thier wallet
*/
navigateRestore = () => {
const navigateToRecover = NavigationActions.navigate({
const navigateToRestore = NavigationActions.navigate({
routeName: 'createWalletNameRecovered',
});
this.props.restoreWallet();
this.props.navigation.dispatch(navigateToRecover);
this.props.navigation.dispatch(navigateToRestore);
};

/**
Expand Down
4 changes: 2 additions & 2 deletions src/screens/setup/recover/CreateWalletName.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ class CreateWalletName extends Component {
* Method is used to navigate back to the recoverWallet screen.
*/
navigate = () => {
const navigateToPassphrase = NavigationActions.navigate({ routeName: 'recoverWallet' });
this.props.navigation.dispatch(navigateToPassphrase);
const navigateToRestore = NavigationActions.navigate({ routeName: 'recoverWallet' });
this.props.navigation.dispatch(navigateToRestore);
};

getWalletName(name) {
Expand Down
7 changes: 3 additions & 4 deletions src/screens/setup/recover/RecoverWallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,24 @@ class RecoverWallet extends Component {
* A new wallet is initialized and created with a wallet name.
*/
navigate = async () => {
const navigateToTokens = NavigationActions.navigate({
const navigateToMain = NavigationActions.navigate({
routeName: 'mainStack',
});

try {
if (this.props.debugMode === true) {
const wallet = new ethers.Wallet('0x923ed0eca1cee12c1c3cf7b8965fef00a2aa106124688a48d925a778315bb0e5');
wallet.provider = provider;
const testWalletName = this.props.testWalletName;
const userWallets = this.props.wallets;
this.props.initializeAppWallet(wallet, testWalletName, userWallets);
this.props.navigation.dispatch(navigateToTokens);
this.props.navigation.dispatch(navigateToMain);
} else {
const mnemonic = this.state.mnemonic.trim();
currentWalletName = this.props.tempWalletName;
const wallet = ethers.Wallet.fromMnemonic(mnemonic);
wallet.provider = provider;
this.props.initializeAppWallet(wallet, currentWalletName, []);
this.props.navigation.dispatch(navigateToTokens);
this.props.navigation.dispatch(navigateToMain);
}
} catch (err) {
Alert.alert(
Expand Down

0 comments on commit b691b65

Please sign in to comment.