related-ui-components 3.0.0 → 3.0.1
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 +12 -22
- package/lib/module/app.js.map +1 -1
- package/lib/module/components/ProgressBar/CircularProgressBar.js +58 -77
- package/lib/module/components/ProgressBar/CircularProgressBar.js.map +1 -1
- package/lib/typescript/src/components/ProgressBar/CircularProgressBar.d.ts +2 -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 +81 -101
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,17 @@ 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
|
-
|
|
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: 40,
|
|
47
|
+
customText: 'بلاتينم',
|
|
48
|
+
totalSteps: 4,
|
|
49
|
+
currentStep: 4,
|
|
50
|
+
size: 150,
|
|
51
|
+
strokeWidth: 2,
|
|
52
|
+
progressColor: "#9CA0A3"
|
|
53
|
+
})
|
|
64
54
|
})]
|
|
65
55
|
})
|
|
66
56
|
})
|
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","customText","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,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AK,EAAEtB,UAAW;UAAAmC,QAAA,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;gBAACyB,QAAQ,EAAE,EAAG;gBAAEa,UAAU,EAAE,SAAU;gBAACC,UAAU,EAAE,CAAE;gBAACC,WAAW,EAAE,CAAE;gBAACC,IAAI,EAAE,GAAI;gBAAEC,WAAW,EAAE,CAAE;gBAACC,aAAa,EAAC;cAAS,CAAsB;YAAC,CAqBxJ,CAAC;UAAA,CACS;QAAC,CACZ;MAAC,CACI;IAAC,CACT;EAAC,CACnB,CAAC;AAEP,CAAC;AAED,MAAMP,MAAM,GAAG1C,UAAU,CAACkD,MAAM,CAAC;EAC/BP,YAAY,EAAE;IACZH,IAAI,EAAE,CAAC;IACPW,eAAe,EAAE,MAAM;IACvBC,cAAc,EAAE,QAAQ;IAAE;IAC1BC,UAAU,EAAC;EACb;AACF,CAAC,CAAC;AAEF,eAAe7B,GAAG","ignoreList":[]}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import React, { useEffect } from "react";
|
|
4
|
-
import { Canvas,
|
|
5
|
-
import { useSharedValue, withTiming,
|
|
6
|
-
import {
|
|
4
|
+
import { Canvas, Path, Shadow, Skia, DashPathEffect } from "@shopify/react-native-skia";
|
|
5
|
+
import { useSharedValue, withTiming, Easing } from "react-native-reanimated";
|
|
6
|
+
import { StyleSheet, Text, View } from "react-native";
|
|
7
|
+
import { useTheme } from "../../theme/index.js";
|
|
7
8
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
8
9
|
const CircularProgressBar = ({
|
|
9
10
|
size = 120,
|
|
10
11
|
strokeWidth = 8,
|
|
11
|
-
backgroundColor
|
|
12
|
-
progressColor
|
|
12
|
+
backgroundColor,
|
|
13
|
+
progressColor,
|
|
13
14
|
lineCap = "round",
|
|
14
15
|
customText,
|
|
15
|
-
textColor
|
|
16
|
+
textColor,
|
|
16
17
|
fontSize = size / 4,
|
|
17
|
-
textFont,
|
|
18
18
|
style,
|
|
19
19
|
innerShadowColor,
|
|
20
20
|
duration = 1000,
|
|
@@ -23,17 +23,16 @@ const CircularProgressBar = ({
|
|
|
23
23
|
progressPadding = 0,
|
|
24
24
|
currentStep = 0,
|
|
25
25
|
totalSteps = 4,
|
|
26
|
-
stepGap = 15
|
|
26
|
+
stepGap = 15,
|
|
27
|
+
textStyle
|
|
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,8 @@ const CircularProgressBar = ({
|
|
|
45
44
|
duration,
|
|
46
45
|
easing: Easing.out(Easing.cubic)
|
|
47
46
|
});
|
|
48
|
-
}, [progress, currentStep, totalSteps, duration, variant]);
|
|
49
|
-
|
|
50
|
-
// --- Text Logic ---
|
|
51
|
-
const textToDisplay = useDerivedValue(() => {
|
|
52
|
-
if (customText !== undefined) {
|
|
53
|
-
return customText;
|
|
54
|
-
}
|
|
55
|
-
if (variant === "steps") {
|
|
56
|
-
// Round the animated value to the nearest step for display
|
|
57
|
-
const displayStep = Math.round(animatedValue.value * (totalSteps || 1));
|
|
58
|
-
return `${displayStep}/${totalSteps}`;
|
|
59
|
-
}
|
|
60
|
-
return `${Math.round(animatedValue.value * 100)}%`;
|
|
61
|
-
});
|
|
62
|
-
const textX = useDerivedValue(() => {
|
|
63
|
-
if (!font) return 0;
|
|
64
|
-
const textWidth = font.measureText(textToDisplay.value).width;
|
|
65
|
-
return size / 2 - textWidth / 2;
|
|
66
|
-
});
|
|
67
|
-
const textY = size / 2 + fontSize / 3;
|
|
68
|
-
|
|
69
|
-
// --- Steps Variant Logic ---
|
|
47
|
+
}, [progress, currentStep, totalSteps, duration, variant, animatedValue]);
|
|
70
48
|
const renderSteps = () => {
|
|
71
|
-
// Calculate the total gap length in the circumference
|
|
72
49
|
const totalGapDegrees = (totalSteps || 1) * stepGap;
|
|
73
50
|
const totalArcDegrees = 360 - totalGapDegrees;
|
|
74
51
|
const stepArcLength = totalArcDegrees / (totalSteps || 1) / 360 * circumference;
|
|
@@ -80,7 +57,7 @@ const CircularProgressBar = ({
|
|
|
80
57
|
style: "stroke",
|
|
81
58
|
strokeWidth: strokeWidth,
|
|
82
59
|
strokeCap: lineCap,
|
|
83
|
-
color:
|
|
60
|
+
color: finalBackgroundColor,
|
|
84
61
|
children: /*#__PURE__*/_jsx(DashPathEffect, {
|
|
85
62
|
intervals: dashPattern
|
|
86
63
|
})
|
|
@@ -89,7 +66,7 @@ const CircularProgressBar = ({
|
|
|
89
66
|
style: "stroke",
|
|
90
67
|
strokeWidth: strokeWidth,
|
|
91
68
|
strokeCap: lineCap,
|
|
92
|
-
color:
|
|
69
|
+
color: finalProgressColor,
|
|
93
70
|
start: 0,
|
|
94
71
|
end: animatedValue,
|
|
95
72
|
children: [/*#__PURE__*/_jsx(DashPathEffect, {
|
|
@@ -104,45 +81,49 @@ const CircularProgressBar = ({
|
|
|
104
81
|
})]
|
|
105
82
|
});
|
|
106
83
|
};
|
|
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, {
|
|
84
|
+
const renderProgress = () => /*#__PURE__*/_jsxs(_Fragment, {
|
|
85
|
+
children: [/*#__PURE__*/_jsx(Path, {
|
|
86
|
+
path: path,
|
|
87
|
+
style: "stroke",
|
|
88
|
+
strokeWidth: strokeWidth,
|
|
89
|
+
strokeCap: lineCap,
|
|
90
|
+
color: finalBackgroundColor
|
|
91
|
+
}), /*#__PURE__*/_jsx(Path, {
|
|
92
|
+
path: path,
|
|
93
|
+
style: "stroke",
|
|
94
|
+
strokeWidth: progressStrokeWidth,
|
|
95
|
+
strokeCap: lineCap,
|
|
96
|
+
color: finalProgressColor,
|
|
97
|
+
start: 0,
|
|
98
|
+
end: animatedValue,
|
|
99
|
+
children: innerShadowColor && /*#__PURE__*/_jsx(Shadow, {
|
|
100
|
+
dx: 0,
|
|
101
|
+
dy: 0,
|
|
102
|
+
blur: 4,
|
|
103
|
+
color: innerShadowColor,
|
|
104
|
+
inner: true
|
|
105
|
+
})
|
|
106
|
+
})]
|
|
107
|
+
});
|
|
108
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
136
109
|
style: [{
|
|
137
110
|
width: size,
|
|
138
|
-
height: size
|
|
111
|
+
height: size,
|
|
112
|
+
justifyContent: "center",
|
|
113
|
+
alignItems: "center"
|
|
139
114
|
}, style],
|
|
140
|
-
children: [
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
115
|
+
children: [/*#__PURE__*/_jsx(Canvas, {
|
|
116
|
+
style: StyleSheet.absoluteFill,
|
|
117
|
+
children: variant === "steps" ? renderSteps() : renderProgress()
|
|
118
|
+
}), /*#__PURE__*/_jsx(Text
|
|
119
|
+
// bold
|
|
120
|
+
, {
|
|
121
|
+
style: [{
|
|
122
|
+
color: finalTextColor,
|
|
123
|
+
fontSize: fontSize,
|
|
124
|
+
textAlign: "center"
|
|
125
|
+
}, textStyle],
|
|
126
|
+
children: customText
|
|
146
127
|
})]
|
|
147
128
|
});
|
|
148
129
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useEffect","Canvas","
|
|
1
|
+
{"version":3,"names":["React","useEffect","Canvas","Path","Shadow","Skia","DashPathEffect","useSharedValue","withTiming","Easing","StyleSheet","Text","View","useTheme","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","CircularProgressBar","size","strokeWidth","backgroundColor","progressColor","lineCap","customText","textColor","fontSize","style","innerShadowColor","duration","variant","progress","progressPadding","currentStep","totalSteps","stepGap","textStyle","theme","animatedValue","finalProgressColor","primary","finalBackgroundColor","disabled","finalTextColor","onSurface","radius","circumference","Math","PI","path","Make","addCircle","progressStrokeWidth","max","targetValue","value","easing","out","cubic","renderSteps","totalGapDegrees","totalArcDegrees","stepArcLength","gapLength","dashPattern","children","strokeCap","color","intervals","start","end","dx","dy","blur","inner","renderProgress","width","height","justifyContent","alignItems","absoluteFill","textAlign"],"sourceRoot":"..\\..\\..\\..\\src","sources":["components/ProgressBar/CircularProgressBar.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,SAAS,QAAQ,OAAO;AACxC,SACEC,MAAM,EAENC,IAAI,EACJC,MAAM,EACNC,IAAI,EAGJC,cAAc,QACT,4BAA4B;AACnC,SACEC,cAAc,EACdC,UAAU,EAEVC,MAAM,QACD,yBAAyB;AAChC,SAIEC,UAAU,EACVC,IAAI,EAEJC,IAAI,QAEC,cAAc;AACr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AQ;MACxBC,UAAU,EAAE;IACd,CAAC,EACDpD,KAAK,CACL;IAAAsC,QAAA,gBAEFpD,IAAA,CAACb,MAAM;MAAC2B,KAAK,EAAEnB,UAAU,CAACwE,YAAa;MAAAf,QAAA,EACpCnC,OAAO,KAAK,OAAO,GAAG6B,WAAW,CAAC,CAAC,GAAGgB,cAAc,CAAC;IAAC,CACjD,CAAC,eACT9D,IAAA,CAACJ;IACC;IAAA;MACAkB,KAAK,EAAE,CACL;QACEwC,KAAK,EAAExB,cAAc;QACrBjB,QAAQ,EAAEA,QAAQ;QAClBuD,SAAS,EAAE;MACb,CAAC,EACD7C,SAAS,CACT;MAAA6B,QAAA,EAEDzC;IAAU,CACP,CAAC;EAAA,CACH,CAAC;AAEX,CAAC;AAED,eAAeN,mBAAmB","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { StyleProp, TextStyle, 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;
|
|
@@ -19,6 +18,7 @@ interface CircularProgressBarProps {
|
|
|
19
18
|
currentStep?: number;
|
|
20
19
|
totalSteps?: number;
|
|
21
20
|
stepGap?: number;
|
|
21
|
+
textStyle?: StyleProp<TextStyle>;
|
|
22
22
|
}
|
|
23
23
|
declare const CircularProgressBar: React.FC<CircularProgressBarProps>;
|
|
24
24
|
export default CircularProgressBar;
|
|
@@ -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;AAiBzC,OAAO,EAGL,SAAS,EAGT,SAAS,EAET,SAAS,EACV,MAAM,cAAc,CAAC;AAGtB,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;IACjB,SAAS,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAClC;AAED,QAAA,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,wBAAwB,CAuI3D,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={40} customText={'بلاتينم'} totalSteps={4} currentStep={4} size={150} strokeWidth={2} progressColor="#9CA0A3"></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>
|
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
Path,
|
|
6
6
|
Shadow,
|
|
7
7
|
Skia,
|
|
8
|
-
Text,
|
|
9
8
|
useFont,
|
|
10
9
|
PathOp,
|
|
11
10
|
DashPathEffect,
|
|
@@ -16,7 +15,17 @@ import {
|
|
|
16
15
|
useDerivedValue,
|
|
17
16
|
Easing,
|
|
18
17
|
} from "react-native-reanimated";
|
|
19
|
-
import {
|
|
18
|
+
import {
|
|
19
|
+
ImageRequireSource,
|
|
20
|
+
Platform,
|
|
21
|
+
StyleProp,
|
|
22
|
+
StyleSheet,
|
|
23
|
+
Text,
|
|
24
|
+
TextStyle,
|
|
25
|
+
View,
|
|
26
|
+
ViewStyle,
|
|
27
|
+
} from "react-native";
|
|
28
|
+
import { useTheme } from "../../theme";
|
|
20
29
|
|
|
21
30
|
interface CircularProgressBarProps {
|
|
22
31
|
size?: number;
|
|
@@ -27,34 +36,27 @@ interface CircularProgressBarProps {
|
|
|
27
36
|
customText?: string;
|
|
28
37
|
textColor?: string;
|
|
29
38
|
fontSize?: number;
|
|
30
|
-
textFont?: ImageRequireSource;
|
|
31
39
|
style?: ViewStyle;
|
|
32
40
|
innerShadowColor?: string;
|
|
33
41
|
duration?: number;
|
|
34
|
-
|
|
35
|
-
// New variant prop
|
|
36
42
|
variant?: "progress" | "steps";
|
|
37
|
-
|
|
38
|
-
// Props for 'progress' variant
|
|
39
|
-
progress?: number; // 0 to 100
|
|
43
|
+
progress?: number;
|
|
40
44
|
progressPadding?: number;
|
|
41
|
-
|
|
42
|
-
// Props for 'steps' variant
|
|
43
45
|
currentStep?: number;
|
|
44
46
|
totalSteps?: number;
|
|
45
|
-
stepGap?: number;
|
|
47
|
+
stepGap?: number;
|
|
48
|
+
textStyle?: StyleProp<TextStyle>;
|
|
46
49
|
}
|
|
47
50
|
|
|
48
51
|
const CircularProgressBar: React.FC<CircularProgressBarProps> = ({
|
|
49
52
|
size = 120,
|
|
50
53
|
strokeWidth = 8,
|
|
51
|
-
backgroundColor
|
|
52
|
-
progressColor
|
|
54
|
+
backgroundColor,
|
|
55
|
+
progressColor,
|
|
53
56
|
lineCap = "round",
|
|
54
57
|
customText,
|
|
55
|
-
textColor
|
|
58
|
+
textColor,
|
|
56
59
|
fontSize = size / 4,
|
|
57
|
-
textFont,
|
|
58
60
|
style,
|
|
59
61
|
innerShadowColor,
|
|
60
62
|
duration = 1000,
|
|
@@ -63,17 +65,15 @@ const CircularProgressBar: React.FC<CircularProgressBarProps> = ({
|
|
|
63
65
|
progressPadding = 0,
|
|
64
66
|
currentStep = 0,
|
|
65
67
|
totalSteps = 4,
|
|
66
|
-
stepGap = 15,
|
|
68
|
+
stepGap = 15,
|
|
69
|
+
textStyle,
|
|
67
70
|
}) => {
|
|
71
|
+
const { theme } = useTheme();
|
|
68
72
|
const animatedValue = useSharedValue(0);
|
|
69
73
|
|
|
70
|
-
const
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
: matchFont({
|
|
74
|
-
fontFamily: Platform.select({ ios: "Helvetica", default: "serif" }),
|
|
75
|
-
fontSize: fontSize,
|
|
76
|
-
});
|
|
74
|
+
const finalProgressColor = progressColor || theme.primary;
|
|
75
|
+
const finalBackgroundColor = backgroundColor || theme.disabled;
|
|
76
|
+
const finalTextColor = textColor || theme.onSurface;
|
|
77
77
|
|
|
78
78
|
const radius = (size - strokeWidth) / 2;
|
|
79
79
|
const circumference = 2 * Math.PI * radius;
|
|
@@ -84,66 +84,38 @@ const CircularProgressBar: React.FC<CircularProgressBarProps> = ({
|
|
|
84
84
|
|
|
85
85
|
useEffect(() => {
|
|
86
86
|
const targetValue =
|
|
87
|
-
variant === "steps"
|
|
88
|
-
? currentStep / (totalSteps || 1)
|
|
89
|
-
: progress / 100;
|
|
87
|
+
variant === "steps" ? currentStep / (totalSteps || 1) : progress / 100;
|
|
90
88
|
animatedValue.value = withTiming(targetValue, {
|
|
91
89
|
duration,
|
|
92
90
|
easing: Easing.out(Easing.cubic),
|
|
93
91
|
});
|
|
94
|
-
}, [progress, currentStep, totalSteps, duration, variant]);
|
|
95
|
-
|
|
96
|
-
// --- Text Logic ---
|
|
97
|
-
const textToDisplay = useDerivedValue(() => {
|
|
98
|
-
if (customText !== undefined) {
|
|
99
|
-
return customText;
|
|
100
|
-
}
|
|
101
|
-
if (variant === "steps") {
|
|
102
|
-
// Round the animated value to the nearest step for display
|
|
103
|
-
const displayStep = Math.round(animatedValue.value * (totalSteps || 1));
|
|
104
|
-
return `${displayStep}/${totalSteps}`;
|
|
105
|
-
}
|
|
106
|
-
return `${Math.round(animatedValue.value * 100)}%`;
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
const textX = useDerivedValue(() => {
|
|
110
|
-
if (!font) return 0;
|
|
111
|
-
const textWidth = font.measureText(textToDisplay.value).width;
|
|
112
|
-
return size / 2 - textWidth / 2;
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
const textY = size / 2 + fontSize / 3;
|
|
92
|
+
}, [progress, currentStep, totalSteps, duration, variant, animatedValue]);
|
|
116
93
|
|
|
117
|
-
// --- Steps Variant Logic ---
|
|
118
94
|
const renderSteps = () => {
|
|
119
|
-
// Calculate the total gap length in the circumference
|
|
120
95
|
const totalGapDegrees = (totalSteps || 1) * stepGap;
|
|
121
96
|
const totalArcDegrees = 360 - totalGapDegrees;
|
|
122
|
-
const stepArcLength =
|
|
97
|
+
const stepArcLength =
|
|
98
|
+
(totalArcDegrees / (totalSteps || 1) / 360) * circumference;
|
|
123
99
|
const gapLength = (stepGap / 360) * circumference;
|
|
124
|
-
|
|
125
100
|
const dashPattern = [stepArcLength, gapLength];
|
|
126
101
|
|
|
127
102
|
return (
|
|
128
103
|
<>
|
|
129
|
-
{/* Background Dashed Path */}
|
|
130
104
|
<Path
|
|
131
105
|
path={path}
|
|
132
106
|
style="stroke"
|
|
133
107
|
strokeWidth={strokeWidth}
|
|
134
108
|
strokeCap={lineCap}
|
|
135
|
-
color={
|
|
109
|
+
color={finalBackgroundColor}
|
|
136
110
|
>
|
|
137
111
|
<DashPathEffect intervals={dashPattern} />
|
|
138
112
|
</Path>
|
|
139
|
-
|
|
140
|
-
{/* Progress Dashed Path */}
|
|
141
113
|
<Path
|
|
142
114
|
path={path}
|
|
143
115
|
style="stroke"
|
|
144
116
|
strokeWidth={strokeWidth}
|
|
145
117
|
strokeCap={lineCap}
|
|
146
|
-
color={
|
|
118
|
+
color={finalProgressColor}
|
|
147
119
|
start={0}
|
|
148
120
|
end={animatedValue}
|
|
149
121
|
>
|
|
@@ -156,52 +128,60 @@ const CircularProgressBar: React.FC<CircularProgressBarProps> = ({
|
|
|
156
128
|
);
|
|
157
129
|
};
|
|
158
130
|
|
|
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
|
-
};
|
|
131
|
+
const renderProgress = () => (
|
|
132
|
+
<>
|
|
133
|
+
<Path
|
|
134
|
+
path={path}
|
|
135
|
+
style="stroke"
|
|
136
|
+
strokeWidth={strokeWidth}
|
|
137
|
+
strokeCap={lineCap}
|
|
138
|
+
color={finalBackgroundColor}
|
|
139
|
+
/>
|
|
140
|
+
<Path
|
|
141
|
+
path={path}
|
|
142
|
+
style="stroke"
|
|
143
|
+
strokeWidth={progressStrokeWidth}
|
|
144
|
+
strokeCap={lineCap}
|
|
145
|
+
color={finalProgressColor}
|
|
146
|
+
start={0}
|
|
147
|
+
end={animatedValue}
|
|
148
|
+
>
|
|
149
|
+
{innerShadowColor && (
|
|
150
|
+
<Shadow dx={0} dy={0} blur={4} color={innerShadowColor} inner />
|
|
151
|
+
)}
|
|
152
|
+
</Path>
|
|
153
|
+
</>
|
|
154
|
+
);
|
|
189
155
|
|
|
190
156
|
return (
|
|
191
|
-
<
|
|
192
|
-
{
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
157
|
+
<View
|
|
158
|
+
style={[
|
|
159
|
+
{
|
|
160
|
+
width: size,
|
|
161
|
+
height: size,
|
|
162
|
+
justifyContent: "center",
|
|
163
|
+
alignItems: "center",
|
|
164
|
+
},
|
|
165
|
+
style,
|
|
166
|
+
]}
|
|
167
|
+
>
|
|
168
|
+
<Canvas style={StyleSheet.absoluteFill}>
|
|
169
|
+
{variant === "steps" ? renderSteps() : renderProgress()}
|
|
170
|
+
</Canvas>
|
|
171
|
+
<Text
|
|
172
|
+
// bold
|
|
173
|
+
style={[
|
|
174
|
+
{
|
|
175
|
+
color: finalTextColor,
|
|
176
|
+
fontSize: fontSize,
|
|
177
|
+
textAlign: "center",
|
|
178
|
+
},
|
|
179
|
+
textStyle,
|
|
180
|
+
]}
|
|
181
|
+
>
|
|
182
|
+
{customText}
|
|
183
|
+
</Text>
|
|
184
|
+
</View>
|
|
205
185
|
);
|
|
206
186
|
};
|
|
207
187
|
|