11import React , { forwardRef } from "react" ;
2- import { Dimensions } from "react-native" ;
2+ import { Dimensions , ViewStyle } from "react-native" ;
33import {
44 Easing ,
55 interpolate ,
@@ -11,36 +11,34 @@ import {
1111 withTiming ,
1212} from "react-native-reanimated" ;
1313
14- import { AnimatedBox } from "../../primitives" ;
14+ import { AnimatedBox , BoxProps } from "../../primitives" ;
1515import { useTheme } from "../../theme/context" ;
16- import { createComponent } from "../../utils" ;
17-
18- import { useProgressBarProps } from "./ProgressProps" ;
16+ import { createComponent , styleAdapter } from "../../utils" ;
1917
2018export type ProgressBarSizes = "sm" | "md" | "lg" | "xl" ;
19+ export type ProgressBarTheme = "base" | "primary" ;
2120
22- export interface ProgressProps {
21+ export interface ProgressProps extends BoxProps {
2322 /**
2423 * The size of the Progress Bar component.
2524 * @default lg
2625 */
2726 size : ProgressBarSizes ;
27+ /**
28+ * The theme of the Progress Bar component.
29+ * @default base
30+ */
31+ themeColor : ProgressBarTheme ;
2832 /**
2933 * The progress value
3034 * If null makes it indeterminate
3135 * @default null
3236 */
3337 value : number | null ;
3438 /**
35- * Track color containing the progress
36- * @default 'bg-gray-200'
39+ * The progress track style
3740 */
38- trackColor : string ;
39- /**
40- * Track color of the progress value
41- * @default 'bg-gray-800'
42- */
43- progressTrackColor : string ;
41+ trackStyle : ViewStyle ;
4442}
4543
4644const SPRING_CONFIG = {
@@ -57,9 +55,16 @@ export const RNProgressBar: React.FC<Partial<ProgressProps>> = forwardRef<
5755 Partial < ProgressProps >
5856> ( ( props , ref ) => {
5957 const tailwind = useTheme ( ) ;
60- const progressStyles = useTheme ( "progress" ) ;
61- const { trackColor, progressTrackColor, value, size } =
62- useProgressBarProps ( props ) ;
58+ const progressTheme = useTheme ( "progress" ) ;
59+ const {
60+ size = "lg" ,
61+ themeColor = "base" ,
62+ value,
63+ style,
64+ trackStyle = { } ,
65+ ...otherProps
66+ } = props ;
67+
6368 const isIndeterminate = React . useMemo (
6469 ( ) => value === null || value === undefined ,
6570 [ value ] ,
@@ -107,24 +112,34 @@ export const RNProgressBar: React.FC<Partial<ProgressProps>> = forwardRef<
107112 < AnimatedBox
108113 ref = { ref }
109114 style = { [
110- tailwind . style ( progressStyles . container [ size ] ) ,
111- { backgroundColor : trackColor } ,
115+ tailwind . style (
116+ progressTheme . size [ size ] ?. container ,
117+ progressTheme . themeColor [ themeColor ] ?. track ,
118+ ) ,
119+ styleAdapter ( style , { pressed : false } , false ) ,
112120 ] }
121+ { ...otherProps }
113122 >
114123 { isIndeterminate && (
115124 < AnimatedBox
116125 style = { [
117- tailwind . style ( progressStyles . bar [ size ] ) ,
118- { backgroundColor : progressTrackColor } ,
126+ tailwind . style (
127+ progressTheme . size [ size ] ?. bar ,
128+ progressTheme . themeColor [ themeColor ] ?. filled ,
129+ ) ,
130+ styleAdapter ( trackStyle , { pressed : false } , false ) ,
119131 translatingStyle ,
120132 ] }
121133 />
122134 ) }
123135 { ! isIndeterminate && (
124136 < AnimatedBox
125137 style = { [
126- tailwind . style ( progressStyles . bar [ size ] ) ,
127- { backgroundColor : progressTrackColor } ,
138+ tailwind . style (
139+ progressTheme . size [ size ] ?. bar ,
140+ progressTheme . themeColor [ themeColor ] ?. filled ,
141+ ) ,
142+ styleAdapter ( trackStyle , { pressed : false } , false ) ,
128143 animatingWidth ,
129144 ] }
130145 />
0 commit comments