Skip to content

Commit a454fe6

Browse files
Amber-Nan杨楠
andauthored
feat(Progress): 增加进度提示字展示 及 Update README.md (#308)
* fix:发布 iOS 应用商店:一. 创建AppID * fix:发布 iOS 应用商店优化排版 * fix:ios应用商店文档更新及排版优化 * fix:修改环境安装文档语法错误及部分内容优化 * fix:更新ios应用发布流程 * fix:ios应用商店发布更新 * fix:更新ios及安卓应用商店发布 * fix:安卓上架更新 * fix:增加button自定义文本实例 * fix:增加checkBox复选框size调整及文档描述效果展示 * doc:更新文档导入图片 * doc(website): Update Readme.md * fix:修复SpeedDial Android 点击事件失效及拖拽失效问题 #286 * fix:解决SelectCascader 在安卓端不能选择问题 #289 * fix:修复Modal 弹出动画底层延迟收起问题 * feat:NoticeBar 通告栏增加文字样式修改及页面demo展示 * doc(website): Update NoticeBar Readme.md * fix:解决 MenuDropdown 安卓下拉菜单被遮挡问题 * feat:Progress 新增进度图标 * doc(website): Update Progress Readme.md * style:删除多余代码 * feat:Progress 增加进度提示字展示 及 doc(website): Update Progress Readme.md Co-authored-by: 杨楠 <[email protected]>
1 parent e3d899a commit a454fe6

File tree

3 files changed

+34
-25
lines changed

3 files changed

+34
-25
lines changed

example/examples/src/routes/Progress/index.tsx

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, {useState} from 'react';
1+
import React, {useState, useEffect} from 'react';
22
import {View, Text} from 'react-native';
33
import {Progress, Button, Spacing} from '@uiw/react-native';
44
import Layout, {Container} from '../../Layout';
@@ -12,9 +12,10 @@ const ProgressDemo = (props: any) => {
1212
const title = route.params.title;
1313

1414
const [val, setValue] = useState<number>(0);
15+
const [automaticVal, setAutomaticVal] = useState<number>(0);
1516

1617
const onPress = () => {
17-
let count = val + 10;
18+
let count = val + 5;
1819
if (count > 100) {
1920
count = 0;
2021
}
@@ -26,35 +27,34 @@ const ProgressDemo = (props: any) => {
2627
<Header title={title} description={description} />
2728
<Body>
2829
<Header description={'基本使用'} />
29-
<Progress progressColor="#5847FF" progress={40} />
30+
<Progress progressColor="#5847FF" progress={40} progressShow={false} />
3031
<Header description={'展示进度图标'} />
31-
<Progress progressColor="#5847FF" iconShow={true} progress={30} />
32+
<Progress
33+
progressColor="#5847FF"
34+
progressShow={false}
35+
iconShow={true}
36+
progress={30}
37+
/>
3238
<Header description={'改变进度图标'} />
3339
<Progress
3440
progressColor="#5847FF"
3541
iconShow={true}
42+
progressShow={false}
3643
progress={60}
3744
xml={motorcycle}
3845
/>
3946
<Header description={'点击变化'} />
4047
<View
4148
style={{
4249
flexDirection: 'column',
43-
marginHorizontal: 15,
50+
marginBottom: 10,
4451
}}>
45-
<View
46-
style={{
47-
flexDirection: 'row',
48-
justifyContent: 'space-between',
49-
}}>
50-
<Progress
51-
progress={val}
52-
progressColor="#5847FF"
53-
iconShow={true}
54-
xml={motorcycle}
55-
/>
56-
<Text style={{fontSize: 12, marginHorizontal: 10}}>{val}%</Text>
57-
</View>
52+
<Progress
53+
progress={val}
54+
progressColor="#9185FF"
55+
iconShow={true}
56+
xml={motorcycle}
57+
/>
5858
<Button color={'#5847FF'} onPress={onPress}>
5959
(+-)10
6060
</Button>

packages/core/src/Progress/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@ function Demo() {
3333
| `iconShow` | 是否展示图标 | boolean | false |
3434
| `xml` | 图标源 | String | 默认图标 |
3535
| `size` | 图标尺寸 | number| 25 |
36+
| `progressShow` | 是否展示进度提示字 | boolean| true |

packages/core/src/Progress/index.tsx

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { has } from 'lodash';
22
import React, { useRef, useState, useEffect } from 'react';
3-
import { Animated, View, StyleSheet, ViewProps, LayoutChangeEvent } from 'react-native';
3+
import { Animated, View, StyleSheet, ViewProps, LayoutChangeEvent, Text } from 'react-native';
44
import { Flex } from 'src';
55
import { run } from './svg';
66
import Icon from '../Icon';
@@ -20,14 +20,17 @@ export interface ProgressProps extends ViewProps {
2020
/** 图标源 */
2121
xml?: string;
2222
/** 是否展示图标 */
23-
iconShow?: boolean | false;
23+
iconShow?: boolean;
2424
/** 图标尺寸 */
2525
size?: number;
26+
/** 是否展示进度提示字 */
27+
progressShow?: boolean;
2628
}
2729

2830
export default (props: ProgressProps) => {
2931
const {
30-
iconShow,
32+
iconShow = false,
33+
progressShow = true,
3134
size = 25,
3235
xml = run,
3336
style,
@@ -36,6 +39,7 @@ export default (props: ProgressProps) => {
3639
position,
3740
animation = { duration: 500 },
3841
} = props;
42+
3943
const progWidth = useRef<any>(new Animated.Value(0)).current;
4044
const [wrapWidth, setWrapWidth] = useState<number>(0);
4145

@@ -74,14 +78,20 @@ export default (props: ProgressProps) => {
7478
style={[
7579
styles.pre,
7680
position === 'fixed' ? { position: 'absolute', top: 0 } : {},
77-
{ borderColor: progressColor },
81+
{ borderColor: progressColor, height: progressShow === true ? 20 : 4 },
7882
]}
7983
>
84+
{progressShow && progressShow === true && (
85+
<View style={{ position: 'absolute', left: '45%', zIndex: 1000 }}>
86+
<Text style={{ fontSize: 12 }}>{progress}%</Text>
87+
</View>
88+
)}
8089
<Animated.View
8190
style={[
8291
styles.preOisn,
8392
{
8493
width: progWidth,
94+
height: progressShow === true ? 20 : 4,
8595
backgroundColor: progressColor,
8696
},
8797
]}
@@ -91,7 +101,7 @@ export default (props: ProgressProps) => {
91101
<View onLayout={onLayout} style={[styles.preIcon, { height: size }]}>
92102
<Animated.View
93103
style={{
94-
marginLeft: progress === 0 ? -50 : -35,
104+
marginLeft: progress === 0 ? -50 : progress === 100 ? -20 : -35,
95105
width: progWidth,
96106
}}
97107
></Animated.View>
@@ -109,7 +119,6 @@ const styles = StyleSheet.create({
109119
},
110120
pre: {
111121
borderWidth: 1,
112-
height: 4,
113122
width: '100%',
114123
borderRadius: 20,
115124
marginBottom: 0,
@@ -124,7 +133,6 @@ const styles = StyleSheet.create({
124133
},
125134
preOisn: {
126135
position: 'absolute',
127-
height: 4,
128136
left: 0,
129137
top: 0,
130138
},

0 commit comments

Comments
 (0)