Add placeholder-color style property.

This commit is contained in:
Nedyalko Nikolov
2016-08-26 17:00:28 +03:00
parent 88d58c3d92
commit e9ceb79b2e
10 changed files with 83 additions and 0 deletions

View File

@@ -25,6 +25,10 @@ export function getNativeColor(textField: textFieldModule.TextField): colorModul
return new colorModule.Color(textField.android.getTextColors().getDefaultColor());
}
export function getNativePlaceholderColor(textField: textFieldModule.TextField): colorModule.Color {
return new colorModule.Color(textField.android.getHintTextColors().getDefaultColor());
}
export function getNativeBackgroundColor(textField: textFieldModule.TextField): colorModule.Color {
var bkg = <any>textField.android.getBackground();
if (bkg instanceof org.nativescript.widgets.BorderDrawable) {

View File

@@ -7,6 +7,7 @@ export declare function getNativeHint(textField: textFieldModule.TextField): str
export declare function getNativeSecure(textField: textFieldModule.TextField): boolean;
export declare function getNativeFontSize(textField: textFieldModule.TextField): number;
export declare function getNativeColor(textField: textFieldModule.TextField): colorModule.Color;
export declare function getNativePlaceholderColor(textField: textFieldModule.TextField): colorModule.Color;
export declare function getNativeBackgroundColor(textField: textFieldModule.TextField): colorModule.Color;
export declare function getNativeTextAlignment(textField: textFieldModule.TextField): string;
export declare function typeTextNatively(textField: textFieldModule.TextField, text: string): void;

View File

@@ -23,6 +23,10 @@ export function getNativeColor(textField: textFieldModule.TextField): colorModul
return utilsModule.ios.getColor(textField.ios.textColor);
}
export function getNativePlaceholderColor(textField: textFieldModule.TextField): colorModule.Color {
return utilsModule.ios.getColor(textField.ios.attributedPlaceholder.attributeAtIndexEffectiveRange(NSForegroundColorAttributeName, 0, null));
}
export function getNativeBackgroundColor(textField: textFieldModule.TextField): colorModule.Color {
return utilsModule.ios.getColor(textField.ios.backgroundColor);
}

View File

@@ -564,4 +564,15 @@ export function test_IntegrationTest_Transform_Decoration_Spacing_WithFormattedT
TKUnit.assertEqual(view.style.textDecoration, enums.TextDecoration.underline, "TextDecoration");
TKUnit.assertEqual(view.style.letterSpacing, 1, "LetterSpacing");
});
}
export function test_set_placeholder_color() {
let view = new textFieldModule.TextField();
let expectedColorHex = "#ffff0000";
helper.buildUIAndRunTest(view, function (views: Array<viewModule.View>) {
view.hint = "Some text for hint";
view.setInlineStyle("placeholder-color: " + expectedColorHex + ";");
let actualColorHex = textFieldTestsNative.getNativePlaceholderColor(view).hex;
TKUnit.assertEqual(actualColorHex, expectedColorHex);
});
}