diff --git a/src/pages/add/single-wallet/single-wallet.html b/src/pages/add/single-wallet/single-wallet.html index 05d8f2d04..20a89ceea 100644 --- a/src/pages/add/single-wallet/single-wallet.html +++ b/src/pages/add/single-wallet/single-wallet.html @@ -5,10 +5,10 @@ -
+ - Wallet name - + Wallet name + @@ -20,31 +20,31 @@
- Wallet service URL - + Wallet service URL + - Wallet key - + Wallet key + {{opt.label}} - Add a password - + Add a password +
- Password - + Password + - Repeat password - + Confirm password + @@ -52,18 +52,23 @@ This password cannot be recovered. If the password is lost, there is no way you could recover your funds.
+ + + I have written it down + +
- Testnet - + Testnet + - Single address - + Single address + - +
\ No newline at end of file diff --git a/src/pages/add/single-wallet/single-wallet.ts b/src/pages/add/single-wallet/single-wallet.ts index c7a45cd69..bc755a2c3 100644 --- a/src/pages/add/single-wallet/single-wallet.ts +++ b/src/pages/add/single-wallet/single-wallet.ts @@ -1,28 +1,68 @@ -import { Component } from '@angular/core'; +import { Component, OnInit } from '@angular/core'; import { NavController } from 'ionic-angular'; +import { Validators, FormBuilder, FormGroup } from '@angular/forms'; + import { AppProvider } from '../../../providers/app/app'; @Component({ selector: 'page-single-wallet', templateUrl: 'single-wallet.html' }) -export class SingleWalletPage { +export class SingleWalletPage implements OnInit{ public formData: any; public showAdvOpts: boolean; public seedOptions: any; private appName: string; + private createForm: FormGroup; - constructor(public navCtrl: NavController, private app: AppProvider) { + constructor( + public navCtrl: NavController, + private app: AppProvider, + private fb: FormBuilder + ) { this.showAdvOpts = false; this.formData = { + walletName: null, bwsURL: 'https://bws.bitpay.com/bws/api', addPassword: false, - passphrase: null, - repeatPassphrase: null, + password: null, + confirmPassword: null, + writtenDown: false, testnet: false, singleAddress: false, }; + this.appName = this.app.info.name; + this.updateSeedSourceSelect(1); + } + + ngOnInit() { + this.createForm = this.fb.group({ + walletName: ['', Validators.required], + bwsURL: [''], + selectedSeed: [''], + addPassword: [''], + password: [''], + confirmPassword: [''], + writtenDown: ['false'], + testnet: [''], + singleAddress: [''], + }); + + this.createForm.get('addPassword').valueChanges.subscribe((addPassword: boolean) => { + if (addPassword) { + this.createForm.get('password').setValidators([Validators.required]); + this.createForm.get('confirmPassword').setValidators([Validators.required]); + }else { + this.createForm.get('password').clearValidators(); + this.createForm.get('confirmPassword').clearValidators(); + } + this.createForm.get('password').updateValueAndValidity(); + this.createForm.get('confirmPassword').updateValueAndValidity(); + }) + } + + updateSeedSourceSelect(n: number) { this.seedOptions = [{ id: 'new', label: 'Random', @@ -32,28 +72,23 @@ export class SingleWalletPage { label: 'Specify Recovery Phrase...', supportsTestnet: false }]; - this.appName = this.app.info.name; - this.updateSeedSourceSelect(1); - } - - updateSeedSourceSelect(n: number) { this.formData.selectedSeed = { id: this.seedOptions[0].id }; /* Disable Hardware Wallets for BitPay distribution */ - var seedOptions = []; + var opts = []; if (this.appName == 'copay') { // if (n > 1 && walletService.externalSource.ledger.supported) - // seedOptions.push({ + // opts.push({ // id: walletService.externalSource.ledger.id, // label: walletService.externalSource.ledger.longName, // supportsTestnet: walletService.externalSource.ledger.supportsTestnet // }); // if (walletService.externalSource.trezor.supported) { - // seedOptions.push({ + // opts.push({ // id: walletService.externalSource.trezor.id, // label: walletService.externalSource.trezor.longName, // supportsTestnet: walletService.externalSource.trezor.supportsTestnet @@ -61,15 +96,14 @@ export class SingleWalletPage { // } // if (walletService.externalSource.intelTEE.supported) { - // seedOptions.push({ + // opts.push({ // id: walletService.externalSource.intelTEE.id, // label: walletService.externalSource.intelTEE.longName, // supportsTestnet: walletService.externalSource.intelTEE.supportsTestnet // }); // } } - this.seedOptions = this.seedOptions.concat(seedOptions); - console.log('Seed options:', this.seedOptions); + this.seedOptions = this.seedOptions.concat(opts); }; seedOptionsChange(seed: any) { @@ -78,11 +112,12 @@ export class SingleWalletPage { } resetPasswordFields() { - this.formData.passphrase = - this.formData.createPassphrase = - this.formData.passwordSaved = - this.formData.repeatPassword = - // this.result = - null; + this.formData.password = null; + this.formData.confirmPassword = null; + this.formData.writtenDown = false; + } + + create() { + console.log(this.formData); } }