@@ -35,8 +35,8 @@ const Progress: React.FC<ProgressProps> = ({
3535 showLabel = true ,
3636 label,
3737 showUnit = true ,
38- top = " 50%" ,
39- left = " 11%" ,
38+ top = ' 50%' ,
39+ left = ' 11%' ,
4040} ) => {
4141 const progressValue = useRef ( new Animated . Value ( 0 ) ) . current ;
4242
@@ -69,49 +69,32 @@ const Progress: React.FC<ProgressProps> = ({
6969 position : 'absolute' ,
7070 top : top ,
7171 left : left ,
72- transform : [
73- { translateX : 0 } ,
74- { translateY : 0 } ,
75- ] ,
72+ transform : [ { translateX : 0 } , { translateY : 0 } ] ,
7673 fontSize : fontSize ,
7774 fontWeight : 'bold' ,
7875 color : typeof color === 'string' ? color : color [ 1 ] ,
79- } } >
76+ } }
77+ >
8078 { label ?? `${ value } ${ showUnit ? '%' : '' } ` }
81- </ Text >
79+ </ Text >
8280 ) ;
8381
8482 return (
8583 < View >
86- < Svg width = { width } height = { width / 3 } >
84+ < Svg width = { width } height = { width / 3 } >
8785 < Defs >
88- < LinearGradient id = "grad" x1 = "0" y1 = "0" x2 = "1" y2 = "0" >
86+ < LinearGradient id = "grad" x1 = "0" y1 = "0" x2 = "1" y2 = "0" >
8987 < Stop offset = "0" stopColor = { typeof color === 'string' ? color : color [ 0 ] } stopOpacity = "1" />
9088 < Stop offset = "1" stopColor = { typeof color === 'string' ? color : color [ 1 ] } stopOpacity = "1" />
9189 </ LinearGradient >
9290 </ Defs >
9391 < G origin = { `${ width / 2 } , ${ width / 2 } ` } >
94- < Rect
95- x = { 0 }
96- y = { 0 }
97- width = { width }
98- height = { strokeWidth }
99- rx = { strokeWidth / 2 }
100- fill = { bgColor }
101- />
102- < AnimatedRect
103- x = { 0 }
104- y = { 0 }
105- width = { progress }
106- height = { strokeWidth }
107- rx = { strokeWidth / 2 }
108- fill = "url(#grad)"
109- >
110- </ AnimatedRect >
92+ < Rect x = { 0 } y = { 0 } width = { width } height = { strokeWidth } rx = { strokeWidth / 2 } fill = { bgColor } />
93+ < AnimatedRect x = { 0 } y = { 0 } width = { progress } height = { strokeWidth } rx = { strokeWidth / 2 } fill = "url(#grad)" />
11194 </ G >
11295 </ Svg >
11396 { progressLabel }
114- </ View >
97+ </ View >
11598 ) ;
11699 } else if ( type === 'circle' ) {
117100 const radius = ( width - strokeWidth ) / 2 ;
@@ -135,14 +118,14 @@ const Progress: React.FC<ProgressProps> = ({
135118 fontSize : fontSize ,
136119 fontWeight : 'bold' ,
137120 color : typeof color === 'string' ? color : color [ 1 ] ,
138- }
139- } >
121+ } }
122+ >
140123 { label ?? `${ value } ${ showUnit ? '%' : '' } ` }
141- </ Text >
124+ </ Text >
142125 ) ;
143126
144127 return (
145- < View >
128+ < View >
146129 < Svg width = { width } height = { width } >
147130 < Defs >
148131 < LinearGradient id = "grad" x1 = "0" y1 = "0" x2 = "1" y2 = "0" >
@@ -151,14 +134,7 @@ const Progress: React.FC<ProgressProps> = ({
151134 </ LinearGradient >
152135 </ Defs >
153136 < G rotation = "-90" origin = { `${ width / 2 } , ${ width / 2 } ` } >
154- < Circle
155- cx = { width / 2 }
156- cy = { width / 2 }
157- r = { radius }
158- stroke = { bgColor }
159- strokeWidth = { strokeWidth }
160- fill = "none"
161- />
137+ < Circle cx = { width / 2 } cy = { width / 2 } r = { radius } stroke = { bgColor } strokeWidth = { strokeWidth } fill = "none" />
162138 < AnimatedCircle
163139 cx = { width / 2 }
164140 cy = { width / 2 }
@@ -175,6 +151,8 @@ const Progress: React.FC<ProgressProps> = ({
175151 { progressLabel }
176152 </ View >
177153 ) ;
154+ } else {
155+ return null ;
178156 }
179157} ;
180158
0 commit comments