mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
refactor(angular): platform uses correct core instance
This commit is contained in:
@@ -1,7 +1,12 @@
|
||||
import { DOCUMENT } from '@angular/common';
|
||||
import { NgZone, Inject, Injectable } from '@angular/core';
|
||||
import { getPlatforms, isPlatform } from '@ionic/core/components';
|
||||
import type { BackButtonEventDetail, KeyboardEventDetail, Platforms } from '@ionic/core/components';
|
||||
import { NgZone, Inject } from '@angular/core';
|
||||
import type {
|
||||
getPlatforms as _getPlatforms,
|
||||
isPlatform as _isPlatform,
|
||||
BackButtonEventDetail,
|
||||
KeyboardEventDetail,
|
||||
Platforms,
|
||||
} from '@ionic/core/components';
|
||||
import { Subscription, Subject } from 'rxjs';
|
||||
|
||||
// TODO(FW-2827): types
|
||||
@@ -13,9 +18,6 @@ export interface BackButtonEmitter extends Subject<BackButtonEventDetail> {
|
||||
): Subscription;
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class Platform {
|
||||
private _readyPromise: Promise<string>;
|
||||
private win: any;
|
||||
@@ -59,7 +61,12 @@ export class Platform {
|
||||
*/
|
||||
resize = new Subject<void>();
|
||||
|
||||
constructor(@Inject(DOCUMENT) private doc: any, zone: NgZone) {
|
||||
constructor(
|
||||
@Inject(DOCUMENT) private doc: any,
|
||||
zone: NgZone,
|
||||
private isPlatform: typeof _isPlatform,
|
||||
private getPlatforms: typeof _getPlatforms
|
||||
) {
|
||||
zone.run(() => {
|
||||
this.win = doc.defaultView;
|
||||
this.backButton.subscribeWithPriority = function (priority, callback) {
|
||||
@@ -138,7 +145,7 @@ export class Platform {
|
||||
*
|
||||
*/
|
||||
is(platformName: Platforms): boolean {
|
||||
return isPlatform(this.win, platformName);
|
||||
return this.isPlatform(this.win, platformName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -161,7 +168,7 @@ export class Platform {
|
||||
* ```
|
||||
*/
|
||||
platforms(): string[] {
|
||||
return getPlatforms(this.win);
|
||||
return this.getPlatforms(this.win);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -32,7 +32,6 @@ export {
|
||||
DomController,
|
||||
NavController,
|
||||
Config,
|
||||
Platform,
|
||||
AngularDelegate,
|
||||
NavParams,
|
||||
IonicRouteStrategy,
|
||||
@@ -42,6 +41,7 @@ export {
|
||||
ViewDidLeave,
|
||||
} from '@ionic/angular/common';
|
||||
export { MenuController } from './providers/menu-controller';
|
||||
export { Platform } from './providers/platform';
|
||||
|
||||
// PACKAGE MODULE
|
||||
export { IonicModule } from './ionic-module';
|
||||
|
||||
12
packages/angular/src/providers/platform.ts
Normal file
12
packages/angular/src/providers/platform.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { DOCUMENT, Injectable, NgZone, Inject } from '@angular/core';
|
||||
import { Platform as PlatformBase } from '@ionic/angular/common';
|
||||
import { isPlatform, getPlatforms } from '@ionic/core';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class Platform extends PlatformBase {
|
||||
constructor(@Inject(DOCUMENT) protected doc: any, zone: NgZone) {
|
||||
super(doc, zone, isPlatform, getPlatforms);
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ export { IonRouterLink, IonRouterLinkWithHref } from './navigation/router-link-d
|
||||
export { IonTabs } from './navigation/tabs';
|
||||
export { provideIonicAngular } from './providers/ionic-angular';
|
||||
export { MenuController } from './providers/menu-controller';
|
||||
export { Platform } from './providers/platform';
|
||||
export {
|
||||
ActionSheetController,
|
||||
AlertController,
|
||||
@@ -19,7 +20,6 @@ export {
|
||||
DomController,
|
||||
NavController,
|
||||
Config,
|
||||
Platform,
|
||||
NavParams,
|
||||
IonicRouteStrategy,
|
||||
ViewWillEnter,
|
||||
|
||||
12
packages/angular/standalone/src/providers/platform.ts
Normal file
12
packages/angular/standalone/src/providers/platform.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { DOCUMENT, Injectable, NgZone, Inject } from '@angular/core';
|
||||
import { Platform as PlatformBase } from '@ionic/angular/common';
|
||||
import { isPlatform, getPlatforms } from '@ionic/core/components';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class Platform extends PlatformBase {
|
||||
constructor(@Inject(DOCUMENT) protected doc: any, zone: NgZone) {
|
||||
super(doc, zone, isPlatform, getPlatforms);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user