add toFiat pipe

This commit is contained in:
JDonadio 2017-11-07 17:34:34 -03:00
parent e7ffbe0c33
commit c55bd2e026
No known key found for this signature in database
GPG Key ID: EC1F4E04B2BFA730
4 changed files with 31 additions and 3 deletions

View File

@ -67,8 +67,10 @@ import { ChooseFeeLevelPage } from '../pages/choose-fee-level/choose-fee-level';
/* Receive */ /* Receive */
import { CustomAmountPage } from '../pages/receive/custom-amount/custom-amount'; import { CustomAmountPage } from '../pages/receive/custom-amount/custom-amount';
/* Providers */ /* Pipes */
import { ToFiatPipe } from '../pipes/toFiat';
/* Providers */
import { AddressBookProvider } from '../providers/address-book/address-book'; import { AddressBookProvider } from '../providers/address-book/address-book';
import { AppProvider } from '../providers/app/app'; import { AppProvider } from '../providers/app/app';
import { BwcProvider } from '../providers/bwc/bwc'; import { BwcProvider } from '../providers/bwc/bwc';
@ -196,8 +198,18 @@ let providers: any = [
} }
]; ];
let pipes = [
ToFiatPipe,
];
export function declarationsComponents() { export function declarationsComponents() {
return pages.concat(directives); let declarations = [];
declarations = declarations.concat(pages);
declarations = declarations.concat(directives);
declarations = declarations.concat(pipes);
return declarations;
} }
export function entryComponents() { export function entryComponents() {

View File

@ -19,7 +19,7 @@
</ion-icon> </ion-icon>
<div class="action">{{tx.action}}</div> <div class="action">{{tx.action}}</div>
<div class="detail"> <div class="detail">
<div class="amount">{{tx.amount}}</div> <div class="amount">{{amountStr | toFiat : tx.amount : unitCode}}</div>
<div class="date">{{tx.time * 1000 | amTimeAgo}}</div> <div class="date">{{tx.time * 1000 | amTimeAgo}}</div>
</div> </div>
</button> </button>

View File

@ -1,6 +1,7 @@
import { Component } from '@angular/core'; import { Component } from '@angular/core';
import { NavParams } from 'ionic-angular'; import { NavParams } from 'ionic-angular';
import { WalletProvider } from '../../providers/wallet/wallet'; import { WalletProvider } from '../../providers/wallet/wallet';
import { ConfigProvider } from '../../providers/config/config';
@Component({ @Component({
selector: 'page-wallet-details', selector: 'page-wallet-details',
@ -8,13 +9,16 @@ import { WalletProvider } from '../../providers/wallet/wallet';
}) })
export class WalletDetailsPage { export class WalletDetailsPage {
public wallet: any; public wallet: any;
public unitCode: string;
public alternativeBalanceStr: string; public alternativeBalanceStr: string;
constructor( constructor(
private navParams: NavParams, private navParams: NavParams,
private walletProvider: WalletProvider, private walletProvider: WalletProvider,
private configProvider: ConfigProvider,
) { ) {
this.wallet = this.navParams.data.wallet; this.wallet = this.navParams.data.wallet;
this.unitCode = this.configProvider.get()['wallet']['settings'].unitCode;
} }
ionViewDidEnter() { ionViewDidEnter() {

12
src/pipes/toFiat.ts Normal file
View File

@ -0,0 +1,12 @@
import { Pipe, PipeTransform } from '@angular/core';
import { TxFormatProvider } from '../providers/tx-format/tx-format';
@Pipe({ name: 'toFiat' })
export class ToFiatPipe implements PipeTransform {
constructor(
private txFormatProvider: TxFormatProvider
) {}
transform(value: string, satoshis: number, coin: string): any {
return this.txFormatProvider.formatAmountStr(coin, satoshis);
}
}