美文网首页
react native 圆形环进度条

react native 圆形环进度条

作者: 王宣成 | 来源:发表于2023-11-27 15:23 被阅读0次
import React, { useEffect, useState } from 'react';
import { View, Text, TouchableOpacity } from 'react-native';
import { AnimatedCircularProgress } from 'react-native-circular-progress';

const CountdownTimer = () => {
  const [progress, setProgress] = useState(50);

  useEffect(() => {

  }, []);

  return (
    <View style={{justifyContent:'center', alignItems:'center'}}>
      <AnimatedCircularProgress
        size={200}
        width={10}
        fill={progress}
        tintColor="#ff0000"
        backgroundColor="#cccccc"
        rotation={0}
        lineCap="round"
      >
        {(fill) => <Text>{progress}</Text>}
      </AnimatedCircularProgress>

      <View style={{justifyContent:'space-between', flexDirection: 'row'}}>

        <TouchableOpacity onPress={() => setProgress(progress + 5)}>
          <View style={{ width: 100, height: 50, backgroundColor: 'green' }}>
            <Text>+5</Text>
          </View>
        </TouchableOpacity>

        <TouchableOpacity onPress={() => setProgress(progress - 5)}>
          <View style={{ width: 100, height: 50, backgroundColor: 'red' }}>
            <Text>-5</Text>
          </View>
        </TouchableOpacity>
      </View>

    </View>
  );
};

export default CountdownTimer;

相关文章

网友评论

      本文标题:react native 圆形环进度条

      本文链接:https://www.haomeiwen.com/subject/zsnzwdtx.html