Skip to content

Commit f5a7c73

Browse files
committed
Styles separated as original
1 parent 79c831b commit f5a7c73

File tree

2 files changed

+46
-28
lines changed

2 files changed

+46
-28
lines changed

lib/src/BouncyCheckbox.js

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import React, { Component } from 'react'
22
import PropTypes from 'prop-types'
3-
import { Animated, Easing, Text, TouchableOpacity, View, StyleSheet } from 'react-native'
3+
import { Animated, Easing, Text, TouchableOpacity, View} from 'react-native'
44
import Icon from 'react-native-dynamic-vector-icons'
5+
import styles, { _iconContainer, _textStyle } from "./BouncyCheckbox.style"
56

67
class BouncyCheckbox extends Component {
78
constructor(props) {
@@ -54,16 +55,7 @@ class BouncyCheckbox extends Component {
5455
<Animated.View
5556
style={[
5657
{ transform: [{ scale: springValue }] },
57-
{
58-
width: size,
59-
height: size,
60-
borderWidth,
61-
borderRadius,
62-
alignItems: 'center',
63-
justifyContent: 'center',
64-
borderColor,
65-
backgroundColor: checked ? fillColor : unfillColor
66-
},
58+
_iconContainer(size, borderWidth, borderRadius, borderColor, checked, fillColor, unfillColor),
6759
iconStyle
6860
]}
6961
>
@@ -80,32 +72,22 @@ class BouncyCheckbox extends Component {
8072
{this.renderCheckIcon()}
8173
<View style={styles.textContainer}>
8274
<Text
83-
style={[
84-
{
85-
fontSize,
86-
fontFamily,
75+
style={[_textStyle(
76+
this.state.checked,
8777
color,
88-
textDecorationLine: !textDecoration && checked ? 'line-through' : 'none'
89-
},
90-
textStyle
91-
]}
92-
>
78+
fontFamily,
79+
fontSize,
80+
textDecoration,
81+
), textStyle ]}>
9382
{text}
9483
</Text>
84+
9585
</View>
9686
</TouchableOpacity>
9787
)
9888
}
9989
}
10090

101-
const styles = StyleSheet.create({
102-
container: {
103-
margin: 8,
104-
alignItems: 'center',
105-
flexDirection: 'row'
106-
},
107-
textContainer: { marginLeft: 16 }
108-
})
10991

11092
BouncyCheckbox.propTypes = {
11193
borderWidth: PropTypes.number,

lib/src/BouncyCheckbox.style.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
export const _iconContainer = (size, borderWidth, borderRadius, borderColor, checked, fillColor, unfillColor) => {
2+
return {
3+
width: size,
4+
height: size,
5+
borderWidth,
6+
borderRadius,
7+
alignItems: 'center',
8+
justifyContent: 'center',
9+
borderColor,
10+
backgroundColor: checked ? fillColor : unfillColor
11+
};
12+
};
13+
14+
export const _textStyle = (
15+
checked,
16+
color,
17+
fontFamily,
18+
fontSize,
19+
textDecoration
20+
) => {
21+
return {
22+
fontSize,
23+
fontFamily,
24+
color ,
25+
textDecorationLine:!textDecoration && checked ? "line-through" : "none",
26+
};
27+
};
28+
29+
export default {
30+
container: {
31+
margin: 8,
32+
alignItems: "center",
33+
flexDirection: "row",
34+
},
35+
textContainer: { marginLeft: 16 },
36+
};

0 commit comments

Comments
 (0)