|
| 1 | +# React Native Loading Spinner Overlay |
| 2 | + |
| 3 | +[](https://github.com/sindresorhus/xo) |
| 4 | +[](https://github.com/prettier/prettier) |
| 5 | +[](https://github.com/lassjs/lass) |
| 6 | +[](LICENSE) |
| 7 | +[](https://npm.im/react-native-loading-spinner-overlay) |
| 8 | + |
| 9 | +<img src="https://cdn.jsdelivr.net/gh/joinspontaneous/react-native-loading-spinner-overlay/media/demo.gif" width="200" height="393.5" alt="" /> |
| 10 | + |
| 11 | + |
| 12 | +## Table of Contents |
| 13 | + |
| 14 | +* [Install](#install) |
| 15 | +* [Example](#example) |
| 16 | +* [Options](#options) |
| 17 | +* [Recommended Implementation](#recommended-implementation) |
| 18 | +* [Contributors](#contributors) |
| 19 | +* [License](#license) |
| 20 | + |
| 21 | + |
| 22 | +## Install |
| 23 | + |
| 24 | +[npm][]: |
| 25 | + |
| 26 | +```sh |
| 27 | +npm install react-native-loading-spinner-overlay |
| 28 | +``` |
| 29 | + |
| 30 | +[yarn][]: |
| 31 | + |
| 32 | +```sh |
| 33 | +yarn add react-native-loading-spinner-overlay |
| 34 | +``` |
| 35 | + |
| 36 | + |
| 37 | +## Example |
| 38 | + |
| 39 | +See [the example App.js file][example] for an example implementation. |
| 40 | + |
| 41 | + |
| 42 | +## Options |
| 43 | + |
| 44 | +| Property | Type | Default | Description | |
| 45 | +| --------------- | ---------------------------------------- | --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | |
| 46 | +| cancelable | Boolean | `false` | **Android**: If set to false, it will prevent spinner from hiding when pressing the hardware back button. If set to true, it will allow spinner to hide if the hardware back button is pressed. | |
| 47 | +| color | String | `"white"` | Changes the spinner's color (example values are `red`, `#ff0000`, etc). For adjusting the contrast see `overlayColor` prop below. | |
| 48 | +| animation | String (enum) `none`, `slide`, `fade` | `"none"` | Changes animation on show and hide spinner's view. | |
| 49 | +| overlayColor | String | `rgba(0, 0, 0, 0.25)` | Changes the color of the overlay. | |
| 50 | +| size | String (enum) `small`, `normal`, `large` | `"large"` | Sets the spinner's size. No other cross-platform sizes are supported right now. | |
| 51 | +| textContent | String | `""` | Optional text field to be shown. | |
| 52 | +| textStyle | StyleSheet | `-` | The style to be applied to the `<Text>` that displays the `textContent`. | |
| 53 | +| visible | Boolean | `false` | Controls the visibility of the spinner. | |
| 54 | +| indicatorStyle | StyleSheet | `undefined` | Additional styles for the [ActivityIndicator](https://facebook.github.io/react-native/docs/activityindicator) to inherit | |
| 55 | +| customIndicator | Element | `undefined` | An alternative, custom component to use instead of the default `<ActivityIndicator />` | |
| 56 | +| children | Element | `undefined` | Children element(s) to nest inside the spinner | |
| 57 | + |
| 58 | + |
| 59 | +## Recommended Implementation |
| 60 | + |
| 61 | +We recommend that you follow two rules when implementing this component. |
| 62 | + |
| 63 | +1. Integrate it inside the parent-most/top-level/root component in your app |
| 64 | +2. Wrap usage of actions after attempting to stop the spinner with `setTimeout` to avoid [the non-stop spinner issue](https://github.com/joinspontaneous/react-native-loading-spinner-overlay/issues/30): |
| 65 | + |
| 66 | + ```js |
| 67 | + this.setState({ spinner: false }); |
| 68 | + |
| 69 | + setTimeout(() => { |
| 70 | + Alert.alert('Oops!', err.message); |
| 71 | + }, 100); |
| 72 | + ``` |
| 73 | + |
| 74 | + |
| 75 | +## Contributors |
| 76 | + |
| 77 | +| Name | Website | |
| 78 | +| ------------------- | ------------------------- | |
| 79 | +| **Nick Baugh** | <http://niftylettuce.com> | |
| 80 | +| **Spencer Snyder** | <http://spencersnyder.io> | |
| 81 | +| **Luciano Lima** | | |
| 82 | +| **George Savvidis** | | |
| 83 | +| **Sandro Machado** | | |
| 84 | +| **Ben Sutter** | | |
| 85 | +| **Ivan Kuznetsov** | | |
| 86 | +| **Darren Camp** | | |
| 87 | +| **Rigo B Castro** | | |
| 88 | +| **Raj Kissu** | | |
| 89 | +| **Ivan Pusic** | | |
| 90 | +| **Antonio Grass** | | |
| 91 | +| **Vijay Chouhan** | | |
| 92 | +| **Jacob Lee** | | |
| 93 | +| **Matt Labrum** | | |
| 94 | + |
| 95 | + |
| 96 | +## License |
| 97 | + |
| 98 | +[MIT](LICENSE) © Nick Baugh |
| 99 | + |
| 100 | + |
| 101 | +## |
| 102 | + |
| 103 | +[npm]: https://www.npmjs.com/ |
| 104 | + |
| 105 | +[yarn]: https://yarnpkg.com/ |
| 106 | + |
| 107 | +[example]: https://github.com/joinspontaneous/react-native-loading-spinner-overlay/blob/master/example/App.js |
0 commit comments