Code Monkey home page Code Monkey logo

react-native-modal-popover's Introduction

react-native-modal-popover

Pure JS popover component for react-native

Android iOS

About this module

The original react-native-popover is now outdated, so I decided to publish my own module to avoid using github url in my package.json. Something got lost in the process of rewriting, but now it uses Modal and native animation drivers, and also has cool helper to use with Touchables. Thanks to @jeanregisser and to the authors of hanging PRs for their code.

Requirements

Previously (version 0.0.6) this module required react version >16.2.0 to work (which corresponds to react-native version >0.52.0).

Version 0.0.7 does not reqire React.Fragment anymore, so you can use with reasonably old versions of react and react-native.

Install

yarn add react-native-modal-popover

Usage

This module exports two react components, Popover and PopoverController, and one react hook, usePopover. Popover works pretty much like original Popover, and PopoverController is a convenience component that uses React Render Props pattern.

Important this example uses React.Fragment to wrap children, but if you use react-native version older than 0.52, then you should reaplce React.Fragment with View

Using hook

usePopover is preferred modern way to have popover in your app.

import React from 'react';
import { Button, StyleSheet, Text, View } from 'react-native';
import { Popover, usePopover } from 'react-native-modal-popover';

const styles = StyleSheet.create({
  app: {
    ...StyleSheet.absoluteFillObject,
    alignItems: 'center',
    justifyContent: 'center',
    backgroundColor: '#c2ffd2',
  },
  content: {
    padding: 16,
    backgroundColor: 'pink',
    borderRadius: 8,
  },
  arrow: {
    borderTopColor: 'pink',
  },
  background: {
    backgroundColor: 'rgba(0, 0, 255, 0.5)',
  },
});

const App = () => {
  const {
    openPopover,
    closePopover,
    popoverVisible,
    touchableRef,
    popoverAnchorRect,
  } = usePopover();
  return (
    <View style={styles.app}>
      <Button title="Press me!" ref={touchableRef} onPress={openPopover} />
      <Popover
        contentStyle={styles.content}
        arrowStyle={styles.arrow}
        backgroundStyle={styles.background}
        visible={popoverVisible}
        onClose={closePopover}
        fromRect={popoverAnchorRect}
        supportedOrientations={['portrait', 'landscape']}>
        <Text>Hello from inside popover!</Text>
      </Popover>
    </View>
  );
};

export default App;

Using PopoverController

Use PopoverController if you cannot use hooks for some reason.

import React from 'react';
import { Button, StyleSheet, Text, View } from 'react-native';
import { Popover, PopoverController } from 'react-native-modal-popover';

const styles = StyleSheet.create({
  app: {
    ...StyleSheet.absoluteFillObject,
    alignItems: 'center',
    justifyContent: 'center',
    backgroundColor: '#c2ffd2',
  },
  content: {
    padding: 16,
    backgroundColor: 'pink',
    borderRadius: 8,
  },
  arrow: {
    borderTopColor: 'pink',
  },
  background: {
    backgroundColor: 'rgba(0, 0, 255, 0.5)',
  },
});

const App = () => (
  <View style={styles.app}>
    <PopoverController>
      {({
        openPopover,
        closePopover,
        popoverVisible,
        setPopoverAnchor,
        popoverAnchorRect,
      }) => (
        <React.Fragment>
          <Button
            title="Press me!"
            ref={setPopoverAnchor}
            onPress={openPopover}
          />
          <Popover
            contentStyle={styles.content}
            arrowStyle={styles.arrow}
            backgroundStyle={styles.background}
            visible={popoverVisible}
            onClose={closePopover}
            fromRect={popoverAnchorRect}
            supportedOrientations={['portrait', 'landscape']}>
            <Text>Hello from inside popover!</Text>
          </Popover>
        </React.Fragment>
      )}
    </PopoverController>
  </View>
);

export default App;

Props

Popover

