Skip to content

Commit b7febed

Browse files
authored
Merge pull request #196 from cityinspain/master
helperColor property on TextField and TextView
2 parents dc15bdf + f5f65d4 commit b7febed

File tree

9 files changed

+33
-0
lines changed

9 files changed

+33
-0
lines changed

src/core/textbase/cssproperties.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ export const helperProperty = new CssProperty<Style, string>({
1212
cssName: 'helper'
1313
});
1414
helperProperty.register(Style);
15+
export const helperColorProperty = new CssProperty<Style, Color>({
16+
name: 'helperColor',
17+
cssName: 'helper-color',
18+
equalityComparer: Color.equals,
19+
valueConverter: v => new Color(v),
20+
});
21+
helperColorProperty.register(Style);
1522
export const errorProperty = new CssProperty<Style, string>({
1623
name: 'error',
1724
cssName: 'error'

src/textfield/textfield.android.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
floatingColorProperty,
77
floatingInactiveColorProperty,
88
floatingProperty,
9+
helperColorProperty,
910
helperProperty,
1011
maxLengthProperty,
1112
strokeColorProperty,
@@ -131,6 +132,10 @@ export class TextField extends TextFieldBase {
131132
this.floatingColor instanceof Color ? this.floatingColor.android : this.layoutView.getDefaultHintTextColor().getColorForState(stateSets.FOCUSED_STATE_SET, placeholderColor);
132133
this.layoutView.setDefaultHintTextColor(getColorStateList(floatingColor, placeholderColor));
133134
}
135+
[helperColorProperty.setNative](value) {
136+
const color = value instanceof Color ? value.android : value;
137+
this.layoutView.setHelperTextColor(android.content.res.ColorStateList.valueOf(color));
138+
}
134139

135140
public requestFocus() {
136141
if (this.layoutView) {

src/textfield/textfield.common.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export abstract class TextFieldBase extends NTextField {
1111
closeOnReturn: boolean;
1212

1313
@cssProperty helper: string;
14+
@cssProperty helperColor: Color;
1415
@cssProperty maxLength: number;
1516
@cssProperty errorColor: Color;
1617
@cssProperty floating: boolean;

src/textfield/textfield.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export class TextField extends NTextField {
1212
nativeViewProtected: any;
1313

1414
helper: string;
15+
helperColor: Color;
1516
maxLength: number;
1617
errorColor: Color;
1718
floating: boolean;

src/textfield/textfield.ios.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
floatingColorProperty,
88
floatingInactiveColorProperty,
99
floatingProperty,
10+
helperColorProperty,
1011
helperProperty,
1112
maxLengthProperty,
1213
strokeColorProperty,
@@ -315,6 +316,11 @@ export class TextField extends TextFieldBase {
315316
[helperProperty.setNative](value: string) {
316317
this._controller.helperText = value;
317318
}
319+
[helperColorProperty.setNative](value: string | Color) {
320+
const temp = typeof value === 'string' ? new Color(value) : value;
321+
const color: UIColor = temp.ios;
322+
this._controller.leadingUnderlineLabelTextColor = color;
323+
}
318324
[maxLengthProperty.setNative](value: number) {
319325
this._controller.characterCountMax = value;
320326
}

src/textview/textview.android.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
floatingColorProperty,
55
floatingInactiveColorProperty,
66
floatingProperty,
7+
helperColorProperty,
78
helperProperty,
89
maxLengthProperty,
910
strokeColorProperty,
@@ -104,6 +105,10 @@ export class TextView extends TextViewBase {
104105
this.layoutView.setHint(text);
105106
}
106107

108+
[helperColorProperty.setNative](value) {
109+
const color = value instanceof Color ? value.android : value;
110+
this.layoutView.setHelperTextColor(android.content.res.ColorStateList.valueOf(color));
111+
}
107112
[placeholderColorProperty.setNative](value: Color) {
108113
const placeholderColor = value instanceof Color ? value.android : value;
109114
const floatingColor = this.floatingColor instanceof Color ? this.floatingColor.android : placeholderColor;

src/textview/textview.common.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export abstract class TextViewBase extends NSTextView {
77
abstract clearFocus();
88

99
@cssProperty helper: string;
10+
@cssProperty helperColor: Color;
1011
@cssProperty maxLength: number;
1112
@cssProperty errorColor: Color;
1213
@cssProperty floating: boolean;

src/textview/textview.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export class TextView extends EditableTextBase {
1212
nativeViewProtected: any;
1313

1414
helper: string;
15+
helperColor: Color;
1516
maxLength: number;
1617
errorColor: Color;
1718
floating: boolean;

src/textview/textview.ios.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
floatingColorProperty,
77
floatingInactiveColorProperty,
88
floatingProperty,
9+
helperColorProperty,
910
helperProperty,
1011
maxLengthProperty,
1112
strokeColorProperty,
@@ -312,6 +313,11 @@ export class TextView extends TextViewBase {
312313
[helperProperty.setNative](value: string) {
313314
this._controller.helperText = value;
314315
}
316+
[helperColorProperty.setNative](value: string | Color) {
317+
const temp = typeof value === 'string' ? new Color(value) : value;
318+
const color: UIColor = temp.ios;
319+
this._controller.leadingUnderlineLabelTextColor = color;
320+
}
315321
[maxLengthProperty.setNative](value: number) {
316322
this._controller.characterCountMax = value;
317323
}

0 commit comments

Comments
 (0)