1.0.12 • Published 1 month ago

react-native-dialog-view v1.0.12

Weekly downloads
44
License
MIT
Repository
github
Last release
1 month ago

react-native-dialog-view

The react-native-dialog-view is an animated overlay that can help you to display on the screen a pop-up/modal/dialog-view. This is a more straightforward solution to the react-native-modal. This implementation is a simpler solution for a modal that is not using the react-native-modal and it uses the react-native-reanimated for a simple animation and the react-native-portal to be above everything. You can display more DialogView modals over each other. Default animation Slide Up Fade/Slide Down Fade.

Installation

npm install react-native-dialog-view

or

yarn add react-native-dialog-view

Packages

PackageVersion
react-native-reanimated^3.7.1
react-native-portal^1.0.14
react-native-screens^3.20.0

Setup

Add the DialogViewProvider to your App.ts files

import { DialogViewProvider } from 'react-native-dialog-view';

// ...

<Provider store={store}>
  <DialogViewProvider>
    <NavigationProvider>
      <MainNavigator />
    </NavigationProvider>
  </DialogViewProvider>
</Provider>;

Usage

import { DialogView } from 'react-native-dialog-view';

// ...

<DialogView
  visible={isVisible}
  animationTime={300} // default
  hideModal={hideModal}
>
  <YourDesignedModal />
</DialogView>;

Props

NameRequiredTypeDescription
visiblerequiredbooleanThis variable is used to display the overview
childrenrequiredReactNode-
animationTimeoptionalnumberThis variable is used to set the speed of the entrance/exit animation of the overlay
animationInoptionalnumberThis variable is used to set entry animation for the overlay. Default FadeIn. For more animations check reanimated.
animationOutoptionalnumberThis variable is used to set exit animation for the overlay. Default FadeOut. For more animations check reanimated.
onPressBackdropoptionalfunctionThis function is called when the use presses on the overlay
backdropColoroptionalstringThis variable is used to change the background color of the overlay
overlayStyleoptionalViewStyleThis prop can be used to change the style of the overlay

Example

import React, { useMemo, useState } from 'react';
import { Text, TouchableOpacity, View } from 'react-native';
import { DialogView } from 'react-native-dialog-view';

const HomeScreen = () => {
  const [isModalVisible, setIsModalVisible] = useState(false);

  return (
    <View style={{flex: 1}}>
      <TouchableOpacity
        style={{
          with:100,
          height:100
        }}
        onPress={() => setIsModalVisible(true)}
      >
        <Text>{Show modal}</Text>
      </TouchableOpacity>
      <DialogView
        visible={isModalVisible}
        backdropColor={'rgba(0, 0, 0, 0.2)'}
        overlayStyle={{ justifyContent: 'center' }}
        onPressBackdrop={() => setIsModalVisible(true)}
      >
        <View style={{
          width: 100,
          height: 100
        }}>
          <Text style={styles.text}>{This is a modal}</Text>
          <TouchableOpacity
            style={{
              with:100,
              height:100
            }}
            onPress={() => setIsModalVisible(false)}
          >
            <Text style={styles.text}>{Hide Modal}</Text>
          </TouchableOpacity>
        </View>
      </DialogView>
    </View>
  );
};

export default HomeScreen;

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.0.12

1 month ago

1.0.11

2 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago

1.0.9

10 months ago

1.0.8

10 months ago

1.0.7

10 months ago

1.0.6

11 months ago

1.0.5

11 months ago

1.0.4

11 months ago

1.0.3

11 months ago

1.0.10

8 months ago

0.1.6

3 years ago

0.1.6-beta.1

3 years ago

0.1.6-beta.0

3 years ago

0.1.5

3 years ago

0.1.5-beta.17

3 years ago

0.1.5-beta.16

3 years ago

0.1.5-beta.15

3 years ago

0.1.5-beta.14

3 years ago

0.1.5-beta.13

3 years ago

0.1.5-beta.12

3 years ago

0.1.5-beta.11

3 years ago

0.1.5-beta.9

3 years ago

0.1.5-beta.10

3 years ago

0.1.5-beta.7

3 years ago

0.1.5-beta.6

3 years ago

0.1.5-beta.4

3 years ago

0.1.5-beta.3

3 years ago

0.1.5-beta.2

3 years ago

0.1.5-beta.1

3 years ago

0.1.5-beta.0

3 years ago

0.1.4

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.3

3 years ago

0.1.0

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago