Skip to content

Commit

Permalink
fix(textview): android font no applied to both floating and inner tex…
Browse files Browse the repository at this point in the history
…tfield
  • Loading branch information
farfromrefug committed Dec 13, 2020
1 parent 4ec6140 commit 9fb4860
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/textview/textview.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@ import {
helperColorProperty,
helperProperty,
strokeColorProperty,
strokeDisabledColorProperty,
strokeInactiveColorProperty
} from '@nativescript-community/ui-material-core/textbase/cssproperties';
import {
Background,
Color,
Font,
Length,
Utils,
backgroundInternalProperty,
borderBottomLeftRadiusProperty,
fontInternalProperty,
hintProperty,
paddingBottomProperty,
paddingLeftProperty,
Expand Down Expand Up @@ -210,6 +213,15 @@ export class TextView extends TextViewBase {
}
}

[strokeDisabledColorProperty.setNative](value: Color) {
const color = value instanceof Color ? value.android : value;
if (this.layoutView.setBoxStrokeColorStateList) {
const activeColor = this.strokeColor instanceof Color ? this.strokeColor.android : this.layoutView.getBoxStrokeColor();
const colorStateList = getFullColorStateList(activeColor, color);
this.layoutView.setBoxStrokeColorStateList(colorStateList);
}
}

[strokeColorProperty.setNative](value: Color) {
const color = value instanceof Color ? value.android : value;
if (this.layoutView.setBoxStrokeColorStateList) {
Expand All @@ -235,6 +247,9 @@ export class TextView extends TextViewBase {
this.layoutView.setBoxBackgroundColor(value.color.android);
}
}
if (value.borderTopColor) {
this.nativeViewProtected.setBoxStrokeColor(value.borderTopColor.android);
}
break;
case 'outline':
case 'underline': {
Expand All @@ -249,13 +264,19 @@ export class TextView extends TextViewBase {
}
}
if (value.borderTopColor) {
// TODO: for now no control over border color. it is an attr
// this.nativeViewProtected.setStrokeColor(value.borderTopColor.android);
this.nativeViewProtected.setBoxStrokeColor(value.borderTopColor.android);
}
break;
}
}
}

[fontInternalProperty.setNative](value: Font | UIFont) {
if (!this.formattedText || !(value instanceof Font)) {
this.nativeViewProtected.setTypeface(value instanceof Font ? value.getAndroidTypeface() : value);
this.nativeTextViewProtected.setTypeface(value instanceof Font ? value.getAndroidTypeface() : value);
}
}
[paddingTopProperty.setNative](value: Length) {
org.nativescript.widgets.ViewHelper.setPaddingTop(this.nativeViewProtected, Length.toDevicePixels(value, 0) + Length.toDevicePixels(this.style.borderTopWidth, 0));
}
Expand Down

0 comments on commit 9fb4860

Please sign in to comment.