Skip to content

Commit

Permalink
Complete refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
mmazzarolo committed Oct 11, 2020
1 parent 918a9d4 commit f707124
Show file tree
Hide file tree
Showing 13 changed files with 2,299 additions and 1,024 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
@@ -1,3 +1,3 @@
{
"extends": ["plugin:react-app/recommended"]
"extends": ["plugin:react-app/recommended", "plugin:prettier/recommended"]
}
15 changes: 0 additions & 15 deletions .npmignore

This file was deleted.

37 changes: 14 additions & 23 deletions README.md
@@ -1,10 +1,6 @@
# NOT ACTIVELY MAINTAINED ANYMORE
# I can still follow issues/PRs

# react-native-dialog

[![npm version](https://badge.fury.io/js/react-native-dialog.svg)](https://badge.fury.io/js/react-native-dialog)
[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)

A pure JavaScript React-Native dialog that follows closely the UI of its native counterpart while expanding its features.

Expand Down Expand Up @@ -35,13 +31,8 @@ Install the library using npm or yarn:
```bash
# Using npm:
$ npm install react-native-dialog
# Also, if you are not already using it, install react-native-modal
$ npm install react-native-modal

# Using yarn:
$ yarn add react-native-dialog
# Also, if you are not already using it, install react-native-modal
$ yarn add react-native-modal
```

## Usage
Expand Down Expand Up @@ -115,7 +106,7 @@ import Dialog from "react-native-dialog";

export default class DialogTester extends Component {
state = {
dialogVisible: false
dialogVisible: false,
};

showDialog = () => {
Expand Down Expand Up @@ -190,23 +181,23 @@ export default class DialogTester extends Component {
| wrapperStyle | any | undefined | The style applied to the input wrapper View |
| textInputRef | ref | undefined | Ref to the input |
`Dialog.Input` also accepts all the React-Native's `TextInput` component props.
`Dialog.Input` also accepts all the React-Native's `TextInput` component props.
### Dialog.Title props
| Name | Type | Default | Description |
| -------- | ------ | ------------ | -------------- |
| children | string | **REQUIRED** | The title text |
`Dialog.Title` also accepts all the React-Native's `Text` component props.
`Dialog.Title` also accepts all the React-Native's `Text` component props.
### Dialog.Switch props
| Name | Type | Default | Description |
| ----- | ------ | --------- | --------------------------- |
| label | string | undefined | The switch description text |
`Dialog.Switch` also accepts all the React-Native's `Switch` component props.
`Dialog.Switch` also accepts all the React-Native's `Switch` component props.
## TODO
Expand Down Expand Up @@ -252,30 +243,30 @@ render() {
### How can I add a 'tap outside dialog' callback?
`react-native-dialog` uses [`react-native-modal`](https://github.com/react-native-community/react-native-modal) for the backdrop and any properties you add to `Dialog.Container` are mapped through to the modal.
`react-native-modal` has an `onBackdropPress` property that can be used to register clicks on the backdrop.
`react-native-dialog` uses [a thin abstraction on top of the React-Native's modal component](./src/Modal.js). Any properties you add to `Dialog.Container` are mapped through to the modal.
The modal has an `onBackdropPress` property that can be used to register clicks on the backdrop.
Below is an example on how you can close the dialog by tapping outside.
```javascript
onCancel() {
this.setState({
visible: false,
})
}

render() {
const { onCancel, visible } = this.props;
const reactNativeModalProps = {
onBackdropPress: onCancel,
};
return (
<Dialog.Container visible={visible} {...reactNativeModalProps}>
<Dialog.Title>{'title'}</Dialog.Title>
<Dialog.Button label="cancel" onPress={onCancel} />
<Dialog.Title>Title</Dialog.Title>
<Dialog.Button label="Cancel" onPress={onCancel} />
</Dialog.Container>
);
}

onCancel() {
this.setState({
visible: false,
})
}
```
## Acknowledgments
Expand Down
1 change: 1 addition & 0 deletions example
Submodule example added at 0a17bb

0 comments on commit f707124

Please sign in to comment.