mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Add placeholder-color style property.
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user