Prop Type Optional Default Description
visible bool Yes false Show/Hide the popover
fromRect Rect No* Rectangle at which to anchor the popover. Optional when used inside PopoverTouchable, required when used standalone. If you set this property, you should also change it when screen orientation changes.
displayArea Rect Yes Screen - 10px padding Area where the popover is allowed to be displayed. Important note: if you use non-default value here and you want to handle screen orientation changes, it is your responsibility to change this value when screen orientation changes.
placement string Yes 'auto' How to position the popover - top | bottom | start | end | auto. When 'auto' is specified, it will determine the ideal placement so that the popover is fully visible within displayArea.
onClose function Yes Callback to be fired when the user closes the popover
onDismiss function Yes Callback to be fired after the popup closes
backgroundStyle ViewStyle Yes Custom style to be applied to background overlay
contentStyle ViewStyle Yes Custom style to be applied to popover reactangle. Use it to set round corners, background color, etc.
arrowStyle ViewStyle Yes Custom style to be applied to popover arrow. Use borderTopColor to match content backgroundColor
duration number Yes 300 Animation duration
easing (show: boolean) => (value: number) => number Yes show => show ? Easing.out(Easing.back(1.70158)) : Easing.inOut(Easing.quad) Function that returns easing function for show or hide animation, depending on show argument
useNativeDriver bool Yes false Defines if animations should use native driver
supportedOrientations array of enum('portrait', 'portrait-upside-down', 'landscape', 'landscape-left', 'landscape-right') Yes This prop is passed to react-native Modal, see react-native docs. Set this to ['portrait', 'landscape'] if you want your popover to resprect screen orientation.
calculateStatusBar bool Yes false Defines if while use status bar height while calculating "Y" origin of anchor.

PopoverController and usePopover hook

PopoverController accepts function as children. This function is called with one argument of type PopoverControllerRenderProps and returns react element. The children of this element are your UI handle to open popover (Button, Toggle, whatever) and Popover element itself. Pass properties to you handle and Popover, and PopoverController will make them work together behind the scenes. All the props are required to make controller work.

usePopover returns object with same props as PopoverControllerRenderProps, except that ref has different name: touchableRef.

PopoverControllerRenderProps:

Prop Type Description
openPopover () => void Call this function when you want to open popover, e.g. pass to onPress of a Button
closePopover () => void Call this function when you want to close popover. Typically you pass this as onClose prop of Popover, which will make popover close when tapped outside. If you have a button inside popover which should close the popover, pass this function to this button.
popoverVisible boolean Pass this to visible prop of Popover component
setPopoverAnchor (PopoverController) / touchableRef (usePopover) ref function Pass this as ref to popover UI handle. This will bind popover display position to the position of this UI handle.
popoverAnchorRect Rect Pass this as fromRect prop of Popover component

Rect

Rect is an object with the following properties: {x: number, y: number, width: number, height: number}

Using without PopoverController

In this case you have to handle refs, measure UI handle and manage popover visibility manually:

import React from 'react';
import {
  findNodeHandle,
  NativeModules,
  StyleSheet,
  Text,
  View,
} from 'react-native';
import Button from './Button';
import Popover from './popover';

const styles = StyleSheet.create({
  app: {
    ...StyleSheet.absoluteFillObject,
    padding: 10,
    backgroundColor: '#c2ffd2',
    alignItems: 'center',
  },
});

export default class App2 extends React.Component {
  state = {
    showPopover: false,
    popoverAnchor: { x: 0, y: 0, width: 0, height: 0 },
  };

  setButton = (e) => {
    const handle = findNodeHandle(this.button);
    if (handle) {
      NativeModules.UIManager.measure(handle, (x0, y0, width, height, x, y) => {
        this.setState({ popoverAnchor: { x, y, width, height } });
      });
    }
  };

  openPopover = () => {
    this.setState({ showPopover: true });
  };

  closePopover = () => this.setState({ showPopover: false });

  render() {
    return (
      <View style={styles.app}>
        <Button
          ref={(r) => {
            this.button = r;
          }}
          icon="arrow-up"
          onPress={this.openPopover}
          onLayout={this.setButton}
        />
        <Popover
          visible={this.state.showPopover}
          fromRect={this.state.popoverAnchor}
          onClose={this.closePopover}
          placement="bottom">
          <Text>Hi</Text>
        </Popover>
      </View>
    );
  }
}

Contributing

If you want to add some features, feel free to submit PR.

react-native-modal-popover's People

Contributors

bang88 avatar doomsower avatar droidmakk avatar mak12 avatar semantic-release-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

react-native-modal-popover's Issues

Not able to close the popover with PopoverTouchable

When I click on the icon the popover works perfectly. But after click on some item even I changed the visible property the popover remains visible.

