Merge pull request #8012 from gabrielbazan7/ref/services

[V4] REF: moving hide/show services from advanced settings to setting tab
This commit is contained in:
Gustavo Maximiliano Cortez 2018-02-09 10:02:01 -03:00 committed by GitHub
commit ed1e098df0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 90 additions and 76 deletions

View File

@ -113,6 +113,7 @@ import { AddressbookAddPage } from '../pages/settings/addressbook/add/add';
import { AddressbookViewPage } from '../pages/settings/addressbook/view/view';
import { AdvancedPage } from '../pages/settings/advanced/advanced';
import { AltCurrencyPage } from '../pages/settings/alt-currency/alt-currency';
import { EnabledServicesPage } from '../pages/settings/enabled-services/enabled-services';
import { FingerprintModalPage } from '../pages/fingerprint/fingerprint';
import { LanguagePage } from '../pages/settings/language/language';
import { LockPage } from '../pages/settings/lock/lock';
@ -234,6 +235,7 @@ export function createTranslateLoader(http: HttpClient) {
CoinbasePage,
CoinbaseTxDetailsPage,
CopayersPage,
EnabledServicesPage,
FeedbackCardPage,
FeedbackPage,
FeedbackCompletePage,
@ -357,6 +359,7 @@ export function createTranslateLoader(http: HttpClient) {
CoinbasePage,
CoinbaseTxDetailsPage,
CopayersPage,
EnabledServicesPage,
FeedbackCardPage,
FeedbackPage,
FeedbackCompletePage,

View File

@ -107,18 +107,14 @@ export class HomePage {
if (this.recentTransactionsEnabled) this.getNotifications();
this.pushNotificationsProvider.init();
if (this.config.showIntegrations.enabled) {
this.homeIntegrations = this.homeIntegrationsProvider.get();
this.showIntegration = this.config.showIntegration;
this.homeIntegrations.forEach((integration: any) => {
integration.show = this.showIntegration[integration.name];
});
this.homeIntegrations = _.filter(this.homeIntegrations, (homeIntegrations) => {
return homeIntegrations.show == true;
});
} else {
this.homeIntegrations = null;
}
this.homeIntegrations = this.homeIntegrationsProvider.get();
this.showIntegration = this.config.showIntegration;
this.homeIntegrations.forEach((integration: any) => {
integration.show = this.showIntegration[integration.name];
});
this.homeIntegrations = _.filter(this.homeIntegrations, (homeIntegrations) => {
return homeIntegrations.show == true;
});
this.events.subscribe('bwsEvent', (walletId, type, n) => {
let wallet = this.profileProvider.getWallet(walletId);

View File

@ -40,20 +40,4 @@
</ion-item-divider>
</ion-list>
<ion-list>
<ion-item>
<ion-label>{{'Show Services Card' | translate}}</ion-label>
<ion-toggle [(ngModel)]="showIntegrations" (ionChange)="integrationsChange()"></ion-toggle>
</ion-item>
<div *ngIf="showIntegrations">
<ion-item *ngFor="let integration of homeIntegrations">
<ion-label>{{integration.title}}</ion-label>
<ion-checkbox [(ngModel)]="integration.show" (ionChange)="integrationChange(integration.name)"></ion-checkbox>
</ion-item>
</div>
<ion-item-divider class="item-description" padding-horizontal text-wrap>
<span translate>If enabled, the "Services Card" will appear in the Home tab.</span>
</ion-item-divider>
</ion-list>
</ion-content>
</ion-content>

View File

@ -3,7 +3,6 @@ import { Logger } from '../../../providers/logger/logger';
//providers
import { ConfigProvider } from '../../../providers/config/config';
import { HomeIntegrationsProvider } from '../../../providers/home-integrations/home-integrations';
@Component({
selector: 'page-advanced',
@ -13,17 +12,12 @@ export class AdvancedPage {
public spendUnconfirmed: boolean;
public recentTransactionsEnabled: boolean;
public showIntegrations: boolean;
public showIntegration: any;
public useLegacyAddress: boolean;
public homeIntegrations: any;
constructor(
private configProvider: ConfigProvider,
private logger: Logger,
private homeIntegrationsProvider: HomeIntegrationsProvider
private logger: Logger
) {
this.homeIntegrations = this.homeIntegrationsProvider.get();
}
ionViewDidLoad() {
@ -36,11 +30,6 @@ export class AdvancedPage {
this.spendUnconfirmed = config.wallet.spendUnconfirmed;
this.recentTransactionsEnabled = config.recentTransactions.enabled;
this.useLegacyAddress = config.wallet.useLegacyAddress;
this.showIntegrations = config.showIntegrations.enabled;
this.showIntegration = config.showIntegration;
this.homeIntegrations.forEach((integration: any) => {
integration.show = this.showIntegration[integration.name];
});
}
public spendUnconfirmedChange(): void {
@ -69,21 +58,4 @@ export class AdvancedPage {
};
this.configProvider.set(opts);
}
public integrationsChange(): void {
let opts = {
showIntegrations: {
enabled: this.showIntegrations
},
};
this.configProvider.set(opts);
}
public integrationChange(integrationName): void {
this.showIntegration[integrationName] = !this.showIntegration[integrationName];
let opts = {
showIntegration: this.showIntegration,
};
this.configProvider.set(opts);
}
}

View File

@ -0,0 +1,19 @@
<ion-header>
<ion-navbar>
<ion-title>{{'Enabled services' | translate}}</ion-title>
</ion-navbar>
</ion-header>
<ion-content>
<ion-item-divider></ion-item-divider>
<ion-list>
<ion-item *ngFor="let integration of homeIntegrations">
<ion-label>{{integration.title || service.name}}</ion-label>
<ion-toggle [(ngModel)]="integration.show" (ionChange)="integrationChange(integration.name)"></ion-toggle>
</ion-item>
</ion-list>
</ion-content>

View File

@ -0,0 +1,3 @@
page-enabled-services {
}

View File

@ -0,0 +1,39 @@
import { Component } from '@angular/core';
import { Logger } from '../../../providers/logger/logger';
import * as _ from 'lodash';
// Providers
import { ConfigProvider } from '../../../providers/config/config';
import { HomeIntegrationsProvider } from '../../../providers/home-integrations/home-integrations';
@Component({
selector: 'page-enabled-services',
templateUrl: 'enabled-services.html',
})
export class EnabledServicesPage {
public showIntegration: any;
public useLegacyAddress: boolean;
public homeIntegrations: any;
constructor(
private logger: Logger,
private configProvider: ConfigProvider,
private homeIntegrationsProvider: HomeIntegrationsProvider
) {
let config: any = this.configProvider.get();
this.showIntegration = config.showIntegration;
this.homeIntegrations = this.homeIntegrationsProvider.get();
this.homeIntegrations.forEach((integration: any) => {
integration.show = this.showIntegration[integration.name];
});
}
public integrationChange(integrationName): void {
this.showIntegration[integrationName] = !this.showIntegration[integrationName];
let opts = {
showIntegration: this.showIntegration,
};
this.configProvider.set(opts);
}
}

View File

@ -127,11 +127,18 @@
<button ion-item *ngFor="let service of exchangeServices" (click)="openIntegrationSettings(service.name)">
<ion-icon item-start>
<img src="{{service.icon}}" class="icon-services" />
<img src="{{service.icon}}" class="icon-services" />
</ion-icon>
<span>{{service.title || service.name}}</span>
</button>
<ion-item-divider></ion-item-divider>
<ion-item (click)="openEnabledServicesPage()">
<ion-icon name="ios-list-outline" item-start></ion-icon>
{{'Enabled services' | translate}}
</ion-item>
<ion-item-divider>More</ion-item-divider>
<button ion-item (click)="openAdvancedPage()">
@ -145,4 +152,4 @@
</button>
<ion-item-divider></ion-item-divider>
</ion-list>
</ion-content>
</ion-content>

View File

@ -27,6 +27,7 @@ import { FeedbackCompletePage } from '../feedback/feedback-complete/feedback-com
import { SendFeedbackPage } from '../feedback/send-feedback/send-feedback';
import { GlideraSettingsPage } from '../integrations/glidera/glidera-settings/glidera-settings';
import { CoinbaseSettingsPage } from '../integrations/coinbase/coinbase-settings/coinbase-settings';
import { EnabledServicesPage } from './enabled-services/enabled-services';
@Component({
selector: 'page-settings',
@ -82,9 +83,7 @@ export class SettingsPage {
isoCode: this.config.wallet.settings.alternativeIsoCode
}
this.lockMethod = this.config.lock.method;
if (this.config.showIntegrations.enabled) {
this.exchangeServices = this.homeIntegrationsProvider.getAvailableExchange();
}
this.exchangeServices = this.homeIntegrationsProvider.getAvailableExchange();
}
public openBitcoinCashPage(): void {
@ -135,6 +134,10 @@ export class SettingsPage {
this.navCtrl.push(FeedbackCompletePage, { score: 4, skipped: true, fromSettings: true });
}
public openEnabledServicesPage(): void {
this.navCtrl.push(EnabledServicesPage);
}
public openIntegrationSettings(name: string): void {
switch (name) {
case 'coinbase':

View File

@ -1109,7 +1109,7 @@ export class BitPayCardProvider {
this.homeItem = {
name: 'bitpaycard',
title: 'Add BitPay Visa® Card',
title: 'BitPay Visa® Card',
icon: 'assets/img/bitpay-card/icon-bitpay.svg',
page: 'BitPayCardIntroPage',
}

View File

@ -65,10 +65,6 @@ interface Config {
enabled: boolean;
};
showIntegrations: {
enabled: boolean;
};
showIntegration: {
coinbase: boolean,
glidera: boolean,
@ -172,10 +168,6 @@ const configDefault: Config = {
enabled: true
},
showIntegrations: {
enabled: true
},
showIntegration: {
coinbase: true,
glidera: true,
@ -276,10 +268,6 @@ export class ConfigProvider {
this.configCache.wallet.settings.unitCode = configDefault.wallet.settings.unitCode;
}
if (!this.configCache.showIntegrations) {
this.configCache.showIntegrations = configDefault.showIntegrations;
}
if (!this.configCache.showIntegration) {
this.configCache.showIntegration = configDefault.showIntegration;
}