Skip to content

Commit d5b921b

Browse files
authored
feat: add support to barContainerStyle prop (#109)
1 parent 1a926a1 commit d5b921b

File tree

8 files changed

+27
-9
lines changed

8 files changed

+27
-9
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ export default App = () => {
8686
| **closeIconStyle** | `Object` | Use this prop to override close button icon style | `{}` |
8787
| **barStyle** | `Object` | Use this prop to override bar style | `{}` |
8888
| **smallPanelHeight** | `Object` | Use this prop to override the small panel default height | |
89+
| **barContainerStyle** | `Object` | Use this prop to override bar container style | `{}` |
8990
| **closeOnTouchOutside** | `bool` | Set true if you want to close panel by touching outside | `false` |
9091
| **allowTouchOutside** | `bool` | Set true if you want to make toucable outside of panel | `false` |
9192
| **noBar** | `bool` | Set true if you want to remove gray bar | `false` |

example/src/components/Panel/Bar.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
import React from 'react';
2-
import {StyleSheet, View} from 'react-native';
1+
import * as React from 'react';
2+
import { StyleSheet, View } from 'react-native';
33

44
type BarProps = {
5-
barStyle?: Object;
5+
barStyle?: object;
6+
barContainerStyle?: object;
67
};
78

8-
export const Bar = ({barStyle}: BarProps) => {
9+
export const Bar = ({ barStyle, barContainerStyle }: BarProps) => {
910
return (
10-
<View style={BarStyles.barContainer}>
11+
<View style={[BarStyles.barContainer, barContainerStyle]}>
1112
<View style={[BarStyles.bar, barStyle]} />
1213
</View>
1314
);

example/src/components/Panel/Panel.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ type SwipeablePanelProps = {
4040
smallPanelHeight?: number;
4141
noBar?: boolean;
4242
barStyle?: object;
43+
barContainerStyle?: object;
4344
allowTouchOutside?: boolean;
4445
scrollViewProps?: ScrollViewProps;
4546
};
@@ -205,6 +206,7 @@ class SwipeablePanel extends Component<SwipeablePanelProps, SwipeablePanelState>
205206
noBackgroundOpacity,
206207
style,
207208
barStyle,
209+
barContainerStyle,
208210
closeRootStyle,
209211
closeIconStyle,
210212
onClose,
@@ -249,7 +251,7 @@ class SwipeablePanel extends Component<SwipeablePanelProps, SwipeablePanelState>
249251
]}
250252
{...this._panResponder.panHandlers}
251253
>
252-
{!this.props.noBar && <Bar barStyle={barStyle} />}
254+
{!this.props.noBar && <Bar barStyle={barStyle} barContainerStyle={barContainerStyle} />}
253255
{this.props.showCloseButton && (
254256
<Close rootStyle={closeRootStyle} iconStyle={closeIconStyle} onPress={this.props.onClose} />
255257
)}

example/src/hooks/useSwipeablePanel.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const useSwipeablePanel = () => {
1818
onlySmall: false,
1919
allowTouchOutside: false,
2020
barStyle: {},
21+
barContainerStyle: {},
2122
style: {},
2223
closeRootStyle: {},
2324
contentType: null,
@@ -77,6 +78,7 @@ const useSwipeablePanel = () => {
7778
noBar: false,
7879
style: { backgroundColor: '#1f1f1f' },
7980
barStyle: { backgroundColor: 'rgba(255,255,255,0.2)' },
81+
barContainerStyle: { backgroundColor: '#1f1f1f' },
8082
closeRootStyle: { backgroundColor: 'rgba(255,255,255,0.2)' },
8183
contentType: 'darkShoppingCart',
8284
});

index.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ declare interface SwipeablePanelProps extends React.Props<SwipeablePanel> {
7979
*/
8080
smallPanelHeight?: number;
8181

82+
/**
83+
* Use this prop to override bar container style
84+
*/
85+
barContainerStyle?: object;
86+
8287
/**
8388
* Set true if you want to make toucable outside of panel
8489
*/

src/Bar.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ import { StyleSheet, View } from 'react-native';
33

44
type BarProps = {
55
barStyle?: object;
6+
barContainerStyle?: object;
67
};
78

8-
export const Bar = ({ barStyle }: BarProps) => {
9+
export const Bar = ({ barStyle, barContainerStyle }: BarProps) => {
910
return (
10-
<View style={BarStyles.barContainer}>
11+
<View style={[BarStyles.barContainer, barContainerStyle]}>
1112
<View style={[BarStyles.bar, barStyle]} />
1213
</View>
1314
);

src/Panel.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ type SwipeablePanelProps = {
4040
smallPanelHeight?: number;
4141
noBar?: boolean;
4242
barStyle?: object;
43+
barContainerStyle?: object,
4344
allowTouchOutside?: boolean;
4445
scrollViewProps?: ScrollViewProps;
4546
};
@@ -205,6 +206,7 @@ class SwipeablePanel extends Component<SwipeablePanelProps, SwipeablePanelState>
205206
noBackgroundOpacity,
206207
style,
207208
barStyle,
209+
barContainerStyle,
208210
closeRootStyle,
209211
closeIconStyle,
210212
onClose,
@@ -249,7 +251,7 @@ class SwipeablePanel extends Component<SwipeablePanelProps, SwipeablePanelState>
249251
]}
250252
{...this._panResponder.panHandlers}
251253
>
252-
{!this.props.noBar && <Bar barStyle={barStyle} />}
254+
{!this.props.noBar && <Bar barStyle={barStyle} barContainerStyle={barContainerStyle} />}
253255
{this.props.showCloseButton && (
254256
<Close rootStyle={closeRootStyle} iconStyle={closeIconStyle} onPress={this.props.onClose} />
255257
)}

src/typings.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ declare interface SwipeablePanelProps extends React.Props<SwipeablePanel> {
7676
* Use this prop to override the small panel default height
7777
*/
7878
smallPanelHeight?: number;
79+
/**
80+
* Use this prop to override bar container style
81+
*/
82+
barContainerStyle?: object;
7983

8084
/**
8185
* Set true if you want to make toucable outside of panel

0 commit comments

Comments
 (0)