@@ -38,10 +38,10 @@ npm i react-native-bouncy-checkbox
3838- Typescript
3939- ** Zero Dependency**
4040- More Customization Options
41- - New customization props are available:
42- - ` iconStyle `
43- - ` bounceEffect `
44- - ` bounceFriction `
41+ - New customization props are available:
42+ - ` iconStyle `
43+ - ` bounceEffect `
44+ - ` bounceFriction `
4545
4646## Import
4747
@@ -92,11 +92,97 @@ import BouncyCheckbox from "react-native-bouncy-checkbox";
9292| bounceEffect | number | 1 | change the bounce effect |
9393| bounceFriction | number | 3 | change the bounce friction |
9494
95+ ## Synthetic Press Functionality with Manual Check State
96+
97+ <div >
98+ <img alt="React Native Bouncy Checkbox"
99+ src="assets/Screenshots/react-native-bouncy-checkbox-syntetic-onpress.gif" />
100+ </div >
101+
102+ Please check the ` example-manual-state ` runable project to how to make it work on a real project.
103+
104+ <b ><i >Becareful while using ` disableBuiltInState ` you MUST set the ` isChecked ` prop to use your own check state manually.</b ></i >
105+
106+ Here is the basic implementation:
107+
108+ ``` jsx
109+ import React from " react" ;
110+ import {
111+ SafeAreaView ,
112+ StyleSheet ,
113+ Text ,
114+ TouchableOpacity ,
115+ View ,
116+ } from " react-native" ;
117+ import BouncyCheckbox from " ./lib/BouncyCheckbox" ;
118+ import RNBounceable from " @freakycoder/react-native-bounceable" ;
119+
120+ const App = () => {
121+ let bouncyCheckboxRef: BouncyCheckbox | null = null ;
122+ const [checkboxState , setCheckboxState ] = React .useState (false );
123+
124+ return (
125+ < SafeAreaView
126+ style= {{
127+ flex: 1 ,
128+ alignItems: " center" ,
129+ justifyContent: " center" ,
130+ }}
131+ >
132+ < View
133+ style= {{
134+ height: 30 ,
135+ width: 150 ,
136+ alignItems: " center" ,
137+ justifyContent: " center" ,
138+ borderRadius: 12 ,
139+ backgroundColor: checkboxState ? " #34eb83" : " #eb4034" ,
140+ }}
141+ >
142+ < Text
143+ style= {{ color: " #fff" }}
144+ > {` Check Status: ${ checkboxState .toString ()} ` }< / Text >
145+ < / View>
146+ < BouncyCheckbox
147+ style= {{ marginTop: 16 }}
148+ ref= {(ref : any ) => (bouncyCheckboxRef = ref)}
149+ isChecked= {checkboxState}
150+ text= " Synthetic Checkbox"
151+ disableBuiltInState
152+ onPress= {(isChecked : boolean = false ) =>
153+ setCheckboxState (! checkboxState)
154+ }
155+ / >
156+ < RNBounceable
157+ style= {{
158+ marginTop: 16 ,
159+ height: 50 ,
160+ width: " 90%" ,
161+ backgroundColor: " #ffc484" ,
162+ borderRadius: 12 ,
163+ alignItems: " center" ,
164+ justifyContent: " center" ,
165+ }}
166+ onPress= {() => bouncyCheckboxRef? .onPress ()}
167+ >
168+ < Text style= {{ color: " #fff" }}> Synthetic Checkbox Press< / Text >
169+ < / RNBounceable>
170+ < / SafeAreaView>
171+ );
172+ };
173+
174+ const styles = StyleSheet .create ({});
175+
176+ export default App ;
177+ ` ` `
178+
95179### Future Plans
96180
97181- [x] ~~LICENSE~~
98182- [x] ~~Typescript Challange!~~
99183- [x] ~~Version 2.0.0 is alive 🥳~~
184+ - [x] ~~Synthetic Press Functionality~~
185+ - [x] ~~Disable built-in check state~~
100186- [ ] Write an article about the lib on Medium
101187
102188## Author
0 commit comments