Skip to content

Commit

Permalink
feat: add support to barContainerStyle prop (#109)
Browse files Browse the repository at this point in the history
  • Loading branch information
PitzTech authored Dec 31, 2021
1 parent 1a926a1 commit d5b921b
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 9 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export default App = () => {
| **closeIconStyle** | `Object` | Use this prop to override close button icon style | `{}` |
| **barStyle** | `Object` | Use this prop to override bar style | `{}` |
| **smallPanelHeight** | `Object` | Use this prop to override the small panel default height | |
| **barContainerStyle** | `Object` | Use this prop to override bar container style | `{}` |
| **closeOnTouchOutside** | `bool` | Set true if you want to close panel by touching outside | `false` |
| **allowTouchOutside** | `bool` | Set true if you want to make toucable outside of panel | `false` |
| **noBar** | `bool` | Set true if you want to remove gray bar | `false` |
Expand Down
11 changes: 6 additions & 5 deletions example/src/components/Panel/Bar.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import React from 'react';
import {StyleSheet, View} from 'react-native';
import * as React from 'react';
import { StyleSheet, View } from 'react-native';

type BarProps = {
barStyle?: Object;
barStyle?: object;
barContainerStyle?: object;
};

export const Bar = ({barStyle}: BarProps) => {
export const Bar = ({ barStyle, barContainerStyle }: BarProps) => {
return (
<View style={BarStyles.barContainer}>
<View style={[BarStyles.barContainer, barContainerStyle]}>
<View style={[BarStyles.bar, barStyle]} />
</View>
);
Expand Down
4 changes: 3 additions & 1 deletion example/src/components/Panel/Panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type SwipeablePanelProps = {
smallPanelHeight?: number;
noBar?: boolean;
barStyle?: object;
barContainerStyle?: object;
allowTouchOutside?: boolean;
scrollViewProps?: ScrollViewProps;
};
Expand Down Expand Up @@ -205,6 +206,7 @@ class SwipeablePanel extends Component<SwipeablePanelProps, SwipeablePanelState>
noBackgroundOpacity,
style,
barStyle,
barContainerStyle,
closeRootStyle,
closeIconStyle,
onClose,
Expand Down Expand Up @@ -249,7 +251,7 @@ class SwipeablePanel extends Component<SwipeablePanelProps, SwipeablePanelState>
]}
{...this._panResponder.panHandlers}
>
{!this.props.noBar && <Bar barStyle={barStyle} />}
{!this.props.noBar && <Bar barStyle={barStyle} barContainerStyle={barContainerStyle} />}
{this.props.showCloseButton && (
<Close rootStyle={closeRootStyle} iconStyle={closeIconStyle} onPress={this.props.onClose} />
)}
Expand Down
2 changes: 2 additions & 0 deletions example/src/hooks/useSwipeablePanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const useSwipeablePanel = () => {
onlySmall: false,
allowTouchOutside: false,
barStyle: {},
barContainerStyle: {},
style: {},
closeRootStyle: {},
contentType: null,
Expand Down Expand Up @@ -77,6 +78,7 @@ const useSwipeablePanel = () => {
noBar: false,
style: { backgroundColor: '#1f1f1f' },
barStyle: { backgroundColor: 'rgba(255,255,255,0.2)' },
barContainerStyle: { backgroundColor: '#1f1f1f' },
closeRootStyle: { backgroundColor: 'rgba(255,255,255,0.2)' },
contentType: 'darkShoppingCart',
});
Expand Down
5 changes: 5 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ declare interface SwipeablePanelProps extends React.Props<SwipeablePanel> {
*/
smallPanelHeight?: number;

/**
* Use this prop to override bar container style
*/
barContainerStyle?: object;

/**
* Set true if you want to make toucable outside of panel
*/
Expand Down
5 changes: 3 additions & 2 deletions src/Bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ import { StyleSheet, View } from 'react-native';

type BarProps = {
barStyle?: object;
barContainerStyle?: object;
};

export const Bar = ({ barStyle }: BarProps) => {
export const Bar = ({ barStyle, barContainerStyle }: BarProps) => {
return (
<View style={BarStyles.barContainer}>
<View style={[BarStyles.barContainer, barContainerStyle]}>
<View style={[BarStyles.bar, barStyle]} />
</View>
);
Expand Down
4 changes: 3 additions & 1 deletion src/Panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type SwipeablePanelProps = {
smallPanelHeight?: number;
noBar?: boolean;
barStyle?: object;
barContainerStyle?: object,
allowTouchOutside?: boolean;
scrollViewProps?: ScrollViewProps;
};
Expand Down Expand Up @@ -205,6 +206,7 @@ class SwipeablePanel extends Component<SwipeablePanelProps, SwipeablePanelState>
noBackgroundOpacity,
style,
barStyle,
barContainerStyle,
closeRootStyle,
closeIconStyle,
onClose,
Expand Down Expand Up @@ -249,7 +251,7 @@ class SwipeablePanel extends Component<SwipeablePanelProps, SwipeablePanelState>
]}
{...this._panResponder.panHandlers}
>
{!this.props.noBar && <Bar barStyle={barStyle} />}
{!this.props.noBar && <Bar barStyle={barStyle} barContainerStyle={barContainerStyle} />}
{this.props.showCloseButton && (
<Close rootStyle={closeRootStyle} iconStyle={closeIconStyle} onPress={this.props.onClose} />
)}
Expand Down
4 changes: 4 additions & 0 deletions src/typings.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ declare interface SwipeablePanelProps extends React.Props<SwipeablePanel> {
* Use this prop to override the small panel default height
*/
smallPanelHeight?: number;
/**
* Use this prop to override bar container style
*/
barContainerStyle?: object;

/**
* Set true if you want to make toucable outside of panel
Expand Down

0 comments on commit d5b921b

Please sign in to comment.