@@ -5,6 +5,7 @@ import * as typesModule from "utils/types";
55import style = require( "ui/styling/style" ) ;
66import view = require( "ui/core/view" ) ;
77import font = require( "ui/styling/font" ) ;
8+ import { Color } from "color" ;
89
910var types : typeof typesModule ;
1011function ensureTypes ( ) {
@@ -21,27 +22,22 @@ function onTextPropertyChanged(data: dependencyObservable.PropertyChangeData) {
2122( < proxy . PropertyMetadata > common . SearchBar . textProperty . metadata ) . onSetNativeValue = onTextPropertyChanged ;
2223
2324function onTextFieldBackgroundColorPropertyChanged ( data : dependencyObservable . PropertyChangeData ) {
24- var bar = < SearchBar > data . object ;
25- var color = require ( "color" ) ;
26- if ( data . newValue instanceof color . Color ) {
27- var tf = ( < any > bar ) . _textField ;
28- if ( tf ) {
29- tf . backgroundColor = data . newValue . ios ;
25+ if ( data . newValue instanceof Color ) {
26+ let bar = < SearchBar > data . object ;
27+ if ( bar . _textField ) {
28+ bar . _textField . backgroundColor = data . newValue . ios ;
3029 }
3130 }
3231}
3332
3433( < proxy . PropertyMetadata > common . SearchBar . textFieldBackgroundColorProperty . metadata ) . onSetNativeValue = onTextFieldBackgroundColorPropertyChanged ;
3534
3635function onTextFieldHintColorPropertyChanged ( data : dependencyObservable . PropertyChangeData ) {
37- // This should be in a Try Catch in case Apple eliminates which ever method in the future;
38- try {
39- // TODO; convert this code into NativeScript Code
40- /* if ([textField respondsToSelector:@selector(setAttributedPlaceholder:)]) {
41- textField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:textField.placeholder attributes:@{NSForegroundColorAttributeName: [UIColor whiteColor]}];
42- } */
43- } catch ( Err ) {
44- // Do Nothing
36+ if ( data . newValue instanceof Color ) {
37+ let bar = < SearchBar > data . object ;
38+ if ( bar . _placeholderLabel ) {
39+ bar . _placeholderLabel . textColor = data . newValue . ios ;
40+ }
4541 }
4642}
4743
@@ -115,6 +111,7 @@ export class SearchBar extends common.SearchBar {
115111 private _ios : UISearchBar ;
116112 private _delegate ;
117113 private __textField : UITextField ;
114+ private __placeholderLabel : UILabel ;
118115
119116 constructor ( ) {
120117 super ( ) ;
@@ -149,6 +146,16 @@ export class SearchBar extends common.SearchBar {
149146
150147 return this . __textField ;
151148 }
149+
150+ get _placeholderLabel ( ) : UILabel {
151+ if ( ! this . __placeholderLabel ) {
152+ if ( this . _textField ) {
153+ this . __placeholderLabel = this . _textField . valueForKey ( "placeholderLabel" ) ;
154+ }
155+ }
156+
157+ return this . __placeholderLabel ;
158+ }
152159}
153160
154161export class SearchBarStyler implements style . Styler {
0 commit comments