Merge pull request #7027 from JDonadio/ref/home-01

Refactor home view
This commit is contained in:
Gabriel Edgardo Bazán 2017-11-03 09:43:03 -03:00 committed by GitHub
commit d559cffe2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 18 deletions

View File

@ -1,6 +1,6 @@
<ion-header> <ion-header>
<ion-navbar> <ion-navbar>
<ion-title>Home</ion-title> <ion-title>{{'Home' | translate}}</ion-title>
</ion-navbar> </ion-navbar>
</ion-header> </ion-header>
@ -15,9 +15,9 @@
<ion-card *ngIf="wallets && wallets[0]"> <ion-card *ngIf="wallets && wallets[0]">
<ion-item> <ion-item>
Wallets <span translate>Wallets</span>
<button ion-button outline item-end icon-left (click)="goToAddView()"> <button ion-button clear item-end class="header-icon" (click)="goToAddView()">
<ion-icon name="md-add"></ion-icon> <ion-icon name="ios-add"></ion-icon>
</button> </button>
</ion-item> </ion-item>
@ -26,9 +26,10 @@
<ion-icon item-start> <ion-icon item-start>
<img src="assets/img/icon-wallet.svg" class="icon-wallet"> <img src="assets/img/icon-wallet.svg" class="icon-wallet">
</ion-icon> </ion-icon>
<h2>{{wallet.credentials.walletName}} {{wallet.credentials.m}}-{{wallet.credentials.n}}</h2> <h2>{{wallet.credentials.walletName}} <span *ngIf="wallet.credentials.m > 1">{{wallet.credentials.m}}-{{wallet.credentials.n}}</span></h2>
<p *ngIf="!wallet.scanning">{{wallet.status.totalBalanceStr ? wallet.status.totalBalanceStr : ( wallet.cachedBalance ? wallet.cachedBalance + (wallet.cachedBalanceUpdatedOn ? ' &middot; ' + ( wallet.cachedBalanceUpdatedOn * 1000 | amTimeAgo) : '') : '' )}}</p> <span *ngIf="wallet.scanning" translate>Scanning funds</span>
<span *ngIf="wallet.scanning"> Scanning funds... </span> <p *ngIf="!wallet.scanning">{{wallet.statusStr}}</p>
<p *ngIf="wallet.error" class="error">{{wallet.error}}</p>
</button> </button>
</ion-list> </ion-list>
</ion-card> </ion-card>

View File

@ -1,15 +1,22 @@
img { img {
&.icon-wallet { &.icon-wallet {
width: 35px !important; width: 35px !important;
background-color: #647ce8; background-color: color($colors, accent);
} }
} }
.button-outline-md { /* Android fix */
margin-right: auto !important; .item-md [item-start] {
border: none; margin: 0 !important;
color: #488aff; }
background-color: transparent;
-webkit-box-shadow: none; .header-icon {
box-shadow: none; font-size: 1.7rem !important;
color: silver;
margin: 0 !important;
padding: 10px !important;
}
.error {
color: color($colors, danger) !important;
} }

View File

@ -6,6 +6,7 @@ import { ReleaseProvider } from '../../providers/release/release';
import { WalletProvider } from '../../providers/wallet/wallet'; import { WalletProvider } from '../../providers/wallet/wallet';
import { BwcErrorProvider } from '../../providers/bwc-error/bwc-error'; import { BwcErrorProvider } from '../../providers/bwc-error/bwc-error';
import * as _ from 'lodash'; import * as _ from 'lodash';
import * as moment from 'moment';
@Component({ @Component({
selector: 'page-home', selector: 'page-home',
@ -20,9 +21,11 @@ export class HomePage {
private releaseProvider: ReleaseProvider, private releaseProvider: ReleaseProvider,
private walletProvider: WalletProvider, private walletProvider: WalletProvider,
private bwcErrorProvider: BwcErrorProvider private bwcErrorProvider: BwcErrorProvider
) { ) {}
this.checkUpdate();
ionViewDidEnter() {
this.wallets = this.profileProvider.getWallets(); this.wallets = this.profileProvider.getWallets();
this.checkUpdate();
this.updateAllWallets(); this.updateAllWallets();
} }
@ -33,6 +36,10 @@ export class HomePage {
private updateAllWallets(): void { private updateAllWallets(): void {
_.each(this.wallets, (wallet: any) => { _.each(this.wallets, (wallet: any) => {
this.walletProvider.getStatus(wallet, {}).then((status: any) => { this.walletProvider.getStatus(wallet, {}).then((status: any) => {
const balanceStr = status.totalBalanceStr ? wallet.status.totalBalanceStr : '';
const cachedBalanceStr = wallet.cachedBalance ? wallet.cachedBalance : '';
const cachedBalanceUpdateOn = wallet.cachedBalanceUpdatedOn ? ' - ' + moment(wallet.cachedBalanceUpdatedOn * 1000).fromNow() : '';
wallet.statusStr = balanceStr || cachedBalanceStr + cachedBalanceUpdateOn;
wallet.status = status; wallet.status = status;
this.profileProvider.setLastKnownBalance(wallet.id, wallet.status.totalBalanceStr); this.profileProvider.setLastKnownBalance(wallet.id, wallet.status.totalBalanceStr);
}).catch((err) => { }).catch((err) => {

View File

@ -70,6 +70,12 @@ $checkbox-md-item-start-margin-end: 20px;
$alert-ios-button-text-color: color($colors, accent); $alert-ios-button-text-color: color($colors, accent);
$alert-md-button-text-color: color($colors, accent); $alert-md-button-text-color: color($colors, accent);
/* tabs */
$tabs-ios-tab-color-active: color($colors, accent);
$tabs-md-tab-color-active: color($colors, accent);
$tabs-wp-tab-color-active: color($colors, accent);
// App iOS Variables // App iOS Variables
// -------------------------------------------------- // --------------------------------------------------
// iOS only Sass variables can go here // iOS only Sass variables can go here