Fix setting text property to number. (#3449)

Fix setting JS property from native.
This commit is contained in:
Hristo Hristov
2017-01-09 18:13:31 +02:00
committed by GitHub
parent e3acdcbc78
commit 309ea148e1
23 changed files with 156 additions and 153 deletions

View File

@ -19,7 +19,7 @@ class QueryTextListener extends java.lang.Object implements android.widget.Searc
onQueryTextChange(newText: string): boolean {
let owner = this.owner.get();
if (owner) {
owner.nativePropertyChanged(textProperty, newText);
textProperty.nativeValueChange(owner, newText);
// This code is needed since sometimes OnCloseListener is not called!
if (newText === "" && this[SEARCHTEXT] !== newText) {
@ -163,13 +163,15 @@ export class SearchBar extends SearchBarBase {
return "";
}
set [textProperty.native](value: string) {
this._android.setQuery(value, false);
const text = (value === null || value === undefined) ? '' : value.toString();
this._android.setQuery(text, false);
}
get [hintProperty.native](): string {
return "";
}
set [hintProperty.native](value: string) {
this._android.setQueryHint(value);
const text = (value === null || value === undefined) ? '' : value.toString();
this._android.setQueryHint(text);
}
get [textFieldBackgroundColorProperty.native](): number {
let textView = this._getTextView();

View File

@ -22,7 +22,7 @@ class UISearchBarDelegateImpl extends NSObject implements UISearchBarDelegate {
return;
}
owner.nativePropertyChanged(textProperty, searchText);
textProperty.nativeValueChange(owner, searchText);
// This code is needed since sometimes searchBarCancelButtonClicked is not called!
if (searchText === "") {
@ -143,19 +143,23 @@ export class SearchBar extends SearchBarBase {
}
get [textProperty.native](): string {
return "";
return '';
}
set [textProperty.native](value: string) {
this._ios.text = value;
const text = (value === null || value === undefined) ? '' : value.toString();
this._ios.text = text;
}
get [hintProperty.native](): string {
return "";
return '';
}
set [hintProperty.native](value: string) {
this._ios.placeholder = value;
const text = (value === null || value === undefined) ? '' : value.toString();
this._ios.placeholder = text;
}
get [textFieldBackgroundColorProperty.native](): UIColor {
let textField = this._textField;
const textField = this._textField;
if (textField) {
return textField.backgroundColor;
}
@ -163,14 +167,15 @@ export class SearchBar extends SearchBarBase {
return null;
}
set [textFieldBackgroundColorProperty.native](value: Color | UIColor) {
let color = value instanceof Color ? value.ios : value
let textField = this._textField;
const color = value instanceof Color ? value.ios : value
const textField = this._textField;
if (textField) {
textField.backgroundColor = color;
}
}
get [textFieldHintColorProperty.native](): UIColor {
let placeholderLabel = this._placeholderLabel;
const placeholderLabel = this._placeholderLabel;
if (placeholderLabel) {
return placeholderLabel.textColor;
}
@ -178,8 +183,8 @@ export class SearchBar extends SearchBarBase {
return null;
}
set [textFieldHintColorProperty.native](value: Color | UIColor) {
let color = value instanceof Color ? value.ios : value
let placeholderLabel = this._placeholderLabel;
const color = value instanceof Color ? value.ios : value
const placeholderLabel = this._placeholderLabel;
if (placeholderLabel) {
placeholderLabel.textColor = color;
}