import { App } from '../components/app/app' ; import { Config } from '../config/config' ; import { isString } from '../util/util' ; import { DeepLinker } from './deep-linker' ; import { NavOptions } from './nav-util' ; import { Overlay } from './overlay' ; export class OverlayProxy { overlay : Overlay ; _onWillDismiss : Function ; _onDidDismiss : Function ; constructor ( public _app , public _component , public _config , public _deepLinker ) { } getImplementation ( ) { throw new Error ( 'Child class must implement "getImplementation" method' ) ; } param { NavOptions } navOptions returns { Promise } present ( navOptions = { } ) { const isLazyLoaded = isString ( this . _component ) ; if ( isLazyLoaded ) { return this . _deepLinker . getComponentFromName ( this . _component ) . then ( ( loadedComponent ) => { this . _component = loadedComponent ; return this . createAndPresentOverlay ( navOptions ) ; } ) ; } else { return this . createAndPresentOverlay ( navOptions ) ; } } dismiss ( data ? , role ? , navOptions ? ) { if ( this . overlay ) { return this . overlay . dismiss ( data , role , navOptions ) ; } } /**
     * Called when the current viewController has be successfully dismissed
     */ onDidDismiss ( callback ) { this . _onDidDismiss = callback ; if ( this . overlay ) { this . overlay . onDidDismiss ( this . _onDidDismiss ) ; } } createAndPresentOverlay ( navOptions ) { this . overlay = this . getImplementation ( ) ; this . overlay . onWillDismiss ( this . _onWillDismiss ) ; this . overlay . onDidDismiss ( this . _onDidDismiss ) ; return this . overlay . present ( navOptions ) ; } /**
     * Called when the current viewController will be dismissed
     */ onWillDismiss ( callback ) { this . _onWillDismiss = callback ; if ( this . overlay ) { this . overlay . onWillDismiss ( this . _onWillDismiss ) ; } } }