11import { VerticalTextAlignment , verticalTextAlignmentProperty } from '@nativescript-community/text' ;
22import { dynamicElevationOffsetProperty , elevationProperty , getRippleColor , rippleColorAlphaProperty , rippleColorProperty , shapeProperty , themer } from '@nativescript-community/ui-material-core' ;
3- import { createStateListAnimator , getColorStateList , getHorizontalGravity , getLayout , getVerticalGravity , isPostLollipop } from '@nativescript-community/ui-material-core/android/utils' ;
3+ import { createStateListAnimator , getColorStateList , getHorizontalGravity , getVerticalGravity , inflateLayout , isPostLollipop } from '@nativescript-community/ui-material-core/android/utils' ;
44import {
55 Background ,
66 Color ,
77 CoreTypes ,
8- Font ,
98 ImageSource ,
109 Length ,
1110 Utils ,
@@ -18,10 +17,6 @@ import {
1817import { textAlignmentProperty , textTransformProperty } from '@nativescript/core/ui/text-base' ;
1918import { ButtonBase , imageSourceProperty , srcProperty } from './button-common' ;
2019
21- let LayoutInflater : typeof android . view . LayoutInflater ;
22-
23- const layoutIds = { } ;
24-
2520export class Button extends ButtonBase {
2621 nativeViewProtected : com . google . android . material . button . MaterialButton ;
2722 nativeTextViewProtected : com . google . android . material . button . MaterialButton ;
@@ -30,7 +25,7 @@ export class Button extends ButtonBase {
3025
3126 @profile
3227 public createNativeView ( ) {
33- let layoutId ;
28+ // let layoutId;
3429 const variant = this . variant ;
3530 // let layoutIdName = 'ns_material_button';
3631 let layoutStringId : string ;
@@ -52,16 +47,8 @@ export class Button extends ButtonBase {
5247 if ( this . src ) {
5348 layoutStringId += '_icon' ;
5449 }
55- layoutId = layoutIds [ layoutStringId ] ;
56- if ( ! layoutId ) {
57- layoutId = layoutIds [ layoutStringId ] = getLayout ( this . _context , layoutStringId ) ;
58- }
59- if ( ! LayoutInflater ) {
60- LayoutInflater = android . view . LayoutInflater ;
61- }
62- const view = LayoutInflater . from ( this . _context ) . inflate ( layoutId , null , false ) as com . google . android . material . button . MaterialButton ;
50+ const view = inflateLayout ( this . _context , layoutStringId ) as com . google . android . material . button . MaterialButton ;
6351 if ( this . src ) {
64- layoutStringId += '_icon' ;
6552 view . setIconGravity ( 0x2 ) ; //com.google.android.material.button.MaterialButton.ICON_GRAVITY_TEXT_START
6653 // view.setIconSize(Utils.layout.toDevicePixels(24));
6754 }
0 commit comments