Skip to content

Commit b3da821

Browse files
committed
Example is updated with new and better example
1 parent cfa6b34 commit b3da821

File tree

3 files changed

+72
-14
lines changed

3 files changed

+72
-14
lines changed

example/App.tsx

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from "react";
2-
import { View, StatusBar, SafeAreaView } from "react-native";
2+
import { View, Text, StatusBar, SafeAreaView } from "react-native";
33
import AppleHeader from "react-native-apple-header";
44
import BottomSearchBar from "react-native-bottom-search-bar";
55
import BouncyCheckbox from "./lib/BouncyCheckbox";
@@ -84,6 +84,65 @@ const App = () => {
8484
/>
8585
</View>
8686
</View>
87+
<View
88+
style={{
89+
marginTop: 16,
90+
}}
91+
>
92+
<Text style={{ marginLeft: 24, fontSize: 24, fontWeight: "700" }}>
93+
Checkbox Only
94+
</Text>
95+
<View
96+
style={{
97+
marginTop: 16,
98+
width: "100%",
99+
flexDirection: "row",
100+
justifyContent: "space-evenly",
101+
}}
102+
>
103+
<BouncyCheckbox
104+
size={50}
105+
isChecked
106+
iconImageStyle={{ width: 18, height: 18 }}
107+
disableText
108+
onPress={() => {}}
109+
/>
110+
<BouncyCheckbox
111+
disableText
112+
fillColor="#f54b42"
113+
size={50}
114+
iconImageStyle={{ width: 18, height: 18 }}
115+
iconStyle={{ borderColor: "#f54b42" }}
116+
onPress={() => {}}
117+
/>
118+
<BouncyCheckbox
119+
isChecked
120+
disableText
121+
fillColor="#4287f5"
122+
size={50}
123+
iconImageStyle={{ width: 18, height: 18 }}
124+
iconStyle={{ borderColor: "#4287f5" }}
125+
onPress={() => {}}
126+
/>
127+
<BouncyCheckbox
128+
disableText
129+
fillColor="#9342f5"
130+
size={50}
131+
iconImageStyle={{ width: 18, height: 18 }}
132+
iconStyle={{ borderColor: "#9342f5" }}
133+
onPress={() => {}}
134+
/>
135+
<BouncyCheckbox
136+
isChecked
137+
disableText
138+
fillColor="green"
139+
size={50}
140+
iconImageStyle={{ width: 18, height: 18 }}
141+
iconStyle={{ borderColor: "green" }}
142+
onPress={() => {}}
143+
/>
144+
</View>
145+
</View>
87146
<BottomSearchBar />
88147
</SafeAreaView>
89148
</View>

example/lib/BouncyCheckbox.style.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { ViewStyle, TextStyle, ImageStyle, StyleSheet } from "react-native";
33
interface Style {
44
container: ViewStyle;
55
textContainer: ViewStyle;
6+
iconImageStyle: ImageStyle;
67
}
78

89
export const _iconContainer = (
@@ -31,18 +32,15 @@ export const _textStyle = (checked: boolean): TextStyle => {
3132
};
3233
};
3334

34-
export const _iconImageStyle = (checked: boolean): ImageStyle => ({
35-
width: 10,
36-
height: 10,
37-
display: checked ? "flex" : "none",
38-
});
39-
4035
export default StyleSheet.create<Style>({
4136
container: {
42-
alignSelf: "baseline",
4337
alignItems: "center",
4438
flexDirection: "row",
4539
},
40+
iconImageStyle: {
41+
width: 10,
42+
height: 10,
43+
},
4644
textContainer: {
4745
marginLeft: 16,
4846
},

example/lib/BouncyCheckbox.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,13 @@ class BouncyCheckbox extends React.Component<IBouncyCheckboxProps, IState> {
100100
iconStyle,
101101
]}
102102
>
103-
{iconComponent || (
104-
<ImageComponent
105-
source={checkIconImageSource}
106-
style={[_iconImageStyle(checked), iconImageStyle]}
107-
/>
108-
)}
103+
{iconComponent ||
104+
(checked && (
105+
<ImageComponent
106+
source={checkIconImageSource}
107+
style={[styles.iconImageStyle, iconImageStyle]}
108+
/>
109+
))}
109110
</Animated.View>
110111
);
111112
};

0 commit comments

Comments
 (0)