1.3.3 • Published 4 months ago

@nguyentc21/react-native-modal-view v1.3.3

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

@nguyentc21/react-native-modal-view

React native Modal view

Installation

yarn add @nguyentc21/react-native-modal-view

Usage

In your root-level component.

import ModalView from '@nguyentc21/react-native-modal-view';
// ...
const App = () => {
  return (
    // ...
    // This will contain all your nested modals
    <ModalView // should be on bottom
      visible={true}
      // containerStyle={{}}
    />
  );
};
// ...

Other View

// ...
import { NestedModal, Modal } from '@nguyentc21/react-native-modal-view';
// ...

const ModalContent = () => {
  const [count, setCount] = useState(0);
  return (
    <>
      <Text>
        Otherwise, change Inside-Count will make modal content re-render, but not NiceView
        Inside-Count: {count}
      </Text>
      <View>
        <Pressable
          onPress={() => { setCount((_count) => _count + 1) }}
        >
          Inside-Count + 1
        </Pressable>
      </View>
    </>
  )
}

const NiceView = (props: Props) => {
  const [nestedModalVisible, setNestedModalVisible] = useState(false);
  const [customModalVisible, setCustomModalVisible] = useState(false);
  const [count, setCount] = useState(0);
  // ...
  return (
    // ...
    <NestedModal
      visible={nestedModalVisible}
      close={() => { setNestedModalVisible(false )}}
      containerStyle={{ backgroundColor: 'grey', padding: 50 }}
      // extraData={dynamicValue} // change value will help this modal re-render
    >
      <Text>
        This is your app modal
      <Text>
      <Text>
        Change Outside-Count will make NiceView re-render, but not the modal content
        Outside-Count: {count}
      </Text>
      <View>
        <Pressable
          onPress={() => { setCount((_count) => _count + 1) }}
        >
          Outside-Count + 1
        </Pressable>
      </View>
      <ModalContent />
    </NestedModal>

    <Modal
      // modalType={"slide"}
      visible={customModalVisible}
      close={() => { setCustomModalVisible(false )}}
      containerStyle={{ backgroundColor: 'blue', padding: 10 }}
    >
      <Text>
        This is your inside-component modal
      <Text>
    </Modal>
    // ...
  )
}

Props

NameTypeDefaultdescription
modalType'fade' | 'slide''fade'
visiblebooleanREQUIRED
close() => voidFunction help close modal. Called when the backdrop is pressed and "blurToClose" is true.
blurToClosebooleantruetrue: On press backdrop will call the "close" function.
maxHeightViewStyle'maxHeight'Fade modal: 60%; Slide modal: 90%;
onOpen(id?: string) => voidCalled when the modal start show animation begins
onDidOpen(id?: string) => voidCalled when the modal is completely visible
onClose(id?: string) => voidCalled when the modal is completely hidden
childrenReactNodeYour modal content
containerStyleViewStyle
backdropStyleViewStyle

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library

1.3.3

4 months ago

1.3.2

4 months ago

1.3.1

4 months ago

1.2.5

4 months ago

1.2.4

4 months ago

1.2.3

4 months ago

1.2.2

4 months ago

1.2.1

6 months ago

1.2.0

6 months ago

1.1.6

6 months ago

1.1.5

7 months ago

1.1.4

8 months ago

1.1.3

8 months ago

1.1.2

8 months ago

1.1.1

8 months ago

1.1.0

8 months ago

1.0.3

8 months ago

1.0.2

8 months ago

1.0.1

8 months ago

1.0.0

8 months ago