import { View as ViewDefinition , Point , Size , ShownModallyData } from '.' ; import { booleanConverter , ShowModalOptions , ViewBase } from '../view-base' ; import { getEventOrGestureName } from '../bindable' ; import { layout } from '../../../utils' ; import { Color } from '../../../color' ; import { Property , InheritedProperty } from '../properties' ; import { EventData } from '../../../data/observable' ; import { Trace } from '../../../trace' ; import { CoreTypes } from '../../../core-types' ; import { ViewHelper } from './view-helper' ; import { PercentLength } from '../../styling/style-properties' ; import { observe as gestureObserve , GesturesObserver , GestureTypes , GestureEventData , fromString as gestureFromString } from '../../gestures' ; import { CSSUtils } from '../../../css/system-classes' ; import { Builder } from '../../builder' ; import { sanitizeModuleName } from '../../builder/module-name-sanitizer' ; import { StyleScope } from '../../styling/style-scope' ; import { LinearGradient } from '../../styling/linear-gradient' ; import * as am from '../../animation' ; import { AccessibilityEventOptions , AccessibilityLiveRegion , AccessibilityRole , AccessibilityState , AccessibilityTrait } from '../../../accessibility/accessibility-types' ; import { accessibilityHintProperty , accessibilityIdentifierProperty , accessibilityLabelProperty , accessibilityValueProperty , accessibilityIgnoresInvertColorsProperty } from '../../../accessibility/accessibility-properties' ; import { accessibilityBlurEvent , accessibilityFocusChangedEvent , accessibilityFocusEvent , accessibilityPerformEscapeEvent , getCurrentFontScale } from '../../../accessibility' ; import { CSSShadow } from '../../styling/css-shadow' ; export * from './view-helper' ; let animationModule ; function ensureAnimationModule ( ) { if ( ! animationModule ) { animationModule = require ( '../../animation' ) ; } } export function CSSType ( type ) { return ( cls ) => { cls . prototype . cssType = type ; } ; } export function viewMatchesModuleContext ( view , context , types ) { return context && view . _moduleName && context . type && types . some ( ( type ) => type === context . type ) && context . path && context . path . includes ( view . _moduleName ) ; } export function PseudoClassHandler ( ... pseudoClasses ) { const stateEventNames = pseudoClasses . map ( ( s ) => ':' + s ) ; const listeners = Symbol ( 'listeners' ) ; return < T > ( target , propertyKey , descriptor ) => { function update ( change ) { const prev = this [ listeners ] || 0 ; const next = prev + change ; if ( prev <= 0 && next > 0 ) { this [ propertyKey ] ( true ) ; } else if ( prev > 0 && next <= 0 ) { this [ propertyKey ] ( false ) ; } } stateEventNames . forEach ( ( s ) => ( target [ s ] = update ) ) ; } ; } export const _rootModalViews = new Array < ViewBase > ( ) ; export abstract class ViewCommon extends ViewBase implements ViewDefinition { public static layoutChangedEvent = 'layoutChanged' ; public static shownModallyEvent = 'shownModally' ; public static showingModallyEvent = 'showingModally' ; public static accessibilityBlurEvent = accessibilityBlurEvent ; public static accessibilityFocusEvent = accessibilityFocusEvent ; public static accessibilityFocusChangedEvent = accessibilityFocusChangedEvent ; public static accessibilityPerformEscapeEvent = accessibilityPerformEscapeEvent ; public accessibilityIdentifier : string ; public accessibilityLabel : string ; public accessibilityValue : string ; public accessibilityHint : string ; protected _closeModalCallback : Function ; public _manager : any ; public _modalParent : ViewCommon ; private _modalContext : any ; private _modal : ViewCommon ; private _measuredWidth : number ; private _measuredHeight : number ; protected _isLayoutValid : boolean ; private _cssType : string ; private _localAnimations : Set < am . Animation > ; _currentWidthMeasureSpec : number ; _currentHeightMeasureSpec : number ; _setMinWidthNative : ( value : CoreTypes . LengthType ) => void ; _setMinHeightNative : ( value : CoreTypes . LengthType ) => void ; public _gestureObservers = { } ; _androidContentDescriptionUpdated ? : boolean ; get css ( ) : string { const scope = this . _styleScope ; return scope && scope . css ; } set css ( value ) { this . _updateStyleScope ( undefined , undefined , value ) ; } public addCss ( cssString ) { this . _updateStyleScope ( undefined , cssString ) ; } public addCssFile ( cssFileName ) { this . _updateStyleScope ( cssFileName ) ; } public changeCssFile ( cssFileName ) { const scope = this . _styleScope ; if ( scope && cssFileName ) { scope . changeCssFile ( cssFileName ) ; this . _onCssStateChange ( ) ; } } public _updateStyleScope ( cssFileName ? , cssString ? , css ? ) { let scope = this . _styleScope ; if ( ! scope ) { scope = new StyleScope ( ) ; this . setScopeProperty ( scope , cssFileName , cssString , css ) ; this . _inheritStyleScope ( scope ) ; this . _isStyleScopeHost = true ; } else { this . setScopeProperty ( scope , cssFileName , cssString , css ) ; this . _onCssStateChange ( ) ; } } private setScopeProperty ( scope , cssFileName ? , cssString ? , css ? ) { if ( cssFileName !== undefined ) { scope . addCssFile ( cssFileName ) ; } else if ( cssString !== undefined ) { scope . addCss ( cssString ) ; } else if ( css !== undefined ) { scope . css = css ; } } public _closeAllModalViewsInternal ( ) { if ( _rootModalViews && _rootModalViews . length > 0 ) { _rootModalViews . forEach ( ( v ) => { v . closeModal ( ) ; } ) ; return true ; } return false ; } public _getRootModalViews ( ) { return _rootModalViews ; } public _onLivesync ( context ? ) { if ( Trace . isEnabled ( ) ) { Trace . write ( `${ this }._onLivesync(${ JSON . stringify ( context ) })` , Trace . categories . Livesync ) ; } if ( this . _closeAllModalViewsInternal ( ) ) { return true ; } if ( this . _handleLivesync ( context ) ) { return true ; } let handled = false ; this . eachChildView ( ( child ) => { if ( child . _onLivesync ( context ) ) { handled = true ; return false ; } } ) ; return handled ; } public _handleLivesync ( context ? ) { if ( Trace . isEnabled ( ) ) { Trace . write ( `${ this }._handleLivesync(${ JSON . stringify ( context ) })` , Trace . categories . Livesync ) ; } if ( viewMatchesModuleContext ( this , context , [ 'style' ] ) ) { if ( Trace . isEnabled ( ) ) { Trace . write ( `Change Handled: Changing CSS for ${ this }` , Trace . categories . Livesync ) ; } const cssModuleName = `${ sanitizeModuleName ( context . path ) }.css` ; this . changeCssFile ( cssModuleName ) ; return true ; } if ( viewMatchesModuleContext ( this , context , [ 'markup' , 'script' ] ) && this . page && this . page . frame ) { if ( Trace . isEnabled ( ) ) { Trace . write ( `Change Handled: Changing ${ context . type } for ${ this } inside ${ this . page }` , Trace . categories . Livesync ) ; } return this . page . frame . _handleLivesync ( { type : context . type , path : this . page . _moduleName , } ) ; } return false ; } _setupAsRootView ( context ) { super . _setupAsRootView ( context ) ; if ( ! this . _styleScope ) { this . _updateStyleScope ( ) ; } } _observe ( type , callback , thisArg ? ) { if ( ! this . _gestureObservers [ type ] ) { this . _gestureObservers [ type ] = [ ] ; } this . _gestureObservers [ type ] . push ( gestureObserve ( this , type , callback , thisArg ) ) ; } public getGestureObservers ( type ) { return this . _gestureObservers [ type ] ; } public addEventListener ( arg , callback , thisArg ? ) { if ( typeof arg === 'string' ) { arg = getEventOrGestureName ( arg ) ; const gesture = gestureFromString ( arg ) ; if ( gesture && ! this . _isEvent ( arg ) ) { this . _observe ( gesture , callback , thisArg ) ; } else { const events = arg . split ( ',' ) ; if ( events . length > 0 ) { for ( let i = 0 ; i < events . length ; i ++ ) { const evt = events [ i ] . trim ( ) ; const gst = gestureFromString ( evt ) ; if ( gst && ! this . _isEvent ( arg ) ) { this . _observe ( gst , callback , thisArg ) ; } else { super . addEventListener ( evt , callback , thisArg ) ; } } } else { super . addEventListener ( arg , callback , thisArg ) ; } } } else if ( typeof arg === 'number' ) { this . _observe ( < GestureTypes > arg , callback , thisArg ) ; } } public removeEventListener ( arg , callback ? , thisArg ? ) { if ( typeof arg === 'string' ) { const gesture = gestureFromString ( arg ) ; if ( gesture && ! this . _isEvent ( arg ) ) { this . _disconnectGestureObservers ( gesture ) ; } else { const events = arg . split ( ',' ) ; if ( events . length > 0 ) { for ( let i = 0 ; i < events . length ; i ++ ) { const evt = events [ i ] . trim ( ) ; const gst = gestureFromString ( evt ) ; if ( gst && ! this . _isEvent ( arg ) ) { this . _disconnectGestureObservers ( gst ) ; } else { super . removeEventListener ( evt , callback , thisArg ) ; } } } else { super . removeEventListener ( arg , callback , thisArg ) ; } } } else if ( typeof arg === 'number' ) { this . _disconnectGestureObservers ( < GestureTypes > arg ) ; } } public onBackPressed ( ) { return false ; } public _getFragmentManager ( ) { return undefined ; } private getModalOptions ( args ) { if ( args . length === 0 ) { throw new Error ( 'showModal without parameters is deprecated. Please call showModal on a view instance instead.' ) ; } else { let options = null ; if ( args . length === 2 ) { options = < ShowModalOptions > args [ 1 ] ; } else { if ( args [ 0 ] instanceof ViewCommon ) { console . log ( 'showModal(view: ViewBase, context: any, closeCallback: Function, fullscreen?: boolean, animated?: boolean, stretched?: boolean) ' + 'is deprecated. Use showModal(view: ViewBase, modalOptions: ShowModalOptions) instead.' ) ; } else { console . log ( 'showModal(moduleName: string, context: any, closeCallback: Function, fullscreen?: boolean, animated?: boolean, stretched?: boolean) ' + 'is deprecated. Use showModal(moduleName: string, modalOptions: ShowModalOptions) instead.' ) ; } options = { context : args [ 1 ] , closeCallback : args [ 2 ] , fullscreen : args [ 3 ] , animated : args [ 4 ] , stretched : args [ 5 ] , } ; } const firstArgument = args [ 0 ] ; const view = firstArgument instanceof ViewCommon ? firstArgument : < ViewCommon > Builder . createViewFromEntry ( { moduleName : firstArgument , } ) ; return { view , options } ; } } public showModal ( ... args ) { const { view , options } = this . getModalOptions ( args ) ; view . _showNativeModalView ( this , options ) ; return view ; } public closeModal ( ... args ) { const closeCallback = this . _closeModalCallback ; if ( closeCallback ) { closeCallback ( ... args ) ; } else { const parent = this . parent ; if ( parent ) { parent . closeModal ( ... args ) ; } } } public get modal ( ) : ViewCommon { return this . _modal ; } protected _showNativeModalView ( parent , options ) { _rootModalViews . push ( this ) ; this . cssClasses . add ( CSSUtils . MODAL_ROOT_VIEW_CSS_CLASS ) ; const modalRootViewCssClasses = CSSUtils . getSystemCssClasses ( ) ; modalRootViewCssClasses . forEach ( ( c ) => this . cssClasses . add ( c ) ) ; parent . _modal = this ; this . style . _fontScale = getCurrentFontScale ( ) ; this . _modalParent = parent ; this . _modalContext = options . context ; const that = this ; this . _closeModalCallback = function ( ... originalArgs ) { if ( that . _closeModalCallback ) { const modalIndex = _rootModalViews . indexOf ( that ) ; _rootModalViews . splice ( modalIndex ) ; that . _modalParent = null ; that . _modalContext = null ; that . _closeModalCallback = null ; that . _dialogClosed ( ) ; parent . _modal = null ; const whenClosedCallback = ( ) => { if ( typeof options . closeCallback === 'function' ) { options . closeCallback . apply ( undefined , originalArgs ) ; } } ; that . _hideNativeModalView ( parent , whenClosedCallback ) ; } } ; } protected abstract _hideNativeModalView ( parent , whenClosedCallback ) ; protected _raiseLayoutChangedEvent ( ) { const args = { eventName : ViewCommon . layoutChangedEvent , object : this , } ; this . notify ( args ) ; } protected _raiseShownModallyEvent ( ) { const args = { eventName : ViewCommon . shownModallyEvent , object : this , context : this . _modalContext , closeCallback : this . _closeModalCallback , } ; this . notify ( args ) ; } protected _raiseShowingModallyEvent ( ) { const args = { eventName : ViewCommon . showingModallyEvent , object : this , context : this . _modalContext , closeCallback : this . _closeModalCallback , } ; this . notify ( args ) ; } private _isEvent ( name ) { return this . constructor && `${ name }Event` in this . constructor ; } private _disconnectGestureObservers ( type ) { const observers = this . getGestureObservers ( type ) ; if ( observers ) { for ( let i = 0 ; i < observers . length ; i ++ ) { observers [ i ] . disconnect ( ) ; } } } get borderColor ( ) : string | Color { return this . style . borderColor ; } set borderColor ( value ) { this . style . borderColor = value ; } get borderTopColor ( ) : Color { return this . style . borderTopColor ; } set borderTopColor ( value ) { this . style . borderTopColor = value ; } get borderRightColor ( ) : Color { return this . style . borderRightColor ; } set borderRightColor ( value ) { this . style . borderRightColor = value ; } get borderBottomColor ( ) : Color { return this . style . borderBottomColor ; } set borderBottomColor ( value ) { this . style . borderBottomColor = value ; } get borderLeftColor ( ) : Color { return this . style . borderLeftColor ; } set borderLeftColor ( value ) { this . style . borderLeftColor = value ; } get borderWidth ( ) : string | CoreTypes . LengthType { return this . style . borderWidth ; } set borderWidth ( value ) { this . style . borderWidth = value ; } get borderTopWidth ( ) : CoreTypes . LengthType { return this . style . borderTopWidth ; } set borderTopWidth ( value ) { this . style . borderTopWidth = value ; } get borderRightWidth ( ) : CoreTypes . LengthType { return this . style . borderRightWidth ; } set borderRightWidth ( value ) { this . style . borderRightWidth = value ; } get borderBottomWidth ( ) : CoreTypes . LengthType { return this . style . borderBottomWidth ; } set borderBottomWidth ( value ) { this . style . borderBottomWidth = value ; } get borderLeftWidth ( ) : CoreTypes . LengthType { return this . style . borderLeftWidth ; } set borderLeftWidth ( value ) { this . style . borderLeftWidth = value ; } get borderRadius ( ) : string | CoreTypes . LengthType { return this . style . borderRadius ; } set borderRadius ( value ) { this . style . borderRadius = value ; } get borderTopLeftRadius ( ) : CoreTypes . LengthType { return this . style . borderTopLeftRadius ; } set borderTopLeftRadius ( value ) { this . style . borderTopLeftRadius = value ; } get borderTopRightRadius ( ) : CoreTypes . LengthType { return this . style . borderTopRightRadius ; } set borderTopRightRadius ( value ) { this . style . borderTopRightRadius = value ; } get borderBottomRightRadius ( ) : CoreTypes . LengthType { return this . style . borderBottomRightRadius ; } set borderBottomRightRadius ( value ) { this . style . borderBottomRightRadius = value ; } get borderBottomLeftRadius ( ) : CoreTypes . LengthType { return this . style . borderBottomLeftRadius ; } set borderBottomLeftRadius ( value ) { this . style . borderBottomLeftRadius = value ; } get color ( ) : Color { return this . style . color ; } set color ( value ) { this . style . color = value ; } get background ( ) : string { return this . style . background ; } set background ( value ) { this . style . background = value ; } get backgroundColor ( ) : Color { return this . style . backgroundColor ; } set backgroundColor ( value ) { this . style . backgroundColor = value ; } get backgroundImage ( ) : string | LinearGradient { return this . style . backgroundImage ; } set backgroundImage ( value ) { this . style . backgroundImage = value ; } get backgroundSize ( ) : string { return this . style . backgroundSize ; } set backgroundSize ( value ) { this . style . backgroundSize = value ; } get backgroundPosition ( ) : string { return this . style . backgroundPosition ; } set backgroundPosition ( value ) { this . style . backgroundPosition = value ; } get backgroundRepeat ( ) : CoreTypes . BackgroundRepeatType { return this . style . backgroundRepeat ; } set backgroundRepeat ( value ) { this . style . backgroundRepeat = value ; } get boxShadow ( ) : CSSShadow { return this . style . boxShadow ; } set boxShadow ( value ) { this . style . boxShadow = value ; } get minWidth ( ) : CoreTypes . LengthType { return this . style . minWidth ; } set minWidth ( value ) { this . style . minWidth = value ; } get minHeight ( ) : CoreTypes . LengthType { return this . style . minHeight ; } set minHeight ( value ) { this . style . minHeight = value ; } get width ( ) : CoreTypes . PercentLengthType { return this . style . width ; } set width ( value ) { this . style . width = value ; } get height ( ) : CoreTypes . PercentLengthType { return this . style . height ; } set height ( value ) { this . style . height = value ; } get margin ( ) : string | CoreTypes . PercentLengthType { return this . style . margin ; } set margin ( value ) { this . style . margin = value ; } get marginLeft ( ) : CoreTypes . PercentLengthType { return this . style . marginLeft ; } set marginLeft ( value ) { this . style . marginLeft = value ; } get marginTop ( ) : CoreTypes . PercentLengthType { return this . style . marginTop ; } set marginTop ( value ) { this . style . marginTop = value ; } get marginRight ( ) : CoreTypes . PercentLengthType { return this . style . marginRight ; } set marginRight ( value ) { this . style . marginRight = value ; } get marginBottom ( ) : CoreTypes . PercentLengthType { return this . style . marginBottom ; } set marginBottom ( value ) { this . style . marginBottom = value ; } get horizontalAlignment ( ) : CoreTypes . HorizontalAlignmentType { return this . style . horizontalAlignment ; } set horizontalAlignment ( value ) { this . style . horizontalAlignment = value ; } get verticalAlignment ( ) : CoreTypes . VerticalAlignmentType { return this . style . verticalAlignment ; } set verticalAlignment ( value ) { this . style . verticalAlignment = value ; } get visibility ( ) : CoreTypes . VisibilityType { return this . style . visibility ; } set visibility ( value ) { this . style . visibility = value ; } get opacity ( ) : number { return this . style . opacity ; } set opacity ( value ) { this . style . opacity = value ; } get rotate ( ) : number { return this . style . rotate ; } set rotate ( value ) { this . style . rotate = value ; } get rotateX ( ) : number { return this . style . rotateX ; } set rotateX ( value ) { this . style . rotateX = value ; } get rotateY ( ) : number { return this . style . rotateY ; } set rotateY ( value ) { this . style . rotateY = value ; } get perspective ( ) : number { return this . style . perspective ; } set perspective ( value ) { this . style . perspective = value ; } get textTransform ( ) : CoreTypes . TextTransformType { return this . style . textTransform ; } set textTransform ( value ) { this . style . textTransform = value ; } get translateX ( ) : CoreTypes . dip { return this . style . translateX ; } set translateX ( value ) { this . style . translateX = value ; } get translateY ( ) : CoreTypes . dip { return this . style . translateY ; } set translateY ( value ) { this . style . translateY = value ; } get scaleX ( ) : number { return this . style . scaleX ; } set scaleX ( value ) { this . style . scaleX = value ; } get scaleY ( ) : number { return this . style . scaleY ; } set scaleY ( value ) { this . style . scaleY = value ; } get accessible ( ) : boolean { return this . style . accessible ; } set accessible ( value ) { this . style . accessible = value ; } get accessibilityHidden ( ) : boolean { return this . style . accessibilityHidden ; } set accessibilityHidden ( value ) { this . style . accessibilityHidden = value ; } get accessibilityRole ( ) : AccessibilityRole { return this . style . accessibilityRole ; } set accessibilityRole ( value ) { this . style . accessibilityRole = value ; } get accessibilityState ( ) : AccessibilityState { return this . style . accessibilityState ; } set accessibilityState ( value ) { this . style . accessibilityState = value ; } get accessibilityLiveRegion ( ) : AccessibilityLiveRegion { return this . style . accessibilityLiveRegion ; } set accessibilityLiveRegion ( value ) { this . style . accessibilityLiveRegion = value ; } get accessibilityLanguage ( ) : string { return this . style . accessibilityLanguage ; } set accessibilityLanguage ( value ) { this . style . accessibilityLanguage = value ; } get accessibilityMediaSession ( ) : boolean { return this . style . accessibilityMediaSession ; } set accessibilityMediaSession ( value ) { this . style . accessibilityMediaSession = value ; } get automationText ( ) : string { return this . accessibilityIdentifier ; } set automationText ( value ) { this . accessibilityIdentifier = value ; } get androidElevation ( ) : number { return this . style . androidElevation ; } set androidElevation ( value ) { this . style . androidElevation = value ; } get androidDynamicElevationOffset ( ) : number { return this . style . androidDynamicElevationOffset ; } set androidDynamicElevationOffset ( value ) { this . style . androidDynamicElevationOffset = value ; } public originX : number ; public originY : number ; public isEnabled : boolean ; public isUserInteractionEnabled : boolean ; public iosOverflowSafeArea : boolean ; public iosOverflowSafeAreaEnabled : boolean ; public iosIgnoreSafeArea : boolean ; get isLayoutValid ( ) : boolean { return this . _isLayoutValid ; } get cssType ( ) : string { if ( ! this . _cssType ) { this . _cssType = this . typeName . toLowerCase ( ) ; } return this . _cssType ; } set cssType ( type ) { this . _cssType = type . toLowerCase ( ) ; } get isLayoutRequired ( ) : boolean { return true ; } public measure ( widthMeasureSpec , heightMeasureSpec ) { this . _setCurrentMeasureSpecs ( widthMeasureSpec , heightMeasureSpec ) ; } public layout ( left , top , right , bottom ) { this . _setCurrentLayoutBounds ( left , top , right , bottom ) ; } public getMeasuredWidth ( ) { return this . _measuredWidth & layout . MEASURED_SIZE_MASK || 0 ; } public getMeasuredHeight ( ) { return this . _measuredHeight & layout . MEASURED_SIZE_MASK || 0 ; } public getMeasuredState ( ) { return ( this . _measuredWidth & layout . MEASURED_STATE_MASK ) | ( ( this . _measuredHeight >> layout . MEASURED_HEIGHT_STATE_SHIFT ) & ( layout . MEASURED_STATE_MASK >> layout . MEASURED_HEIGHT_STATE_SHIFT ) ) ; } public setMeasuredDimension ( measuredWidth , measuredHeight ) { this . _measuredWidth = measuredWidth ; this . _measuredHeight = measuredHeight ; if ( Trace . isEnabled ( ) ) { Trace . write ( this + ' :setMeasuredDimension: ' + measuredWidth + ', ' + measuredHeight , Trace . categories . Layout ) ; } } public requestLayout ( ) { this . _isLayoutValid = false ; super . requestLayout ( ) ; } public abstract onMeasure ( widthMeasureSpec , heightMeasureSpec ) ; public abstract onLayout ( left , top , right , bottom ) ; public abstract layoutNativeView ( left , top , right , bottom ) ; public static resolveSizeAndState ( size , specSize , specMode , childMeasuredState ) { return ViewHelper . resolveSizeAndState ( size , specSize , specMode , childMeasuredState ) ; } public static combineMeasuredStates ( curState , newState ) { return ViewHelper . combineMeasuredStates ( curState , newState ) ; } public static layoutChild ( parent , child , left , top , right , bottom , setFrame = true ) { ViewHelper . layoutChild ( parent , child , left , top , right , bottom ) ; } public static measureChild ( parent , child , widthMeasureSpec , heightMeasureSpec ) { return ViewHelper . measureChild ( parent , child , widthMeasureSpec , heightMeasureSpec ) ; } _setCurrentMeasureSpecs ( widthMeasureSpec , heightMeasureSpec ) { const changed = this . _currentWidthMeasureSpec !== widthMeasureSpec || this . _currentHeightMeasureSpec !== heightMeasureSpec ; this . _currentWidthMeasureSpec = widthMeasureSpec ; this . _currentHeightMeasureSpec = heightMeasureSpec ; return changed ; } _getCurrentLayoutBounds ( ) { return { left : 0 , top : 0 , right : 0 , bottom : 0 } ; } /**
     * Returns two booleans - the first if "boundsChanged" the second is "sizeChanged".
     */ _setCurrentLayoutBounds ( left , top , right , bottom ) { this . _isLayoutValid = true ; const boundsChanged = this . _oldLeft !== left || this . _oldTop !== top || this . _oldRight !== right || this . _oldBottom !== bottom ; const sizeChanged = this . _oldRight - this . _oldLeft !== right - left || this . _oldBottom - this . _oldTop !== bottom - top ; this . _oldLeft = left ; this . _oldTop = top ; this . _oldRight = right ; this . _oldBottom = bottom ; return { boundsChanged , sizeChanged } ; } public eachChild ( callback ) { this . eachChildView ( < any > callback ) ; } public eachChildView ( callback ) { } _getNativeViewsCount ( ) { return this . _isAddedToNativeVisualTree ? 1 : 0 ; } _eachLayoutView ( callback ) { return callback ( this ) ; } public focus ( ) { return undefined ; } public getSafeAreaInsets ( ) { return { left : 0 , top : 0 , right : 0 , bottom : 0 } ; } public getLocationInWindow ( ) { return undefined ; } public getLocationOnScreen ( ) { return undefined ; } public getLocationRelativeTo ( otherView ) { return undefined ; } public getActualSize ( ) { const currentBounds = this . _getCurrentLayoutBounds ( ) ; if ( ! currentBounds ) { return undefined ; } return { width : layout . toDeviceIndependentPixels ( currentBounds . right - currentBounds . left ) , height : layout . toDeviceIndependentPixels ( currentBounds . bottom - currentBounds . top ) , } ; } public animate ( animation ) { return this . createAnimation ( animation ) . play ( ) ; } public createAnimation ( animation ) { ensureAnimationModule ( ) ; if ( ! this . _localAnimations ) { this . _localAnimations = new Set ( ) ; } animation . target = this ; const anim = new animationModule . Animation ( [ animation ] ) ; this . _localAnimations . add ( anim ) ; return anim ; } public _removeAnimation ( animation ) { const localAnimations = this . _localAnimations ; if ( localAnimations && localAnimations . has ( animation ) ) { localAnimations . delete ( animation ) ; if ( animation . isPlaying ) { animation . cancel ( ) ; } return true ; } return false ; } public resetNativeView ( ) { if ( this . _localAnimations ) { this . _localAnimations . forEach ( ( a ) => this . _removeAnimation ( a ) ) ; } super . resetNativeView ( ) ; } public _setNativeViewFrame ( nativeView , frame ) { } public _getValue ( ) { throw new Error ( 'The View._getValue is obsolete. There is a new property system.' ) ; } public _setValue ( ) { throw new Error ( 'The View._setValue is obsolete. There is a new property system.' ) ; } _updateEffectiveLayoutValues ( parentWidthMeasureSize , parentWidthMeasureMode , parentHeightMeasureSize , parentHeightMeasureMode ) { const style = this . style ; const availableWidth = parentWidthMeasureMode === layout . UNSPECIFIED ? - 1 : parentWidthMeasureSize ; this . effectiveWidth = PercentLength . toDevicePixels ( style . width , - 2 , availableWidth ) ; this . effectiveMarginLeft = PercentLength . toDevicePixels ( style . marginLeft , 0 , availableWidth ) ; this . effectiveMarginRight = PercentLength . toDevicePixels ( style . marginRight , 0 , availableWidth ) ; const availableHeight = parentHeightMeasureMode === layout . UNSPECIFIED ? - 1 : parentHeightMeasureSize ; this . effectiveHeight = PercentLength . toDevicePixels ( style . height , - 2 , availableHeight ) ; this . effectiveMarginTop = PercentLength . toDevicePixels ( style . marginTop , 0 , availableHeight ) ; this . effectiveMarginBottom = PercentLength . toDevicePixels ( style . marginBottom , 0 , availableHeight ) ; } public _setNativeClipToBounds ( ) { } public _redrawNativeBackground ( value ) { } _onAttachedToWindow ( ) { } _onDetachedFromWindow ( ) { } _hasAncestorView ( ancestorView ) { const matcher = ( view ) => view === ancestorView ; for ( let parent = this . parent ; parent != null ; parent = parent . parent ) { if ( matcher ( < ViewDefinition > parent ) ) { return true ; } } return false ; } public sendAccessibilityEvent ( options ) { return ; } public accessibilityAnnouncement ( msg ? ) { return ; } public accessibilityScreenChanged ( ) { return ; } } export const originXProperty = new Property < ViewCommon , number > ( { name : 'originX' , defaultValue : 0.5 , valueConverter : ( v ) => parseFloat ( v ) , } ) ; originXProperty . register ( ViewCommon ) ; export const originYProperty = new Property < ViewCommon , number > ( { name : 'originY' , defaultValue : 0.5 , valueConverter : ( v ) => parseFloat ( v ) , } ) ; originYProperty . register ( ViewCommon ) ; export const isEnabledProperty = new Property < ViewCommon , boolean > ( { name : 'isEnabled' , defaultValue : true , valueConverter : booleanConverter , valueChanged ( this , target , oldValue , newValue ) { target . _goToVisualState ( newValue ? 'normal' : 'disabled' ) ; } , } ) ; isEnabledProperty . register ( ViewCommon ) ; export const isUserInteractionEnabledProperty = new Property < ViewCommon , boolean > ( { name : 'isUserInteractionEnabled' , defaultValue : true , valueConverter : booleanConverter , } ) ; isUserInteractionEnabledProperty . register ( ViewCommon ) ; export const iosOverflowSafeAreaProperty = new Property < ViewCommon , boolean > ( { name : 'iosOverflowSafeArea' , defaultValue : false , valueConverter : booleanConverter , } ) ; iosOverflowSafeAreaProperty . register ( ViewCommon ) ; export const iosOverflowSafeAreaEnabledProperty = new InheritedProperty < ViewCommon , boolean > ( { name : 'iosOverflowSafeAreaEnabled' , defaultValue : true , valueConverter : booleanConverter , } ) ; iosOverflowSafeAreaEnabledProperty . register ( ViewCommon ) ; export const iosIgnoreSafeAreaProperty = new InheritedProperty ( { name : 'iosIgnoreSafeArea' , defaultValue : false , valueConverter : booleanConverter , } ) ; iosIgnoreSafeAreaProperty . register ( ViewCommon ) ; accessibilityIdentifierProperty . register ( ViewCommon ) ; accessibilityLabelProperty . register ( ViewCommon ) ; accessibilityValueProperty . register ( ViewCommon ) ; accessibilityHintProperty . register ( ViewCommon ) ; accessibilityIgnoresInvertColorsProperty . register ( ViewCommon ) ;