Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add statusBarTranslucent modal prop to fix issue with the backdrop no… #153

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
7 changes: 6 additions & 1 deletion src/tooltip.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ declare module 'react-native-walkthrough-tooltip' {
childrenWrapperStyle?: StyleProp<ViewStyle>;

// Styles the view element that wraps the original children
parentWrapperStyle?: StyleProp<ViewStyle>
parentWrapperStyle?: StyleProp<ViewStyle>;
}

export interface TooltipProps extends Partial<TooltipStyleProps> {
Expand Down Expand Up @@ -129,6 +129,11 @@ declare module 'react-native-walkthrough-tooltip' {

/** Will use given component instead of default react-native Modal component **/
modalComponent?: object;

/**
*Set this to true to use translucent status bar (cover enire screen on android)
*/
statusBarTranslucent?: boolean;
}

/**
Expand Down
29 changes: 16 additions & 13 deletions src/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ const DEFAULT_DISPLAY_INSETS = {
right: 24,
};

const computeDisplayInsets = insetsFromProps =>
const computeDisplayInsets = (insetsFromProps) =>
Object.assign({}, DEFAULT_DISPLAY_INSETS, insetsFromProps);

const invertPlacement = placement => {
const invertPlacement = (placement) => {
switch (placement) {
case 'top':
return 'bottom';
Expand Down Expand Up @@ -75,6 +75,8 @@ class Tooltip extends Component {
useReactNativeModal: true,
topAdjustment: 0,
accessible: true,
statusBarTranslucent: false,
animationType: 'fade',
};

static propTypes = {
Expand Down Expand Up @@ -105,6 +107,8 @@ class Tooltip extends Component {
useReactNativeModal: PropTypes.bool,
topAdjustment: PropTypes.number,
accessible: PropTypes.bool,
statusBarTranslucent: PropTypes.bool,
animationType: PropTypes.oneOf(['none', 'fade', 'slide']),
};

constructor(props) {
Expand Down Expand Up @@ -208,7 +212,7 @@ class Tooltip extends Component {
return null;
}

updateWindowDims = dims => {
updateWindowDims = (dims) => {
this.setState(
{
windowDims: dims.window,
Expand Down Expand Up @@ -237,15 +241,15 @@ class Tooltip extends Component {
);
};

measureContent = e => {
measureContent = (e) => {
const { width, height } = e.nativeEvent.layout;
const contentSize = new Size(width, height);
this.setState({ contentSize }, () => {
this.computeGeometry();
});
};

onChildMeasurementComplete = rect => {
onChildMeasurementComplete = (rect) => {
this.setState(
{
childRect: rect,
Expand All @@ -272,7 +276,7 @@ class Tooltip extends Component {
(x, y, width, height, pageX, pageY) => {
const childRect = new Rect(pageX, pageY, width, height);
if (
Object.values(childRect).every(value => value !== undefined)
Object.values(childRect).every((value) => value !== undefined)
) {
this.onChildMeasurementComplete(childRect);
} else {
Expand Down Expand Up @@ -300,13 +304,8 @@ class Tooltip extends Component {

computeGeometry = () => {
const { arrowSize, childContentSpacing } = this.props;
const {
childRect,
contentSize,
displayInsets,
placement,
windowDims,
} = this.state;
const { childRect, contentSize, displayInsets, placement, windowDims } =
this.state;

const options = {
displayInsets,
Expand Down Expand Up @@ -446,6 +445,8 @@ class Tooltip extends Component {
isVisible,
useReactNativeModal,
modalComponent,
statusBarTranslucent,
animationType,
} = this.props;

const hasChildren = React.Children.count(children) > 0;
Expand All @@ -456,10 +457,12 @@ class Tooltip extends Component {
<React.Fragment>
{useReactNativeModal ? (
<ModalComponent
animationType={this.props.animationType}
transparent
visible={showTooltip}
onRequestClose={this.props.onClose}
supportedOrientations={this.props.supportedOrientations}
statusBarTranslucent={statusBarTranslucent}
>
{this.renderContentForTooltip()}
</ModalComponent>
Expand Down