related-ui-components 3.0.0 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/module/app.js +11 -22
- package/lib/module/app.js.map +1 -1
- package/lib/module/components/ProgressBar/CircularProgressBar.js +69 -67
- package/lib/module/components/ProgressBar/CircularProgressBar.js.map +1 -1
- package/lib/typescript/src/components/ProgressBar/CircularProgressBar.d.ts +1 -2
- package/lib/typescript/src/components/ProgressBar/CircularProgressBar.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/app.tsx +5 -5
- package/src/components/ProgressBar/CircularProgressBar.tsx +75 -99
package/lib/module/app.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
import React, { useState } from "react";
|
|
4
4
|
import { SafeAreaView, StyleSheet, StatusBar } from "react-native";
|
|
5
|
-
|
|
5
|
+
// Adjust path as needed
|
|
6
6
|
import { GestureHandlerRootView } from "react-native-gesture-handler";
|
|
7
|
-
import { SelaDealCard } from "./components/index.js";
|
|
8
7
|
import { lightTheme, RelatedProvider, useTheme } from "./theme/index.js";
|
|
8
|
+
import CircularProgressBar from "./components/ProgressBar/CircularProgressBar.js";
|
|
9
9
|
import { BottomSheetStackProvider } from "./contexts/index.js";
|
|
10
10
|
import { SafeAreaProvider } from "react-native-safe-area-context";
|
|
11
11
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
@@ -40,27 +40,16 @@ const App = () => {
|
|
|
40
40
|
children: /*#__PURE__*/_jsxs(BottomSheetStackProvider, {
|
|
41
41
|
children: [/*#__PURE__*/_jsx(StatusBar, {
|
|
42
42
|
barStyle: "light-content"
|
|
43
|
-
}), /*#__PURE__*/
|
|
43
|
+
}), /*#__PURE__*/_jsx(SafeAreaView, {
|
|
44
44
|
style: styles.appContainer,
|
|
45
|
-
children:
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
width: 300,
|
|
54
|
-
height: 300,
|
|
55
|
-
label: "discount",
|
|
56
|
-
description: "HELLO",
|
|
57
|
-
providerName: "Riva Club",
|
|
58
|
-
price: "100",
|
|
59
|
-
lockOverlay: true
|
|
60
|
-
// grayscaleIntensity={80}
|
|
61
|
-
,
|
|
62
|
-
backgroundImage: require("./assets/images/namshi-banner.png")
|
|
63
|
-
})]
|
|
45
|
+
children: /*#__PURE__*/_jsx(CircularProgressBar, {
|
|
46
|
+
progress: 0,
|
|
47
|
+
totalSteps: 4,
|
|
48
|
+
currentStep: 1,
|
|
49
|
+
size: 43,
|
|
50
|
+
strokeWidth: 2,
|
|
51
|
+
progressColor: "blue"
|
|
52
|
+
})
|
|
64
53
|
})]
|
|
65
54
|
})
|
|
66
55
|
})
|
package/lib/module/app.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useState","SafeAreaView","StyleSheet","StatusBar","
|
|
1
|
+
{"version":3,"names":["React","useState","SafeAreaView","StyleSheet","StatusBar","GestureHandlerRootView","lightTheme","RelatedProvider","useTheme","CircularProgressBar","BottomSheetStackProvider","SafeAreaProvider","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","DUMMY_DATA","Array","from","length","_","i","id","image","title","App","theme","departureDate","setDepartureDate","undefined","returnDate","setReturnDate","progress","setProgress","handleAnimate","newProgress","Math","floor","random","children","style","flex","barStyle","styles","appContainer","totalSteps","currentStep","size","strokeWidth","progressColor","create","backgroundColor","justifyContent","alignItems"],"sourceRoot":"..\\..\\src","sources":["app.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAeC,QAAQ,QAAQ,OAAO;AAClD,SAASC,YAAY,EAAEC,UAAU,EAAEC,SAAS,QAAkC,cAAc;AACV;AAClF,SAASC,sBAAsB,QAAQ,8BAA8B;AAarE,SAAoBC,UAAU,EAAEC,eAAe,EAAEC,QAAQ,QAAQ,kBAAS;AAC1E,O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A,eACjC1B,KAAA,CAACL,wBAAwB;YAAA+B,QAAA,gBACvB5B,IAAA,CAACT,SAAS;cAACwC,QAAQ,EAAC;YAAe,CAAE,CAAC,eACtC/B,IAAA,CAACX,YAAY;cAACwC,KAAK,EAAEG,MAAM,CAACC,YAAa;cAAAL,QAAA,eAuDvC5B,IAAA,CAACJ,mBAAmB;gBAAEyB,QAAQ,EAAE,CAAE;gBAACa,UAAU,EAAE,CAAE;gBAACC,WAAW,EAAE,CAAE;gBAACC,IAAI,EAAE,EAAG;gBAAEC,WAAW,EAAE,CAAE;gBAACC,aAAa,EAAC;cAAM,CAAsB;YAAC,CAqB5H,CAAC;UAAA,CACS;QAAC,CACZ;MAAC,CACI;IAAC,CACT;EAAC,CACnB,CAAC;AAEP,CAAC;AAED,MAAMN,MAAM,GAAG1C,UAAU,CAACiD,MAAM,CAAC;EAC/BN,YAAY,EAAE;IACZH,IAAI,EAAE,CAAC;IACPU,eAAe,EAAE,MAAM;IACvBC,cAAc,EAAE,QAAQ;IAAE;IAC1BC,UAAU,EAAC;EACb;AACF,CAAC,CAAC;AAEF,eAAe5B,GAAG","ignoreList":[]}
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import React, { useEffect } from "react";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { StyleSheet, TextInput, View } from "react-native";
|
|
5
|
+
import { Canvas, DashPathEffect, Path, Shadow, Skia } from "@shopify/react-native-skia";
|
|
6
|
+
import Animated, { Easing, useAnimatedProps, useDerivedValue, useSharedValue, withTiming } from "react-native-reanimated";
|
|
7
|
+
import { useTheme } from "../../theme/index.js";
|
|
7
8
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
9
|
+
const AnimatedTextInput = Animated.createAnimatedComponent(TextInput);
|
|
8
10
|
const CircularProgressBar = ({
|
|
9
11
|
size = 120,
|
|
10
12
|
strokeWidth = 8,
|
|
11
|
-
backgroundColor
|
|
12
|
-
progressColor
|
|
13
|
+
backgroundColor,
|
|
14
|
+
progressColor,
|
|
13
15
|
lineCap = "round",
|
|
14
16
|
customText,
|
|
15
|
-
textColor
|
|
17
|
+
textColor,
|
|
16
18
|
fontSize = size / 4,
|
|
17
|
-
textFont,
|
|
18
19
|
style,
|
|
19
20
|
innerShadowColor,
|
|
20
21
|
duration = 1000,
|
|
@@ -23,17 +24,15 @@ const CircularProgressBar = ({
|
|
|
23
24
|
progressPadding = 0,
|
|
24
25
|
currentStep = 0,
|
|
25
26
|
totalSteps = 4,
|
|
26
|
-
stepGap = 15
|
|
27
|
+
stepGap = 15
|
|
27
28
|
}) => {
|
|
29
|
+
const {
|
|
30
|
+
theme
|
|
31
|
+
} = useTheme();
|
|
28
32
|
const animatedValue = useSharedValue(0);
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
ios: "Helvetica",
|
|
33
|
-
default: "serif"
|
|
34
|
-
}),
|
|
35
|
-
fontSize: fontSize
|
|
36
|
-
});
|
|
33
|
+
const finalProgressColor = progressColor || theme.primary;
|
|
34
|
+
const finalBackgroundColor = backgroundColor || theme.disabled;
|
|
35
|
+
const finalTextColor = textColor || theme.onSurface;
|
|
37
36
|
const radius = (size - strokeWidth) / 2;
|
|
38
37
|
const circumference = 2 * Math.PI * radius;
|
|
39
38
|
const path = Skia.Path.Make();
|
|
@@ -45,30 +44,28 @@ const CircularProgressBar = ({
|
|
|
45
44
|
duration,
|
|
46
45
|
easing: Easing.out(Easing.cubic)
|
|
47
46
|
});
|
|
48
|
-
}, [progress, currentStep, totalSteps, duration, variant]);
|
|
49
|
-
|
|
50
|
-
// --- Text Logic ---
|
|
47
|
+
}, [progress, currentStep, totalSteps, duration, variant, animatedValue]);
|
|
51
48
|
const textToDisplay = useDerivedValue(() => {
|
|
52
49
|
if (customText !== undefined) {
|
|
53
50
|
return customText;
|
|
54
51
|
}
|
|
55
52
|
if (variant === "steps") {
|
|
56
|
-
// Round the animated value to the nearest step for display
|
|
57
53
|
const displayStep = Math.round(animatedValue.value * (totalSteps || 1));
|
|
58
54
|
return `${displayStep}/${totalSteps}`;
|
|
59
55
|
}
|
|
60
56
|
return `${Math.round(animatedValue.value * 100)}%`;
|
|
57
|
+
}, [customText, variant, animatedValue, totalSteps]);
|
|
58
|
+
const animatedProps = useAnimatedProps(() => {
|
|
59
|
+
return {
|
|
60
|
+
text: textToDisplay.value
|
|
61
|
+
};
|
|
61
62
|
});
|
|
62
|
-
const
|
|
63
|
-
if (
|
|
64
|
-
|
|
65
|
-
return
|
|
66
|
-
}
|
|
67
|
-
const textY = size / 2 + fontSize / 3;
|
|
68
|
-
|
|
69
|
-
// --- Steps Variant Logic ---
|
|
63
|
+
const getInitialText = () => {
|
|
64
|
+
if (customText !== undefined) return customText;
|
|
65
|
+
if (variant === 'steps') return `${currentStep}/${totalSteps}`;
|
|
66
|
+
return `${progress}%`;
|
|
67
|
+
};
|
|
70
68
|
const renderSteps = () => {
|
|
71
|
-
// Calculate the total gap length in the circumference
|
|
72
69
|
const totalGapDegrees = (totalSteps || 1) * stepGap;
|
|
73
70
|
const totalArcDegrees = 360 - totalGapDegrees;
|
|
74
71
|
const stepArcLength = totalArcDegrees / (totalSteps || 1) / 360 * circumference;
|
|
@@ -80,7 +77,7 @@ const CircularProgressBar = ({
|
|
|
80
77
|
style: "stroke",
|
|
81
78
|
strokeWidth: strokeWidth,
|
|
82
79
|
strokeCap: lineCap,
|
|
83
|
-
color:
|
|
80
|
+
color: finalBackgroundColor,
|
|
84
81
|
children: /*#__PURE__*/_jsx(DashPathEffect, {
|
|
85
82
|
intervals: dashPattern
|
|
86
83
|
})
|
|
@@ -89,7 +86,7 @@ const CircularProgressBar = ({
|
|
|
89
86
|
style: "stroke",
|
|
90
87
|
strokeWidth: strokeWidth,
|
|
91
88
|
strokeCap: lineCap,
|
|
92
|
-
color:
|
|
89
|
+
color: finalProgressColor,
|
|
93
90
|
start: 0,
|
|
94
91
|
end: animatedValue,
|
|
95
92
|
children: [/*#__PURE__*/_jsx(DashPathEffect, {
|
|
@@ -104,45 +101,50 @@ const CircularProgressBar = ({
|
|
|
104
101
|
})]
|
|
105
102
|
});
|
|
106
103
|
};
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
})]
|
|
133
|
-
});
|
|
134
|
-
};
|
|
135
|
-
return /*#__PURE__*/_jsxs(Canvas, {
|
|
104
|
+
const renderProgress = () => /*#__PURE__*/_jsxs(_Fragment, {
|
|
105
|
+
children: [/*#__PURE__*/_jsx(Path, {
|
|
106
|
+
path: path,
|
|
107
|
+
style: "stroke",
|
|
108
|
+
strokeWidth: strokeWidth,
|
|
109
|
+
strokeCap: lineCap,
|
|
110
|
+
color: finalBackgroundColor
|
|
111
|
+
}), /*#__PURE__*/_jsx(Path, {
|
|
112
|
+
path: path,
|
|
113
|
+
style: "stroke",
|
|
114
|
+
strokeWidth: progressStrokeWidth,
|
|
115
|
+
strokeCap: lineCap,
|
|
116
|
+
color: finalProgressColor,
|
|
117
|
+
start: 0,
|
|
118
|
+
end: animatedValue,
|
|
119
|
+
children: innerShadowColor && /*#__PURE__*/_jsx(Shadow, {
|
|
120
|
+
dx: 0,
|
|
121
|
+
dy: 0,
|
|
122
|
+
blur: 4,
|
|
123
|
+
color: innerShadowColor,
|
|
124
|
+
inner: true
|
|
125
|
+
})
|
|
126
|
+
})]
|
|
127
|
+
});
|
|
128
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
136
129
|
style: [{
|
|
137
130
|
width: size,
|
|
138
|
-
height: size
|
|
131
|
+
height: size,
|
|
132
|
+
justifyContent: 'center',
|
|
133
|
+
alignItems: 'center'
|
|
139
134
|
}, style],
|
|
140
|
-
children: [
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
135
|
+
children: [/*#__PURE__*/_jsx(Canvas, {
|
|
136
|
+
style: StyleSheet.absoluteFill,
|
|
137
|
+
children: variant === "steps" ? renderSteps() : renderProgress()
|
|
138
|
+
}), /*#__PURE__*/_jsx(AnimatedTextInput, {
|
|
139
|
+
editable: false,
|
|
140
|
+
defaultValue: getInitialText(),
|
|
141
|
+
style: {
|
|
142
|
+
color: finalTextColor,
|
|
143
|
+
fontSize: fontSize,
|
|
144
|
+
textAlign: 'center',
|
|
145
|
+
padding: 0
|
|
146
|
+
},
|
|
147
|
+
animatedProps: animatedProps
|
|
146
148
|
})]
|
|
147
149
|
});
|
|
148
150
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useEffect","Canvas","
|
|
1
|
+
{"version":3,"names":["React","useEffect","StyleSheet","TextInput","View","Canvas","DashPathEffect","Path","Shadow","Skia","Animated","Easing","useAnimatedProps","useDerivedValue","useSharedValue","withTiming","useTheme","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","AnimatedTextInput","createAnimatedComponent","CircularProgressBar","size","strokeWidth","backgroundColor","progressColor","lineCap","customText","textColor","fontSize","style","innerShadowColor","duration","variant","progress","progressPadding","currentStep","totalSteps","stepGap","theme","animatedValue","finalProgressColor","primary","finalBackgroundColor","disabled","finalTextColor","onSurface","radius","circumference","Math","PI","path","Make","addCircle","progressStrokeWidth","max","targetValue","value","easing","out","cubic","textToDisplay","undefined","displayStep","round","animatedProps","text","getInitialText","renderSteps","totalGapDegrees","totalArcDegrees","stepArcLength","gapLength","dashPattern","children","strokeCap","color","intervals","start","end","dx","dy","blur","inner","renderProgress","width","height","justifyContent","alignItems","absoluteFill","editable","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gE,MAAM,EAAEhE,IAAI;MAAEiE,cAAc,EAAE,QAAQ;MAAEC,UAAU,EAAE;IAAS,CAAC,EAAE1D,KAAK,CAAE;IAAA4C,QAAA,gBAClG5D,IAAA,CAACb,MAAM;MAAC6B,KAAK,EAAEhC,UAAU,CAAC2F,YAAa;MAAAf,QAAA,EACpCzC,OAAO,KAAK,OAAO,GAAGmC,WAAW,CAAC,CAAC,GAAGgB,cAAc,CAAC;IAAC,CACjD,CAAC,eACTtE,IAAA,CAACK,iBAAiB;MAChBuE,QAAQ,EAAE,KAAM;MAChBC,YAAY,EAAExB,cAAc,CAAC,CAAE;MAC/BrC,KAAK,EAAE;QACL8C,KAAK,EAAE/B,cAAc;QACrBhB,QAAQ,EAAEA,QAAQ;QAClB+D,SAAS,EAAE,QAAQ;QACnBC,OAAO,EAAE;MACX,CAAE;MACF5B,aAAa,EAAEA;IAAc,CAC9B,CAAC;EAAA,CACE,CAAC;AAEX,CAAC;AAED,eAAe5C,mBAAmB","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { ViewStyle } from "react-native";
|
|
3
3
|
interface CircularProgressBarProps {
|
|
4
4
|
size?: number;
|
|
5
5
|
strokeWidth?: number;
|
|
@@ -9,7 +9,6 @@ interface CircularProgressBarProps {
|
|
|
9
9
|
customText?: string;
|
|
10
10
|
textColor?: string;
|
|
11
11
|
fontSize?: number;
|
|
12
|
-
textFont?: ImageRequireSource;
|
|
13
12
|
style?: ViewStyle;
|
|
14
13
|
innerShadowColor?: string;
|
|
15
14
|
duration?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CircularProgressBar.d.ts","sourceRoot":"","sources":["../../../../../src/components/ProgressBar/CircularProgressBar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"CircularProgressBar.d.ts","sourceRoot":"","sources":["../../../../../src/components/ProgressBar/CircularProgressBar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AACzC,OAAO,EAA+B,SAAS,EAAE,MAAM,cAAc,CAAC;AAatE,UAAU,wBAAwB;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;IACtC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,QAAA,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,wBAAwB,CAmJ3D,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
|
package/package.json
CHANGED
package/src/app.tsx
CHANGED
|
@@ -52,13 +52,13 @@ const App = () => {
|
|
|
52
52
|
<BottomSheetStackProvider>
|
|
53
53
|
<StatusBar barStyle="light-content" />
|
|
54
54
|
<SafeAreaView style={styles.appContainer}>
|
|
55
|
-
<CarouselCardStack
|
|
55
|
+
{/* <CarouselCardStack
|
|
56
56
|
data={DUMMY_DATA}
|
|
57
57
|
// backgroundColor="#333" // Set a background color for the component area
|
|
58
58
|
// onActiveIndexChange={(index) => {
|
|
59
59
|
// console.log("Active item index:", index);
|
|
60
60
|
// }}
|
|
61
|
-
/>
|
|
61
|
+
/> */}
|
|
62
62
|
{/* <CircularProgressBar
|
|
63
63
|
progress={5}
|
|
64
64
|
lineCap="round"
|
|
@@ -106,7 +106,7 @@ const App = () => {
|
|
|
106
106
|
{/* <DateRangePicker onDatesChange={()=>{}} labelContainerStyle={{backgroundColor:"red"}}></DateRangePicker> */}
|
|
107
107
|
{/* <CarRentalForm onSelectionChange={console.log}></CarRentalForm> */}
|
|
108
108
|
{/* <CarouselCardStack data={DUMMY_DATA} /> */}
|
|
109
|
-
|
|
109
|
+
<CircularProgressBar progress={0} totalSteps={4} currentStep={1} size={43} strokeWidth={2} progressColor="blue"></CircularProgressBar>
|
|
110
110
|
{/* <RangeSlider initialMinValue={0} initialMaxValue={100} min={0} max={500} sliderWidth={300} onValueChange={console.log}></RangeSlider> */}
|
|
111
111
|
{/* <PhoneInput
|
|
112
112
|
value=""
|
|
@@ -114,7 +114,7 @@ const App = () => {
|
|
|
114
114
|
inputContainerStyle={{ height: 55 }}
|
|
115
115
|
></PhoneInput> */}
|
|
116
116
|
|
|
117
|
-
<SelaDealCard
|
|
117
|
+
{/* <SelaDealCard
|
|
118
118
|
variant="horizontal"
|
|
119
119
|
width={300}
|
|
120
120
|
height={300}
|
|
@@ -126,7 +126,7 @@ const App = () => {
|
|
|
126
126
|
// grayscaleIntensity={80}
|
|
127
127
|
backgroundImage={require("./assets/images/namshi-banner.png")}
|
|
128
128
|
></SelaDealCard>
|
|
129
|
-
|
|
129
|
+
*/}
|
|
130
130
|
</SafeAreaView>
|
|
131
131
|
</BottomSheetStackProvider>
|
|
132
132
|
</RelatedProvider>
|
|
@@ -1,22 +1,16 @@
|
|
|
1
1
|
import React, { useEffect } from "react";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Text,
|
|
9
|
-
useFont,
|
|
10
|
-
PathOp,
|
|
11
|
-
DashPathEffect,
|
|
12
|
-
} from "@shopify/react-native-skia";
|
|
13
|
-
import {
|
|
2
|
+
import { StyleSheet, TextInput, View, ViewStyle } from "react-native";
|
|
3
|
+
import { Canvas, DashPathEffect, Path, Shadow, Skia } from "@shopify/react-native-skia";
|
|
4
|
+
import Animated, {
|
|
5
|
+
Easing,
|
|
6
|
+
useAnimatedProps,
|
|
7
|
+
useDerivedValue,
|
|
14
8
|
useSharedValue,
|
|
15
9
|
withTiming,
|
|
16
|
-
useDerivedValue,
|
|
17
|
-
Easing,
|
|
18
10
|
} from "react-native-reanimated";
|
|
19
|
-
import {
|
|
11
|
+
import { useTheme } from "../../theme";
|
|
12
|
+
|
|
13
|
+
const AnimatedTextInput = Animated.createAnimatedComponent(TextInput);
|
|
20
14
|
|
|
21
15
|
interface CircularProgressBarProps {
|
|
22
16
|
size?: number;
|
|
@@ -27,34 +21,26 @@ interface CircularProgressBarProps {
|
|
|
27
21
|
customText?: string;
|
|
28
22
|
textColor?: string;
|
|
29
23
|
fontSize?: number;
|
|
30
|
-
textFont?: ImageRequireSource;
|
|
31
24
|
style?: ViewStyle;
|
|
32
25
|
innerShadowColor?: string;
|
|
33
26
|
duration?: number;
|
|
34
|
-
|
|
35
|
-
// New variant prop
|
|
36
27
|
variant?: "progress" | "steps";
|
|
37
|
-
|
|
38
|
-
// Props for 'progress' variant
|
|
39
|
-
progress?: number; // 0 to 100
|
|
28
|
+
progress?: number;
|
|
40
29
|
progressPadding?: number;
|
|
41
|
-
|
|
42
|
-
// Props for 'steps' variant
|
|
43
30
|
currentStep?: number;
|
|
44
31
|
totalSteps?: number;
|
|
45
|
-
stepGap?: number;
|
|
32
|
+
stepGap?: number;
|
|
46
33
|
}
|
|
47
34
|
|
|
48
35
|
const CircularProgressBar: React.FC<CircularProgressBarProps> = ({
|
|
49
36
|
size = 120,
|
|
50
37
|
strokeWidth = 8,
|
|
51
|
-
backgroundColor
|
|
52
|
-
progressColor
|
|
38
|
+
backgroundColor,
|
|
39
|
+
progressColor,
|
|
53
40
|
lineCap = "round",
|
|
54
41
|
customText,
|
|
55
|
-
textColor
|
|
42
|
+
textColor,
|
|
56
43
|
fontSize = size / 4,
|
|
57
|
-
textFont,
|
|
58
44
|
style,
|
|
59
45
|
innerShadowColor,
|
|
60
46
|
duration = 1000,
|
|
@@ -63,17 +49,14 @@ const CircularProgressBar: React.FC<CircularProgressBarProps> = ({
|
|
|
63
49
|
progressPadding = 0,
|
|
64
50
|
currentStep = 0,
|
|
65
51
|
totalSteps = 4,
|
|
66
|
-
stepGap = 15,
|
|
52
|
+
stepGap = 15,
|
|
67
53
|
}) => {
|
|
54
|
+
const { theme } = useTheme();
|
|
68
55
|
const animatedValue = useSharedValue(0);
|
|
69
56
|
|
|
70
|
-
const
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
: matchFont({
|
|
74
|
-
fontFamily: Platform.select({ ios: "Helvetica", default: "serif" }),
|
|
75
|
-
fontSize: fontSize,
|
|
76
|
-
});
|
|
57
|
+
const finalProgressColor = progressColor || theme.primary;
|
|
58
|
+
const finalBackgroundColor = backgroundColor || theme.disabled;
|
|
59
|
+
const finalTextColor = textColor || theme.onSurface;
|
|
77
60
|
|
|
78
61
|
const radius = (size - strokeWidth) / 2;
|
|
79
62
|
const circumference = 2 * Math.PI * radius;
|
|
@@ -91,59 +74,56 @@ const CircularProgressBar: React.FC<CircularProgressBarProps> = ({
|
|
|
91
74
|
duration,
|
|
92
75
|
easing: Easing.out(Easing.cubic),
|
|
93
76
|
});
|
|
94
|
-
}, [progress, currentStep, totalSteps, duration, variant]);
|
|
77
|
+
}, [progress, currentStep, totalSteps, duration, variant, animatedValue]);
|
|
95
78
|
|
|
96
|
-
// --- Text Logic ---
|
|
97
79
|
const textToDisplay = useDerivedValue(() => {
|
|
98
80
|
if (customText !== undefined) {
|
|
99
81
|
return customText;
|
|
100
82
|
}
|
|
101
83
|
if (variant === "steps") {
|
|
102
|
-
// Round the animated value to the nearest step for display
|
|
103
84
|
const displayStep = Math.round(animatedValue.value * (totalSteps || 1));
|
|
104
85
|
return `${displayStep}/${totalSteps}`;
|
|
105
86
|
}
|
|
106
87
|
return `${Math.round(animatedValue.value * 100)}%`;
|
|
107
|
-
});
|
|
88
|
+
}, [customText, variant, animatedValue, totalSteps]);
|
|
108
89
|
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
90
|
+
const animatedProps = useAnimatedProps(() => {
|
|
91
|
+
return {
|
|
92
|
+
text: textToDisplay.value,
|
|
93
|
+
} as any;
|
|
113
94
|
});
|
|
114
95
|
|
|
115
|
-
const
|
|
96
|
+
const getInitialText = () => {
|
|
97
|
+
if (customText !== undefined) return customText;
|
|
98
|
+
if (variant === 'steps') return `${currentStep}/${totalSteps}`;
|
|
99
|
+
return `${progress}%`;
|
|
100
|
+
};
|
|
116
101
|
|
|
117
|
-
// --- Steps Variant Logic ---
|
|
118
102
|
const renderSteps = () => {
|
|
119
|
-
// Calculate the total gap length in the circumference
|
|
120
103
|
const totalGapDegrees = (totalSteps || 1) * stepGap;
|
|
121
104
|
const totalArcDegrees = 360 - totalGapDegrees;
|
|
122
|
-
const stepArcLength =
|
|
105
|
+
const stepArcLength =
|
|
106
|
+
(totalArcDegrees / (totalSteps || 1) / 360) * circumference;
|
|
123
107
|
const gapLength = (stepGap / 360) * circumference;
|
|
124
|
-
|
|
125
108
|
const dashPattern = [stepArcLength, gapLength];
|
|
126
109
|
|
|
127
110
|
return (
|
|
128
111
|
<>
|
|
129
|
-
{/* Background Dashed Path */}
|
|
130
112
|
<Path
|
|
131
113
|
path={path}
|
|
132
114
|
style="stroke"
|
|
133
115
|
strokeWidth={strokeWidth}
|
|
134
116
|
strokeCap={lineCap}
|
|
135
|
-
color={
|
|
117
|
+
color={finalBackgroundColor}
|
|
136
118
|
>
|
|
137
119
|
<DashPathEffect intervals={dashPattern} />
|
|
138
120
|
</Path>
|
|
139
|
-
|
|
140
|
-
{/* Progress Dashed Path */}
|
|
141
121
|
<Path
|
|
142
122
|
path={path}
|
|
143
123
|
style="stroke"
|
|
144
124
|
strokeWidth={strokeWidth}
|
|
145
125
|
strokeCap={lineCap}
|
|
146
|
-
color={
|
|
126
|
+
color={finalProgressColor}
|
|
147
127
|
start={0}
|
|
148
128
|
end={animatedValue}
|
|
149
129
|
>
|
|
@@ -156,53 +136,49 @@ const CircularProgressBar: React.FC<CircularProgressBarProps> = ({
|
|
|
156
136
|
);
|
|
157
137
|
};
|
|
158
138
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
{
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
color={
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
<Shadow dx={0} dy={0} blur={4} color={innerShadowColor} inner />
|
|
184
|
-
)}
|
|
185
|
-
</Path>
|
|
186
|
-
</>
|
|
187
|
-
);
|
|
188
|
-
};
|
|
139
|
+
const renderProgress = () => (
|
|
140
|
+
<>
|
|
141
|
+
<Path
|
|
142
|
+
path={path}
|
|
143
|
+
style="stroke"
|
|
144
|
+
strokeWidth={strokeWidth}
|
|
145
|
+
strokeCap={lineCap}
|
|
146
|
+
color={finalBackgroundColor}
|
|
147
|
+
/>
|
|
148
|
+
<Path
|
|
149
|
+
path={path}
|
|
150
|
+
style="stroke"
|
|
151
|
+
strokeWidth={progressStrokeWidth}
|
|
152
|
+
strokeCap={lineCap}
|
|
153
|
+
color={finalProgressColor}
|
|
154
|
+
start={0}
|
|
155
|
+
end={animatedValue}
|
|
156
|
+
>
|
|
157
|
+
{innerShadowColor && (
|
|
158
|
+
<Shadow dx={0} dy={0} blur={4} color={innerShadowColor} inner />
|
|
159
|
+
)}
|
|
160
|
+
</Path>
|
|
161
|
+
</>
|
|
162
|
+
);
|
|
189
163
|
|
|
190
164
|
return (
|
|
191
|
-
<
|
|
192
|
-
{
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
165
|
+
<View style={[{ width: size, height: size, justifyContent: 'center', alignItems: 'center' }, style]}>
|
|
166
|
+
<Canvas style={StyleSheet.absoluteFill}>
|
|
167
|
+
{variant === "steps" ? renderSteps() : renderProgress()}
|
|
168
|
+
</Canvas>
|
|
169
|
+
<AnimatedTextInput
|
|
170
|
+
editable={false}
|
|
171
|
+
defaultValue={getInitialText()}
|
|
172
|
+
style={{
|
|
173
|
+
color: finalTextColor,
|
|
174
|
+
fontSize: fontSize,
|
|
175
|
+
textAlign: 'center',
|
|
176
|
+
padding: 0
|
|
177
|
+
}}
|
|
178
|
+
animatedProps={animatedProps}
|
|
179
|
+
/>
|
|
180
|
+
</View>
|
|
205
181
|
);
|
|
206
182
|
};
|
|
207
183
|
|
|
208
|
-
export default CircularProgressBar;
|
|
184
|
+
export default CircularProgressBar;
|