import React, { useState } from 'react'; import { View, Text } from 'react-native'; import { Progress, Button, Space, Size } from '@xrnjs/ui'; import { IconMADownload1, IconPPUpload1, } from '../../../icons'; import Card from '_global/Card'; import styles from './style'; const perventText = ({ percent }: { percent?: number }) => ( {`${percent}% (${ percent ? (percent * 2.5).toFixed(1) : 0 }MB/250MB)`} ); const ScenarioUsage: React.FC = () => { const [uploadProgress, setUploadProgress] = useState(0); const [downloadProgress, setDownloadProgress] = useState(0); const [taskProgress, setTaskProgress] = useState(0); const [isUploading, setIsUploading] = useState(false); const [isDownloading, setIsDownloading] = useState(false); // 模拟上传进度 const startUpload = () => { setIsUploading(true); setUploadProgress(0); const timer = setInterval(() => { setUploadProgress((prev) => { if (prev >= 100) { clearInterval(timer); setIsUploading(false); return 100; } return prev + Math.random() * 15; }); }, 200); }; // 模拟下载进度 const startDownload = () => { setIsDownloading(true); setDownloadProgress(0); const timer = setInterval(() => { setDownloadProgress((prev) => { if (prev >= 100) { clearInterval(timer); setIsDownloading(false); return 100; } return prev + Math.random() * 10; }); }, 300); }; return ( 展示进度条在实际业务场景中的应用 文件上传 {isUploading ? '上传中...' : uploadProgress === 100 ? '上传完成' : '准备上传'} 文件下载 {isDownloading ? '下载中...' : downloadProgress === 100 ? '下载完成' : '准备下载'} perventText({ percent })} /> 任务完成度 ( {percent} 任务完成 )} /> 步骤进度 ); }; export default ScenarioUsage;