@@ -12,11 +12,14 @@ import {
1212
1313export * from "./flexbox-layout-common" ;
1414
15+ let widgetFlexboxLayout : typeof org . nativescript . widgets . FlexboxLayout ;
16+ let widgetLayoutParams : typeof org . nativescript . widgets . FlexboxLayout . LayoutParams ;
17+
1518function makeNativeSetter < T > ( setter : ( lp : org . nativescript . widgets . FlexboxLayout . LayoutParams , value : T ) => void ) {
1619 return function ( this : View , value : T ) {
1720 const nativeView : android . view . View = this . nativeView ;
18- const lp = nativeView . getLayoutParams ( ) || new org . nativescript . widgets . FlexboxLayout . LayoutParams ( ) ;
19- if ( lp instanceof org . nativescript . widgets . FlexboxLayout . LayoutParams ) {
21+ const lp = nativeView . getLayoutParams ( ) || new widgetLayoutParams ( ) ;
22+ if ( lp instanceof widgetLayoutParams ) {
2023 setter ( lp , value ) ;
2124 nativeView . setLayoutParams ( lp ) ;
2225 }
@@ -80,7 +83,11 @@ export class FlexboxLayout extends FlexboxLayoutBase {
8083 nativeView : org . nativescript . widgets . FlexboxLayout ;
8184
8285 public createNativeView ( ) {
83- return new org . nativescript . widgets . FlexboxLayout ( this . _context ) ;
86+ if ( ! widgetFlexboxLayout ) {
87+ widgetFlexboxLayout = org . nativescript . widgets . FlexboxLayout ;
88+ widgetLayoutParams = widgetFlexboxLayout . LayoutParams ;
89+ }
90+ return new widgetFlexboxLayout ( this . _context ) ;
8491 }
8592
8693 public disposeNativeView ( ) {
@@ -127,29 +134,32 @@ export class FlexboxLayout extends FlexboxLayoutBase {
127134 super . _updateNativeLayoutParams ( child ) ;
128135
129136 const lp = < org . nativescript . widgets . FlexboxLayout . LayoutParams > child . nativeView . getLayoutParams ( ) ;
130- lp . order = child . order ;
131- lp . flexGrow = child . flexGrow ;
132- lp . flexShrink = child . flexShrink ;
133- lp . wrapBefore = child . flexWrapBefore ;
134- lp . alignSelf = alignSelfMap [ child . alignSelf ] ;
137+ const style = child . style ;
138+ lp . order = style . order ;
139+ lp . flexGrow = style . flexGrow ;
140+ lp . flexShrink = style . flexShrink ;
141+ lp . wrapBefore = style . flexWrapBefore ;
142+ lp . alignSelf = alignSelfMap [ style . alignSelf ] ;
135143 child . nativeView . setLayoutParams ( lp ) ;
136144 }
137145
138146 public _setChildMinWidthNative ( child : View ) : void {
139147 child . _setMinWidthNative ( 0 ) ;
140- const lp = child . nativeView . getLayoutParams ( ) ;
141- if ( lp instanceof org . nativescript . widgets . FlexboxLayout . LayoutParams ) {
142- lp . minWidth = Length . toDevicePixels ( child . minWidth , 0 ) ;
143- child . nativeView . setLayoutParams ( lp ) ;
148+ const nativeView = child . nativeView ;
149+ const lp = nativeView . getLayoutParams ( ) ;
150+ if ( lp instanceof widgetLayoutParams ) {
151+ lp . minWidth = Length . toDevicePixels ( child . style . minWidth , 0 ) ;
152+ nativeView . setLayoutParams ( lp ) ;
144153 }
145154 }
146155
147156 public _setChildMinHeightNative ( child : View ) : void {
148157 child . _setMinHeightNative ( 0 ) ;
149- const lp = child . nativeView . getLayoutParams ( ) ;
150- if ( lp instanceof org . nativescript . widgets . FlexboxLayout . LayoutParams ) {
151- lp . minHeight = Length . toDevicePixels ( child . minHeight , 0 ) ;
152- child . nativeView . setLayoutParams ( lp ) ;
158+ const nativeView = child . nativeView ;
159+ const lp = nativeView . getLayoutParams ( ) ;
160+ if ( lp instanceof widgetLayoutParams ) {
161+ lp . minHeight = Length . toDevicePixels ( child . style . minHeight , 0 ) ;
162+ nativeView . setLayoutParams ( lp ) ;
153163 }
154164 }
155165}
0 commit comments