feat(switch): add property for off state background color (#7138)

This commit is contained in:
Martin Yankov
2019-04-15 18:26:49 +03:00
committed by GitHub
parent ed0d9df441
commit f0146f0e1b
5 changed files with 72 additions and 8 deletions

View File

@ -1,5 +1,5 @@
import {
SwitchBase, layout, Color, colorProperty, backgroundColorProperty, backgroundInternalProperty, checkedProperty
SwitchBase, layout, Color, colorProperty, backgroundColorProperty, backgroundInternalProperty, checkedProperty, offBackgroundColorProperty
} from "./switch-common";
export * from "./switch-common";
@ -95,4 +95,15 @@ export class Switch extends SwitchBase {
[backgroundInternalProperty.setNative](value: any) {
//
}
[offBackgroundColorProperty.getDefault](): UIColor {
return this.nativeViewProtected.backgroundColor;
}
[offBackgroundColorProperty.setNative](value: Color | UIColor) {
const nativeValue = value instanceof Color ? value.ios : value;
this.nativeViewProtected.tintColor = nativeValue;
this.nativeViewProtected.backgroundColor = nativeValue;
this.nativeViewProtected.layer.cornerRadius = this.nativeViewProtected.frame.size.height / 2;
}
}