<PopoverTouchable> <Icon style = {Styles.sortInfoViewItemText } name= "envelope" /> <Popover ref = {(ref) => this._popover = ref} placement = 'left' visible = {this.state.visible}> <View style = {Styles.popOverContentView}> <Text onPress = {() => this._copyContent(email)} > Copy</Text> <Text onPress = {() => this._sendEmail(email)} >Send Mail</Text> </View> </Popover> </PopoverTouchable>

This is my _copyContent method.

_copyContent(info) { this.setState({visible:false}); Clipboard.setString(info); return; }

Please help me to fix this.

No declaration of module 'react-native-modal-popover' error, when trying to use the dependency on a .tsx file

No declaration of module 'react-native-modal-popover' error, when trying to use the dependency on a .tsx file

I created a .tsx file and checked for index.d.ts in the node modules, I saw it . I then when ahead to import Popover , PopoverController from 'react-native-modal-popover' but it gives me the error Cannot find module 'react-native-modal-popover'
Could not find a declaration file for module 'react-native-modal-popover'. 'c:/Users/react-native-typescript/node_modules/react-native-modal-popover/lib/index.js' implicitly has an 'any' type.
Try npm install @types/react-native-modal-popover if it exists or add a new declaration (.d.ts) file containing declare module 'react-native-modal-popover';

Error of typing. Need update

StyleSheet.create of React Native return RegisteredStyle<ViewStyle | TextStyle | ImageStyle>(^0.57.*)
and error of typescript occurs Type 'Registered Style<ViewStyle | Image Style | Text Style>' has no properties in common with type 'ViewStyle'.

Current typings
backgroundStyle?: ViewStyle;
arrowStyle: ViewStyle;
popoverStyle?: ViewStyle;
contentStyle: ViewStyle;

On Android, the status bar theme changes to light when the popover is active

RN: 0.55.4

Code:

// (...)

export class InfoPopover extends PureComponent<Props> {
  static defaultProps = {
    style: {},
  };
  static styles = StyleSheet.create({
    infoButton: {
      paddingLeft: 6,
      color: colors.ink,
    },
    popoverContent: {
      padding: 12,
      backgroundColor: colors.ink,
      borderRadius: 4,
      width: 230,
      shadowOpacity: 0.25,
      shadowRadius: 4,
      shadowOffset: {
        width: 0,
        height: 0,
      },
      elevation: 2,
    },
    popoverText: {
      color: colors.white,
    },
    popoverArrow: {
      display: 'none',
      borderTopColor: 'transparent',
    },
    popoverBackground: {
      backgroundColor: 'transparent',
    },
  });

  render() {
    const { message, style } = this.props;
    const { styles } = InfoPopover;
    return (
      <PopoverController>
        {({ openPopover, closePopover, popoverVisible, setPopoverAnchor, popoverAnchorRect }) => ([
          <View key="button" style={style}>
            <TouchableWithoutFeedback
              hitSlop={{ top: 1, bottom: 1, left: 1, right: 1 }}
              ref={setPopoverAnchor}
              onPress={openPopover}
            >
              <Header style={styles.infoButton}>
                {popoverVisible ? TextIcons.InfoInverted : TextIcons.Info}
              </Header>
            </TouchableWithoutFeedback>
          </View>,
          <Popover
            key="popover"
            contentStyle={styles.popoverContent}
            arrowStyle={styles.popoverArrow}
            backgroundStyle={styles.popoverBackground}
            placement="left"
            visible={popoverVisible}
            onClose={closePopover}
            fromRect={popoverAnchorRect}
            easing={() => Easing.inOut(Easing.quad)}
          >
            <Subtitle style={styles.popoverText}>{message}</Subtitle>
          </Popover>,
        ])}
      </PopoverController>
    );
  }
}

Popover ScrollView Child Can't Scroll – Android Only

Scrolling working fine on iOS, but not working on Android.

Scrollview is a direct child component inside of Popover.

TouchableOpacity inside of Popover works fine, so i know that it is receiving touch events. However there aren't any ScrollView events registered on Android like onScrollBeginDrag. Scrolling does not work.

Have tried all the tricks like setting flex, setting height, messing around with all the ScrollView and Popover props to see if anything fixes it, but can't find any solution.

Has anybody been able to make Popover with ScrollView child component work on Android? Thanks!

gap between arrow and popoverbox w/ border radius

When I add a border radius to the popover box, there is a few px gap between it and the arrow. I've tried adding a border to the box and/or arrow to no avail. It is pretty subtle but noticeable.
Can I move the arrow down or left?
Thanks

