mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
slider css color and background-color support fixed
This commit is contained in:
@@ -612,6 +612,44 @@ export class ProgressStyler implements definition.stylers.Styler {
|
||||
}
|
||||
}
|
||||
|
||||
export class SliderStyler implements definition.stylers.Styler {
|
||||
private static setColorProperty(view: view.View, newValue: any) {
|
||||
var bar = <android.widget.SeekBar>view._nativeView;
|
||||
bar.getThumb().setColorFilter(newValue, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||
}
|
||||
|
||||
private static resetColorProperty(view: view.View, nativeValue: number) {
|
||||
var bar = <android.widget.SeekBar>view._nativeView;
|
||||
bar.getThumb().clearColorFilter();
|
||||
}
|
||||
|
||||
private static setBackgroundAndBorderProperty(view: view.View, newValue: any) {
|
||||
var bar = <android.widget.SeekBar>view._nativeView;
|
||||
bar.getProgressDrawable().setColorFilter(newValue, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||
}
|
||||
|
||||
private static resetBackgroundAndBorderProperty(view: view.View, nativeValue: number) {
|
||||
var bar = <android.widget.SeekBar>view._nativeView;
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
public static registerHandlers() {
|
||||
style.registerHandler(style.colorProperty, new stylersCommon.StylePropertyChangedHandler(
|
||||
SliderStyler.setColorProperty,
|
||||
SliderStyler.resetColorProperty), "Slider");
|
||||
|
||||
var borderHandler = new stylersCommon.StylePropertyChangedHandler(
|
||||
SliderStyler.setBackgroundAndBorderProperty,
|
||||
SliderStyler.resetBackgroundAndBorderProperty);
|
||||
|
||||
style.registerHandler(style.backgroundColorProperty, borderHandler, "Slider");
|
||||
style.registerHandler(style.borderWidthProperty, borderHandler, "Slider");
|
||||
style.registerHandler(style.borderColorProperty, borderHandler, "Slider");
|
||||
style.registerHandler(style.borderRadiusProperty, borderHandler, "Slider");
|
||||
style.registerHandler(style.backgroundInternalProperty, borderHandler, "Slider");
|
||||
}
|
||||
}
|
||||
|
||||
export class SwitchStyler implements definition.stylers.Styler {
|
||||
private static setColorProperty(view: view.View, newValue: any) {
|
||||
var sw = <android.widget.Switch>view._nativeView;
|
||||
@@ -859,4 +897,5 @@ export function _registerDefaultStylers() {
|
||||
TabViewStyler.registerHandlers();
|
||||
ProgressStyler.registerHandlers();
|
||||
SwitchStyler.registerHandlers();
|
||||
SliderStyler.registerHandlers();
|
||||
}
|
||||
|
||||
@@ -500,7 +500,6 @@ export class SegmentedBarStyler implements definition.stylers.Styler {
|
||||
}
|
||||
|
||||
export class ActivityIndicatorStyler implements definition.stylers.Styler {
|
||||
//Text color methods
|
||||
private static setColorProperty(view: view.View, newValue: any) {
|
||||
var bar = <UIActivityIndicatorView>view.ios;
|
||||
bar.color = newValue;
|
||||
@@ -515,7 +514,6 @@ export class ActivityIndicatorStyler implements definition.stylers.Styler {
|
||||
var bar = <UIActivityIndicatorView>view.ios;
|
||||
return bar.color;
|
||||
}
|
||||
|
||||
public static registerHandlers() {
|
||||
style.registerHandler(style.colorProperty, new stylersCommon.StylePropertyChangedHandler(
|
||||
ActivityIndicatorStyler.setColorProperty,
|
||||
@@ -524,6 +522,51 @@ export class ActivityIndicatorStyler implements definition.stylers.Styler {
|
||||
}
|
||||
}
|
||||
|
||||
export class SliderStyler implements definition.stylers.Styler {
|
||||
private static setColorProperty(view: view.View, newValue: any) {
|
||||
var bar = <UISlider>view.ios;
|
||||
bar.thumbTintColor = newValue;
|
||||
}
|
||||
|
||||
private static resetColorProperty(view: view.View, nativeValue: any) {
|
||||
var bar = <UISlider>view.ios;
|
||||
bar.thumbTintColor = nativeValue;
|
||||
}
|
||||
|
||||
private static getNativeColorValue(view: view.View): any {
|
||||
var bar = <UISlider>view.ios;
|
||||
return bar.thumbTintColor;
|
||||
}
|
||||
|
||||
private static setBackgroundColorProperty(view: view.View, newValue: any) {
|
||||
var bar = <UISlider>view.ios;
|
||||
bar.minimumTrackTintColor = newValue;
|
||||
}
|
||||
|
||||
private static resetBackgroundColorProperty(view: view.View, nativeValue: any) {
|
||||
var bar = <UISlider>view.ios;
|
||||
bar.minimumTrackTintColor = nativeValue;
|
||||
}
|
||||
|
||||
private static getBackgroundColorProperty(view: view.View): any {
|
||||
var bar = <UISlider>view.ios;
|
||||
return bar.minimumTrackTintColor;
|
||||
}
|
||||
|
||||
public static registerHandlers() {
|
||||
SliderStyler.setColorProperty,
|
||||
SliderStyler.resetColorProperty,
|
||||
SliderStyler.getNativeColorValue), "Slider");
|
||||
|
||||
style.registerHandler(style.backgroundColorProperty, new stylersCommon.StylePropertyChangedHandler(
|
||||
SliderStyler.setBackgroundColorProperty,
|
||||
SliderStyler.resetBackgroundColorProperty,
|
||||
SliderStyler.getBackgroundColorProperty), "Slider");
|
||||
|
||||
style.registerHandler(style.backgroundInternalProperty, ignorePropertyHandler, "Slider");
|
||||
}
|
||||
}
|
||||
|
||||
export class ProgressStyler implements definition.stylers.Styler {
|
||||
//Text color methods
|
||||
private static setColorProperty(view: view.View, newValue: any) {
|
||||
@@ -800,4 +843,5 @@ export function _registerDefaultStylers() {
|
||||
SwitchStyler.registerHandlers();
|
||||
TextFieldStyler.registerHandlers();
|
||||
ActivityIndicatorStyler.registerHandlers();
|
||||
SliderStyler.registerHandlers();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user