From 3fe3e9307303fb3e050046d4f5ef1aa611e1c6d8 Mon Sep 17 00:00:00 2001 From: JDonadio Date: Thu, 12 Oct 2017 10:18:13 -0300 Subject: [PATCH] join wallet template --- src/app/app.module.ts | 2 + src/pages/add/add.ts | 3 +- src/pages/add/join-wallet/join-wallet.html | 79 ++++++++++++++ src/pages/add/join-wallet/join-wallet.ts | 113 +++++++++++++++++++++ 4 files changed, 196 insertions(+), 1 deletion(-) create mode 100644 src/pages/add/join-wallet/join-wallet.html create mode 100644 src/pages/add/join-wallet/join-wallet.ts diff --git a/src/app/app.module.ts b/src/app/app.module.ts index c002c4ce6..d9fca05ae 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -27,6 +27,7 @@ import { CopayApp } from './app.component'; import { AddPage } from '../pages/add/add'; import { CreateWalletPage } from '../pages/add/create-wallet/create-wallet'; import { ImportWalletPage } from '../pages/add/import-wallet/import-wallet'; +import { JoinWalletPage } from '../pages/add/join-wallet/join-wallet'; import { BackupRequestPage } from '../pages/onboarding/backup-request/backup-request'; import { DisclaimerPage } from '../pages/onboarding/disclaimer/disclaimer'; import { EmailPage } from '../pages/onboarding/email/email'; @@ -80,6 +81,7 @@ let pages: any = [ AddPage, CreateWalletPage, ImportWalletPage, + JoinWalletPage, AboutPage, AdvancedPage, AltCurrencyPage, diff --git a/src/pages/add/add.ts b/src/pages/add/add.ts index 9360f4483..2dd514197 100644 --- a/src/pages/add/add.ts +++ b/src/pages/add/add.ts @@ -2,6 +2,7 @@ import { Component } from '@angular/core'; import { NavController } from 'ionic-angular'; import { CreateWalletPage } from "./create-wallet/create-wallet"; import { ImportWalletPage } from "./import-wallet/import-wallet"; +import { JoinWalletPage } from "./join-wallet/join-wallet"; @Component({ selector: 'page-add', @@ -19,7 +20,7 @@ export class AddPage { } goToJoinWallet() { - // this.navCtrl.push(); + this.navCtrl.push(JoinWalletPage); } goToImportWallet() { diff --git a/src/pages/add/join-wallet/join-wallet.html b/src/pages/add/join-wallet/join-wallet.html new file mode 100644 index 000000000..57d64d016 --- /dev/null +++ b/src/pages/add/join-wallet/join-wallet.html @@ -0,0 +1,79 @@ + + + Join wallet + + + + +
+ + Your name + + + + + Wallet invitation + + + + + + + Show advanced options + Hide advanced options + + +
+ + Wallet service URL + + + + + Wallet key + + {{opt.label}} + + + + + Wallet recovery phrase + + + + + Add a password + + + +
+ + Password + + + + + Confirm password + + + + +
+ This password cannot be recovered. If the password is lost, there is no way you could recover your funds. +
+
+ + + I have written it down + + +
+ + + Derivation path + + +
+ +
+
\ No newline at end of file diff --git a/src/pages/add/join-wallet/join-wallet.ts b/src/pages/add/join-wallet/join-wallet.ts new file mode 100644 index 000000000..7aabe0cf1 --- /dev/null +++ b/src/pages/add/join-wallet/join-wallet.ts @@ -0,0 +1,113 @@ +import { Component, OnInit } from '@angular/core'; +import { NavController } from 'ionic-angular'; +import { Validators, FormBuilder, FormGroup } from '@angular/forms'; + +import { AppProvider } from '../../../providers/app/app'; +import * as _ from 'lodash'; + +@Component({ + selector: 'page-join-wallet', + templateUrl: 'join-wallet.html' +}) +export class JoinWalletPage implements OnInit{ + public formData: any; + public showAdvOpts: boolean; + public seedOptions: any; + + private appName: string; + private derivationPathByDefault: string; + private derivationPathForTestnet: string; + private joinForm: FormGroup; + + constructor( + public navCtrl: NavController, + private app: AppProvider, + private fb: FormBuilder + ) { + this.derivationPathByDefault = "m/44'/0'/0'"; + this.derivationPathForTestnet = "m/44'/1'/0'"; + this.showAdvOpts = false; + this.formData = { + copayerName: null, + invitationCode: null, + bwsURL: 'https://bws.bitpay.com/bws/api', + recoveryPhrase: null, + addPassword: false, + password: null, + confirmPassword: null, + passwordSaved: null, + derivationPath: this.derivationPathByDefault, + }; + this.seedOptions = [{ + id: 'new', + label: 'Random', + supportsTestnet: true + }, { + id: 'set', + label: 'Specify Recovery Phrase', + supportsTestnet: false + }]; + this.formData.selectedSeed = { + id: this.seedOptions[0].id + }; + } + + ngOnInit() { + this.joinForm = this.fb.group({ + copayerName: ['', Validators.required], + invitationCode: ['', Validators.required], + bwsURL: [''], + selectedSeed: [''], + recoveryPhrase: [''], + addPassword: [''], + password: [''], + confirmPassword: [''], + passwordSaved: [''], + derivationPath: [''], + }); + + this.joinForm.get('addPassword').valueChanges.subscribe((addPassword: boolean) => { + if (addPassword) { + this.joinForm.get('password').setValidators([Validators.required]); + this.joinForm.get('confirmPassword').setValidators([Validators.required]); + }else { + this.joinForm.get('password').clearValidators(); + this.joinForm.get('confirmPassword').clearValidators(); + } + this.joinForm.get('password').updateValueAndValidity(); + this.joinForm.get('confirmPassword').updateValueAndValidity(); + }) + } + + validatePasswords() { + if (this.formData.addPassword) { + if (this.formData.password == this.formData.confirmPassword) { + if (this.formData.passwordSaved) return false; + } + return true; + } + return false; + } + + seedOptionsChange(seed: any) { + this.formData.selectedSeed.id = seed; + this.formData.testnet = false; + this.formData.derivationPath = this.derivationPathByDefault; + this.resetFormFields(); + } + + resetFormFields() { + this.formData.password = null; + this.formData.confirmPassword = null; + this.formData.passwordSaved = null; + this.formData.recoveryPhrase = null; + } + + setDerivationPath() { + this.formData.derivationPath = this.formData.testnet ? this.derivationPathForTestnet : this.derivationPathByDefault; + } + + join() { + console.log(this.formData); + } +}