<Popover
    backgroundStyle={ styles.background }
    contentStyle={ styles.popoverContent }
    fromRect={ popoverAnchorRect }
    onClose={ closePopover }
    placement="left"
    supportedOrientations={ ['portrait', 'landscape'] }
    visible={ popoverVisible }
>
styles = {
    popoverContent: {
        borderRadius: 8
    }
}

screen shot 2018-11-28 at 11 27 00 am

Is it just horizontal screen?

When the horizontal screen display will switch back to vertical screen directly.

  • react 16.2.0
  • react-native 0.53.3
  • react-native-modal-popover v0.0.5

PopOver not showing when manually making visible flag to true

Screen Shot 2021-09-06 at 6 24 23 PM

I wanna make this tooltip to be visible all time, not only when the button is clicked. So, I make the visible flag to true. But it's not working. Could anyone help me resolve it? Here is code sandbox **https://codesandbox.io/s/react-native-web-forked-3q100?file=/src/App.js**

componentWillReceiveProps deprecation warning

old lifecycle method is used:

Popover.prototype.componentWillReceiveProps = function (nextProps) { var _this = this; var willBeVisible = nextProps.visible; var _a = this.props, visible = _a.visible, fromRect = _a.fromRect, displayArea = _a.displayArea; if (willBeVisible !== visible) { if (willBeVisible) { this.setState({ contentSize: { width: 0, height: 0 }, isAwaitingShow: true, visible: true }); } else { this.startAnimation(false); } } else if (willBeVisible && (fromRect !== nextProps.fromRect || displayArea !== nextProps.displayArea)) { var geom = this.computeGeometry(nextProps, this.state.contentSize); var isAwaitingShow_2 = this.state.isAwaitingShow; this.setState(__assign({}, geom), function () { if (isAwaitingShow_2) { _this.startAnimation(true); } }); } };

This should be changed to componentDidUpdate

Modal not displaying after navigating from react-native-modal-popover

I have a screen in which I have added a component called <Loader />. This <Loader /> component renders the a modal, which contains the ActivityIndicator. Basically <Loader /> component renders the ActivityIndicator in react-native modal to displays the loading in full screen. Now, If I come in screen where <Loader /> component is added from StackNavigator or elsewhere then it displays the loading ActivityIndicator.

But the problem is that, if I navigate to screen where this <Loader /> component is added, from react-native-modal-popover then <Loader /> component does not displaying the ActivityIndicator. Actually Modal is not displaying.

Here is the problem explanation gif :

ezgif com-video-to-gif (1)

As you can see, If I navigate to screen from some of list item then modal is displayed with ActivityIndicator but if I navigate from react-native-modal-popover then modal is not displaying.

How to solve it ?

Popover not shown when wrapping Switch

Popover not shown on tap when wrapping Switch. If I change Switch to Text it works fine.

<View style={style}>
        <PopoverTouchable>
            <Switch
              onValueChange={onValueChange}
              value={state}
            />
          <Popover
            placement="top"
            contentStyle={styles.popoverContent}
            arrowStyle={styles.popoverArrow}
            backgroundStyle={styles.popoverBackground}>
            <Tooltip style={styles.tooltip} title={title} state={state} description={description} />
          </Popover>
        </PopoverTouchable>
 </View>

How to show in center of screen

it is working perfectly. i am facing issue to get value of x,y,widh and height.

can someone help me to show middle of screen ?

Popover anchor not being anchored with orientation change

Hello, when I switch orientation the popover seems to be anchored to the coordinates initially rendered on the app startup. If I start in portrait mode it will be anchored correctly then switching to landscape will place the popover with the same coordinates as portrait mode (leaving it in an awkward place on the screen). This occurs for me on android and iOS.

popovermodallandscape
popovermodalportrait

The only change I made to Popover.js was to add the supported orientations otherwise the whole screens orientation would not rotate. <react_native_1.Modal transparent visible={this.state.visible} onRequestClose={this.props.onClose} supportedOrientations={['portrait', 'landscape']}>
popovermodalsidewaysportrait

