0.1.2 • Published 4 years ago

react-native-popup-view v0.1.2

Weekly downloads
45
License
MIT
Repository
github
Last release
4 years ago

react-native-popup-view

A flexible way to show several types of popup views in React Native.

  • Easy to integrate, easy to use
  • Less code in component
  • Customizable in many ways

Example

npm.io

example/Main.js

Installation

If using yarn:

yarn add react-native-popup-view

If using npm:

npm i react-native-popup-view

Usage

Wrap App in the PopupProvider

import {PopupProvider} from 'react-native-popup';

export default function App() {
  return (
    <PopupProvider>
      <App />
    </PopupProvider>
  );
}

Declare with usePopup

import {usePopup} from 'react-native-popup';
...
const {showToast} = usePopup();
...
const onPress = () => {
  showToast({
    message: 'This is a toast',
    toastType: TOAST_TYPE.SUCCESS,
  });
};

Documentation

Generic params

NameTypeDescription
showOverlayBooleandisplay a gray translucent full screen overlay
disableDismissBooleandisable default touch to dismiss feature
onDismissStartFunctioncalled on the start of dismiss animation
onDismissEndFunctioncalled on the end of dismiss animation
onShowStartFunctioncalled on the start of display animation
onShowEndFunctioncalled on the end of display animation

Actionsheet Params

NameTypeDescription
optionsArrayan array of ActionSheetOption, which has title, subtitle, onPress and isDestructive
actionViewsArrayalternative to options, take a list of customized option view. It could be anything
headerViewReact elementheader view of the action sheet
containerStylestyle objectlayout style of the action sheet wrapper

ActionSheetOption Prams

NameTypeDescription
titleStringtitle of the action
subtitleStringsubtitle of the action
disabledBooleandetermine if this action is clickable
onPressFunctioncallback function
actionStylestyle objectstyle of the action view
actionTitleStylestyle objectstyle of title text
actionSubtitleStylestyle objectstyle of subtitle text

FloatingView Params

NameTypeDescription
anchorPointobjectcoordinate in the form of {x, y}
popupDirectionPOPUP_DIRECTIONtowards which direction the pop up view should be displayed
customViewReact elementthe actual view needs to be displayed

Modal Prams

NameTypeDescription
messageStringtext message shown in toast
customViewReact elementthe actual view needs to be displayed

Toast Params

NameTypeDescription
showDismissBooleandetermine dismiss button visibility. default true
toastTypeTOAST_TYPEone of the toast type with preset style
toastStylestyle objectcustomize toast style
durationIntegerduration before toast is dismissed, in milliseconds, default to 3000
positionTOAST_POSITIONtoast display position, default to top

Tooltip Params

NameTypeDescription
anchorPointobjectcoordinate in the form of {x, y}
popupDirectionPOPUP_DIRECTIONtowards which direction the pop up view should be displayed
textStringtext to be displayed in the tool tip
stylestyle objectcustomize tooltip style

Contributing

Pull requests are welcome! Open a new GitHub issue for any bug or suggestion.

Author

Xiao Ma

License

MIT