Skip to content

Commit e722877

Browse files
authored
Merge pull request #2029 from NativeScript/mdonev/deprecated-api-fix
refactor: deprecated topmost() usage
2 parents 40878ff + b44df23 commit e722877

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

nativescript-angular/directives/dialogs.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { AppHostView } from "../app-host-view";
1717
import { DetachedLoader } from "../common/detached-loader";
1818
import { PageFactory, PAGE_FACTORY } from "../platform-providers";
1919
import { once } from "../common/utils";
20-
import { topmost, Frame } from "tns-core-modules/ui/frame";
20+
import { Frame } from "tns-core-modules/ui/frame";
2121
import { ShowModalOptions } from "tns-core-modules/ui/core/view";
2222

2323
export type BaseShowModalOptions = Pick<ShowModalOptions, Exclude<keyof ShowModalOptions, "closeCallback" | "context">>;
@@ -86,7 +86,7 @@ export class ModalDialogService {
8686

8787
let frame = parentView;
8888
if (!(parentView instanceof Frame)) {
89-
frame = (parentView.page && parentView.page.frame) || topmost();
89+
frame = (parentView.page && parentView.page.frame) || Frame.topmost();
9090
}
9191

9292
this.location._beginModalNavigation(frame);

nativescript-angular/platform-providers.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { InjectionToken, Injectable } from "@angular/core";
22

3-
import { topmost, Frame } from "tns-core-modules/ui/frame";
3+
import { Frame } from "tns-core-modules/ui/frame";
44
import { View } from "tns-core-modules/ui/core/view";
55
import { Page } from "tns-core-modules/ui/page";
66
import { device, Device } from "tns-core-modules/platform";
@@ -26,7 +26,7 @@ export function getDefaultPage(): Page {
2626
return rootPage;
2727
}
2828

29-
const frame = topmost();
29+
const frame = Frame.topmost();
3030
if (frame && frame.currentPage) {
3131
return frame.currentPage;
3232
}
@@ -38,7 +38,7 @@ export const defaultPageProvider = { provide: Page, useFactory: getDefaultPage }
3838

3939
// Use an exported function to make the AoT compiler happy.
4040
export function getDefaultFrame(): Frame {
41-
return topmost();
41+
return Frame.topmost();
4242
}
4343

4444
export const defaultFrameProvider = { provide: Frame, useFactory: getDefaultFrame };
@@ -67,7 +67,7 @@ export const defaultPageFactoryProvider = { provide: PAGE_FACTORY, useValue: def
6767
export class FrameService {
6868
// TODO: Add any methods that are needed to handle frame/page navigation
6969
getFrame(): Frame {
70-
let topmostFrame = topmost();
70+
let topmostFrame = Frame.topmost();
7171
return topmostFrame;
7272
}
7373
}

nativescript-angular/router/ns-location-strategy.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ export class NSLocationStrategy extends LocationStrategy {
411411
this._modalNavigationDepth--;
412412
}
413413

414-
// currentOutlet should be the one that corresponds to the topmost() frame
414+
// currentOutlet should be the one that corresponds to the topmost frame
415415
const topmostOutlet = this.getOutletByFrame(this.frameService.getFrame());
416416
const outlet = this.findOutletByModal(this._modalNavigationDepth, isShowingModal) || topmostOutlet;
417417

nativescript-angular/testing/src/util.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
import { View } from "tns-core-modules/ui/core/view";
3-
import { topmost } from "tns-core-modules/ui/frame";
3+
import { Frame } from "tns-core-modules/ui/frame";
44
import { LayoutBase } from "tns-core-modules/ui/layouts/layout-base";
55
import { ComponentFixture, TestBed } from "@angular/core/testing";
66
import { NgModule, Type } from "@angular/core";
@@ -17,7 +17,7 @@ const TESTING_ROOT_ID = "__testing_container";
1717
* Get a reference to the fixtures container.
1818
*/
1919
export function testingRootView(): LayoutBase {
20-
const rootPageLayout = topmost().currentPage.content as LayoutBase;
20+
const rootPageLayout = Frame.topmost().currentPage.content as LayoutBase;
2121

2222
let testingRoot: LayoutBase;
2323
rootPageLayout.eachChild(child => {

0 commit comments

Comments
 (0)