1.0.2 • Published 5 years ago

react-native-spinner-screen-overlay v1.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

react-native-spinner-screen-overlay

There are cases when we want to block the UI with a spinner overlay. It's the simplest way to prevent the user from doing any actions in the UI while a crucial process is taking place, like payments for example. This library provides such a functionality while still making itself as small as it can be.

I created this library to solve a problem I encountered while using react-native-loading-spinner-overlay. In iOS there were times when you show an alert right after removing the spinner and sometimes the alert will close itself even with cancelable: false option, there were also times when the spinner won't go away.

Install

npm install --save react-native-spinner-screen-overlay

Usage

Rendering SpinnerOverlay component

The recommended way is to put the component on your root component and simply toggle the visible props on or off. Pass true to visible when you want the spinner to show, false if otherwise.

export default class App extends Component {
  constructor () {
    this.state = {
      blockUI: false
    };
  }

  render () {
    return (
      <View style={{ flex: 1 }}>
        // ... rest of the app
        <SpinnerOverlay visible={this.state.blockUI} />
      </View>
    );
  }
}

Though you can also render it anywhere, say on a particular route by simply doing something like this:

export default class LoginRoute extends Component {
  // ... rest of the code
  render () {
    return (
      <View style={{ flex: 1 }}>
        // ... rest of the code
        <SpinnerOverlay visible={this.state.sendingForm} />
      </View>
    );
  }
}

SpinnerOverlay props

NameDescriptionExpectedDefault
modalBackgroundThe background color of the modal.Any color recognized by React-Native.rgba(0, 0, 0, 0.3)
spinnerColorThe color of the ActivityIndicator.Any color recognized by React-Native.#000
spinnerContainerStylesAn object passed to the View which serves as the container of the ActivityIndicator.A valid React-Native StyleSheet{ padding: 20, backgroundColor: '#fff', borderRadius: 20 }

Contributing

Discussions, questions, suggestions, bug reports, feature request, etc are all welcome. Just create an issue. Just ensure that you are responsive enough.


Created with :heart: by April Mintac Pineda.