import { Loading, Space, View, Text } from 'taro-uno-ui';
import { useState } from 'react';
const LoadingExample = () => {
const [fullScreenVisible, setFullScreenVisible] = useState(false);
const showFullScreenLoading = () => {
setFullScreenVisible(true);
setTimeout(() => {
setFullScreenVisible(false);
}, 3000);
};
return (
<View>
<Text style={{ fontSize: '20px', fontWeight: 'bold', marginBottom: '12px', display: 'block' }}>基础加载</Text>
<Space style={{ marginBottom: '20px' }}>
<Loading />
<Loading type="circular" />
<Loading type="dots" />
<Loading type="wave" />
<Loading type="pulse" />
</Space>
<Text style={{ fontSize: '20px', fontWeight: 'bold', marginBottom: '12px', display: 'block', marginTop: '20px' }}>不同大小</Text>
<Space style={{ marginBottom: '20px' }}>
<Loading size="small" />
<Loading size="medium" />
<Loading size="large" />
<Loading size={48} />
</Space>
<Text style={{ fontSize: '20px', fontWeight: 'bold', marginBottom: '12px', display: 'block', marginTop: '20px' }}>不同颜色</Text>
<Space style={{ marginBottom: '20px' }}>
<Loading color="primary" />
<Loading color="success" />
<Loading color="warning" />
<Loading color="error" />
<Loading color="#ff6b6b" />
<Loading color="#4ecdc4" />
</Space>
<Text style={{ fontSize: '20px', fontWeight: 'bold', marginBottom: '12px', display: 'block', marginTop: '20px' }}>带文字的加载</Text>
<Space direction="vertical" style={{ marginBottom: '20px' }}>
<Loading text="加载中..." />
<Loading text="处理中..." color="primary" type="circular" />
<Loading text="数据加载中..." color="success" type="dots" />
<Loading text="提交中..." color="warning" type="wave" />
<Loading text="加载失败..." color="error" type="pulse" />
</Space>
<Text style={{ fontSize: '20px', fontWeight: 'bold', marginBottom: '12px', display: 'block', marginTop: '20px' }}>带遮罩的加载</Text>
<View style={{ position: 'relative', width: '200px', height: '100px', border: '1px solid #e0e0e0', borderRadius: '4px', overflow: 'hidden' }}>
<View style={{ padding: '16px' }}>
<Text>内容区域</Text>
</View>
<Loading overlay text="加载中..." />
</View>
<Text style={{ fontSize: '20px', fontWeight: 'bold', marginBottom: '12px', display: 'block', marginTop: '20px' }}>自定义样式</Text>
<Space style={{ marginBottom: '20px' }}>
<Loading
style={{ backgroundColor: 'rgba(255, 255, 255, 0.9)', padding: '20px', borderRadius: '8px', boxShadow: '0 2px 12px rgba(0, 0, 0, 0.1)' }}
text="自定义样式加载"
color="primary"
/>
<Loading
style={{ backgroundColor: 'rgba(0, 0, 0, 0.8)', padding: '16px', borderRadius: '4px' }}
text={<Text style={{ color: '#fff' }}>深色主题加载</Text>}
color="#fff"
/>
</Space>
<Text style={{ fontSize: '20px', fontWeight: 'bold', marginBottom: '12px', display: 'block', marginTop: '20px' }}>全屏加载</Text>
<View style={{ marginBottom: '20px' }}>
<Button type="primary" onClick={showFullScreenLoading}>显示全屏加载</Button>
{fullScreenVisible && (
<Loading fullScreen text="全屏加载中..." color="primary" onClose={() => setFullScreenVisible(false)} />
)}
</View>
</View>
);
};
export default LoadingExample;