Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pull updates #3

Merged
merged 15 commits into from
Jan 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Ionic is based on [Web Components](https://www.webcomponents.org/introduction) a
| **Core** | [`@ionic/core`](https://www.npmjs.com/package/@ionic/core) | [![version](https://img.shields.io/npm/v/@ionic/core/latest.svg)](https://www.npmjs.com/package/@ionic/core) | [`README.md`](core/README.md)
| **Angular** | [`@ionic/angular`](https://www.npmjs.com/package/@ionic/angular) | [![version](https://img.shields.io/npm/v/@ionic/angular/latest.svg)](https://www.npmjs.com/package/@ionic/angular) | [`README.md`](angular/README.md)
| **Vue** | `@ionic/vue` | | [`README.md`](vue/README.md)
| **React** | `@ionic/react` | | [`README.md`](react/README.md)

Looking for the `ionic-angular` package? Ionic 3 has been moved to the [`ionic-v3`](https://github.com/ionic-team/ionic-v3) repo. See [Earlier Versions](#earlier-versions).

Expand Down
5 changes: 4 additions & 1 deletion angular/src/directives/navigation/ion-tabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ export class IonTabs {
? href
: this.outlet.getLastUrl(tab) || href;

return this.navCtrl.navigateBack(url);
return this.navCtrl.navigateRoot(url, {
animated: true,
animationDirection: 'back'
});
}
}
1 change: 0 additions & 1 deletion angular/src/directives/proxies-list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ export const DIRECTIVES = [
d.IonSegmentButton,
d.IonSelect,
d.IonSelectOption,
d.IonSelectPopover,
d.IonSkeletonText,
d.IonSlide,
d.IonSlides,
Expand Down
721 changes: 362 additions & 359 deletions angular/src/directives/proxies.ts

Large diffs are not rendered by default.

37 changes: 19 additions & 18 deletions angular/src/directives/virtual-scroll/virtual-scroll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export declare interface IonVirtualScroll {
export class IonVirtualScroll {

private differ?: IterableDiffer<any>;
private nativeEl: HTMLIonVirtualScrollElement;
private el: HTMLIonVirtualScrollElement;
private refMap = new WeakMap<HTMLElement, EmbeddedViewRef<VirtualContext>> ();

@ContentChild(VirtualItem) itmTmp!: VirtualItem;
Expand Down Expand Up @@ -122,23 +122,8 @@ export class IonVirtualScroll {
private iterableDiffers: IterableDiffers,
elementRef: ElementRef,
) {
this.nativeEl = elementRef.nativeElement as HTMLIonVirtualScrollElement;
this.nativeEl.nodeRender = this.nodeRender.bind(this);

proxyInputs(this, this.nativeEl, [
'approxItemHeight',
'approxHeaderHeight',
'approxFooterHeight',
'headerFn',
'footerFn',
'items',
'itemHeight'
]);
proxyMethods(this, this.nativeEl, [
'checkEnd',
'checkRange',
'positionForItem'
]);
this.el = elementRef.nativeElement as HTMLIonVirtualScrollElement;
this.el.nodeRender = this.nodeRender.bind(this);
}

ngOnChanges(changes: SimpleChanges): void {
Expand Down Expand Up @@ -208,3 +193,19 @@ function getElement(view: EmbeddedViewRef<VirtualContext>): HTMLElement {
}
throw new Error('virtual element was not created');
}

proxyInputs(IonVirtualScroll, [
'approxItemHeight',
'approxHeaderHeight',
'approxFooterHeight',
'headerFn',
'footerFn',
'items',
'itemHeight'
]);

proxyMethods(IonVirtualScroll, [
'checkEnd',
'checkRange',
'positionForItem'
]);
1 change: 0 additions & 1 deletion angular/src/ionic-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ const DECLARATIONS = [
d.IonSegmentButton,
d.IonSelect,
d.IonSelectOption,
d.IonSelectPopover,
d.IonSkeletonText,
d.IonSlide,
d.IonSlides,
Expand Down
17 changes: 6 additions & 11 deletions angular/src/providers/nav-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,25 +44,20 @@ export class NavController {

navigateForward(url: string | UrlTree | any[], options: NavigationOptions = {}) {
this.setDirection('forward', options.animated, options.animationDirection);
if (Array.isArray(url)) {
return this.router!.navigate(url, options);
} else {
return this.router!.navigateByUrl(url, options);
}
this.navigate(url, options);
}

navigateBack(url: string | UrlTree | any[], options: NavigationOptions = {}) {
this.setDirection('back', options.animated, options.animationDirection);
// extras = { replaceUrl: true, ...extras };
if (Array.isArray(url)) {
return this.router!.navigate(url, options);
} else {
return this.router!.navigateByUrl(url, options);
}
this.navigate(url, options);
}

navigateRoot(url: string | UrlTree | any[], options: NavigationOptions = {}) {
this.setDirection('root', options.animated, options.animationDirection);
this.navigate(url, options);
}

navigate(url: string | UrlTree | any[], options: NavigationOptions) {
if (Array.isArray(url)) {
return this.router!.navigate(url, options);
} else {
Expand Down
15 changes: 10 additions & 5 deletions angular/src/providers/platform.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { Injectable } from '@angular/core';
import { BackButtonDetail, Platforms, getPlatforms, isPlatform } from '@ionic/core';
import { BackButtonEventDetail, Platforms, getPlatforms, isPlatform } from '@ionic/core';
import { Subject, Subscription } from 'rxjs';

import { proxyEvent } from '../util/util';

export interface BackButtonEmitter extends Subject<BackButtonDetail> {
export interface BackButtonEmitter extends Subject<BackButtonEventDetail> {
subscribeWithPriority(priority: number, callback: () => Promise<any> | void): Subscription;
}

Expand All @@ -16,7 +14,7 @@ export class Platform {
/**
* @hidden
*/
backButton: BackButtonEmitter = new Subject<BackButtonDetail>() as any;
backButton: BackButtonEmitter = new Subject<BackButtonEventDetail>() as any;

/**
* The pause event emits when the native platform puts the application
Expand Down Expand Up @@ -177,3 +175,10 @@ function readQueryParam(url: string, key: string) {
const results = regex.exec(url);
return results ? decodeURIComponent(results[1].replace(/\+/g, ' ')) : null;
}

function proxyEvent<T>(emitter: Subject<T>, el: EventTarget, eventName: string) {
el.addEventListener(eventName, (ev: Event | undefined | null) => {
// ?? cordova might emit "null" events
emitter.next(ev != null ? (ev as any).detail as T : undefined);
});
}
2 changes: 1 addition & 1 deletion angular/src/util/overlay.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { proxyMethod } from '../util/util';
import { proxyMethod } from './util';

export class OverlayBaseController<Opts, Overlay> {
constructor(private ctrl: string) {}
Expand Down
33 changes: 0 additions & 33 deletions angular/src/util/util.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,3 @@
import { ElementRef } from '@angular/core';
import { Subject } from 'rxjs';

export function inputs(instance: any, el: ElementRef, props: string[]) {
props.forEach(propName => {
Object.defineProperty(instance, propName, {
get: () => el.nativeElement[propName], set: (val: any) => el.nativeElement[propName] = val
});
});
}

export function proxyEvent<T>(emitter: Subject<T>, el: EventTarget, eventName: string) {
el.addEventListener(eventName, (ev: Event | undefined | null) => {
// ?? cordova might emit "null" events
emitter.next(ev != null ? (ev as any).detail as T : undefined);
});
}

export function proxyMethod(ctrlName: string, methodName: string, ...args: any[]) {
const controller = ensureElementInBody(ctrlName);
Expand All @@ -30,19 +13,3 @@ export function ensureElementInBody(elementName: string) {
}
return element as HTMLStencilElement;
}

export function deepEqual(x: any, y: any) {
if (x === y) {
return true;
} else if (typeof x === 'object' && x != null && (typeof y === 'object' && y != null)) {
if (Object.keys(x).length !== Object.keys(y).length) { return false; }

for (const prop in x) {
if (y.hasOwnProperty(prop)) {
if (!deepEqual(x[prop], y[prop])) { return false; }
} else { return false; }
}

return true;
} else { return false; }
}
Loading