react-native-smart-loading-spinner-overlay
A smart loading spinner overlay for React Native apps, written in JS for cross-platform support. It works on iOS and Android.
This component is compatible with React Native 0.25 and newer.
Preview
Installation
npm install react-native-smart-loading-spinner-overlay --save
Full Demo
Usage
Install the loading-spinner-overlay from npm with npm install react-native-smart-loading-spinner-overlay --save
.
Then, require it from your app's JavaScript files with import loading-spinner-overlay from 'react-native-smart-loading-spinner-overlay'
.
{ superprops thisstate = {} } { return <View style= paddingTop: 64 flex: 1 backgroundColor: '#fff'> <Button onPress=this_showModalLoadingSpinnerOverLay touchableType=ButtonconstantstouchableTypesfadeContent style=margin: 10 height: 40 backgroundColor: 'red' borderRadius: 3 borderWidth: StyleSheethairlineWidth borderColor: 'red' justifyContent: 'center' textStyle=fontSize: 17 color: 'white' > show modal loading </Button> <Button onPress=this_showPartModalLoadingSpinnerOverLay touchableType=ButtonconstantstouchableTypeshighlight underlayColor='#C90000' style=margin: 10 justifyContent: 'center' height: 40 backgroundColor: 'red' borderRadius: 3 borderWidth: StyleSheethairlineWidth borderColor: 'red' justifyContent: 'center' textStyle=fontSize: 17 color: 'white' > part modalcan click </Button> <Button onPress=this_showNoModalLoadingSpinnerOverLay touchableType=ButtonconstantstouchableTypesblur style=margin: 10 justifyContent: 'center' height: 40 backgroundColor: 'red' borderRadius: 3 borderWidth: StyleSheethairlineWidth borderColor: 'red' justifyContent: 'center' textStyle=fontSize: 17 color: 'white' > show no modal loading </Button> <Button onPress=this_showImmediateLoadingSpinnerOverLayAndImmediateHide touchableType=ButtonconstantstouchableTypesfade style=margin: 10 justifyContent: 'center' height: 40 backgroundColor: 'red' borderRadius: 3 borderWidth: StyleSheethairlineWidth borderColor: 'red' justifyContent: 'center' textStyle=fontSize: 17 color: 'white' > show and hide </Button> <Button onPress=this_showModal_2_LoadingSpinnerOverLay touchableType=ButtonconstantstouchableTypesfadeContent style=margin: 10 height: 40 backgroundColor: 'red' borderRadius: 3 borderWidth: StyleSheethairlineWidth borderColor: 'red' justifyContent: 'center' textStyle=fontSize: 17 color: 'white' > custom </Button> <LoadingSpinnerOverlay ref= this_modalLoadingSpinnerOverLay = component /> <LoadingSpinnerOverlay ref= this_partModalLoadingSpinnerOverLay = component modal=true marginTop=64/> <LoadingSpinnerOverlay ref= this_LoadingSpinnerOverLay = component modal=false/> <LoadingSpinnerOverlay ref= this_modalImmediateLoadingSpinnerOverLay = component /> <LoadingSpinnerOverlay ref= this_modal_2_LoadingSpinnerOverLay = component > this </LoadingSpinnerOverlay> </View> } { this_modalLoadingSpinnerOverLay //simulate http request this } { this_partModalLoadingSpinnerOverLay //simulate http request this } { this_LoadingSpinnerOverLay //simulate http request this } { this_modalImmediateLoadingSpinnerOverLay //simulate http request this } { this_modal_2_LoadingSpinnerOverLay //simulate http request this } { return ActivityIndicator ? <ActivityIndicator animating=true color='#ff0000' size='small'/> : PlatformOS == 'android' ? <ProgressBarAndroid color='#ff0000' styleAttr='small'/> : <ActivityIndicatorIOS animating=true color='#ff0000' size='small'/> } LoadingSpinnerOverLayDemo
Props
Prop | Type | Optional | Default | Description |
---|---|---|---|---|
style | style | Yes | see react-native documents | |
overlayStyle | style | Yes | see react-native documents | |
duration | number | Yes | 255 | determine the duration of loading-spinner-overlay animation |
delay | number | Yes | 0 | determine the delay of loading-spinner-overlay animation |
marginTop | number | Yes | 0 | determine the marginTop of the root container view, it is used when the modal prop is false |
modal | bool | Yes | true | determine if the modal will be used |
Method
-
show({modal, marginTop, children, duration, easing, delay, animationEnd,})
- modal: determine if the modal will be used
- marginTop: determine the marginTop of the root container view, it is used when the modal prop is false
- children: determine the children of loading-spinner-overlay
- duration: determine the duration of animation
- easing: determine the easing of animation
- delay: determine the delay of animation
- animationEnd: determine the callback when animation is end
-
hide({duration, easing, delay, animationEnd,})
- duration: determine the duration of animation
- easing: determine the easing of animation
- delay: determine the delay of animation
- animationEnd: determine the callback when animation is end