merge single and shared wallet

This commit is contained in:
JDonadio 2017-10-10 15:21:50 -03:00
parent a364d215da
commit 21a746a51d
No known key found for this signature in database
GPG Key ID: EC1F4E04B2BFA730
6 changed files with 65 additions and 17 deletions

View File

@ -25,7 +25,7 @@ import { CopayApp } from './app.component';
/* Pages */
import { AddPage } from '../pages/add/add';
import { SingleWalletPage } from '../pages/add/create-wallet/single-wallet/single-wallet';
import { CreateWalletPage } from '../pages/add/create-wallet/create-wallet';
import { BackupRequestPage } from '../pages/onboarding/backup-request/backup-request';
import { DisclaimerPage } from '../pages/onboarding/disclaimer/disclaimer';
import { EmailPage } from '../pages/onboarding/email/email';
@ -76,7 +76,7 @@ export function createTranslateLoader(http: Http) {
let pages: any = [
AddPage,
SingleWalletPage,
CreateWalletPage,
AboutPage,
AdvancedPage,
AltCurrencyPage,

View File

@ -6,13 +6,13 @@
<ion-content padding>
<ion-card>
<ion-item (click)="goToSingleWallet()" detail-push>
<ion-item (click)="goToCreateWallet(false)" detail-push>
<span translate>New personal wallet</span>
</ion-item>
</ion-card>
<ion-card>
<ion-item (click)="goToSharedWallet()" detail-push>
<ion-item (click)="goToCreateWallet(true)" detail-push>
<span translate>Create shared wallet</span>
</ion-item>
</ion-card>

View File

@ -1,6 +1,6 @@
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { SingleWalletPage } from "./create-wallet/single-wallet/single-wallet";
import { CreateWalletPage } from "./create-wallet/create-wallet";
@Component({
selector: 'page-add',
@ -13,12 +13,8 @@ export class AddPage {
console.log('ionViewDidLoad AddPage');
}
goToSingleWallet() {
this.navCtrl.push(SingleWalletPage);
}
goToSharedeWallet() {
// this.navCtrl.push();
goToCreateWallet(isShared: boolean) {
this.navCtrl.push(CreateWalletPage, {isShared: isShared});
}
goToJoinWallet() {

View File

@ -1,6 +1,6 @@
<ion-header>
<ion-navbar>
<ion-title>Create personal wallet</ion-title>
<ion-title>{{title}}</ion-title>
</ion-navbar>
</ion-header>
@ -11,6 +11,27 @@
<ion-input type="text" [(ngModel)]="formData.walletName" formControlName="walletName" required></ion-input>
</ion-item>
<div *ngIf="isShared">
<ion-item>
<ion-label stacked>Your name</ion-label>
<ion-input type="text" [(ngModel)]="formData.copayerName" formControlName="copayerName" required></ion-input>
</ion-item>
<ion-item>
<ion-label stacked>Total number of copayers</ion-label>
<ion-select [(ngModel)]="formData.copayerSelected" formControlName="copayerSelected" (ionChange)="copayersChange(formData.copayerSelected)">
<ion-option *ngFor="let copayer of copayers" [value]="copayer">{{copayer}}</ion-option>
</ion-select>
</ion-item>
<ion-item>
<ion-label stacked>Required number of signatures</ion-label>
<ion-select [(ngModel)]="formData.signatureSelected" formControlName="signatureSelected" (ionChange)="signaturesChange(formData.signatureSelected)">
<ion-option *ngFor="let signature of signatures" [value]="signature">{{signature}}</ion-option>
</ion-select>
</ion-item>
</div>
<ion-item-divider color="light"></ion-item-divider>
<ion-item (click)="showAdvOpts = !showAdvOpts">

View File

@ -1,17 +1,23 @@
import { Component, OnInit } from '@angular/core';
import { NavController } from 'ionic-angular';
import { NavController, NavParams } from 'ionic-angular';
import { Validators, FormBuilder, FormGroup } from '@angular/forms';
import { AppProvider } from '../../../../providers/app/app';
import { AppProvider } from '../../../providers/app/app';
import * as _ from 'lodash';
@Component({
selector: 'page-single-wallet',
templateUrl: 'single-wallet.html'
selector: 'page-create-wallet',
templateUrl: 'create-wallet.html'
})
export class SingleWalletPage implements OnInit{
export class CreateWalletPage implements OnInit{
public formData: any;
public showAdvOpts: boolean;
public COPAYER_PAIR_LIMITS: Array<any>;
public copayers: any;
public signatures: any;
public seedOptions: any;
public isShared: boolean;
public title: string;
private appName: string;
private derivationPathByDefault: string;
@ -20,14 +26,23 @@ export class SingleWalletPage implements OnInit{
constructor(
public navCtrl: NavController,
public navParams: NavParams,
private app: AppProvider,
private fb: FormBuilder
) {
this.isShared = navParams.get('isShared');
this.title = this.isShared ? 'Create shared wallet' : 'Create personal wallet';
this.derivationPathByDefault = "m/44'/0'/0'";
this.derivationPathForTestnet = "m/44'/1'/0'";
this.showAdvOpts = false;
this.COPAYER_PAIR_LIMITS = [2, 3, 4, 5, 6];
this.copayers = _.clone(this.COPAYER_PAIR_LIMITS);
this.signatures = _.clone(this.COPAYER_PAIR_LIMITS);
this.formData = {
walletName: null,
copayerName: null,
copayerSelected: this.copayers[0],
signatureSelected: this.copayers[0],
bwsURL: 'https://bws.bitpay.com/bws/api',
recoveryPhrase: null,
addPassword: false,
@ -45,6 +60,9 @@ export class SingleWalletPage implements OnInit{
ngOnInit() {
this.createForm = this.fb.group({
walletName: ['', Validators.required],
copayerName: [''],
copayerSelected: [''],
signatureSelected: [''],
bwsURL: [''],
selectedSeed: [''],
recoveryPhrase: [''],
@ -57,6 +75,10 @@ export class SingleWalletPage implements OnInit{
singleAddress: [''],
});
if (this.isShared) {
this.createForm.get('copayerName').setValidators([Validators.required]);
}
this.createForm.get('addPassword').valueChanges.subscribe((addPassword: boolean) => {
if (addPassword) {
this.createForm.get('password').setValidators([Validators.required]);
@ -131,6 +153,15 @@ export class SingleWalletPage implements OnInit{
this.resetFormFields();
}
copayersChange(copayer: any) {
console.log(copayer);
}
signaturesChange(signature: any) {
// TODO modify based on copayers
console.log(signature);
}
resetFormFields() {
this.formData.password = null;
this.formData.confirmPassword = null;