setButton = (e) => {
const handle = findNodeHandle(this.button);
if (handle) {
NativeModules.UIManager.measure(handle, (x0, y0, width, height, x, y) => {
this.setState({ popoverAnchor: { x, y, width, height } });
});
console.log(this.state.popoverAnchor);
}
};
...
render() {
return (

<PopoverTouchable onPopoverDisplayed={() => console.log(this.state.popoverAnchor)}>
<Button
buttonRef={ (c) => (this.button = c) }
style={{ alignSelf: 'center' }}
onPress={() => this.setState({ showPopover: true })}
onLayout={this.setButton.bind(this)}
>
Filters

<Popover
visible={this.state.showPopover}
fromRect={this.state.popoverAnchor}
contentStyle={styles.content}
arrowStyle={styles.arrow}
backgroundStyle={styles.background}
onClose={() => this.setState({ showPopover: false })}
placement='bottom'
>
...


yandex-map-kit

Добрый день, попробовали подключать ваш репозиторий по работе с яндекс картами, но сама карта не отображается. Не планируется ли обновление библиотеки? Возможно за дополнительное финансирование. Дайте, пожалуйста, обратную связь.
[email protected]
[email protected]

Good afternoon, tried to connect your repository to work with Yandex maps, but the map itself is not displayed. Are there any plans to update the library? Perhaps for additional funding. Please give feedback.

Making the background overlay optional

I have a use-case where I want to use a small close button (like an "x") in the top right corner of the popover, instead of using the overlay to close. I can add the button, but I can't get rid of the overlay.

I propose to make it optional to use the overlay (using a prop on Popover). I've taken a look at the source code, and could probably provide a PR for this. But do you think it will work, and is it a "general" enough feature to add?

arrowStyle not work

menuArrow: {
        borderTopColor: 'white',
        width:6,
        height:3
    }

set color will work,
but set size (width,height) not work

Visible prop is not working.

Hi sir visible prop is not working. Any example sir for visible prop? I cannot get working on my side. Here is my code:

<PopoverTouchable onPopoverDisplayed={() => console.log('show')}> <TouchableOpacity style={styles.profileAction_btn}> <MyIcon name='report' color='#fff' size={22}/> </TouchableOpacity> <Popover placement='left' contentStyle={styles.content} arrowStyle={styles.arrow} backgroundStyle={styles.background} visible={this.state.visible} > <TouchableOpacity style={styles.reportBtn}> <Text style={[styles.txtWhite, styles.font_medium]}>Block User</Text> </TouchableOpacity> <TouchableOpacity style={styles.reportBtn} onPress={() => { this.setState({ visible: false }) }}> <Text style={[styles.txtWhite, styles.font_medium]}>Report User</Text> </TouchableOpacity> </Popover> </PopoverTouchable>

Update remove deprecated function removeEventListener

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-modal-popover/lib/PopoverController.js b/node_modules/react-native-modal-popover/lib/PopoverController.js
index 005c07f..9a0eb11 100644
--- a/node_modules/react-native-modal-popover/lib/PopoverController.js
+++ b/node_modules/react-native-modal-popover/lib/PopoverController.js
@@ -62,10 +62,10 @@ class PopoverController extends React.PureComponent {
         this.closePopover = () => this.setState({ showPopover: false });
     }
     componentDidMount() {
-        react_native_1.Dimensions.addEventListener('change', this.onOrientationChange);
+        this.listener = react_native_1.Dimensions.addEventListener('change', this.onOrientationChange);
     }
     componentWillUnmount() {
-        react_native_1.Dimensions.removeEventListener('change', this.onOrientationChange);
+		this.listener?.remove?.();
     }
     render() {
         return this.props.children({
diff --git a/node_modules/react-native-modal-popover/lib/usePopover.js b/node_modules/react-native-modal-popover/lib/usePopover.js
index 75cc72a..820f98d 100644
--- a/node_modules/react-native-modal-popover/lib/usePopover.js
+++ b/node_modules/react-native-modal-popover/lib/usePopover.js
@@ -45,9 +45,9 @@ function usePopover(calculateStatusBar = false) {
                 requestAnimationFrame(openPopover);
             }
         };
-        react_native_1.Dimensions.addEventListener('change', onOrientationChange);
+        const listener = react_native_1.Dimensions.addEventListener('change', onOrientationChange);
         return () => {
-            react_native_1.Dimensions.removeEventListener('change', onOrientationChange);
+			listener?.remove?.();
         };
     }, [showPopover, openPopover]);
     return result;

This issue body was partially generated by patch-package.

How to set align for content of Popoper

I'm using prop visible to controll open/hide of popoper but I can't align for content to center , My code:
render() {
return (
<Popover
visible={this.state.visible}
contentStyle={styles.tooltipContent}
arrowStyle={styles.tooltipArrow}
backgroundStyle={styles.tooltipBg}
placement = {"bottom"}
fromRect={{x: this.state.x, y: this.state.y, width: this.state.width, height: this.state.height}}
>


)
}
tooltipBg :{
backgroundColor:"rgba(0,0,0,0.3)",
alignItems:"center",
},

tooltipArrow :{
backgroundColor:"rgba(0,0,0,0)"
},

tooltipContent :{
width : "90%",
backgroundColor: 'white',
borderRadius: 8,
alignSelf:"center"
},
screen shot 2017-11-04 at 1 01 19 am

iPhone file manager

When I open the file selection mode box on the iPhone, the operation time Close popover forces the file selection mode box to close

when change the arrow style, can't replace transform style

Screen Shot 2021-01-05 at 09 45 38

have line between top and right with this style `arrowStyle: { borderRightColor: '#FFFFFF', borderTopColor: '#FFFFFF', }`

need like this style in below to not have line in between
arrowStyle: { borderLeftColor: '#FFFFFF', borderTopColor: 'transparent', borderBottomColor: '#FFFFFF', transform: [{rotate: '180deg'}] }

Update deprecated function removeEventListener

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-modal-popover/lib/usePopover.js b/node_modules/react-native-modal-popover/lib/usePopover.js
index 75cc72a..820f98d 100644
--- a/node_modules/react-native-modal-popover/lib/usePopover.js
+++ b/node_modules/react-native-modal-popover/lib/usePopover.js
@@ -45,9 +45,9 @@ function usePopover(calculateStatusBar = false) {
                 requestAnimationFrame(openPopover);
             }
         };
-        react_native_1.Dimensions.addEventListener('change', onOrientationChange);
+        const listener = react_native_1.Dimensions.addEventListener('change', onOrientationChange);
         return () => {
-            react_native_1.Dimensions.removeEventListener('change', onOrientationChange);
+			listener?.remove?.();
         };
     }, [showPopover, openPopover]);
     return result;

