blob: 068cbfbdec3b9c2828657b0b1ae9397e52a02b32 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
import React from 'react';
import { Switch } from 'react-native';
import { RkComponent } from 'react-native-ui-kitten';
export class RkSwitch extends RkComponent {
componentName = 'RkSwitch';
typeMapping = {
container: {
onColor: 'onColor',
offColor: 'offColor',
},
main: {},
};
selectedType = 'selected';
constructor(props) {
super(props);
this.onChange = this.props.onValueChange ?
this.props.onValueChange
: () => true;
}
render() {
const { container } = this.defineStyles();
const onColor = this.extractNonStyleValue(container, 'onColor');
return (
<Switch
style={this.props.style}
value={this.props.value}
onValueChange={(value) => this.onChange(value)}
onTintColor={onColor}
/>
);
}
}
|