Skip to content

Commit 32fa85f

Browse files
committed
new: custom component is available with the new library
1 parent fc37542 commit 32fa85f

File tree

12 files changed

+274
-151
lines changed

12 files changed

+274
-151
lines changed

example/App.tsx

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,62 @@
11
import React from "react";
2-
import { SafeAreaView, StyleSheet } from "react-native";
2+
import { ViewStyle, SafeAreaView } from "react-native";
3+
import Icon from "react-native-dynamic-vector-icons";
34
import RoundedCheckboxGroup, {
45
ICheckboxButton,
56
} from "./lib/RoundedCheckboxGroup";
67

78
const styles = {
8-
outerStyle: { height: 75, width: 75, borderRadius: 75 },
9-
innerStyle: { height: 60, width: 60, borderRadius: 75 },
9+
innerStyle: { height: 45, width: 45, borderRadius: 75 },
1010
};
1111

12+
const _outerStyle = (borderColor: string): ViewStyle => ({
13+
width: 55,
14+
height: 55,
15+
marginLeft: 16,
16+
borderRadius: 60,
17+
borderColor: borderColor,
18+
});
19+
1220
const staticData: ICheckboxButton[] = [
1321
{
1422
id: 0,
15-
checkedColor: "red",
16-
outerStyle: styles.outerStyle,
23+
text: "",
24+
checkedColor: "#ff7473",
25+
uncheckedColor: "#fbbfbb",
26+
outerStyle: _outerStyle("#fbbfbb"),
27+
innerStyle: styles.innerStyle,
28+
},
29+
{
30+
id: 1,
31+
text: "",
32+
checkedColor: "#5567e9",
33+
uncheckedColor: "#afb5f5",
34+
outerStyle: _outerStyle("#afb5f5"),
35+
innerStyle: styles.innerStyle,
36+
},
37+
{
38+
id: 2,
39+
text: "",
40+
checkedColor: "#a98ae7",
41+
uncheckedColor: "#cab6f4",
42+
outerStyle: _outerStyle("#cab6f4"),
43+
innerStyle: styles.innerStyle,
44+
},
45+
{
46+
id: 3,
47+
text: "",
48+
checkedColor: "#fcb779",
49+
uncheckedColor: "#ffd1a7",
50+
outerStyle: _outerStyle("#ffd1a7"),
1751
innerStyle: styles.innerStyle,
1852
},
19-
{ id: 1 },
20-
{ id: 2 },
21-
{ id: 3 },
2253
];
2354

