-
Notifications
You must be signed in to change notification settings - Fork 10
/
BEMCheckBox.ios.js
68 lines (59 loc) · 1.65 KB
/
BEMCheckBox.ios.js
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/**
* @providesModule BEMCheckBox
* @flow
*/
'use strict';
import React, { Component } from 'react';
import { StyleSheet, requireNativeComponent } from 'react-native';
import PropTypes from 'prop-types';
const RNBEMCheckBox = requireNativeComponent('RNBEMCheckBox', null);
const BOX_TYPES = ['circle', 'square'];
const ANIMATION_TYPES = ['stroke', 'fill', 'bounce', 'flat', 'one-stroke', 'fade'];
export default class BEMCheckBox extends Component {
static propTypes = {
value: PropTypes.bool,
lineWidth: PropTypes.number,
hideBox: PropTypes.bool,
boxType: PropTypes.oneOf(BOX_TYPES),
tintColor: PropTypes.string,
onCheckColor: PropTypes.string,
onFillColor: PropTypes.string,
onTintColor: PropTypes.string,
animationDuration: PropTypes.number,
onAnimationType: PropTypes.oneOf(ANIMATION_TYPES),
offAnimationType: PropTypes.oneOf(ANIMATION_TYPES),
onValueChange: PropTypes.func,
onAnimationEnd: PropTypes.func,
};
static defaultProps = {
};
render () {
const { style, ...rest} = this.props;
return (
<RNBEMCheckBox
style={[styles.checkbox, style]}
onChange={this._onChange}
{...rest}
/>
);
}
_onChange = (event: Object): void => {
const { name, value } = event.nativeEvent;
const { onValueChange, onAnimationEnd } = this.props;
switch (name) {
case 'tap':
onValueChange && onValueChange(value);
break;
case 'animation':
onAnimationEnd && onAnimationEnd(value);
break;
}
};
}
const styles = StyleSheet.create({
checkbox: {
height: 50,
width: 50,
backgroundColor: 'transparent',
},
});