This issue body was partially generated by patch-package.

Return array instead of wrapping view

With React 16 it is no longer necessary to return an empty view wrapping a list of elements. Instead we can return an array on the render method of PopoverTouchable. This is favorable as an empty view might screw up styles.

iOS - onClose not firing on background tap

When tapping on the background to close the popover, onClose does not fire on iOS. Is this an expected behaviour?

Conversely, if you don't define onClose as a prop, tapping the background still closes the popover.

show drop shadow on Android

hey there! found this commit when searching the repo for "shadow", just wondering if there is a way to style the Popover in order to enable drop shadow on Android. Have tried to passing in my own popoverStyle to Popover, based on your IOS specific code in that commit, with no success.

popoverStyle contained:

shadowColor: 'black',
shadowOffset: { width: 0, height: 2 },
shadowRadius: 2,
shadowOpacity: 0.4,
backgroundColor: 'transparent',

Can definitely find another way to do this, just wondering if there's a supported method, thanks for your time :)

In Android getting Blur layer on childrens of PopOverController

In Android The Button and popOverView gets blured in android but its is working fine in iOS.

<PopoverController> {({ openPopover, closePopover, popoverVisible, setPopoverAnchor, popoverAnchorRect }) => ( <React.Fragment> <View> <View style={styles.vwLike}> <TouchableOpacity style={{ marginTop: -20, height: 80 }} ref={setPopoverAnchor} delayPressIn={1000} onPress={openPopover}> {reactionId != null && (reactionId.length != 0 && reactionId != "0") ? <Text style={{ fontSize: 30, height: 40, marginTop: 30 }}>{getReactionNumber()}</Text> : <CustomImage style={styles.imgLike} source={require('../../../assets/Images/ic_like/ic_like.png')} /> } </TouchableOpacity> <Text style={styles.txtLike}>{likeCount}</Text> </View> <Popover contentStyle={popoverStyle.content} arrowStyle={popoverStyle.arrow} backgroundStyle={popoverStyle.background} visible={popoverVisible} onClose={closePopover} fromRect={popoverAnchorRect} supportedOrientations={['portrait', 'landscape']} > <View style={{ flexDirection: 'row', justifyContent: 'space-around' }}> <TouchableOpacity delayPressIn={1000} onPress={() => { closePopover() onReactionClick(1) }}> <Text style={styles.emojiStyle}>{String.fromCodePoint(128077)}</Text> </TouchableOpacity> <TouchableOpacity delayPressIn={1000} onPress={() => { closePopover() onReactionClick(2) }}> <Text style={[styles.emojiStyle, { marginLeft: 5 }]}>{String.fromCodePoint(128525)}</Text> </TouchableOpacity> <TouchableOpacity delayPressIn={1000} onPress={() => { closePopover() onReactionClick(3) }}> <Text style={[styles.emojiStyle, { marginLeft: 5 }]}>{String.fromCodePoint(128518)}</Text> </TouchableOpacity> <TouchableOpacity delayPressIn={1000} onPress={() => { closePopover() onReactionClick(4) }}> <Text style={[styles.emojiStyle, { marginLeft: 5 }]}>{String.fromCodePoint(128559)}</Text> </TouchableOpacity> <TouchableOpacity delayPressIn={1000} onPress={() => { closePopover() onReactionClick(5) }}> <Text style={[styles.emojiStyle, { marginLeft: 5 }]}>{String.fromCodePoint(128578)}</Text> </TouchableOpacity> <TouchableOpacity delayPressIn={1000} onPress={() => { closePopover() onReactionClick(6) }}> <Text style={[styles.emojiStyle, { marginLeft: 5 }]}>{String.fromCodePoint(128533)}</Text> </TouchableOpacity> <TouchableOpacity delayPressIn={1000} onPress={() => { closePopover() onReactionClick(7) }}> <Text style={[styles.emojiStyle, { marginLeft: 5 }]}>{String.fromCodePoint(128546)}</Text> </TouchableOpacity> <TouchableOpacity delayPressIn={1000} onPress={() => { closePopover() onReactionClick(8) }}> <Text style={[styles.emojiStyle, { marginLeft: 5 }]}>{String.fromCodePoint(128545)}</Text> </TouchableOpacity> </View> </Popover> </View> </React.Fragment> )} </PopoverController>

