|
| 1 | +import React, {useRef} from 'react'; |
| 2 | +import {ImageBackground, StyleSheet, Text, View} from 'react-native'; |
| 3 | +import RNBounceable from '@freakycoder/react-native-bounceable'; |
| 4 | +import BouncyCheckbox, {BouncyCheckboxHandle} from './build/dist'; |
| 5 | + |
| 6 | +const App = () => { |
| 7 | + const bouncyCheckboxRef = useRef<BouncyCheckboxHandle>(null); |
| 8 | + |
| 9 | + const [checkboxState, setCheckboxState] = React.useState(false); |
| 10 | + |
| 11 | + return ( |
| 12 | + <ImageBackground |
| 13 | + style={styles.container} |
| 14 | + source={require('./assets/bg.jpg')}> |
| 15 | + <View |
| 16 | + style={[ |
| 17 | + styles.stateContainer, |
| 18 | + { |
| 19 | + backgroundColor: checkboxState ? '#34eb83' : '#eb4034', |
| 20 | + }, |
| 21 | + ]}> |
| 22 | + <Text |
| 23 | + style={ |
| 24 | + styles.stateTextStyle |
| 25 | + }>{`Check Status: ${checkboxState.toString()}`}</Text> |
| 26 | + </View> |
| 27 | + <BouncyCheckbox |
| 28 | + size={50} |
| 29 | + textStyle={styles.textStyle} |
| 30 | + style={{marginTop: 16}} |
| 31 | + iconImageStyle={styles.iconImageStyle} |
| 32 | + fillColor={'#00C0EE'} |
| 33 | + unFillColor={'transparent'} |
| 34 | + ref={bouncyCheckboxRef} |
| 35 | + isChecked={checkboxState} |
| 36 | + text="Synthetic Checkbox" |
| 37 | + onPress={() => setCheckboxState(!checkboxState)} |
| 38 | + /> |
| 39 | + <RNBounceable |
| 40 | + style={styles.syntheticButton} |
| 41 | + onPress={() => { |
| 42 | + bouncyCheckboxRef.current?.onCheckboxPress(); |
| 43 | + }}> |
| 44 | + <Text style={{color: '#fff'}}>Synthetic Checkbox Press</Text> |
| 45 | + </RNBounceable> |
| 46 | + </ImageBackground> |
| 47 | + ); |
| 48 | +}; |
| 49 | + |
| 50 | +const styles = StyleSheet.create({ |
| 51 | + container: { |
| 52 | + flex: 1, |
| 53 | + alignItems: 'center', |
| 54 | + justifyContent: 'center', |
| 55 | + }, |
| 56 | + stateContainer: { |
| 57 | + height: 45, |
| 58 | + width: 175, |
| 59 | + alignItems: 'center', |
| 60 | + justifyContent: 'center', |
| 61 | + borderRadius: 12, |
| 62 | + marginBottom: 12, |
| 63 | + }, |
| 64 | + stateTextStyle: { |
| 65 | + color: '#fff', |
| 66 | + fontWeight: 'bold', |
| 67 | + }, |
| 68 | + syntheticButton: { |
| 69 | + height: 50, |
| 70 | + marginTop: 64, |
| 71 | + borderRadius: 12, |
| 72 | + width: '60%', |
| 73 | + alignItems: 'center', |
| 74 | + justifyContent: 'center', |
| 75 | + backgroundColor: '#00C0EE', |
| 76 | + }, |
| 77 | + iconImageStyle: { |
| 78 | + width: 20, |
| 79 | + height: 20, |
| 80 | + }, |
| 81 | + textStyle: { |
| 82 | + color: '#010101', |
| 83 | + fontWeight: '600', |
| 84 | + }, |
| 85 | +}); |
| 86 | + |
| 87 | +export default App; |
0 commit comments