mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
stylers fixed
This commit is contained in:
@@ -241,6 +241,11 @@ export class SegmentedBarStyler implements definition.stylers.Styler {
|
|||||||
|
|
||||||
export class SearchBarStyler 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) {
|
private static setBackgroundColorProperty(view: view.View, newValue: any) {
|
||||||
var bar = <android.widget.SearchView>view.android;
|
var bar = <android.widget.SearchView>view.android;
|
||||||
bar.setBackgroundColor(newValue);
|
bar.setBackgroundColor(newValue);
|
||||||
@@ -253,6 +258,17 @@ export class SearchBarStyler implements definition.stylers.Styler {
|
|||||||
SearchBarStyler._changeSearchViewPlateBackgroundColor(bar, nativeValue);
|
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) {
|
private static setColorProperty(view: view.View, newValue: any) {
|
||||||
var bar = <android.widget.SearchView>view.android;
|
var bar = <android.widget.SearchView>view.android;
|
||||||
SearchBarStyler._changeSearchViewTextColor(bar, newValue);
|
SearchBarStyler._changeSearchViewTextColor(bar, newValue);
|
||||||
@@ -266,25 +282,35 @@ export class SearchBarStyler implements definition.stylers.Styler {
|
|||||||
public static registerHandlers() {
|
public static registerHandlers() {
|
||||||
style.registerHandler(style.backgroundColorProperty, new stylersCommon.StylePropertyChangedHandler(
|
style.registerHandler(style.backgroundColorProperty, new stylersCommon.StylePropertyChangedHandler(
|
||||||
SearchBarStyler.setBackgroundColorProperty,
|
SearchBarStyler.setBackgroundColorProperty,
|
||||||
SearchBarStyler.resetBackgroundColorProperty), "SearchBar");
|
SearchBarStyler.resetBackgroundColorProperty,
|
||||||
|
SearchBarStyler.getBackgroundColorProperty), "SearchBar");
|
||||||
|
|
||||||
style.registerHandler(style.colorProperty, new stylersCommon.StylePropertyChangedHandler(
|
style.registerHandler(style.colorProperty, new stylersCommon.StylePropertyChangedHandler(
|
||||||
SearchBarStyler.setColorProperty,
|
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) {
|
private static _changeSearchViewTextColor(bar: android.widget.SearchView, color: number) {
|
||||||
var id = bar.getContext().getResources().getIdentifier("android:id/search_src_text", null, null);
|
var textView = SearchBarStyler._getSearchViewTextView(bar);
|
||||||
var textView = <android.widget.TextView> bar.findViewById(id);
|
if (textView) {
|
||||||
textView.setTextColor(color);
|
textView.setTextColor(color);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static _changeSearchViewPlateBackgroundColor(bar: android.widget.SearchView, color: number) {
|
private static _changeSearchViewPlateBackgroundColor(bar: android.widget.SearchView, color: number) {
|
||||||
var id = bar.getContext().getResources().getIdentifier("android:id/search_plate", null, null);
|
var id = bar.getContext().getResources().getIdentifier("android:id/search_plate", null, null);
|
||||||
var textView = <android.view.View> bar.findViewById(id);
|
var textView = <android.view.View> bar.findViewById(id);
|
||||||
|
if (textView) {
|
||||||
textView.setBackgroundColor(color);
|
textView.setBackgroundColor(color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function _registerDefaultStylers() {
|
export function _registerDefaultStylers() {
|
||||||
style.registerNoStylingClass("Frame");
|
style.registerNoStylingClass("Frame");
|
||||||
|
|||||||
@@ -496,31 +496,55 @@ export class SearchBarStyler implements definition.stylers.Styler {
|
|||||||
bar.barTintColor = newValue;
|
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) {
|
private static resetBackgroundColorProperty(view: view.View, nativeValue: any) {
|
||||||
var bar = <UISearchBar>view.ios;
|
var bar = <UISearchBar>view.ios;
|
||||||
bar.barTintColor = nativeValue;
|
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) {
|
private static setColorProperty(view: view.View, newValue: any) {
|
||||||
var bar = <UISearchBar>view.ios;
|
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) {
|
private static resetColorProperty(view: view.View, nativeValue: any) {
|
||||||
var bar = <UISearchBar>view.ios;
|
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() {
|
public static registerHandlers() {
|
||||||
style.registerHandler(style.backgroundColorProperty, new stylersCommon.StylePropertyChangedHandler(
|
style.registerHandler(style.backgroundColorProperty, new stylersCommon.StylePropertyChangedHandler(
|
||||||
SearchBarStyler.setBackgroundColorProperty,
|
SearchBarStyler.setBackgroundColorProperty,
|
||||||
SearchBarStyler.resetBackgroundColorProperty), "SearchBar");
|
SearchBarStyler.resetBackgroundColorProperty,
|
||||||
|
SearchBarStyler.getBackgroundColorProperty), "SearchBar");
|
||||||
|
|
||||||
style.registerHandler(style.colorProperty, new stylersCommon.StylePropertyChangedHandler(
|
style.registerHandler(style.colorProperty, new stylersCommon.StylePropertyChangedHandler(
|
||||||
SearchBarStyler.setColorProperty,
|
SearchBarStyler.setColorProperty,
|
||||||
SearchBarStyler.resetColorProperty), "SearchBar");
|
SearchBarStyler.resetColorProperty,
|
||||||
|
SearchBarStyler.getColorProperty), "SearchBar");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user