npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-customized-modal

v1.0.10

Published

A react native component that you can use for title, subtitle, buttons and inputs within modal.

Downloads

14

Readme

React Native Customized Modal

npm i react-native-customized-modal --save

import CustomizedModal from 'react-native-customized-modal';

Screenshots

  1. Modal with buttons buttonWithTitleModal
  2. Modal with labels labelsModal
  3. Modal with input InputModal
  4. Modal with vertical buttons verticalButtonsModal
  5. Modal with title,subtitle,small label and buttons smallLabelModal
  6. Modal with 3 input fields(with validation) modalWith3Input modalWith3InputValidation

Component Properties

animation: PropTypes.string,

options: PropTypes.bool,

showButton1: PropTypes.bool,

showButton2: PropTypes.bool,

disableOutSideTouch: PropTypes.bool,

modalVisible: PropTypes.bool.isRequired,

input: PropTypes.bool,

labels: PropTypes.bool,

label1: PropTypes.string,

label2: PropTypes.string,

headerTitle: PropTypes.string,

onRequestClose: PropTypes.func,

fontFamily: PropTypes.string,

fontFamilyBold: PropTypes.string,

label1Color: PropTypes.string,

label2Color: PropTypes.string,

smallLabelColor: PropTypes.string,

smallLabel: PropTypes.string,

verticalButtons: PropTypes.bool,

modalBackgroundColor: PropTypes.string,

input1: PropTypes.bool,

input2: PropTypes.bool,

inputProps: PropTypes.exact({ label: PropTypes.string.isRequired, labelColor: PropTypes.string, keyboardType: PropTypes.string, placeholder: PropTypes.string, multiline: PropTypes.number, placeholderTextColor: PropTypes.string, requiredErrorMessage: PropTypes.string, pattern: PropTypes.string, patternErrorMessage: PropTypes.string, maxLength: PropTypes.number, maxLengthErrorMessage: PropTypes.string, }),

input1Props: PropTypes.exact({ label: PropTypes.string.isRequired, labelColor: PropTypes.string, keyboardType: PropTypes.string, placeholder: PropTypes.string, multiline: PropTypes.number, placeholderTextColor: PropTypes.string, requiredErrorMessage: PropTypes.string, pattern: PropTypes.string, patternErrorMessage: PropTypes.string, maxLength: PropTypes.number, maxLengthErrorMessage: PropTypes.string, }),

input2Props: PropTypes.exact({ label: PropTypes.string.isRequired, labelColor: PropTypes.string, keyboardType: PropTypes.string, placeholder: PropTypes.string, multiline: PropTypes.number, placeholderTextColor: PropTypes.string, requiredErrorMessage: PropTypes.string, pattern: PropTypes.string, patternErrorMessage: PropTypes.string, maxLength: PropTypes.number, maxLengthErrorMessage: PropTypes.string, }),

errorTextColor: PropTypes.string,

button1Props: PropTypes.exact({ title: PropTypes.string.isRequired, backgroundColor: PropTypes.string, borderColor: PropTypes.string, onPress: PropTypes.func, borderRadius: PropTypes.number, }),

button2Props: PropTypes.exact({ title: PropTypes.string.isRequired, backgroundColor: PropTypes.string, textColor: PropTypes.string, onPress: PropTypes.func, borderRadius: PropTypes.number, width: PropTypes.number, }),

headerTitleColor: PropTypes.string,

Code for above screenshots

import React, {useState} from 'react';

import {View} from 'react-native';

import {styles} from './styles';

import {Label} from 'src/component';
import {Color} from '../../../utils/Color';
import CustomizedModal from 'react-native-customized-modal';