2455
const App = () => {
56+
const [selectedItem, setSelectedItem] = React.useState<
57+
ICheckboxButton | undefined
58+
>(undefined);
59+
2560
return (
2661
<SafeAreaView
2762
style={{ flex: 1, alignItems: "center", justifyContent: "center" }}
@@ -30,8 +65,11 @@ const App = () => {
3065
data={staticData}
3166
initial={2}
3267
onChange={(selectedItem: ICheckboxButton) => {
33-
console.log(JSON.stringify(selectedItem));
68+
setSelectedItem(selectedItem);
3469
}}
70+
component={(isActive: boolean) =>
71+
isActive && <Icon name="check" type="Entypo" color="#fff" />
72+
}
3573
/>
3674
</SafeAreaView>
3775
);

example/ios/Podfile.lock

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,8 @@ PODS:
337337
- React-jsi (= 0.66.0)
338338
- React-logger (= 0.66.0)
339339
- React-perflogger (= 0.66.0)
340+
- RNVectorIcons (8.1.0):
341+
- React-Core
340342
- Yoga (1.14.0)
341343
- YogaKit (1.18.1):
342344
- Yoga (~> 1.14)
@@ -394,6 +396,7 @@ DEPENDENCIES:
394396
- React-RCTVibration (from `../node_modules/react-native/Libraries/Vibration`)
395397
- React-runtimeexecutor (from `../node_modules/react-native/ReactCommon/runtimeexecutor`)
396398
- ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`)
399+
- RNVectorIcons (from `../node_modules/react-native-vector-icons`)
397400
- Yoga (from `../node_modules/react-native/ReactCommon/yoga`)
398401

399402
SPEC REPOS:
@@ -472,6 +475,8 @@ EXTERNAL SOURCES:
472475
:path: "../node_modules/react-native/ReactCommon/runtimeexecutor"
473476
ReactCommon:
474477
:path: "../node_modules/react-native/ReactCommon"
478+
RNVectorIcons:
479+
:path: "../node_modules/react-native-vector-icons"
475480
Yoga:
476481
:path: "../node_modules/react-native/ReactCommon/yoga"
477482

@@ -518,6 +523,7 @@ SPEC CHECKSUMS:
518523
React-RCTVibration: 53b92d54b923283638cb0186da7a5c2d2b70a49b
519524
React-runtimeexecutor: 4bb657a97aa74568d9ed634c8bd478299bb8a3a6
520525
ReactCommon: eb059748e842a1a86025ebbd4ac9d99e74492f88
526+
RNVectorIcons: 31cebfcf94e8cf8686eb5303ae0357da64d7a5a4
521527
Yoga: c11abbf5809216c91fcd62f5571078b83d9b6720
522528
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a
523529

example/ios/example/Info.plist

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,24 @@
5151
</array>
5252
<key>UIViewControllerBasedStatusBarAppearance</key>
5353
<false/>
54+
<key>UIAppFonts</key>
55+
<array>
56+
<string>AntDesign.ttf</string>
57+
<string>Entypo.ttf</string>
58+
<string>EvilIcons.ttf</string>
59+
<string>Feather.ttf</string>
60+
<string>FontAwesome.ttf</string>
61+
<string>FontAwesome5_Brands.ttf</string>
62+
<string>FontAwesome5_Regular.ttf</string>
63+
<string>FontAwesome5_Solid.ttf</string>
64+
<string>Foundation.ttf</string>
65+
<string>Ionicons.ttf</string>
66+
<string>MaterialIcons.ttf</string>
67+
<string>MaterialCommunityIcons.ttf</string>
68+
<string>SimpleLineIcons.ttf</string>
69+
<string>Octicons.ttf</string>
70+
<string>Zocial.ttf</string>
71+
<string>Fontisto.ttf</string>
72+
</array>
5473
</dict>
5574
</plist>

example/lib/RoundedCheckboxGroup.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import * as React from "react";
22
import { View, StyleProp, ViewStyle } from "react-native";
3-
4-
import {
5-
PureRoundedCheckbox,
6-
IRoundedCheckboxProps,
7-
} from "react-native-rounded-checkbox";
8-
3+
import { PureRoundedCheckbox } from "react-native-rounded-checkbox";
4+
import { IRoundedCheckboxProps } from "react-native-rounded-checkbox/build/dist/functional/RoundedCheckbox";
95
/**
106
* ? Local Imports
117
*/
@@ -20,14 +16,18 @@ export interface ICheckboxButton extends IRoundedCheckboxProps {
2016
export interface IRoundedCheckboxGroupProps {
2117
style?: CustomStyleProp;
2218
initial?: number;
19+
children?: React.ReactNode;
2320
data: ICheckboxButton[];
21+
component?: (isActive: boolean) => React.ReactNode;
2422
onChange: (selectedItem: ICheckboxButton) => void;
2523
}
2624

2725
const RoundedCheckboxGroup: React.FC<IRoundedCheckboxGroupProps> = ({
2826
style,
2927
data,
3028
initial,
29+
children,
30+
component,
3131
onChange,
3232
}) => {
3333
const [selectedItem, setSelectedItem] = React.useState<
@@ -54,7 +54,9 @@ const RoundedCheckboxGroup: React.FC<IRoundedCheckboxGroupProps> = ({
5454
key={item.id}
5555
active={isActive}
5656
onPress={() => handleItemPress(item)}
57-
/>
57+
>
58+
{component ? component(isActive) : children}
59+
</PureRoundedCheckbox>
5860
);
5961
})}
6062
</View>

example/package-lock.json

Lines changed: 113 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
"@freakycoder/react-native-bounceable": "^0.2.5",
1414
"react": "17.0.2",
1515
"react-native": "0.66.0",
16-
"react-native-rounded-checkbox": "^0.3.3"
16+
"react-native-dynamic-vector-icons": "^1.1.6",
17+
"react-native-rounded-checkbox": "^0.3.3",
18+
"react-native-vector-icons": "^8.1.0"
1719
},
1820
"devDependencies": {
1921
"@babel/core": "^7.12.9",

lib/FunctionalComponent/Size.ts

Lines changed: 0 additions & 7 deletions
This file was deleted.

lib/FunctionalComponent/Text.tsx

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)