mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-08 23:58:13 +08:00
refactor(nav): update interface's public api
This commit is contained in:
@ -1,4 +1,4 @@
|
|||||||
import { Component, Element, Method, Prop } from '@stencil/core';
|
import { Component, Element, Event, EventEmitter, Method, Prop } from '@stencil/core';
|
||||||
import { AnimationController, Config } from '../..';
|
import { AnimationController, Config } from '../..';
|
||||||
import { ComponentDataPair, FrameworkDelegate, Nav, NavController, NavOptions, ViewController } from '../../navigation/nav-interfaces';
|
import { ComponentDataPair, FrameworkDelegate, Nav, NavController, NavOptions, ViewController } from '../../navigation/nav-interfaces';
|
||||||
|
|
||||||
@ -11,6 +11,8 @@ import { isReady } from '../../utils/helpers';
|
|||||||
export class IonNav implements Nav {
|
export class IonNav implements Nav {
|
||||||
|
|
||||||
@Element() element: HTMLElement;
|
@Element() element: HTMLElement;
|
||||||
|
@Event() navInit: EventEmitter;
|
||||||
|
|
||||||
id: number;
|
id: number;
|
||||||
parent: Nav;
|
parent: Nav;
|
||||||
views: ViewController[];
|
views: ViewController[];
|
||||||
@ -33,7 +35,8 @@ export class IonNav implements Nav {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ionViewDidLoad() {
|
ionViewDidLoad() {
|
||||||
this.setRoot(this.root);
|
ionViewDidLoadImpl(this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getViews(): ViewController[] {
|
getViews(): ViewController[] {
|
||||||
@ -41,52 +44,52 @@ export class IonNav implements Nav {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Method()
|
@Method()
|
||||||
push(component: any, data?: any, opts?: NavOptions) {
|
push(component: any, data?: any, opts?: NavOptions): Promise<any> {
|
||||||
return pushImpl(this, component, data, opts);
|
return pushImpl(this, component, data, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Method()
|
@Method()
|
||||||
pop(opts?: NavOptions) {
|
pop(opts?: NavOptions): Promise<any> {
|
||||||
return popImpl(this, opts);
|
return popImpl(this, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Method()
|
@Method()
|
||||||
setRoot(component: any, data?: any, opts?: NavOptions) {
|
setRoot(component: any, data?: any, opts?: NavOptions): Promise<any> {
|
||||||
return setRootImpl(this, component, data, opts);
|
return setRootImpl(this, component, data, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Method()
|
@Method()
|
||||||
insert(insertIndex: number, page: any, params?: any, opts?: NavOptions) {
|
insert(insertIndex: number, page: any, params?: any, opts?: NavOptions): Promise<any> {
|
||||||
return insertImpl(this, insertIndex, page, params, opts);
|
return insertImpl(this, insertIndex, page, params, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Method()
|
@Method()
|
||||||
insertPages(insertIndex: number, insertPages: any[], opts?: NavOptions) {
|
insertPages(insertIndex: number, insertPages: any[], opts?: NavOptions): Promise<any> {
|
||||||
return insertPagesImpl(this, insertIndex, insertPages, opts);
|
return insertPagesImpl(this, insertIndex, insertPages, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Method()
|
@Method()
|
||||||
popToRoot(opts?: NavOptions) {
|
popToRoot(opts?: NavOptions): Promise<any> {
|
||||||
return popToRootImpl(this, opts);
|
return popToRootImpl(this, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Method()
|
@Method()
|
||||||
popTo(indexOrViewCtrl: any, opts?: NavOptions) {
|
popTo(indexOrViewCtrl: any, opts?: NavOptions): Promise<any> {
|
||||||
return popToImpl(this, indexOrViewCtrl, opts);
|
return popToImpl(this, indexOrViewCtrl, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Method()
|
@Method()
|
||||||
remove(startIndex: number, removeCount?: number, opts?: NavOptions) {
|
remove(startIndex: number, removeCount?: number, opts?: NavOptions): Promise<any> {
|
||||||
return removeImpl(this, startIndex, removeCount, opts);
|
return removeImpl(this, startIndex, removeCount, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Method()
|
@Method()
|
||||||
removeView(viewController: ViewController, opts?: NavOptions) {
|
removeView(viewController: ViewController, opts?: NavOptions): Promise<any> {
|
||||||
return removeViewImpl(this, viewController, opts);
|
return removeViewImpl(this, viewController, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Method()
|
@Method()
|
||||||
setPages(componentDataPairs: ComponentDataPair[], opts? : NavOptions) {
|
setPages(componentDataPairs: ComponentDataPair[], opts? : NavOptions): Promise<any> {
|
||||||
return setPagesImpl(this, componentDataPairs, opts);
|
return setPagesImpl(this, componentDataPairs, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,6 +123,13 @@ export class IonNav implements Nav {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function ionViewDidLoadImpl(nav: Nav) {
|
||||||
|
nav.
|
||||||
|
if (nav.root) {
|
||||||
|
nav.setRoot(nav.root);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function pushImpl(nav: Nav, component: any, data: any, opts: NavOptions) {
|
export function pushImpl(nav: Nav, component: any, data: any, opts: NavOptions) {
|
||||||
return getNavController(nav).then(() => {
|
return getNavController(nav).then(() => {
|
||||||
return nav.navController.push(nav, component, data, opts);
|
return nav.navController.push(nav, component, data, opts);
|
||||||
|
|||||||
17
packages/core/src/navigation/nav-interfaces.d.ts
vendored
17
packages/core/src/navigation/nav-interfaces.d.ts
vendored
@ -23,11 +23,22 @@ export interface Nav {
|
|||||||
swipeToGoBackTransition?: any; // TODO Transition
|
swipeToGoBackTransition?: any; // TODO Transition
|
||||||
navController?: NavController;
|
navController?: NavController;
|
||||||
parent?: Nav;
|
parent?: Nav;
|
||||||
|
childNavs?: Nav[]; // TODO - make nav container
|
||||||
|
root?: any;
|
||||||
|
|
||||||
getActive(): ViewController;
|
getActive(): ViewController;
|
||||||
getPrevious(view?: ViewController): ViewController;
|
getPrevious(view?: ViewController): ViewController;
|
||||||
childNavs?: Nav[]; // TODO - make nav container
|
getViews(): ViewController[];
|
||||||
animationCtrl?: AnimationController;
|
push(component: any, data?: any, opts?: NavOptions): Promise<any>;
|
||||||
config?: Config;
|
pop(opts?: NavOptions): Promise<any>;
|
||||||
|
setRoot(component: any, data?: any, opts?: NavOptions): Promise<any>;
|
||||||
|
insert(insertIndex: number, page: any, params?: any, opts?: NavOptions): Promise<any>;
|
||||||
|
insertPages(insertIndex: number, insertPages: any[], opts?: NavOptions): Promise<any>;
|
||||||
|
popToRoot(opts?: NavOptions): Promise<any>;
|
||||||
|
popTo(indexOrViewCtrl: any, opts?: NavOptions): Promise<any>;
|
||||||
|
remove(startIndex: number, removeCount?: number, opts?: NavOptions): Promise<any>;
|
||||||
|
removeView(viewController: ViewController, opts?: NavOptions): Promise<any>;
|
||||||
|
setPages(componentDataPairs: ComponentDataPair[], opts? : NavOptions): Promise<any>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface NavController {
|
export interface NavController {
|
||||||
|
|||||||
Reference in New Issue
Block a user