Skip to content

Commit

Permalink
feat: ⚡ Fixed style overriding through containerStyle prop and added …
Browse files Browse the repository at this point in the history
…new prop tileStyle
  • Loading branch information
Karthik-B-06 committed Apr 24, 2021
1 parent d5838d7 commit 1a805f1
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/segmentedControl/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ const SegmentedControl = (props) => {
return (
<Animated.View
style={[
props?.containerStyle,
styles.segmentedControlWrapper,
props?.containerStyle,
{
width: width,
},
Expand All @@ -85,18 +85,17 @@ const SegmentedControl = (props) => {
>
<Animated.View
style={[
styles.defaultTileStyle,
props?.tileStyle,
{
...StyleSheet.absoluteFill,
position: "absolute",
width: (width - 4) / props?.tabs?.length,
top: 0,
marginVertical: 2,
marginHorizontal: 2,
backgroundColor: getActiveSegmentedBackgroundColor(
props?.theme,
props?.activeSegmentBackgroundColor
),
borderRadius: 8,
...shadow,
},
{
Expand Down Expand Up @@ -164,6 +163,11 @@ const styles = StyleSheet.create({
textAlign: "center",
fontWeight: "600",
},
defaultTileStyle: {
marginVertical: 2,
marginHorizontal: 2,
borderRadius: 8,
}
});

SegmentedControl.propTypes = {
Expand Down Expand Up @@ -191,6 +195,7 @@ SegmentedControl.propTypes = {
shadowRadius: PropTypes.number,
elevation: PropTypes.number,
}),
tileStyle: ViewPropTypes.style,
};

SegmentedControl.defaultProps = {
Expand All @@ -209,6 +214,7 @@ SegmentedControl.defaultProps = {
isRTL: false,
theme: "LIGHT",
shadowStyle: null,
tileStyle: {},
};

export default SegmentedControl;

0 comments on commit 1a805f1

Please sign in to comment.