mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
Compare commits
2 Commits
ionic-modu
...
sp/angular
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d512d3cedc | ||
|
|
71772451e9 |
@@ -6,7 +6,7 @@ import { Config } from '../../providers/config';
|
||||
import { NavController } from '../../providers/nav-controller';
|
||||
import { ProxyCmp } from '../../utils/proxy';
|
||||
|
||||
import { IonRouterOutlet } from './router-outlet';
|
||||
import { IonRouterOutletBase } from './router-outlet';
|
||||
|
||||
const BACK_BUTTON_INPUTS = ['color', 'defaultHref', 'disabled', 'icon', 'mode', 'routerAnimation', 'text', 'type'];
|
||||
|
||||
@@ -31,7 +31,7 @@ export class IonBackButton {
|
||||
protected el: HTMLElement;
|
||||
|
||||
constructor(
|
||||
@Optional() private routerOutlet: IonRouterOutlet,
|
||||
@Optional() private routerOutlet: IonRouterOutletBase,
|
||||
private navCtrl: NavController,
|
||||
private config: Config,
|
||||
private r: ElementRef,
|
||||
|
||||
@@ -42,7 +42,7 @@ import { RouteView, StackDidChangeEvent, StackWillChangeEvent, getUrl, isTabSwit
|
||||
inputs: ['animated', 'animation', 'mode', 'swipeGesture'],
|
||||
})
|
||||
// eslint-disable-next-line @angular-eslint/directive-class-suffix
|
||||
export class IonRouterOutlet implements OnDestroy, OnInit {
|
||||
export class IonRouterOutletBase implements OnDestroy, OnInit {
|
||||
nativeEl: HTMLIonRouterOutletElement;
|
||||
activatedView: RouteView | null = null;
|
||||
tabsPrefix: string | undefined;
|
||||
@@ -116,7 +116,7 @@ export class IonRouterOutlet implements OnDestroy, OnInit {
|
||||
router: Router,
|
||||
zone: NgZone,
|
||||
activatedRoute: ActivatedRoute,
|
||||
@SkipSelf() @Optional() readonly parentOutlet?: IonRouterOutlet
|
||||
@SkipSelf() @Optional() readonly parentOutlet?: IonRouterOutletBase
|
||||
) {
|
||||
this.nativeEl = elementRef.nativeElement;
|
||||
this.name = name || PRIMARY_OUTLET;
|
||||
@@ -463,19 +463,19 @@ const INPUT_BINDER = new InjectionToken<RoutedComponentInputBinder>('');
|
||||
*/
|
||||
@Injectable()
|
||||
class RoutedComponentInputBinder {
|
||||
private outletDataSubscriptions = new Map<IonRouterOutlet, Subscription>();
|
||||
private outletDataSubscriptions = new Map<IonRouterOutletBase, Subscription>();
|
||||
|
||||
bindActivatedRouteToOutletComponent(outlet: IonRouterOutlet): void {
|
||||
bindActivatedRouteToOutletComponent(outlet: IonRouterOutletBase): void {
|
||||
this.unsubscribeFromRouteData(outlet);
|
||||
this.subscribeToRouteData(outlet);
|
||||
}
|
||||
|
||||
unsubscribeFromRouteData(outlet: IonRouterOutlet): void {
|
||||
unsubscribeFromRouteData(outlet: IonRouterOutletBase): void {
|
||||
this.outletDataSubscriptions.get(outlet)?.unsubscribe();
|
||||
this.outletDataSubscriptions.delete(outlet);
|
||||
}
|
||||
|
||||
private subscribeToRouteData(outlet: IonRouterOutlet) {
|
||||
private subscribeToRouteData(outlet: IonRouterOutletBase) {
|
||||
const { activatedRoute } = outlet;
|
||||
const dataSubscription = combineLatest([activatedRoute.queryParams, activatedRoute.params, activatedRoute.data])
|
||||
.pipe(
|
||||
|
||||
@@ -15,7 +15,7 @@ export { NavParams } from './directives/navigation/nav-params';
|
||||
export { IonPopover } from './overlays/popover';
|
||||
export { IonModal } from './overlays/modal';
|
||||
|
||||
export { IonRouterOutlet, provideComponentInputBinding } from './directives/navigation/router-outlet';
|
||||
export { IonRouterOutletBase, provideComponentInputBinding } from './directives/navigation/router-outlet';
|
||||
|
||||
export { IonBackButton } from './directives/navigation/back-button';
|
||||
export {
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Injectable, Optional } from '@angular/core';
|
||||
import { NavigationExtras, Router, UrlSerializer, UrlTree, NavigationStart } from '@angular/router';
|
||||
import type { AnimationBuilder, NavDirection, RouterDirection } from '@ionic/core/components';
|
||||
|
||||
import { IonRouterOutlet } from '../directives/navigation/router-outlet';
|
||||
import { IonRouterOutletBase } from '../directives/navigation/router-outlet';
|
||||
|
||||
import { Platform } from './platform';
|
||||
|
||||
@@ -19,7 +19,7 @@ export interface NavigationOptions extends NavigationExtras, AnimationOptions {}
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class NavController {
|
||||
private topOutlet?: IonRouterOutlet;
|
||||
private topOutlet?: IonRouterOutletBase;
|
||||
private direction: 'forward' | 'back' | 'root' | 'auto' = DEFAULT_DIRECTION;
|
||||
private animated?: NavDirection = DEFAULT_ANIMATED;
|
||||
private animationBuilder?: AnimationBuilder;
|
||||
@@ -169,7 +169,7 @@ export class NavController {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
setTopOutlet(outlet: IonRouterOutlet): void {
|
||||
setTopOutlet(outlet: IonRouterOutletBase): void {
|
||||
this.topOutlet = outlet;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Location } from '@angular/common';
|
||||
import { Directive, Attribute, Optional, SkipSelf, ElementRef, NgZone } from '@angular/core';
|
||||
import { Router, ActivatedRoute } from '@angular/router';
|
||||
import { IonRouterOutlet as IonRouterOutletBase } from '@ionic/angular/common';
|
||||
import { IonRouterOutletBase } from '@ionic/angular/common';
|
||||
|
||||
@Directive({
|
||||
selector: 'ion-router-outlet',
|
||||
|
||||
@@ -1,28 +1,69 @@
|
||||
import { Component, Optional, ChangeDetectionStrategy, ElementRef, NgZone, ChangeDetectorRef } from '@angular/core';
|
||||
import { IonBackButton as IonBackButtonBase, NavController, Config, ProxyCmp } from '@ionic/angular/common';
|
||||
import {
|
||||
Component,
|
||||
Optional,
|
||||
ChangeDetectionStrategy,
|
||||
ElementRef,
|
||||
NgZone,
|
||||
ChangeDetectorRef,
|
||||
HostListener,
|
||||
Input,
|
||||
} from '@angular/core';
|
||||
import { NavController, Config, ProxyCmp } from '@ionic/angular/common';
|
||||
import type { AnimationBuilder } from '@ionic/core/components';
|
||||
import { defineCustomElement } from '@ionic/core/components/ion-back-button.js';
|
||||
|
||||
import { IonRouterOutlet } from './router-outlet';
|
||||
|
||||
const BACK_BUTTON_INPUTS = ['color', 'defaultHref', 'disabled', 'icon', 'mode', 'routerAnimation', 'text', 'type'];
|
||||
|
||||
@ProxyCmp({
|
||||
defineCustomElementFn: defineCustomElement,
|
||||
inputs: BACK_BUTTON_INPUTS,
|
||||
})
|
||||
@Component({
|
||||
selector: 'ion-back-button',
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
template: '<ng-content></ng-content>',
|
||||
// eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
|
||||
inputs: BACK_BUTTON_INPUTS,
|
||||
standalone: true,
|
||||
})
|
||||
// eslint-disable-next-line @angular-eslint/directive-class-suffix
|
||||
export class IonBackButton extends IonBackButtonBase {
|
||||
export class IonBackButton {
|
||||
@Input()
|
||||
defaultHref: string | undefined;
|
||||
|
||||
@Input()
|
||||
routerAnimation: AnimationBuilder | undefined;
|
||||
|
||||
protected el: HTMLElement;
|
||||
|
||||
constructor(
|
||||
@Optional() routerOutlet: IonRouterOutlet,
|
||||
navCtrl: NavController,
|
||||
config: Config,
|
||||
@Optional() private routerOutlet: IonRouterOutlet,
|
||||
private navCtrl: NavController,
|
||||
private config: Config,
|
||||
r: ElementRef,
|
||||
z: NgZone,
|
||||
protected z: NgZone,
|
||||
c: ChangeDetectorRef
|
||||
) {
|
||||
super(routerOutlet, navCtrl, config, r, z, c);
|
||||
c.detach();
|
||||
this.el = r.nativeElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
@HostListener('click', ['$event'])
|
||||
onClick(ev: Event): void {
|
||||
const defaultHref = this.defaultHref || this.config.get('backButtonDefaultHref');
|
||||
|
||||
if (this.routerOutlet?.canGoBack()) {
|
||||
this.navCtrl.setDirection('back', undefined, undefined, this.routerAnimation);
|
||||
this.routerOutlet.pop();
|
||||
ev.preventDefault();
|
||||
} else if (defaultHref != null) {
|
||||
this.navCtrl.navigateBack(defaultHref, { animation: this.routerAnimation });
|
||||
ev.preventDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Location } from '@angular/common';
|
||||
import { Directive, Attribute, Optional, SkipSelf, ElementRef, NgZone } from '@angular/core';
|
||||
import { Router, ActivatedRoute } from '@angular/router';
|
||||
import { IonRouterOutlet as IonRouterOutletBase, ProxyCmp } from '@ionic/angular/common';
|
||||
import { IonRouterOutletBase, ProxyCmp } from '@ionic/angular/common';
|
||||
import { defineCustomElement } from '@ionic/core/components/ion-router-outlet.js';
|
||||
|
||||
@ProxyCmp({
|
||||
|
||||
Reference in New Issue
Block a user