Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Progress Dialog in ReactNative

Tags:

react-native

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

enter image description here

enter image description here

like image 410
maheshgupta024 Avatar asked Jan 12 '18 05:01

maheshgupta024


People also ask

How do you show progress dialog in react native?

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.

How do I display progress bar in react native?

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.

How do I create a ProgressBar in react native?

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.

How do I change the color of my progress bar in react native?

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.


1 Answers

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

like image 160
Jitendra Suthar Avatar answered Oct 05 '22 12:10

Jitendra Suthar