Skip to content

Commit

Permalink
Merge pull request #11493 from JohnathanWhite/feat/apple-pay-slide-re…
Browse files Browse the repository at this point in the history
…direction

[FEAT] apple pay - slide redirection
  • Loading branch information
cmgustavo authored Feb 11, 2021
2 parents 3675da2 + 8123a01 commit 258a8d6
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/pages/new-feature/new-feature.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</ion-slide>
</ion-slides>
<div padding>
<button ion-button clear class="try-it-button" (click)="close(tryit)" *ngIf="tryit">
<button @fade ion-button clear class="try-it-button" (click)="close(tryit)" *ngIf="tryit">
{{ 'Try it' | translate }}
</button>
<button ion-button clear class="next-slide-button" (click)="nextSlide()" *ngIf="!endSlide">
Expand Down
30 changes: 27 additions & 3 deletions src/pages/new-feature/new-feature.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,31 @@
import { animate, style, transition, trigger } from '@angular/animations';
import { Component, ViewChild } from '@angular/core';
import { NavParams, Slides, ViewController } from 'ionic-angular';
import { TryItType } from '../../providers/new-feature-data/new-feature-data';
import { ThemeProvider } from '../../providers/theme/theme';
@Component({
selector: 'page-new-feature',
templateUrl: 'new-feature.html'
templateUrl: 'new-feature.html',
animations: [
trigger('fade', [
transition(':enter', [
style({
transform: 'translateX(3px)',
opacity: 0
}),
animate('200ms')
]),
transition(':leave', [
animate(
'200ms',
style({
transform: 'translateX(3px)',
opacity: 0
})
)
])
])
]
})
export class NewFeaturePage {
@ViewChild('newFeatureSlides') slider: Slides;
Expand Down Expand Up @@ -54,7 +76,9 @@ export class NewFeaturePage {
this.slider.slideNext();
}

public close(data: any): void {
this.viewCtrl.dismiss({ data, done: this.endSlide });
public close(data: TryItType): void {
typeof data === 'function'
? data(this.viewCtrl)
: this.viewCtrl.dismiss({ data, done: this.endSlide });
}
}
42 changes: 38 additions & 4 deletions src/providers/new-feature-data/new-feature-data.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { Injectable } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Events, ViewController } from 'ionic-angular';
import _ from 'lodash';
import { AppProvider } from '../app/app';
import { IABCardProvider } from '../in-app-browser/card';
import { LocationProvider } from '../location/location';
import { PersistenceProvider } from '../persistence/persistence';
import { PlatformProvider } from '../platform/platform';

interface FeatureList {
Expand All @@ -24,15 +27,21 @@ interface TryIt {
name: string;
params?: any;
}
export type TryItType = ((viewCtrl?: ViewController) => void) | TryIt | boolean;

@Injectable()
export class NewFeatureData {
private feature_list: FeatureList[];
private country: string;
private NETWORK = 'livenet';
constructor(
private appProv: AppProvider,
private locationProv: LocationProvider,
private platProv: PlatformProvider,
private translate: TranslateService
private translate: TranslateService,
private persistenceProvider: PersistenceProvider,
private iabCardProvider: IABCardProvider,
private events: Events
) {
this.feature_list = [
{
Expand Down Expand Up @@ -79,16 +88,41 @@ export class NewFeatureData {
{
title: 'Connect to Apple Pay',
details:
"Now it's easy to use your BitPay MasterCard with Apple Pay making payments in stores, in apps, and online even easier.",
"Now it's easy to use your BitPay Mastercard with Apple Pay making payments in stores, in apps, and online even easier.",
image: 'assets/img/new-feature/12.1/12.1-1.png'
},
{
title: 'Setup your virtual card',
details:
'To get started, go to your card settings and select “Add to Apple Wallet”',
image: 'assets/img/new-feature/12.1/12.1-2.png',
tryit: {
name: 'CardsPage'
tryit: async (viewCtrl: ViewController) => {
await viewCtrl.dismiss({ done: true });
const cards = await this.persistenceProvider.getBitpayDebitCards(
this.NETWORK
);
const virtualCard = cards.find(
c => c.provider === 'galileo' && c.cardType === 'virtual'
);
if (virtualCard) {
// go to card settings directly
this.iabCardProvider.loadingWrapper(() => {
this.iabCardProvider.show();
setTimeout(() => {
this.iabCardProvider.sendMessage(
{
message: `openSettings?${virtualCard.id}`
},
() => {}
);
});
});
} else {
// new signup - * using events over navCtrl due to dependency issue
this.events.publish('IncomingDataRedir', {
name: 'BitPayCardIntroPage'
});
}
}
}
]
Expand Down
4 changes: 2 additions & 2 deletions src/providers/providers.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ import {
FCMNG,
HomeIntegrationsProvider,
HttpRequestsProvider,
NewFeatureData,
IABCardProvider,
InAppBrowserProvider,
FeeProvider,
Expand Down Expand Up @@ -180,8 +181,7 @@ import {
DecimalPipe,
PersistenceProvider,
File,
CardPhasesProvider,
NewFeatureData
CardPhasesProvider
]
})
export class ProvidersModule {}

0 comments on commit 258a8d6

Please sign in to comment.