From 01f9b65e2426a3d78c7be63545320b56b75d50ec Mon Sep 17 00:00:00 2001 From: Vladimir Enchev Date: Mon, 2 Nov 2015 10:25:06 +0200 Subject: [PATCH] TextField CSS cursor color support added --- ui/styling/stylers.ios.ts | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/ui/styling/stylers.ios.ts b/ui/styling/stylers.ios.ts index c6a0e988d..0ded477d7 100644 --- a/ui/styling/stylers.ios.ts +++ b/ui/styling/stylers.ios.ts @@ -358,6 +358,7 @@ export class TextViewStyler implements definition.stylers.Styler { } else { textView.textColor = color; + textView.tintColor = color; } } @@ -379,6 +380,41 @@ export class TextViewStyler implements definition.stylers.Styler { } } +export class TextFieldStyler implements definition.stylers.Styler { + private static setColorProperty(view: view.View, newValue: any) { + var tf: UITextField = view._nativeView; + TextFieldStyler._setTextFieldColor(tf, newValue); + } + + private static resetColorProperty(view: view.View, nativeValue: any) { + var tf: UITextField = view._nativeView; + TextFieldStyler._setTextFieldColor(tf, nativeValue); + } + + private static _setTextFieldColor(tf: UITextField, newValue: any) { + var color: UIColor = newValue; + if ((tf).isShowingHint && color) { + tf.textColor = (color).colorWithAlphaComponent(0.22); + } + else { + tf.textColor = color; + tf.tintColor = color; + } + } + + private static getNativeColorValue(view: view.View): any { + var tf: UITextField = view._nativeView; + return tf.tintColor; + } + + public static registerHandlers() { + style.registerHandler(style.colorProperty, new stylersCommon.StylePropertyChangedHandler( + TextFieldStyler.setColorProperty, + TextFieldStyler.resetColorProperty, + TextFieldStyler.getNativeColorValue), "TextField"); + } +} + export class SegmentedBarStyler implements definition.stylers.Styler { //Text color methods private static setColorProperty(view: view.View, newValue: any) { @@ -585,6 +621,7 @@ export class SearchBarStyler implements definition.stylers.Styler { var sf = (view)._textField; if (sf) { sf.textColor = newValue; + sf.tintColor = newValue; } } @@ -592,6 +629,7 @@ export class SearchBarStyler implements definition.stylers.Styler { var sf = (view)._textField; if (sf) { sf.textColor = nativeValue; + sf.tintColor = nativeValue; } } @@ -735,4 +773,5 @@ export function _registerDefaultStylers() { TabViewStyler.registerHandlers(); ProgressStyler.registerHandlers(); SwitchStyler.registerHandlers(); + TextFieldStyler.registerHandlers(); }