import { TabContentItem as TabContentItemDefinition } from '.' ; import { TabNavigationBase } from '../tab-navigation-base' ; import { GridLayout , Trace , View } from '@nativescript/core' ; import { TabContentItemBase , traceCategory } from './tab-content-item-common' ; export * from './tab-content-item-common' ; export class TabContentItem extends TabContentItemBase { public nativeViewProtected : org . nativescript . widgets . GridLayout ; public tabItemSpec : com . nativescript . material . core . TabItemSpec ; public index : number ; get _hasFragments ( ) : boolean { return true ; } public createNativeView ( ) { const layout = new org . nativescript . widgets . GridLayout ( this . _context ) ; layout . addRow ( new org . nativescript . widgets . ItemSpec ( 1 , org . nativescript . widgets . GridUnitType . star ) ) ; return layout ; } public initNativeView ( ) { super . initNativeView ( ) ; } public _addViewToNativeVisualTree ( child , atIndex ? ) { if ( this . nativeViewProtected && child . nativeViewProtected ) { GridLayout . setRow ( child , 0 ) ; } return super . _addViewToNativeVisualTree ( child , atIndex ) ; } public disposeNativeView ( ) { super . disposeNativeView ( ) ; ( this as TabContentItemDefinition ) . canBeLoaded = false ; } public _getChildFragmentManager ( ) { const tabView = this . parent as TabNavigationBase ; let tabFragment = null ; const fragmentManager = tabView . _getFragmentManager ( ) ; if ( typeof this . index === 'undefined' ) { Trace . write ( 'Current TabContentItem index is not set' , traceCategory , Trace . messageType . error ) ; } const fragments = fragmentManager . getFragments ( ) . toArray ( ) ; for ( let i = 0 ; i < fragments . length ; i ++ ) { if ( fragments [ i ] . index === this . index ) { tabFragment = fragments [ i ] ; break ; } } if ( ! tabFragment ) { return tabView . _getRootFragmentManager ( ) ; } return tabFragment . getChildFragmentManager ( ) ; } }