From 4e9c9f54518fe13318c76fe2c1fdfead354d1e24 Mon Sep 17 00:00:00 2001 From: Darren Nelsen Date: Thu, 8 Feb 2018 17:47:59 -0500 Subject: [PATCH] added rudimentary blockchain switcher --- app/src/assets/img/currency_logos/bch.svg | 14 +++++++ app/src/assets/img/currency_logos/btc.svg | 15 ++++++++ app/src/assets/img/currency_logos/ltc.svg | 16 ++++++++ .../components/denomination/denomination.html | 15 +++++++- .../components/denomination/denomination.ts | 29 +++++++++++++-- app/src/components/head-nav/head-nav.ts | 37 ------------------- 6 files changed, 84 insertions(+), 42 deletions(-) create mode 100644 app/src/assets/img/currency_logos/bch.svg create mode 100644 app/src/assets/img/currency_logos/btc.svg create mode 100644 app/src/assets/img/currency_logos/ltc.svg diff --git a/app/src/assets/img/currency_logos/bch.svg b/app/src/assets/img/currency_logos/bch.svg new file mode 100644 index 0000000..95a0282 --- /dev/null +++ b/app/src/assets/img/currency_logos/bch.svg @@ -0,0 +1,14 @@ + + + + cash + Created with Sketch. + + + + + + + + + \ No newline at end of file diff --git a/app/src/assets/img/currency_logos/btc.svg b/app/src/assets/img/currency_logos/btc.svg new file mode 100644 index 0000000..a421df2 --- /dev/null +++ b/app/src/assets/img/currency_logos/btc.svg @@ -0,0 +1,15 @@ + + + + bitcoin + Created with Sketch. + + + + + + + + + + \ No newline at end of file diff --git a/app/src/assets/img/currency_logos/ltc.svg b/app/src/assets/img/currency_logos/ltc.svg new file mode 100644 index 0000000..d7afa3f --- /dev/null +++ b/app/src/assets/img/currency_logos/ltc.svg @@ -0,0 +1,16 @@ + + + + litecoin + Created with Sketch. + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/components/denomination/denomination.html b/app/src/components/denomination/denomination.html index 65c736b..ab0aefb 100644 --- a/app/src/components/denomination/denomination.html +++ b/app/src/components/denomination/denomination.html @@ -1,10 +1,21 @@ - + + + Blockchain + + + + + + + + Units {{ unit }} - + diff --git a/app/src/components/denomination/denomination.ts b/app/src/components/denomination/denomination.ts index b484472..e683b1c 100644 --- a/app/src/components/denomination/denomination.ts +++ b/app/src/components/denomination/denomination.ts @@ -9,17 +9,33 @@ import { ViewController } from 'ionic-angular'; export class DenominationComponent { public text: string; + public switcherOn: boolean; + public currencies: any = []; public units: any = []; constructor( - public currency: CurrencyProvider, + public currencyProvider: CurrencyProvider, public viewCtrl: ViewController ) { this.text = 'Hello World'; + this.switcherOn = true; + this.currencies = [ + { + name: 'Bitcoin', + ticker: 'BTC', + url: 'https://insight.bitpay.com' + }, + { + name: 'Bitcoin Cash', + ticker: 'BCH', + url: 'https://bch-insight.bitpay.com' + } + ]; + this.units = [ 'USD', - this.currency.defaultCurrency, - 'm' + this.currency.defaultCurrency, + this.currencyProvider.defaultCurrency, + 'm' + this.currencyProvider.defaultCurrency, 'bits' ]; } @@ -28,4 +44,11 @@ export class DenominationComponent { this.viewCtrl.dismiss(); } + public changeCurrency(currency: any): void { + console.log('selected currency is', currency.name, currency.ticker); + this.close(); + let theUrl: string = currency.url; + console.log('theUrl is', theUrl); + window.location.href = theUrl; + } } diff --git a/app/src/components/head-nav/head-nav.ts b/app/src/components/head-nav/head-nav.ts index 1ccf83d..dfdf998 100644 --- a/app/src/components/head-nav/head-nav.ts +++ b/app/src/components/head-nav/head-nav.ts @@ -112,43 +112,6 @@ export class HeadNavComponent { /* tslint:enable:no-unused-variable */ public changeCurrency(myEvent: any): void { - /* - let actionSheet: any = this.actionSheetCtrl.create({ - title: 'Change Denomination', - buttons: [ - { - text: 'USD', - handler: () => { - this.currency.setCurrency('USD'); - } - }, - { - text: this.currency.defaultCurrency, - handler: () => { - this.currency.setCurrency(this.currency.defaultCurrency); - } - }, - { - text: 'm' + this.currency.defaultCurrency, - handler: () => { - this.currency.setCurrency('m' + this.currency.defaultCurrency); - } - }, - { - text: 'bits', - handler: () => { - this.currency.setCurrency('bits'); - } - }, - { - text: 'Cancel', - role: 'cancel' - } - ] - }); - actionSheet.present(); - */ - let popover: any = this.popoverCtrl.create(DenominationComponent); popover.present({ ev: myEvent