Skip to content

Commit 10d7694

Browse files
committed
feat: version 2 - rewritten the library
1 parent f2a61ac commit 10d7694

File tree

81 files changed

+17401
-8424
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+17401
-8424
lines changed

example/.gitignore

Lines changed: 30 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,37 @@
1-
# OSX
2-
#
3-
.DS_Store
4-
5-
# Xcode
6-
#
7-
build/
8-
*.pbxuser
9-
!default.pbxuser
10-
*.mode1v3
11-
!default.mode1v3
12-
*.mode2v3
13-
!default.mode2v3
14-
*.perspectivev3
15-
!default.perspectivev3
16-
xcuserdata
17-
*.xccheckout
18-
*.moved-aside
19-
DerivedData
20-
*.hmap
21-
*.ipa
22-
*.xcuserstate
23-
ios/.xcode.env.local
1+
# Learn more https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files
242

25-
# Android/IntelliJ
26-
#
27-
build/
28-
.idea
29-
.gradle
30-
local.properties
31-
*.iml
32-
*.hprof
33-
.cxx/
34-
*.keystore
35-
!debug.keystore
36-
37-
# node.js
38-
#
3+
# dependencies
394
node_modules/
40-
npm-debug.log
41-
yarn-error.log
42-
43-
# fastlane
44-
#
45-
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
46-
# screenshots whenever they are needed.
47-
# For more information about the recommended setup visit:
48-
# https://docs.fastlane.tools/best-practices/source-control/
495

50-
**/fastlane/report.xml
51-
**/fastlane/Preview.html
52-
**/fastlane/screenshots
53-
**/fastlane/test_output
6+
# Expo
7+
.expo/
8+
dist/
9+
web-build/
10+
expo-env.d.ts
11+
12+
# Native
13+
.kotlin/
14+
*.orig.*
15+
*.jks
16+
*.p8
17+
*.p12
18+
*.key
19+
*.mobileprovision
20+
21+
# Metro
22+
.metro-health-check*
5423

55-
# Bundle artifact
56-
*.jsbundle
24+
# debug
25+
npm-debug.*
26+
yarn-debug.*
27+
yarn-error.*
5728

58-
# Ruby / CocoaPods
59-
/ios/Pods/
60-
/vendor/bundle/
29+
# macOS
30+
.DS_Store
31+
*.pem
6132

62-
# Temporary files created by Metro to check the health of the file watcher
63-
.metro-health-check*
33+
# local env files
34+
.env*.local
6435

65-
# testing
66-
/coverage
36+
# typescript
37+
*.tsbuildinfo

example/App.tsx

Lines changed: 162 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import React from 'react';
2-
import {View, Text, SafeAreaView} from 'react-native';
1+
import React, { useState } from 'react';
2+
import { View, Text, SafeAreaView, StyleSheet, ScrollView } from 'react-native';
33
import AppleHeader from 'react-native-apple-header';
4-
import BouncyCheckboxGroup, {CheckboxButton} from './lib/BouncyCheckboxGroup';
4+
import BouncyCheckboxGroup, { CheckboxButton } from './lib/BouncyCheckboxGroup';
55

