import { topmost } from 'tns-core-modules/ui/frame' ; import { Property , Style , CssProperty , Color , View } from 'tns-core-modules/ui/core/view' ; import { DimUtilsBase , Bounds , UIServiceBase } from "./lib.common" ; export * from "./lib.common" ; export class DimUtils extends DimUtilsBase { static onNextLayout ( view , callback ) { if ( view . isLayoutValid ) { setTimeout ( ( ) => callback ( ) ) ; } else { const old = view . onLayout ; view . onLayout = function ( ) { view . onLayout = old ; old . apply ( view , arguments ) ; const nativeView = view . ios ; try { setTimeout ( ( ) => callback ( ) ) ; } catch ( e ) { console . error ( e ) ; } } ; } } static onLayoutReady ( view , callback ) { const old = view . onLoaded ; if ( view . isLoaded ) { setTimeout ( ( ) => callback ( ) ) ; } else { view . onLoaded = ( ) => { old . call ( view ) ; const nativeView = view . ios ; try { setTimeout ( ( ) => callback ( ) ) ; } catch ( e ) { console . error ( e ) ; } } ; } } } export class UIService extends UIServiceBase { static addOnScreen ( view , origin ) { try { const frame = topmost ( ) ; let group = frame . ios . controller ; group . view . insertSubviewAtIndex ( view . nativeView , 0 ) ; } catch ( e ) { console . error ( e ) ; throw "failed to add on screen: " + e ; } } static removeOnScreen ( view ) { const frame = topmost ( ) ; let native = view . ios ; native . removeFromSuperview ( ) ; } }