11import { has } from 'lodash' ;
22import 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' ;
44import { Flex } from 'src' ;
55import { run } from './svg' ;
66import 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
2830export 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