@@ -2,14 +2,14 @@ import React, { Component } from "react";
22import PropTypes from "prop-types" ;
33import { Animated , Easing , Text , TouchableOpacity , View } from "react-native" ;
44import Icon from "react-native-dynamic-vector-icons" ;
5- import styles , { iconContainer , textStyle } from "./BouncyCheckbox.style" ;
5+ import styles , { _iconContainer , _textStyle } from "./BouncyCheckbox.style" ;
66
77class BouncyCheckbox extends Component {
88 constructor ( props ) {
99 super ( props ) ;
1010 this . state = {
1111 checked : false ,
12- springValue : new Animated . Value ( 1 )
12+ springValue : new Animated . Value ( 1 ) ,
1313 } ;
1414 }
1515
@@ -18,12 +18,14 @@ class BouncyCheckbox extends Component {
1818 }
1919
2020 spring = ( ) => {
21+ const { useNativeDriver } = this . props ;
2122 const { checked, springValue } = this . state ;
2223 this . setState ( { checked : ! checked } , ( ) => {
2324 springValue . setValue ( 0.7 ) ;
2425 Animated . spring ( springValue , {
2526 toValue : 1 ,
26- friction : 3
27+ friction : 3 ,
28+ useNativeDriver,
2729 } ) . start ( ) ;
2830 // Outside of the onPress function
2931 const { onPress } = this . props ;
@@ -34,29 +36,29 @@ class BouncyCheckbox extends Component {
3436 renderCheckIcon = ( ) => {
3537 const { checked, springValue } = this . state ;
3638 const {
37- checkboxSize,
38- borderColor,
39- fillColor,
40- borderRadius,
41- unfillColor,
42- iconComponent,
4339 iconName,
4440 iconSize,
4541 iconType,
46- iconColor
42+ iconColor,
43+ fillColor,
44+ borderColor,
45+ unfillColor,
46+ checkboxSize,
47+ borderRadius,
48+ iconComponent,
4749 } = this . props ;
4850 return (
4951 < Animated . View
5052 style = { [
51- iconContainer (
53+ _iconContainer (
5254 checkboxSize ,
5355 checked ,
5456 borderRadius ,
5557 borderColor ,
5658 fillColor ,
5759 unfillColor
5860 ) ,
59- { transform : [ { scale : springValue } ] }
61+ { transform : [ { scale : springValue } ] } ,
6062 ] }
6163 >
6264 { iconComponent || (
@@ -74,10 +76,11 @@ class BouncyCheckbox extends Component {
7476 render ( ) {
7577 const {
7678 text,
79+ fontSize,
7780 textColor,
81+ textStyle,
7882 fontFamily,
79- fontSize,
80- disableTextDecoration
83+ disableTextDecoration,
8184 } = this . props ;
8285
8386 return (
@@ -88,13 +91,16 @@ class BouncyCheckbox extends Component {
8891 { this . renderCheckIcon ( ) }
8992 < View style = { styles . textContainer } >
9093 < Text
91- style = { textStyle (
92- this . state . checked ,
93- textColor ,
94- fontFamily ,
95- fontSize ,
96- disableTextDecoration
97- ) }
94+ style = {
95+ textStyle ||
96+ _textStyle (
97+ this . state . checked ,
98+ textColor ,
99+ fontFamily ,
100+ fontSize ,
101+ disableTextDecoration
102+ )
103+ }
98104 >
99105 { text }
100106 </ Text >
@@ -106,20 +112,21 @@ class BouncyCheckbox extends Component {
106112
107113BouncyCheckbox . propTypes = {
108114 text : PropTypes . string ,
109- textColor : PropTypes . string ,
110- fontFamily : PropTypes . string ,
111- borderRadius : PropTypes . number ,
112- fontSize : PropTypes . number ,
113115 isChecked : PropTypes . bool ,
114- checkboxSize : PropTypes . number ,
115- borderColor : PropTypes . string ,
116- fillColor : PropTypes . string ,
117- unfillColor : PropTypes . string ,
116+ fontSize : PropTypes . number ,
118117 iconName : PropTypes . string ,
119- iconSize : PropTypes . number ,
120118 iconType : PropTypes . string ,
119+ iconSize : PropTypes . number ,
121120 iconColor : PropTypes . string ,
122- disableTextDecoration : PropTypes . bool
121+ textColor : PropTypes . string ,
122+ fillColor : PropTypes . string ,
123+ fontFamily : PropTypes . string ,
124+ unfillColor : PropTypes . string ,
125+ borderColor : PropTypes . string ,
126+ borderRadius : PropTypes . number ,
127+ checkboxSize : PropTypes . number ,
128+ useNativeDriver : PropTypes . bool ,
129+ disableTextDecoration : PropTypes . bool ,
123130} ;
124131
125132BouncyCheckbox . defaultProps = {
@@ -135,8 +142,9 @@ BouncyCheckbox.defaultProps = {
135142 iconColor : "#fdfdfd" ,
136143 text : "Call my mom 😇" ,
137144 borderColor : "#ffc484" ,
145+ useNativeDriver : true ,
138146 unfillColor : "transparent" ,
139- disableTextDecoration : false
147+ disableTextDecoration : false ,
140148} ;
141149
142150export default BouncyCheckbox ;
0 commit comments