import { applyMixins } from '@nativescript-community/ui-material-core' ; import { ActionBar , Application , Page as INSPage , View } from '@nativescript/core' ; function getLayout ( id ) { const context = Application . android . context ; return context . getResources ( ) . getIdentifier ( id , 'layout' , context . getPackageName ( ) ) ; } function getId ( id ) { const context = Application . android . context ; return context . getResources ( ) . getIdentifier ( id , 'id' , context . getPackageName ( ) ) ; } export class Page extends INSPage { appBarLayout : com . google . android . material . appbar . AppBarLayout ; collapsingToolbarLayout : com . google . android . material . appbar . CollapsingToolbarLayout ; nativeViewProtected : androidx . coordinatorlayout . widget . CoordinatorLayout ; contentLayout : android . widget . LinearLayout ; createNativeView ( ) { const layout = android . view . LayoutInflater . from ( this . _context ) . inflate ( getLayout ( 'material_page' ) , null , false ) as androidx . coordinatorlayout . widget . CoordinatorLayout ; this . appBarLayout = layout . findViewById ( getId ( 'appbarLayout' ) ) as com . google . android . material . appbar . AppBarLayout ; this . collapsingToolbarLayout = layout . findViewById ( getId ( 'collapsingToolbarLayout' ) ) as com . google . android . material . appbar . CollapsingToolbarLayout ; this . contentLayout = layout . findViewById ( getId ( 'contentLayout' ) ) as android . widget . LinearLayout ; return layout ; } _addViewToNativeVisualTree ( child , atIndex ? ) { if ( this . nativeViewProtected && child . nativeViewProtected ) { if ( child instanceof ActionBar ) { const params = new com . google . android . material . appbar . AppBarLayout . LayoutParams ( - 1 , - 1 ) ; params . setScrollFlags ( 0 ) ; child . nativeViewProtected . setLayoutParams ( params ) ; this . appBarLayout . addView ( child . nativeViewProtected ) ; } else { this . contentLayout . addView ( child . nativeViewProtected ) ; } if ( child instanceof View ) { ( this as any ) . _updateNativeLayoutParams ( child ) ; } return true ; } return false ; } } let mixinInstalled = false ; export function overridePage ( ) { applyMixins ( INSPage , [ Page ] ) ; } export function install ( ) { if ( ! mixinInstalled ) { mixinInstalled = true ; overridePage ( ) ; } }