diff --git a/src/app/app.module.ts b/src/app/app.module.ts index f986fbb4c..303c75613 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -25,6 +25,7 @@ import { CopayApp } from './app.component'; /* Pages */ import { AddPage } from '../pages/add/add'; +import { SingleWalletPage } from '../pages/add/single-wallet/single-wallet'; import { BackupRequestPage } from '../pages/onboarding/backup-request/backup-request'; import { DisclaimerPage } from '../pages/onboarding/disclaimer/disclaimer'; import { EmailPage } from '../pages/onboarding/email/email'; @@ -75,6 +76,7 @@ export function createTranslateLoader(http: Http) { let pages: any = [ AddPage, + SingleWalletPage, AboutPage, AdvancedPage, AltCurrencyPage, diff --git a/src/pages/add/add.ts b/src/pages/add/add.ts index d00fc631d..deac5f81d 100644 --- a/src/pages/add/add.ts +++ b/src/pages/add/add.ts @@ -1,5 +1,6 @@ import { Component } from '@angular/core'; import { NavController } from 'ionic-angular'; +import { SingleWalletPage } from "./single-wallet/single-wallet"; @Component({ selector: 'page-add', @@ -13,7 +14,7 @@ export class AddPage { } goToSingleWallet() { - // this.navCtrl.push(); + this.navCtrl.push(SingleWalletPage); } goToSharedeWallet() { diff --git a/src/pages/add/single-wallet/single-wallet.html b/src/pages/add/single-wallet/single-wallet.html new file mode 100644 index 000000000..63e58ad8b --- /dev/null +++ b/src/pages/add/single-wallet/single-wallet.html @@ -0,0 +1,74 @@ + + + Create personal wallet + + + + +
+ + Wallet name + + + + + + + Show advanced options + Hide advanced options + + +
+ + Wallet service URL + + + + + Wallet key + + {{opt.label}} + + + + + 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 + + +
+ + + Testnet + + + + + Single address + + +
+ +
+
\ No newline at end of file diff --git a/src/pages/add/single-wallet/single-wallet.scss b/src/pages/add/single-wallet/single-wallet.scss new file mode 100644 index 000000000..40b44287f --- /dev/null +++ b/src/pages/add/single-wallet/single-wallet.scss @@ -0,0 +1,9 @@ +.warning { + background-color: #ef473a; + border-color: #e42112; + color: #fff; + padding: 0.5rem; + border: 1px solid; + white-space: normal; + text-align: center; +} \ 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 new file mode 100644 index 000000000..d76a8c23e --- /dev/null +++ b/src/pages/add/single-wallet/single-wallet.ts @@ -0,0 +1,133 @@ +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 implements OnInit{ + public formData: any; + public showAdvOpts: boolean; + public seedOptions: any; + + private appName: string; + private createForm: FormGroup; + + 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, + 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(); + }) + } + + validatePasswords() { + if (this.formData.addPassword) { + if (this.formData.password == this.formData.confirmPassword) { + if (this.formData.writtenDown) return false; + } + return true; + } + return false; + } + + updateSeedSourceSelect(n: number) { + this.seedOptions = [{ + id: 'new', + label: 'Random', + supportsTestnet: true + }, { + id: 'set', + label: 'Specify Recovery Phrase...', + supportsTestnet: false + }]; + this.formData.selectedSeed = { + id: this.seedOptions[0].id + }; + + /* Disable Hardware Wallets for BitPay distribution */ + var opts = []; + + if (this.appName == 'copay') { + // if (n > 1 && walletService.externalSource.ledger.supported) + // opts.push({ + // id: walletService.externalSource.ledger.id, + // label: walletService.externalSource.ledger.longName, + // supportsTestnet: walletService.externalSource.ledger.supportsTestnet + // }); + + // if (walletService.externalSource.trezor.supported) { + // opts.push({ + // id: walletService.externalSource.trezor.id, + // label: walletService.externalSource.trezor.longName, + // supportsTestnet: walletService.externalSource.trezor.supportsTestnet + // }); + // } + + // if (walletService.externalSource.intelTEE.supported) { + // opts.push({ + // id: walletService.externalSource.intelTEE.id, + // label: walletService.externalSource.intelTEE.longName, + // supportsTestnet: walletService.externalSource.intelTEE.supportsTestnet + // }); + // } + } + this.seedOptions = this.seedOptions.concat(opts); + }; + + seedOptionsChange(seed: any) { + this.formData.selectedSeed.id = seed; + this.resetPasswordFields(); + } + + resetPasswordFields() { + this.formData.password = null; + this.formData.confirmPassword = null; + this.formData.writtenDown = false; + } + + create() { + console.log(this.formData); + } +}