stylers fixed

This commit is contained in:
Vladimir Enchev
2015-03-10 10:10:23 +02:00
parent 4fcaabcfec
commit 2d984022ef
2 changed files with 60 additions and 10 deletions

View File

@@ -241,6 +241,11 @@ export class SegmentedBarStyler implements definition.stylers.Styler {
export class SearchBarStyler implements definition.stylers.Styler {
private static getBackgroundColorProperty(view: view.View): any {
var bar = <android.widget.SearchView>view.android;
return bar.getDrawingCacheBackgroundColor();
}
private static setBackgroundColorProperty(view: view.View, newValue: any) {
var bar = <android.widget.SearchView>view.android;
bar.setBackgroundColor(newValue);
@@ -253,6 +258,17 @@ export class SearchBarStyler implements definition.stylers.Styler {
SearchBarStyler._changeSearchViewPlateBackgroundColor(bar, nativeValue);
}
private static getColorProperty(view: view.View): any {
var bar = <android.widget.SearchView>view.android;
var textView = SearchBarStyler._getSearchViewTextView(bar);
if (textView) {
return textView.getCurrentTextColor();
}
return undefined;
}
private static setColorProperty(view: view.View, newValue: any) {
var bar = <android.widget.SearchView>view.android;
SearchBarStyler._changeSearchViewTextColor(bar, newValue);
@@ -266,23 +282,33 @@ export class SearchBarStyler implements definition.stylers.Styler {
public static registerHandlers() {
style.registerHandler(style.backgroundColorProperty, new stylersCommon.StylePropertyChangedHandler(
SearchBarStyler.setBackgroundColorProperty,
SearchBarStyler.resetBackgroundColorProperty), "SearchBar");
SearchBarStyler.resetBackgroundColorProperty,
SearchBarStyler.getBackgroundColorProperty), "SearchBar");
style.registerHandler(style.colorProperty, new stylersCommon.StylePropertyChangedHandler(
SearchBarStyler.setColorProperty,
SearchBarStyler.resetColorProperty), "SearchBar");
SearchBarStyler.resetColorProperty,
SearchBarStyler.getColorProperty), "SearchBar");
}
private static _getSearchViewTextView(bar: android.widget.SearchView): android.widget.TextView {
var id = bar.getContext().getResources().getIdentifier("android:id/search_src_text", null, null);
return <android.widget.TextView> bar.findViewById(id);
}
private static _changeSearchViewTextColor(bar: android.widget.SearchView, color: number) {
var id = bar.getContext().getResources().getIdentifier("android:id/search_src_text", null, null);
var textView = <android.widget.TextView> bar.findViewById(id);
textView.setTextColor(color);
var textView = SearchBarStyler._getSearchViewTextView(bar);
if (textView) {
textView.setTextColor(color);
}
}
private static _changeSearchViewPlateBackgroundColor(bar: android.widget.SearchView, color: number) {
var id = bar.getContext().getResources().getIdentifier("android:id/search_plate", null, null);
var textView = <android.view.View> bar.findViewById(id);
textView.setBackgroundColor(color);
if (textView) {
textView.setBackgroundColor(color);
}
}
}

View File

@@ -496,31 +496,55 @@ export class SearchBarStyler implements definition.stylers.Styler {
bar.barTintColor = newValue;
}
private static getBackgroundColorProperty(view: view.View): any {
var bar = <UISearchBar>view.ios;
return bar.barTintColor;
}
private static resetBackgroundColorProperty(view: view.View, nativeValue: any) {
var bar = <UISearchBar>view.ios;
bar.barTintColor = nativeValue;
}
private static getColorProperty(view: view.View): any {
var bar = <UISearchBar>view.ios;
var sf = <UITextField>bar.valueForKey("_searchField");
if (sf) {
return sf.textColor;
}
return undefined;
}
private static setColorProperty(view: view.View, newValue: any) {
var bar = <UISearchBar>view.ios;
(<UITextField>bar.valueForKey("_searchField")).textColor = newValue;
var sf = <UITextField>bar.valueForKey("_searchField");
if (sf) {
sf.textColor = newValue;
}
}
private static resetColorProperty(view: view.View, nativeValue: any) {
var bar = <UISearchBar>view.ios;
(<UITextField>bar.valueForKey("_searchField")).textColor = nativeValue;
var sf = <UITextField>bar.valueForKey("_searchField");
if (sf) {
sf.textColor = nativeValue;
}
}
public static registerHandlers() {
style.registerHandler(style.backgroundColorProperty, new stylersCommon.StylePropertyChangedHandler(
SearchBarStyler.setBackgroundColorProperty,
SearchBarStyler.resetBackgroundColorProperty), "SearchBar");
SearchBarStyler.resetBackgroundColorProperty,
SearchBarStyler.getBackgroundColorProperty), "SearchBar");
style.registerHandler(style.colorProperty, new stylersCommon.StylePropertyChangedHandler(
SearchBarStyler.setColorProperty,
SearchBarStyler.resetColorProperty), "SearchBar");
SearchBarStyler.resetColorProperty,
SearchBarStyler.getColorProperty), "SearchBar");
}
}