0.0.21 • Published 6 years ago

@paraboly/react-native-generic-modal v0.0.21

Weekly downloads
-
License
MIT
Repository
github
Last release
6 years ago

Fully customizable Generic Modal via Paraboly for React Native.

npm version npm Platform - Android and iOS License: MIT styled with prettier

Installation

Add the dependency:

npm i @paraboly/react-native-generic-modal

Peer Dependencies

IMPORTANT! You need install them.
"lodash": "^4.17.x",
"react": ">= 16.x",
"react-native": ">= 0.55.x",
"react-native-easy-grid": ">= 0.2.1",
"react-native-custom-icon": ">= x.x.x",
"react-native-vector-icons": ">= 6.x.x",
"react-native-dynamic-vector-icons": ">= x.x.x",
"react-native-floating-action-button": ">= x.x.x"

Basic Usage

<GenericModal />

Advanced Usage

<GenericModal
  isOpen={true}
  backdrop
  title="Title"
  ref="testModal"
  refName="testModal"
  context="Test Modal"
  generateButtons={this.getButtons()}
  contextTextStyle={styles.contextTextStyle}
  backgroundColor={colors.theme.light.default}
/>

Configuration - Props

PropertyTypeDefaultDescription
isOpenbooleanfalseuse this to open modal directly
coverScreenbooleanfalseuse this to set your modal covers the whole screen
refNamestringnullset a reference name for the modal, this is for dynamic usage of the modal
backdropbooleanfalseuse this to add a backdrop for the modal
modalWidthnumberdynamicuse this to set custom modal width
modalHeightnumberdynamicuse this to set custom modal height
modalBottomnumberheight * 0.6use this to change where modal will be appear depends on the bottom
generateButtonsarraynulluse this to generate buttons as an example (You must create an array with the format)
modalDesignComponentcomponentModelDesignset your own modal design as a component
titlestring""change the title
contextstring""change the context
rightTextstring""change the title right side
titleFontFamilyfont familyHelveticause this to set the font family for the modal
rightTextFontFamilyfont familyHelveticause this to set the font family for the modal
contextFontFamilyfont familyHelveticause this to set the font family for the modal
contextHeightnumber55use this to set context's height
defaultContextstring""use this to set a default context value
titleTextStylestylestyleuse this to set your own style for title text
rightTextStylestylestyleuse this to set your own style for right title text
contextTextStylestylestyleuse this to set your own style for context text
backgroundColorcolor#a092d6use this to set background color for the header part of the modal
customIconComponentcomponentnulluse this to set your own custom icon component for the generated buttons
onOpenedfunctionnulluse this to set your own onOpened function
onClosedfunctionnulluse this to set your own onClosed function

Generated Buttons Usage

Okey, we can use Dynamic Vector Icons component as generated buttons but we must follow this format. "generateButtons" prop accepts an array and it must be like this : (You can check the example)

buttons = [
    {
      size: 35,
      name: "cancel",
      icon: "cancel",
      color: "#C60817",
      type: "MaterialIcons",
      onPress: () => {}
    },
    {
      size: 35,
      name: "verify",
      color: "#06CAA6",
      icon: "verified-user",
      type: "MaterialIcons",
      onPress: () => {}
    }
  ];

Generated Buttons Custom Icon Usage

We can use our own custom icon component as well but still we must follow the above format for the generatedButtons but this time we need to send "customIcon: true" data as well. It let the lib knows that a custom icon will be used and also we need to provide "customIconComponent" to let it knows that which component will be implement.

CustomIconComponent should be something like the below. It has to be item.icon, item.size and item.color for the usage of generatedButtons.

 buttons = [
    {
      size: 28,
      name: "map",
      icon: "map",
      color: "#C60817",
      customIcon: true, // Magic is here, DO NOT FORGET this line!
      onPress: () => {}
    },
    {
      size: 28,
      color: "#06CAA6",
      customIcon: true, // Magic is here, DO NOT FORGET this line!
      icon: "announcement",
      name: "announcement",
      onPress: () => {}
    }
  ];
<GenericModal
  isOpen={true}
  backdrop
  title="Title"
  ref="testModal"
  refName="testModal"
  context="Test Modal"
  generateButtons={this.getButtons()}
  contextTextStyle={styles.contextTextStyle}
  backgroundColor={colors.theme.light.default}
  customIconComponent={
      <MyIcon
          name={item.icon}
          size={item.size}
          color={item.color || colors.theme.light.primaryDark}
       />
    }
/>

Author

FreakyCoder, kuray.ogun@paraboly.com || kurayogun@gmail.com

License

React Native Generic Modal Library is available under the MIT license. See the LICENSE file for more info.

0.0.21

6 years ago

0.0.20

6 years ago

0.0.19

6 years ago

0.0.18

6 years ago

0.0.17

6 years ago

0.0.16

6 years ago

0.0.15

6 years ago

0.0.14

6 years ago

0.0.13

6 years ago

0.0.12

6 years ago

0.0.11

6 years ago

0.0.1

6 years ago