Modal Border Excludes Arrow

When setting a border on the modal using the contentStyle, the border should wrap around the indicator triangle, currently it does not, and it splits the view:

Expected Result:
screen shot 2018-06-22 at 2 53 03 pm

Actual Result:
screen shot 2018-06-22 at 2 53 48 pm

Code:
<Popover placement="bottom" contentStyle={{ borderWidth: 2, borderRadius: 6, borderColor: '#9A9A9A', padding: 0, }} visible={popoverVisible} onClose={closePopover} fromRect={popoverAnchorRect} supportedOrientations={['portrait', 'landscape']} >

how to use Popover alone? it's props visible do not work when use it alone!

//here is my code i use Popover alone but the visible prop don't work!And i can't see it on my device!!!
import React from 'react';
import { Button, StyleSheet, Text, View } from 'react-native';
import Popover, { PopoverTouchable } from 'react-native-modal-popover';

const styles = StyleSheet.create({
app: {
...StyleSheet.absoluteFillObject,
alignItems: 'center',
justifyContent: 'center',
backgroundColor: '#c2ffd2',
flex:1,
},
content: {
padding: 16,
backgroundColor: 'pink',
borderRadius: 8,
},
arrow: {
borderTopColor: 'pink',
},
background: {
backgroundColor: 'rgba(0, 0, 255, 0.5)'
},
});

const App = () => (

  <Popover
    contentStyle={styles.content}
    arrowStyle={styles.arrow}
    backgroundStyle={styles.background}
    visible={true}
    fromRect={ {x:0, y:0, width:100, height:100} }
  >
    <Text>Hello from inside popover!</Text>
  </Popover>

);

export default App;

Allow usage of other animation libraries

At the moment, the module uses its own animation for the popover, making it impossible to use another library like React Move or React Motion. Is it possible to refactor to allow custom animations, or at least to disable the built in animation so that other libraries could be used?

When popover is visible, status bar is shown

In my app I've decided to hide the status bar but when I click on a button to show a popover, the status bar is shown.

React 16.2.0
React native 0.52.2
react-native-modal-popover 0.0.5

How to close popover on button click

I have a CANCEL button on popover, and I'm trying to close it when its open on CANCEL click. Any tips how. Tried combinig state and visible prop, but that doesn't seem to work

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.