@@ -13,7 +13,9 @@ import {
1313 helperProperty ,
1414 strokeColorProperty ,
1515 strokeDisabledColorProperty ,
16- strokeInactiveColorProperty
16+ strokeInactiveColorProperty ,
17+ strokeWidthFocusedProperty ,
18+ strokeWidthProperty
1719} from '@nativescript-community/ui-material-core/textbase/cssproperties' ;
1820import {
1921 Background ,
@@ -24,6 +26,7 @@ import {
2426 Utils ,
2527 backgroundInternalProperty ,
2628 borderBottomLeftRadiusProperty ,
29+ editableProperty ,
2730 fontInternalProperty ,
2831 hintProperty ,
2932 paddingBottomProperty ,
@@ -36,6 +39,7 @@ import {
3639} from '@nativescript/core' ;
3740import { secureProperty } from '@nativescript/core/ui/text-field' ;
3841import { TextFieldBase } from './textfield.common' ;
42+ import { layout } from '@nativescript/core/utils' ;
3943
4044let LayoutInflater : typeof android . view . LayoutInflater ;
4145let FrameLayoutLayoutParams : typeof android . widget . FrameLayout . LayoutParams ;
@@ -109,7 +113,10 @@ export class TextField extends TextFieldBase {
109113 if ( needsTransparent ) {
110114 layoutView . setBoxBackgroundColor ( 0 ) ; // android.graphics.Color.TRANSPARENT
111115 editText . setBackground ( null ) ;
116+ layoutView . setHintEnabled ( false ) ;
112117 }
118+
119+ layoutView . setErrorIconDrawable ( null ) ;
113120 // layoutView.setFocusableInTouchMode(true); // to prevent focus on view creation
114121 return layoutView ;
115122 }
@@ -179,7 +186,9 @@ export class TextField extends TextFieldBase {
179186
180187 [ errorColorProperty . setNative ] ( value : Color ) {
181188 const color = value instanceof Color ? value . android : value ;
182- ( this . layoutView as any ) . setErrorTextColor ( android . content . res . ColorStateList . valueOf ( color ) ) ;
189+ const nColor = android . content . res . ColorStateList . valueOf ( color ) ;
190+ this . layoutView . setErrorTextColor ( nColor ) ;
191+ this . layoutView . setBoxStrokeErrorColor ( nColor ) ;
183192 }
184193
185194 [ helperProperty . setNative ] ( value : string ) {
@@ -215,6 +224,14 @@ export class TextField extends TextFieldBase {
215224 }
216225 }
217226
227+ [ strokeWidthProperty . setNative ] ( value : CoreTypes . LengthType ) {
228+ this . layoutView . setBoxStrokeWidth ( Length . toDevicePixels ( value , 0 ) ) ;
229+ }
230+
231+ [ strokeWidthFocusedProperty . setNative ] ( value : CoreTypes . LengthType ) {
232+ this . layoutView . setBoxStrokeWidthFocused ( Length . toDevicePixels ( value , 0 ) ) ;
233+ }
234+
218235 [ strokeColorProperty . setNative ] ( value : Color ) {
219236 const color = value instanceof Color ? value . android : value ;
220237 if ( this . layoutView . setBoxStrokeColorStateList ) {
@@ -293,16 +310,28 @@ export class TextField extends TextFieldBase {
293310 }
294311 }
295312 [ paddingTopProperty . setNative ] ( value : CoreTypes . LengthType ) {
296- org . nativescript . widgets . ViewHelper . setPaddingTop ( this . nativeViewProtected , Length . toDevicePixels ( value , 0 ) + Length . toDevicePixels ( this . style . borderTopWidth , 0 ) ) ;
313+ org . nativescript . widgets . ViewHelper . setPaddingTop (
314+ this . nativeTextViewProtected ,
315+ layout . toDeviceIndependentPixels ( Length . toDevicePixels ( value , 0 ) + Length . toDevicePixels ( this . style . borderTopWidth , 0 ) )
316+ ) ;
297317 }
298318 [ paddingRightProperty . setNative ] ( value : CoreTypes . LengthType ) {
299- org . nativescript . widgets . ViewHelper . setPaddingRight ( this . nativeViewProtected , Length . toDevicePixels ( value , 0 ) + Length . toDevicePixels ( this . style . borderRightWidth , 0 ) ) ;
319+ org . nativescript . widgets . ViewHelper . setPaddingRight (
320+ this . nativeTextViewProtected ,
321+ layout . toDeviceIndependentPixels ( Length . toDevicePixels ( value , 0 ) + Length . toDevicePixels ( this . style . borderRightWidth , 0 ) )
322+ ) ;
300323 }
301324 [ paddingBottomProperty . setNative ] ( value : CoreTypes . LengthType ) {
302- org . nativescript . widgets . ViewHelper . setPaddingBottom ( this . nativeViewProtected , Length . toDevicePixels ( value , 0 ) + Length . toDevicePixels ( this . style . borderBottomWidth , 0 ) ) ;
325+ org . nativescript . widgets . ViewHelper . setPaddingBottom (
326+ this . nativeTextViewProtected ,
327+ layout . toDeviceIndependentPixels ( Length . toDevicePixels ( value , 0 ) + Length . toDevicePixels ( this . style . borderBottomWidth , 0 ) )
328+ ) ;
303329 }
304330 [ paddingLeftProperty . setNative ] ( value : CoreTypes . LengthType ) {
305- org . nativescript . widgets . ViewHelper . setPaddingLeft ( this . nativeViewProtected , Length . toDevicePixels ( value , 0 ) + Length . toDevicePixels ( this . style . borderLeftWidth , 0 ) ) ;
331+ org . nativescript . widgets . ViewHelper . setPaddingLeft (
332+ this . nativeTextViewProtected ,
333+ layout . toDeviceIndependentPixels ( Length . toDevicePixels ( value , 0 ) + Length . toDevicePixels ( this . style . borderLeftWidth , 0 ) )
334+ ) ;
306335 }
307336 [ textAlignmentProperty . setNative ] ( value : CoreTypes . TextAlignmentType ) {
308337 this . nativeTextViewProtected . setGravity ( getHorizontalGravity ( value ) | getVerticalGravity ( this . verticalTextAlignment ) ) ;
@@ -311,5 +340,11 @@ export class TextField extends TextFieldBase {
311340 // TODO: not working for now
312341 this . nativeTextViewProtected . setGravity ( getHorizontalGravity ( this . textAlignment ) | getVerticalGravity ( value ) ) ;
313342 }
343+
344+ [ editableProperty . setNative ] ( value : boolean ) {
345+ super [ editableProperty . setNative ] ( value ) ;
346+ const nativeView = this . nativeTextViewProtected ;
347+ nativeView . setFocusable ( value ) ;
348+ }
314349}
315350//
0 commit comments