|
1 | | -import React, {useState, useEffect} from 'react'; |
2 | | -import {View, Text} from 'react-native'; |
3 | | -import {Progress, Button, Spacing} from '@uiw/react-native'; |
4 | | -import Layout, {Container} from '../../Layout'; |
5 | | -import {motorcycle} from './svg'; |
| 1 | +import React, { useState, useEffect } from 'react'; |
| 2 | +import { View, Text } from 'react-native'; |
| 3 | +import { Progress, Spacing, Button, Toast } from '@uiw/react-native'; |
| 4 | +import Layout, { Container } from '../../Layout'; |
6 | 5 |
|
7 | | -const {Header, Body, Card} = Layout; |
| 6 | +const { Header, Body, Card } = Layout; |
8 | 7 |
|
9 | 8 | const ProgressDemo = (props: any) => { |
10 | | - const {route} = props; |
| 9 | + const { route } = props; |
11 | 10 | const description = route.params.description; |
12 | 11 | const title = route.params.title; |
13 | 12 |
|
14 | | - const [val, setValue] = useState<number>(0); |
15 | | - const [automaticVal, setAutomaticVal] = useState<number>(0); |
| 13 | + const [val, setValue] = useState<number>(15); |
| 14 | + console.log('val', val); |
16 | 15 |
|
17 | 16 | const onPress = () => { |
18 | | - let count = val + 5; |
19 | | - if (count > 100) { |
20 | | - count = 0; |
| 17 | + if (val < 100) { |
| 18 | + setValue(val + 5); |
| 19 | + } else { |
| 20 | + Toast.info('宝,别点了,要溢出了') |
21 | 21 | } |
22 | | - setValue(count); |
23 | 22 | }; |
24 | 23 |
|
25 | 24 | return ( |
26 | 25 | <Container> |
27 | 26 | <Header title={title} description={description} /> |
28 | | - <Body style={{paddingLeft: 16, paddingRight: 16}}> |
29 | | - <Header description={'基本使用'} /> |
30 | | - <Progress |
31 | | - // progressColor="#5847FF" |
32 | | - progress={40} |
33 | | - progressShow={false} |
34 | | - /> |
35 | | - <Header description={'展示进度图标'} /> |
36 | | - <Progress |
37 | | - // progressColor="#5847FF" |
38 | | - progressShow={false} |
39 | | - iconShow={true} |
40 | | - progress={30} |
41 | | - /> |
42 | | - <Header description={'改变进度图标'} /> |
43 | | - <Progress |
44 | | - // progressColor="#5847FF" |
45 | | - iconShow={true} |
46 | | - progressShow={false} |
47 | | - progress={60} |
48 | | - xml={motorcycle} |
49 | | - /> |
50 | | - <Header description={'点击变化'} /> |
51 | | - <View |
52 | | - style={{ |
53 | | - flexDirection: 'column', |
54 | | - marginBottom: 10, |
55 | | - }}> |
56 | | - <Progress |
57 | | - progress={val} |
58 | | - // progressColor="#9185FF" |
59 | | - iconShow={true} |
60 | | - xml={motorcycle} |
61 | | - /> |
62 | | - <Button color={'#3578e5'} onPress={onPress}> |
63 | | - (+-)10 |
64 | | - </Button> |
65 | | - </View> |
| 27 | + <Body style={{ paddingLeft: 16, paddingRight: 16 }}> |
| 28 | + <Card title="基础实例"> |
| 29 | + <Progress type='circle' value={60} /> |
| 30 | + <Spacing /> |
| 31 | + <Progress type='line' value={60} /> |
| 32 | + </Card> |
| 33 | + <Card title="自定义值"> |
| 34 | + <Progress type='circle' value={val} /> |
| 35 | + <Spacing /> |
| 36 | + <Progress type='line' value={val} /> |
| 37 | + <Spacing /> |
| 38 | + <Button onPress={() => onPress()} >你点我呀!</Button> |
| 39 | + </Card> |
| 40 | + <Card title="自定义渐变色"> |
| 41 | + <Progress type='circle' color={['#FFD080', 'red']} value={80} /> |
| 42 | + <Spacing /> |
| 43 | + <Progress type='line' color={['red', '#FFD080',]} value={80} /> |
| 44 | + </Card> |
| 45 | + <Card title="设置大小"> |
| 46 | + <Progress type='circle' width={60} left='6.5%' value={10} /> |
| 47 | + <Spacing /> |
| 48 | + <Progress type='circle' width={80} left='8.5%' value={20} /> |
| 49 | + <Spacing /> |
| 50 | + <Progress type='line' width={60} value={40} /> |
| 51 | + <Spacing /> |
| 52 | + <Progress type='line' width={80} value={60} /> |
| 53 | + </Card> |
| 54 | + <Card title="是否显示单位"> |
| 55 | + <Progress type='circle' showUnit={false} left='13%' value={20} /> |
| 56 | + <Spacing /> |
| 57 | + <Progress type='line' showUnit={false} value={40} /> |
| 58 | + </Card> |
| 59 | + <Card title="自定义单色"> |
| 60 | + <Progress type='circle' color='#FFD080' value={50} /> |
| 61 | + <Spacing /> |
| 62 | + <Progress type='line' color='#FFD080' value={60} /> |
| 63 | + </Card> |
| 64 | + <Card title="自定义背景色"> |
| 65 | + <Progress type='circle' bgColor="#FFD080" value={5} /> |
| 66 | + <Spacing /> |
| 67 | + <Progress type='line' bgColor='#FFD080' value={70} /> |
| 68 | + </Card> |
| 69 | + <Card title="设置外环宽度"> |
| 70 | + <Progress type='circle' value={5} strokeWidth={25} /> |
| 71 | + <Spacing /> |
| 72 | + <Progress type='line' value={70} strokeWidth={15} /> |
| 73 | + </Card> |
| 74 | + |
| 75 | + <Card title="是否显示文本"> |
| 76 | + <Progress type='circle' value={68} showLabel={false} /> |
| 77 | + <Spacing /> |
| 78 | + <Progress type='line' value={70} showLabel={false} /> |
| 79 | + </Card> |
| 80 | + <Card title="自定义标签"> |
| 81 | + <Progress type='circle' value={53} label={<Text>饕餮</Text>} /> |
| 82 | + <Spacing /> |
| 83 | + <Progress type='line' value={30} label={<Text>饕餮</Text>} /> |
| 84 | + </Card> |
| 85 | + <Card title="设置外环宽度"> |
| 86 | + <Progress type='circle' value={5} strokeWidth={25} /> |
| 87 | + <Spacing /> |
| 88 | + <Progress type='line' value={70} strokeWidth={15} /> |
| 89 | + </Card> |
| 90 | + <Card title="自定义文本位置"> |
| 91 | + <Progress type='circle' value={5} top="50%" left='50%' /> |
| 92 | + <Spacing /> |
| 93 | + <Progress type='line' value={70} top="-20%" left='50%' /> |
| 94 | + </Card> |
| 95 | + <Spacing /> |
66 | 96 | </Body> |
67 | | - </Container> |
| 97 | + </Container > |
68 | 98 | ); |
69 | 99 | }; |
70 | 100 |
|
|
0 commit comments