Skip to content

Commit 03b06e9

Browse files
committed
innerBackgroundColor prop is added
1 parent 7dcfb80 commit 03b06e9

7 files changed

Lines changed: 37 additions & 15 deletions

File tree

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,12 @@ You can check the example out 😏
5858

5959
# Configuration - Props
6060

61-
| Property | Type | Default | Description |
62-
| -------------- | :------: | :-----: | ----------------------------------------------- |
63-
| style | style | default | set the main container's style (outer circle) |
64-
| innerContainer | style | default | set the inner container's style (inner circle) |
65-
| onPress | function | default | set your own function when onPress is triggered |
61+
| Property | Type | Default | Description |
62+
| -------------------- | :------: | :-----: | ----------------------------------------------- |
63+
| style | style | default | set the main container's style (outer circle) |
64+
| innerContainerStyle | style | default | set the inner container's style (inner circle) |
65+
| innerBackgroundColor | color | red | change the inner circle's background color |
66+
| onPress | function | default | set your own function when onPress is triggered |
6667

6768
## Future Plans
6869

example/App.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ const App = () => {
1313
<RadioButton
1414
onPress={(isActive: boolean) => console.log("isActive: ", isActive)}
1515
/>
16+
<RadioButton
17+
style={{ borderColor: "#019310" }}
18+
innerContainer={{ backgroundColor: "#019310" }}
19+
onPress={(isActive: boolean) => console.log("isActive: ", isActive)}
20+
/>
21+
<RadioButton
22+
onPress={(isActive: boolean) => console.log("isActive: ", isActive)}
23+
/>
1624
</SafeAreaView>
1725
);
1826
};

example/package-lock.json

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

example/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"@freakycoder/react-native-bounceable": "^0.2.5",
1414
"react": "17.0.1",
1515
"react-native": "0.64.1",
16-
"react-native-animated-radio-button": "^2.0.0"
16+
"react-native-animated-radio-button": "^2.0.1"
1717
},
1818
"devDependencies": {
1919
"@babel/core": "^7.12.9",

lib/RadioButton.style.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@ interface Style {
44
container: ViewStyle;
55
}
66

7-
export const _innerStyle = (isActive: boolean): ViewStyle => ({
7+
export const _innerStyle = (
8+
isActive: boolean,
9+
innerBackgroundColor: string,
10+
): ViewStyle => ({
811
width: 30,
912
height: 30,
1013
borderRadius: 25,
11-
backgroundColor: isActive ? "red" : "transparent",
14+
backgroundColor: isActive ? innerBackgroundColor : "transparent",
1215
});
1316

1417
export default StyleSheet.create<Style>({

lib/RadioButton.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ type CustomStyleProp = StyleProp<ViewStyle> | Array<StyleProp<ViewStyle>>;
1010

1111
interface IRadioButtonProps {
1212
style?: CustomStyleProp;
13-
innerContainer?: CustomStyleProp;
13+
innerContainerStyle?: CustomStyleProp;
14+
innerBackgroundColor?: string;
1415
onPress: (isActive: boolean) => void;
1516
}
1617

@@ -36,13 +37,22 @@ export default class RadioButton extends React.Component<
3637
};
3738

3839
render() {
39-
const { style, innerContainer } = this.props;
40+
const {
41+
style,
42+
innerContainerStyle,
43+
innerBackgroundColor = "red",
44+
} = this.props;
4045
return (
4146
<RNBounceable
4247
style={[styles.container, style]}
4348
onPress={this.handlePress}
4449
>
45-
<View style={[_innerStyle(this.state.isActive), innerContainer]} />
50+
<View
51+
style={[
52+
_innerStyle(this.state.isActive, innerBackgroundColor),
53+
innerContainerStyle,
54+
]}
55+
/>
4656
</RNBounceable>
4757
);
4858
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-animated-radio-button",
3-
"version": "2.0.1",
3+
"version": "2.0.2",
44
"description": "Fully customizable animated radio button for React Native",
55
"keywords": [
66
"bouncy",

0 commit comments

Comments
 (0)