import { CancelToken } from "@web-atoms/core/dist/core/types"; import type { ContentPage } from "./mobile-app/MobileApp"; import { PageCommands } from "@web-atoms/core/dist/core/Command"; export type Page = typeof ContentPage; export type PageWith = typeof ContentPage; export default class PageNavigator { public static openPage(page: Page, parameters?: T, clearHistory?: boolean): void; public static openPage( page: string | any, parameters: {[key: string]: any} = {}, clearHistory: boolean = true) { this.pushPageForResult(page, parameters, clearHistory).catch((e) => { if (!CancelToken.isCancelled(e)) { // tslint:disable-next-line: no-console console.error(e); } }); } public static pushPage(page: Page, parameters?: T, clearHistory?: boolean); public static pushPage( page: string | any, parameters: {[key: string]: any} = {}, clearHistory: boolean = false) { this.pushPageForResult(page, parameters, clearHistory).catch((e) => { if (!CancelToken.isCancelled(e)) { // tslint:disable-next-line: no-console console.error(e); } }); } public static pushPageForResult( page: PageWith, parameters?: T, clearHistory?: boolean): Promise; public static async pushPageForResult( page: string | any, parameters: {[key: string]: any} = {}, clearHistory: boolean = false): Promise { return null; } public static pushPageForResultOrCancel( page: PageWith, parameters?: T, clearHistory?: boolean): Promise { try { return this.pushPageForResult(page, parameters); } catch (e) { if (CancelToken.isCancelled(e)) { return; } console.error(e); return; } } } PageCommands.openPage = (c, p) => PageNavigator.openPage(c, p); PageCommands.pushPage = (c, p) => PageNavigator.pushPage(c, p); PageCommands.pushPageForResult = (c, p) => PageNavigator.pushPageForResult(c, p);