66
const _iconStyle = (borderColor: string) => ({
77
height: 50,
@@ -10,12 +10,55 @@ const _iconStyle = (borderColor: string) => ({
1010
borderColor: borderColor,
1111
});
1212

13-
const styles = {
14-
container: {marginTop: 24},
15-
verticalStyle: {marginTop: 16},
16-
textStyle: {textDecorationLine: 'none'},
17-
iconImageStyle: {height: 20, width: 20},
18-
};
13+
const styles = StyleSheet.create({
14+
container: {
15+
flex: 1,
16+
},
17+
verticalStyle: {
18+
marginTop: 16,
19+
},
20+
textStyle: {
21+
textDecorationLine: 'none',
22+
fontSize: 16,
23+
},
24+
iconImageStyle: {
25+
height: 20,
26+
width: 20,
27+
},
28+
sectionTitle: {
29+
color: '#a8a8ac',
30+
fontWeight: '500',
31+
fontSize: 16,
32+
marginLeft: 32,
33+
marginTop: 24,
34+
},
35+
checkboxContainer: {
36+
marginTop: 16,
37+
alignItems: 'center',
38+
justifyContent: 'center',
39+
},
40+
verticalCheckboxContainer: {
41+
marginTop: 16,
42+
marginLeft: 32,
43+
justifyContent: 'center',
44+
},
45+
scrollView: {
46+
paddingBottom: 48,
47+
},
48+
selected: {
49+
marginLeft: 32,
50+
marginTop: 8,
51+
fontSize: 14,
52+
color: '#555',
53+
},
54+
description: {
55+
marginLeft: 32,
56+
marginTop: 4,
57+
fontSize: 12,
58+
color: '#888',
59+
maxWidth: '90%',
60+
},
61+
});
1962

2063
const staticData: CheckboxButton[] = [
2164
{
@@ -109,73 +152,147 @@ const verticalStaticData: CheckboxButton[] = [
109152
];
110153

111154
const App = () => {
155+
const [singleSelected, setSingleSelected] = useState<CheckboxButton | null>(null);
156+
const [multipleSelected, setMultipleSelected] = useState<CheckboxButton[]>([]);
157+
const [verticalSelected, setVerticalSelected] = useState<CheckboxButton | null>(null);
158+
const [fastAnimationSelected, setFastAnimationSelected] = useState<CheckboxButton | null>(null);
159+
const [alwaysSelected, setAlwaysSelected] = useState<CheckboxButton | null>(null);
160+
112161
const imageSource = {
113162
uri: 'https://images.unsplash.com/photo-1499482125586-91609c0b5fd4?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=987&q=80',
114163
};
115164

116165
const horizontalCheckboxGroupContainer = () => (
117166
<>
118-
<View style={{marginLeft: 32}}>
119-
<Text style={{color: '#a8a8ac', fontWeight: '500', fontSize: 16}}>
120-
Pick your favorite color
121-
</Text>
122-
</View>
123-
<View
124-
style={{
125-
marginTop: 16,
126-
alignItems: 'center',
127-
justifyContent: 'center',
128-
}}>
167+
<Text style={styles.sectionTitle}>
168+
Single Select - Pick your favorite color
169+
</Text>
170+
<View style={styles.checkboxContainer}>
129171
<BouncyCheckboxGroup
130172
data={staticData}
173+
spacing={8}
174+
initial={0}
131175
onChange={(selectedItem: CheckboxButton) => {
132-
console.log('SelectedItem: ', JSON.stringify(selectedItem));
176+
setSingleSelected(selectedItem);
177+
console.log('Single Selected: ', JSON.stringify(selectedItem));
133178
}}
134179
/>
135180
</View>
181+
{singleSelected && (
182+
<Text style={styles.selected}>
183+
Selected: {singleSelected.id}
184+
</Text>
185+
)}
136186
</>
137187
);
138188

139-
const verticalCheckboxGroupContainer = () => (
189+
const alwaysSelectCheckboxGroupContainer = () => (
140190
<>
141-
<View style={{marginLeft: 32, marginTop: 24}}>
142-
<Text style={{color: '#a8a8ac', fontWeight: '500', fontSize: 16}}>
143-
Pick your favorite color (Horizontal Style)
191+
<Text style={styles.sectionTitle}>
192+
Always Selected Mode - Can't deselect
193+
</Text>
194+
<Text style={styles.description}>
195+
Once an option is selected, it can't be deselected. You must select another option to change.
196+
</Text>
197+
<View style={styles.checkboxContainer}>
198+
<BouncyCheckboxGroup
199+
data={staticData}
200+
spacing={8}
201+
initial={0}
202+
alwaysSelect={true}
203+
onChange={(selectedItem: CheckboxButton) => {
204+
setAlwaysSelected(selectedItem);
205+
console.log('Always Selected: ', JSON.stringify(selectedItem));
206+
}}
207+
/>
208+
</View>
209+
{alwaysSelected && (
210+
<Text style={styles.selected}>
211+
Selected: {alwaysSelected.id}
144212
</Text>
213+
)}
214+
</>
215+
);
216+
217+
const multiSelectCheckboxGroupContainer = () => (
218+
<>
219+
<Text style={styles.sectionTitle}>
220+
Multi Select - Choose multiple colors
221+
</Text>
222+
<View style={styles.checkboxContainer}>
223+
<BouncyCheckboxGroup
224+
data={staticData}
225+
spacing={8}
226+
multiple={true}
227+
initial={[1, 3]}
228+
onChange={(selectedItems: CheckboxButton[]) => {
229+
setMultipleSelected(selectedItems);
230+
console.log('Multiple Selected: ', JSON.stringify(selectedItems));
231+
}}
232+
/>
145233
</View>
146-
<View
147-
style={{
148-
marginTop: 16,
149-
marginLeft: 32,
150-
justifyContent: 'center',
151-
}}>
234+
{multipleSelected.length > 0 && (
235+
<Text style={styles.selected}>
236+
Selected: {multipleSelected.map(item => item.id).join(', ')}
237+
</Text>
238+
)}
239+
</>
240+
);
241+
242+
const verticalCheckboxGroupContainer = () => (
243+
<>
244+
<Text style={styles.sectionTitle}>
245+
Vertical Layout - Pick your favorite color
246+
</Text>
247+
<View style={styles.verticalCheckboxContainer}>
152248
<BouncyCheckboxGroup
153249
data={verticalStaticData}
154-
style={{flexDirection: 'column'}}
250+
style={{ flexDirection: 'column' }}
251+
spacing={0}
155252
onChange={(selectedItem: CheckboxButton) => {
156-
console.log('SelectedItem: ', JSON.stringify(selectedItem));
253+
setVerticalSelected(selectedItem);
254+
console.log('Vertical Selected: ', JSON.stringify(selectedItem));
157255
}}
158256
/>
159257
</View>
258+
{verticalSelected && (
259+
<Text style={styles.selected}>
260+
Selected: {verticalSelected.text}
261+
</Text>
262+
)}
160263
</>
161264
);
162265

163-
return (
266+
const fastAnimationCheckboxGroupContainer = () => (
164267
<>
165-
<SafeAreaView>
166-
<AppleHeader
167-
dateTitle="Apr 19, 2024"
168-
largeTitle="Welcome"
169-
imageSource={imageSource}
170-
onPress={() => {}}
268+
<Text style={styles.sectionTitle}>
269+
Custom Animation Speed (100ms)
270+
</Text>
271+
<View style={styles.checkboxContainer}>
272+
<BouncyCheckboxGroup
273+
data={staticData}
274+
spacing={8}
275+
animationDuration={100}
276+
onChange={(selectedItem: CheckboxButton) => {
277+
setFastAnimationSelected(selectedItem);
278+
}}
171279
/>
172-
<View style={styles.container}>
173-
{horizontalCheckboxGroupContainer()}
174-
{verticalCheckboxGroupContainer()}
175-
</View>
176-
</SafeAreaView>
280+
</View>
177281
</>
178282
);
283+
284+
return (
285+
<SafeAreaView style={{ flex: 1 }}>
286+
287+
<ScrollView style={styles.container} contentContainerStyle={styles.scrollView}>
288+
{horizontalCheckboxGroupContainer()}
289+
{alwaysSelectCheckboxGroupContainer()}
290+
{multiSelectCheckboxGroupContainer()}
291+
{verticalCheckboxGroupContainer()}
292+
{fastAnimationCheckboxGroupContainer()}
293+
</ScrollView>
294+
</SafeAreaView>
295+
);
179296
};
180297

181298
export default App;

example/app.json

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,29 @@
11
{
2-
"name": "example",
3-
"displayName": "example"
2+
"expo": {
3+
"name": "example",
4+
"slug": "example",
5+
"version": "1.0.0",
6+
"orientation": "portrait",
7+
"icon": "./assets/icon.png",
8+
"userInterfaceStyle": "light",
9+
"newArchEnabled": true,
10+
"splash": {
11+
"image": "./assets/splash-icon.png",
12+
"resizeMode": "contain",
13+
"backgroundColor": "#ffffff"
14+
},
15+
"ios": {
16+
"supportsTablet": true
17+
},
18+
"android": {
19+
"adaptiveIcon": {
20+
"foregroundImage": "./assets/adaptive-icon.png",
21+
"backgroundColor": "#ffffff"
22+
},
23+
"edgeToEdgeEnabled": true
24+
},
25+
"web": {
26+
"favicon": "./assets/favicon.png"
27+
}
28+
}
429
}

example/assets/adaptive-icon.png

17.1 KB
Loading

example/assets/favicon.png

1.43 KB
Loading

example/assets/icon.png

21.9 KB
Loading

example/assets/splash-icon.png

17.1 KB
Loading

example/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { registerRootComponent } from 'expo';
2+
3+
import App from './App';
4+
5+
// registerRootComponent calls AppRegistry.registerComponent('main', () => App);
6+
// It also ensures that whether you load the app in Expo Go or in a native build,
7+
// the environment is set up appropriately
8+
registerRootComponent(App);

0 commit comments

Comments
 (0)