I'm pretty new to ReactNative world. Im struggling to find an api or a library that shows the Progress Dialog as below in React Native. I believe ActivityIndicator can be used, but it does not show as overlay. Can anyone help me how can I show as an overlay using styles or if there is good library to make this.
Thanks
create({ container: { flex: 1, //backgroundColor: '#fff', alignItems: 'center', justifyContent: 'center', } }); You can use this component and use it where you want to show the Progress. You just have to maintain the state for visible the loading or not in your render function of the component.
To work with the progress bar component install react-native-paper module using npm. It takes value from 0 to 10. The number value to be given to show inside the progress bar. The color of the progress bar.
React Native ProgressBar with Animated Example To create an animated progessbar we need to import theAnimated class. Add Animated. View and Animated. Text component inside View.
Color of the progress bar. The background color will be calculated based on this but you can change it by passing backgroundColor to style prop. If the progress bar will show indeterminate progress.
Here is the code to Open Prgressbar:
import React from 'react';
import { Modal, View, Text, ActivityIndicator, Button } from 'react-native';
export default class App extends React.Component {
constructor(props) {
super(props);
this.state = { isProgress: false }
}
openProgressbar = () => {
this.setState({ isProgress: true })
}
render() {
return (
this.state.isProgress ?
<CustomProgressBar />
:
<View style={{ flex: 1, backgroundColor: '#fff', alignItems: 'center', justifyContent: 'center' }}>
<Button title="Please click here to Open ProgressBar" onPress={this.openProgressbar} />
</View>
);
}
}
const CustomProgressBar = ({ visible }) => (
<Modal onRequestClose={() => null} visible={visible}>
<View style={{ flex: 1, backgroundColor: '#dcdcdc', alignItems: 'center', justifyContent: 'center' }}>
<View style={{ borderRadius: 10, backgroundColor: 'white', padding: 25 }}>
<Text style={{ fontSize: 20, fontWeight: '200' }}>Loading</Text>
<ActivityIndicator size="large" />
</View>
</View>
</Modal>
);
Expo url for live demo https://snack.expo.io/@jitendra.mca13/progress-bar-demo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With