1
1
import { has } from 'lodash' ;
2
2
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' ;
4
4
import { Flex } from 'src' ;
5
5
import { run } from './svg' ;
6
6
import Icon from '../Icon' ;
@@ -20,14 +20,17 @@ export interface ProgressProps extends ViewProps {
20
20
/** 图标源 */
21
21
xml ?: string ;
22
22
/** 是否展示图标 */
23
- iconShow ?: boolean | false ;
23
+ iconShow ?: boolean ;
24
24
/** 图标尺寸 */
25
25
size ?: number ;
26
+ /** 是否展示进度提示字 */
27
+ progressShow ?: boolean ;
26
28
}
27
29
28
30
export default ( props : ProgressProps ) => {
29
31
const {
30
- iconShow,
32
+ iconShow = false ,
33
+ progressShow = true ,
31
34
size = 25 ,
32
35
xml = run ,
33
36
style,
@@ -36,6 +39,7 @@ export default (props: ProgressProps) => {
36
39
position,
37
40
animation = { duration : 500 } ,
38
41
} = props ;
42
+
39
43
const progWidth = useRef < any > ( new Animated . Value ( 0 ) ) . current ;
40
44
const [ wrapWidth , setWrapWidth ] = useState < number > ( 0 ) ;
41
45
@@ -74,14 +78,20 @@ export default (props: ProgressProps) => {
74
78
style = { [
75
79
styles . pre ,
76
80
position === 'fixed' ? { position : 'absolute' , top : 0 } : { } ,
77
- { borderColor : progressColor } ,
81
+ { borderColor : progressColor , height : progressShow === true ? 20 : 4 } ,
78
82
] }
79
83
>
84
+ { progressShow && progressShow === true && (
85
+ < View style = { { position : 'absolute' , left : '45%' , zIndex : 1000 } } >
86
+ < Text style = { { fontSize : 12 } } > { progress } %</ Text >
87
+ </ View >
88
+ ) }
80
89
< Animated . View
81
90
style = { [
82
91
styles . preOisn ,
83
92
{
84
93
width : progWidth ,
94
+ height : progressShow === true ? 20 : 4 ,
85
95
backgroundColor : progressColor ,
86
96
} ,
87
97
] }
@@ -91,7 +101,7 @@ export default (props: ProgressProps) => {
91
101
< View onLayout = { onLayout } style = { [ styles . preIcon , { height : size } ] } >
92
102
< Animated . View
93
103
style = { {
94
- marginLeft : progress === 0 ? - 50 : - 35 ,
104
+ marginLeft : progress === 0 ? - 50 : progress === 100 ? - 20 : - 35 ,
95
105
width : progWidth ,
96
106
} }
97
107
> </ Animated . View >
@@ -109,7 +119,6 @@ const styles = StyleSheet.create({
109
119
} ,
110
120
pre : {
111
121
borderWidth : 1 ,
112
- height : 4 ,
113
122
width : '100%' ,
114
123
borderRadius : 20 ,
115
124
marginBottom : 0 ,
@@ -124,7 +133,6 @@ const styles = StyleSheet.create({
124
133
} ,
125
134
preOisn : {
126
135
position : 'absolute' ,
127
- height : 4 ,
128
136
left : 0 ,
129
137
top : 0 ,
130
138
} ,
0 commit comments