react native (附代码)实现热更新下载进度条弹窗Modal

本文介绍如何在React Native项目中创建一个进度条弹窗Modal组件,包括编写进度条Bar和Modal组件,以及如何在项目中集成显示。通过getRealDP方法调整样式,最终展示了一个美观的下载进度条效果。
摘要由CSDN通过智能技术生成

1. 编写进度条Bar组件

import React, { PureComponent } from 'react';
import {
  View,
  Animated,
} from 'react-native';
import PropTypes from 'prop-types';
import { getRealDP } from '../utils/utility';

const propTypes = {
  progress: PropTypes.number.isRequired,
  backgroundStyle: PropTypes.number.isRequired,
  style: PropTypes.object.isRequired,
};

/* 进度条组件 */
class Bar extends PureComponent {

  constructor(props) {
    super(props);
    this.progress = new Animated.Value(0);
    this.update = this.update.bind(this);
  }

  componentWillReceiveProps(nextProps) {
    if (this.props.progress >= 0 && this.props.progress !== nextProps.progress) {
      this.update(nextProps.progress);
    }
  }

  update(progress) {
    Animated.spring(this.progress, {
      toValue: progress
    }).start();
  }

  render() {
    return (
      <View style={[this.props.backgroundStyle, this.props.style]}>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值