const CustomizedModalDemo = props => {
  const [verticalButtonsModalVisible, setVerticalButtonsModalVisible] =
    useState(false);
  const [inputModalVisible, setInputModalVisible] = useState(false);
  const [horzButtonsModalVisible, setHorzButtonsModalVisible] = useState(false);
  const [smallLabelModalVisible, setSmallLabelModalVisible] = useState(false);
  const [labelsModalVisible, setLabelsModalVisible] = useState(false);
  const [optionsModalVisible, setOptionsModalVisible] = useState(false);
  const [input1ModalVisible, setInput1ModalVisible] = useState(false);

  return (
    <View style={styles.container}>
      <Label
        style={styles.labelStyle}
        color={Color.BLACK}
        onPress={() =>
          setVerticalButtonsModalVisible(!verticalButtonsModalVisible)
        }>
        {'View Vertical Button Modal'}
      </Label>
      <CustomizedModal
        modalVisible={verticalButtonsModalVisible}
        labels
        options={false}
        label1={'Title'}
        label2={'Subtitle'}
        label1Color={Color.PRIMARY1}
        label2Color={Color.SHOT_COLOR}
        button1Props={{
          title: 'Cancel',
          onPress: () => {
            setVerticalButtonsModalVisible(!verticalButtonsModalVisible);
          },
          borderColor: Color.TEXT_PLACEHOLDER,
          backgroundColor: Color.WHITE,
        }}
        button2Props={{
          title: 'Okay',
          onPress: () => {
            setVerticalButtonsModalVisible(!verticalButtonsModalVisible);
          },
          backgroundColor: Color.PRIMARY1,
          textColor: Color.WHITE,
        }}
        onRequestClose={() =>
          setVerticalButtonsModalVisible(!verticalButtonsModalVisible)
        }
        verticalButtons
      />
      <Label
        style={styles.labelStyle}
        color={Color.BLACK}
        onPress={() => setInputModalVisible(!inputModalVisible)}>
        {'View Input Modal'}
      </Label>
      <CustomizedModal
        modalVisible={inputModalVisible}
        input
        inputProps={{
          label: 'Name',
          requiredErrorMessage: 'Enter your validation message',
        }}
        button1Props={{
          title: 'Cancel',
          onPress: () => {
            setInputModalVisible(!inputModalVisible);
          },
          borderColor: Color.TEXT_PLACEHOLDER,
          backgroundColor: Color.WHITE,
        }}
        button2Props={{
          title: 'Okay',
          onPress: ({input}) => {  
            // here you'll get values          
            console.log('input ', input);
            setInputModalVisible(!inputModalVisible);
          },
          backgroundColor: Color.PRIMARY1,
          textColor: Color.WHITE,
        }}
        onRequestClose={() => setInputModalVisible(!inputModalVisible)}
      />
      <Label
        style={styles.labelStyle}
        color={Color.BLACK}
        onPress={() => setHorzButtonsModalVisible(!horzButtonsModalVisible)}>
        {'View Horizontal Buttons Modal'}
      </Label>
      <CustomizedModal
        modalVisible={horzButtonsModalVisible}
        options={false}
        labels
        label1={'Title'}
        label2={'Subtitle'}
        button1Props={{
          title: 'No',
          onPress: () => {
            setHorzButtonsModalVisible(!horzButtonsModalVisible);
          },
          borderColor: Color.TEXT_PLACEHOLDER,
          backgroundColor: Color.WHITE,
        }}
        button2Props={{
          title: 'Yes',
          onPress: () => {
            setHorzButtonsModalVisible(!horzButtonsModalVisible);
          },
          backgroundColor: Color.PRIMARY1,
          textColor: Color.WHITE,
        }}
        onRequestClose={() =>
          setHorzButtonsModalVisible(!horzButtonsModalVisible)
        }
      />

      <Label
        style={styles.labelStyle}
        color={Color.BLACK}
        onPress={() => setSmallLabelModalVisible(!smallLabelModalVisible)}>
        {'View Small Label Modal'}
      </Label>
      <CustomizedModal
        modalVisible={smallLabelModalVisible}
        options={false}
        labels
        label1={'Title'}
        label2={'Subtitle'}
        button1Props={{
          title: 'No',
          onPress: () => {
            setSmallLabelModalVisible(!smallLabelModalVisible);
          },
          borderColor: Color.TEXT_PLACEHOLDER,
          backgroundColor: Color.WHITE,
        }}
        button2Props={{
          title: 'Yes',
          onPress: () => {
            setSmallLabelModalVisible(!smallLabelModalVisible);
          },
          backgroundColor: Color.PRIMARY1,
          textColor: Color.WHITE,
        }}
        onRequestClose={() =>
          setSmallLabelModalVisible(!smallLabelModalVisible)
        }
        smallLabel={'Give information'}
        disableOutSideTouch
      />

      <Label
        style={styles.labelStyle}
        color={Color.BLACK}
        onPress={() => setLabelsModalVisible(!labelsModalVisible)}>
        {'View Labels Modal'}
      </Label>
      <CustomizedModal
        modalVisible={labelsModalVisible}
        options={false}
        labels
        label1={'Enter your Title'}
        label2={'Enter your Subtitle'}
        onRequestClose={() => setLabelsModalVisible(!labelsModalVisible)}
        showButton1={false}
        showButton2={false}
      />

      <Label
        style={styles.labelStyle}
        color={Color.BLACK}
        onPress={() => setOptionsModalVisible(!optionsModalVisible)}>
        {'View Options Modal'}
      </Label>
      <CustomizedModal
        modalVisible={optionsModalVisible}
        options
        headerTitle={'Header Title'}
        headerTitleColor={Color.PRIMARY1}
        label1={'Enter your Subtitle'}
        onRequestClose={() => setOptionsModalVisible(!optionsModalVisible)}
        showButton1={false}
        showButton2={false}
      />

      <Label
        style={styles.labelStyle}
        color={Color.BLACK}
        onPress={() => setInput1ModalVisible(!input1ModalVisible)}>
        {'View Input 1 Modal'}
      </Label>
      <CustomizedModal
        modalVisible={input1ModalVisible}
        options={false}
        onRequestClose={() => setInput1ModalVisible(!input1ModalVisible)}
        input
        inputProps={{
          label: 'Name',
          placeholder: 'Enter name',
          labelColor: Color.PRIMARY1,
          requiredErrorMessage: 'Please enter name',
        }}
        input1
        input1Props={{
          placeholder: 'Enter email',
          label: 'Email',
          labelColor: Color.PRIMARY1,
          requiredErrorMessage: 'Please enter email',
        }}
        input2
        input2Props={{
          placeholder: 'Enter description',
          label: 'Description',
          labelColor: Color.PRIMARY1,
          requiredErrorMessage: 'Please enter description',
        }}
        button1Props={{
          title: 'Cancel',
          onPress: () => {
            setInput1ModalVisible(!input1ModalVisible);
          },
          borderColor: Color.TEXT_PLACEHOLDER,
          backgroundColor: Color.WHITE,
        }}
        button2Props={{
          title: 'Submit',
          onPress: val => {
            // here you'll get values
            console.log('VAL ', val);
            setInput1ModalVisible(!input1ModalVisible);
          },
          backgroundColor: Color.PRIMARY1,
          textColor: Color.WHITE,
        }}
      />
    </View>
  );
};

export default CustomizedModalDemo;