related-ui-components 1.9.0 → 1.9.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/commonjs/app.js +151 -159
- package/lib/commonjs/app.js.map +1 -1
- package/lib/commonjs/components/Banner/Banner.js +2 -1
- package/lib/commonjs/components/Banner/Banner.js.map +1 -1
- package/lib/commonjs/components/Wheel/Wheel.js +17 -7
- package/lib/commonjs/components/Wheel/Wheel.js.map +1 -1
- package/lib/module/app.js +151 -153
- package/lib/module/app.js.map +1 -1
- package/lib/module/components/Banner/Banner.js +2 -1
- package/lib/module/components/Banner/Banner.js.map +1 -1
- package/lib/module/components/Wheel/Wheel.js +18 -8
- package/lib/module/components/Wheel/Wheel.js.map +1 -1
- package/lib/typescript/commonjs/app.d.ts +0 -3
- package/lib/typescript/commonjs/app.d.ts.map +1 -1
- package/lib/typescript/commonjs/components/Banner/Banner.d.ts.map +1 -1
- package/lib/typescript/commonjs/components/Wheel/Wheel.d.ts +1 -0
- package/lib/typescript/commonjs/components/Wheel/Wheel.d.ts.map +1 -1
- package/lib/typescript/module/app.d.ts +0 -3
- package/lib/typescript/module/app.d.ts.map +1 -1
- package/lib/typescript/module/components/Banner/Banner.d.ts.map +1 -1
- package/lib/typescript/module/components/Wheel/Wheel.d.ts +1 -0
- package/lib/typescript/module/components/Wheel/Wheel.d.ts.map +1 -1
- package/package.json +6 -3
- package/src/app.tsx +145 -121
- package/src/components/Banner/Banner.tsx +1 -1
- package/src/components/Wheel/Wheel.tsx +49 -37
package/src/app.tsx
CHANGED
|
@@ -1,127 +1,151 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
import {
|
|
13
|
-
import { useTheme } from "./theme";
|
|
14
|
-
import RedeemedVoucherSheet from "./components/RedeemedVoucher/RedeemedVoucherSheet";
|
|
15
|
-
import { GestureHandlerRootView } from "react-native-gesture-handler";
|
|
1
|
+
// // App.tsx or any other screen component
|
|
2
|
+
// import React, { useState } from "react";
|
|
3
|
+
// import {
|
|
4
|
+
// SafeAreaView,
|
|
5
|
+
// StyleSheet,
|
|
6
|
+
// TextInput,
|
|
7
|
+
// View,
|
|
8
|
+
// Text,
|
|
9
|
+
// ScrollView,
|
|
10
|
+
// Button,
|
|
11
|
+
// } from "react-native";
|
|
12
|
+
// import Barcode, { BarcodeFormat } from "./components/Barcode/Barcode";
|
|
16
13
|
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
// export default function App() {
|
|
15
|
+
// const [barcodeValue, setBarcodeValue] = useState("123456789012");
|
|
16
|
+
// const [barcodeFormat, setBarcodeFormat] = useState<BarcodeFormat>(
|
|
17
|
+
// BarcodeFormat.EAN13,
|
|
18
|
+
// );
|
|
19
|
+
// const [errorMsg, setErrorMsg] = useState<string | null>(null);
|
|
19
20
|
|
|
20
|
-
|
|
21
|
+
// const handleBarcodeError = (error: Error) => {
|
|
22
|
+
// console.error("Custom Barcode Error:", error.message);
|
|
23
|
+
// setErrorMsg(`Barcode Error: ${error.message}`);
|
|
24
|
+
// };
|
|
21
25
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
// const cycleFormat = () => {
|
|
27
|
+
// const formats = Object.values(BarcodeFormat);
|
|
28
|
+
// const currentIndex = formats.indexOf(barcodeFormat);
|
|
29
|
+
// const nextIndex = (currentIndex + 1) % formats.length;
|
|
30
|
+
// setBarcodeFormat(formats[nextIndex]);
|
|
31
|
+
// // Adjust value for specific formats if needed
|
|
32
|
+
// if (formats[nextIndex] === BarcodeFormat.EAN13) setBarcodeValue("978020137962"); // Valid EAN13
|
|
33
|
+
// else if (formats[nextIndex] === BarcodeFormat.UPC) setBarcodeValue("012345678905"); // Valid UPC
|
|
34
|
+
// else if (formats[nextIndex] === BarcodeFormat.CODE39) setBarcodeValue("HELLO-WORLD");
|
|
35
|
+
// else setBarcodeValue("TEST12345");
|
|
26
36
|
|
|
27
|
-
|
|
28
|
-
{
|
|
29
|
-
icon: (
|
|
30
|
-
<Ionicons name="briefcase-outline" size={30} color={theme.primary} />
|
|
31
|
-
),
|
|
32
|
-
activeIcon: (
|
|
33
|
-
<Ionicons name="briefcase-outline" size={30} color={theme.onPrimary} />
|
|
34
|
-
),
|
|
35
|
-
title: "Aqua Guardian",
|
|
36
|
-
description:
|
|
37
|
-
"Maintain water usage below the community average for a month.",
|
|
38
|
-
isActive: false,
|
|
39
|
-
status: "0/1",
|
|
40
|
-
statusBackgroundColor: "#FFCDD2",
|
|
41
|
-
statusTextColor: "#D32F2F",
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
icon: <Ionicons name="heart-outline" size={30} color={theme.primary} />,
|
|
45
|
-
activeIcon: (
|
|
46
|
-
<Ionicons name="heart-outline" size={30} color={theme.onPrimary} />
|
|
47
|
-
),
|
|
48
|
-
title: "Wellness Warrior",
|
|
49
|
-
description: "Complete 30 days of healthy hydration tracking.",
|
|
50
|
-
isActive: true,
|
|
51
|
-
status: "15/30",
|
|
52
|
-
statusBackgroundColor: "#C8E6C9",
|
|
53
|
-
statusTextColor: "#388E3C",
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
icon: <Ionicons name="airplane-outline" size={24} color={theme.helper} />,
|
|
57
|
-
activeIcon: (
|
|
58
|
-
<Ionicons name="airplane-outline" size={24} color={theme.primary} />
|
|
59
|
-
),
|
|
60
|
-
title: "Eco Traveler",
|
|
61
|
-
description: "Log 5 trips where you chose sustainable travel options.",
|
|
62
|
-
isActive: false,
|
|
63
|
-
status: "2/5",
|
|
64
|
-
statusBackgroundColor: theme.disabled,
|
|
65
|
-
statusTextColor: theme.text,
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
icon: <Ionicons name="school-outline" size={24} color={theme.helper} />,
|
|
69
|
-
activeIcon: (
|
|
70
|
-
<Ionicons name="school-outline" size={24} color={theme.primary} />
|
|
71
|
-
),
|
|
72
|
-
title: "Knowledge Seeker",
|
|
73
|
-
description: "Complete all water conservation learning modules.",
|
|
74
|
-
isActive: false,
|
|
75
|
-
status: "3/5",
|
|
76
|
-
statusBackgroundColor: theme.disabled,
|
|
77
|
-
statusTextColor: theme.text,
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
icon: <Ionicons name="settings-outline" size={24} color={theme.helper} />,
|
|
81
|
-
activeIcon: (
|
|
82
|
-
<Ionicons name="settings-outline" size={24} color={theme.primary} />
|
|
83
|
-
),
|
|
84
|
-
title: "Smart Saver",
|
|
85
|
-
description: "Set up and use all water-saving features in the app.",
|
|
86
|
-
isActive: true,
|
|
87
|
-
status: "4/4",
|
|
88
|
-
statusBackgroundColor: theme.primary,
|
|
89
|
-
statusTextColor: theme.background,
|
|
90
|
-
},
|
|
91
|
-
];
|
|
37
|
+
// };
|
|
92
38
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
<ScratchCard
|
|
98
|
-
backgroundColor="#8A2BE2"
|
|
99
|
-
text="Scratch to reveal your prize!"
|
|
100
|
-
textFontColor="#FFFFFF"
|
|
101
|
-
textFontSize={18}
|
|
102
|
-
textFont={require("@/assets/fonts/SpaceMono-Regular.ttf")}
|
|
103
|
-
width={300}
|
|
104
|
-
height={150}
|
|
105
|
-
gradient={{
|
|
106
|
-
colors: ["#ff0000", "#00ff00", "#0000ff"],
|
|
107
|
-
start: { x: 0, y: 0 },
|
|
108
|
-
end: { x: 300, y: 300 },
|
|
109
|
-
}}
|
|
110
|
-
onScratched={() => alert("Congratulations! You won a prize!")}
|
|
111
|
-
>
|
|
112
|
-
<ScratchCardContent style={{ backgroundColor: "#FFD700" }}>
|
|
113
|
-
<Text style={{ fontSize: 24, fontWeight: "bold", color: "#000" }}>
|
|
114
|
-
50% OFF COUPON
|
|
115
|
-
</Text>
|
|
116
|
-
<Text style={{ marginTop: 8, color: "#333" }}>
|
|
117
|
-
Use code: SCRATCH50
|
|
118
|
-
</Text>
|
|
119
|
-
</ScratchCardContent>
|
|
120
|
-
</ScratchCard>
|
|
121
|
-
</Popup>
|
|
122
|
-
</GestureHandlerRootView>
|
|
123
|
-
</>
|
|
124
|
-
);
|
|
125
|
-
};
|
|
39
|
+
// return (
|
|
40
|
+
// <SafeAreaView style={styles.container}>
|
|
41
|
+
// <ScrollView contentContainerStyle={styles.scrollContent}>
|
|
42
|
+
// <Text style={styles.title}>Custom Barcode Generator</Text>
|
|
126
43
|
|
|
127
|
-
|
|
44
|
+
// <TextInput
|
|
45
|
+
// style={styles.input}
|
|
46
|
+
// placeholder="Enter barcode value"
|
|
47
|
+
// value={barcodeValue}
|
|
48
|
+
// onChangeText={setBarcodeValue}
|
|
49
|
+
// autoCapitalize="characters" // Good for some formats like CODE39
|
|
50
|
+
// />
|
|
51
|
+
|
|
52
|
+
// <View style={styles.formatSelector}>
|
|
53
|
+
// <Text>Format: {barcodeFormat}</Text>
|
|
54
|
+
// <Button title="Cycle Format" onPress={cycleFormat} />
|
|
55
|
+
// </View>
|
|
56
|
+
|
|
57
|
+
// {errorMsg && <Text style={styles.errorTextDisplay}>{errorMsg}</Text>}
|
|
58
|
+
|
|
59
|
+
// <Text style={styles.label}>Default:</Text>
|
|
60
|
+
// <Barcode
|
|
61
|
+
// value={barcodeValue}
|
|
62
|
+
// format={barcodeFormat}
|
|
63
|
+
// onError={handleBarcodeError}
|
|
64
|
+
// />
|
|
65
|
+
|
|
66
|
+
// <Text style={styles.label}>Customized (CODE128):</Text>
|
|
67
|
+
// <Barcode
|
|
68
|
+
// value="CUSTOM-CODE-128"
|
|
69
|
+
// format={BarcodeFormat.CODE128}
|
|
70
|
+
// lineColor="blue"
|
|
71
|
+
// backgroundColor="#e0e0ff"
|
|
72
|
+
// height={80}
|
|
73
|
+
// width={1.5} // Bar width
|
|
74
|
+
// fontSize={16}
|
|
75
|
+
// textMargin={5}
|
|
76
|
+
// margin={20} // Margin around the SVG
|
|
77
|
+
// onError={handleBarcodeError}
|
|
78
|
+
// style={styles.customBarcodeStyle}
|
|
79
|
+
// />
|
|
80
|
+
|
|
81
|
+
// <Text style={styles.label}>No Text Value (EAN13):</Text>
|
|
82
|
+
// <Barcode
|
|
83
|
+
// value="590123412345" // Needs valid check digit for EAN13
|
|
84
|
+
// format={BarcodeFormat.EAN13}
|
|
85
|
+
// displayValue={false}
|
|
86
|
+
// onError={handleBarcodeError}
|
|
87
|
+
// />
|
|
88
|
+
|
|
89
|
+
// <Text style={styles.label}>Invalid Value Example (for EAN13):</Text>
|
|
90
|
+
// <Barcode
|
|
91
|
+
// value="INVALID" // This will likely cause an error for EAN13
|
|
92
|
+
// format={BarcodeFormat.EAN13}
|
|
93
|
+
// onError={handleBarcodeError}
|
|
94
|
+
// />
|
|
95
|
+
// <Text style={styles.label}>Empty Value:</Text>
|
|
96
|
+
// <Barcode
|
|
97
|
+
// value=""
|
|
98
|
+
// format={BarcodeFormat.CODE128}
|
|
99
|
+
// onError={handleBarcodeError}
|
|
100
|
+
// />
|
|
101
|
+
// </ScrollView>
|
|
102
|
+
// </SafeAreaView>
|
|
103
|
+
// );
|
|
104
|
+
// }
|
|
105
|
+
|
|
106
|
+
// const styles = StyleSheet.create({
|
|
107
|
+
// container: {
|
|
108
|
+
// flex: 1,
|
|
109
|
+
// backgroundColor: "#f0f0f0",
|
|
110
|
+
// },
|
|
111
|
+
// scrollContent: {
|
|
112
|
+
// alignItems: "center",
|
|
113
|
+
// padding: 20,
|
|
114
|
+
// },
|
|
115
|
+
// title: {
|
|
116
|
+
// fontSize: 24,
|
|
117
|
+
// fontWeight: "bold",
|
|
118
|
+
// marginBottom: 20,
|
|
119
|
+
// },
|
|
120
|
+
// input: {
|
|
121
|
+
// height: 40,
|
|
122
|
+
// borderColor: "gray",
|
|
123
|
+
// borderWidth: 1,
|
|
124
|
+
// paddingHorizontal: 10,
|
|
125
|
+
// marginBottom: 20,
|
|
126
|
+
// width: "90%",
|
|
127
|
+
// backgroundColor: "white",
|
|
128
|
+
// },
|
|
129
|
+
// label: {
|
|
130
|
+
// fontSize: 16,
|
|
131
|
+
// fontWeight: "600",
|
|
132
|
+
// marginTop: 20,
|
|
133
|
+
// marginBottom: 8,
|
|
134
|
+
// },
|
|
135
|
+
// customBarcodeStyle: {
|
|
136
|
+
// borderWidth: 1,
|
|
137
|
+
// borderColor: "purple",
|
|
138
|
+
// padding: 5, // Padding for the View container, not the barcode margin
|
|
139
|
+
// },
|
|
140
|
+
// formatSelector: {
|
|
141
|
+
// flexDirection: "row",
|
|
142
|
+
// alignItems: "center",
|
|
143
|
+
// justifyContent: "space-between",
|
|
144
|
+
// width: "90%",
|
|
145
|
+
// marginBottom: 15,
|
|
146
|
+
// },
|
|
147
|
+
// errorTextDisplay: {
|
|
148
|
+
// color: 'red',
|
|
149
|
+
// marginVertical: 10,
|
|
150
|
+
// }
|
|
151
|
+
// });
|
|
@@ -2,7 +2,6 @@ import React from "react";
|
|
|
2
2
|
import {
|
|
3
3
|
StyleSheet,
|
|
4
4
|
Text,
|
|
5
|
-
TouchableOpacity,
|
|
6
5
|
ViewStyle,
|
|
7
6
|
TextStyle,
|
|
8
7
|
ImageSourcePropType,
|
|
@@ -12,6 +11,7 @@ import {
|
|
|
12
11
|
} from "react-native";
|
|
13
12
|
import { Card, CardFooter } from "../Card";
|
|
14
13
|
import { useTheme, ThemeType } from "../../theme";
|
|
14
|
+
import { TouchableOpacity } from "react-native-gesture-handler";
|
|
15
15
|
|
|
16
16
|
export interface BannerProps {
|
|
17
17
|
backgroundImage: ImageSourcePropType;
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
ViewStyle,
|
|
10
10
|
TextStyle,
|
|
11
11
|
} from "react-native";
|
|
12
|
-
import { Svg, Path, G, Text as SvgText } from "react-native-svg";
|
|
12
|
+
import { Svg, Path, G, Text as SvgText, Circle } from "react-native-svg";
|
|
13
13
|
import { AppButtonProps, Button } from "../Button";
|
|
14
14
|
|
|
15
15
|
export interface SpinWheelItem {
|
|
@@ -79,6 +79,7 @@ interface SpinWheelProps {
|
|
|
79
79
|
>;
|
|
80
80
|
|
|
81
81
|
wheelBorderColor?: string;
|
|
82
|
+
wheelBorderWidth?: number;
|
|
82
83
|
wheelTextColor?: string;
|
|
83
84
|
knobColor?: string;
|
|
84
85
|
|
|
@@ -104,6 +105,7 @@ const SpinWheel: React.FC<SpinWheelProps> = ({
|
|
|
104
105
|
actionButtonStyle,
|
|
105
106
|
actionButtonTextStyle,
|
|
106
107
|
wheelBorderColor,
|
|
108
|
+
wheelBorderWidth,
|
|
107
109
|
wheelTextColor = "#FFFFFF",
|
|
108
110
|
actionButtonProps,
|
|
109
111
|
centerSize
|
|
@@ -281,41 +283,46 @@ const SpinWheel: React.FC<SpinWheelProps> = ({
|
|
|
281
283
|
>
|
|
282
284
|
<Svg width={size} height={size} viewBox={`0 0 ${size} ${size}`}>
|
|
283
285
|
<G>
|
|
284
|
-
{wheelPaths.map(
|
|
285
|
-
(
|
|
286
|
-
|
|
287
|
-
<
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
{item.label}
|
|
313
|
-
</SvgText>
|
|
314
|
-
</React.Fragment>
|
|
315
|
-
);
|
|
316
|
-
}
|
|
317
|
-
)}
|
|
286
|
+
{wheelPaths.map(({ path, item, textX, textY, angle }, index) => {
|
|
287
|
+
return (
|
|
288
|
+
<React.Fragment key={item.id}>
|
|
289
|
+
<Path
|
|
290
|
+
d={path}
|
|
291
|
+
fill={
|
|
292
|
+
item.color == "" || item.color == null
|
|
293
|
+
? colors[Math.floor(Math.random() * colors.length)]
|
|
294
|
+
: item.color
|
|
295
|
+
}
|
|
296
|
+
// stroke="#FA8072"
|
|
297
|
+
// strokeWidth={1}
|
|
298
|
+
/>
|
|
299
|
+
<SvgText
|
|
300
|
+
x={textX}
|
|
301
|
+
y={textY}
|
|
302
|
+
fill={item.textColor || wheelTextColor}
|
|
303
|
+
fontSize={wheelTextStyle?.fontSize || 14}
|
|
304
|
+
fontWeight={(wheelTextStyle?.fontWeight as any) || "bold"}
|
|
305
|
+
textAnchor="middle"
|
|
306
|
+
alignmentBaseline="central"
|
|
307
|
+
transform={`rotate(${angle + 180}, ${textX}, ${textY} )`}
|
|
308
|
+
>
|
|
309
|
+
{item.label}
|
|
310
|
+
</SvgText>
|
|
311
|
+
</React.Fragment>
|
|
312
|
+
);
|
|
313
|
+
})}
|
|
318
314
|
</G>
|
|
315
|
+
|
|
316
|
+
{wheelBorderWidth && (
|
|
317
|
+
<Circle
|
|
318
|
+
cx={size / 2}
|
|
319
|
+
cy={size / 2}
|
|
320
|
+
r={size / 2 - wheelBorderWidth / 2}
|
|
321
|
+
stroke={wheelBorderColor}
|
|
322
|
+
strokeWidth={wheelBorderWidth}
|
|
323
|
+
fill="none"
|
|
324
|
+
/>
|
|
325
|
+
)}
|
|
319
326
|
</Svg>
|
|
320
327
|
</Animated.View>
|
|
321
328
|
|
|
@@ -326,7 +333,7 @@ const SpinWheel: React.FC<SpinWheelProps> = ({
|
|
|
326
333
|
{
|
|
327
334
|
width: actualCenterSize,
|
|
328
335
|
height: actualCenterSize,
|
|
329
|
-
borderRadius: actualCenterSize / 2,
|
|
336
|
+
borderRadius: actualCenterSize / 2,
|
|
330
337
|
transform: [
|
|
331
338
|
{ translateX: -actualCenterSize / 2 },
|
|
332
339
|
{ translateY: -actualCenterSize / 2 },
|
|
@@ -337,7 +344,12 @@ const SpinWheel: React.FC<SpinWheelProps> = ({
|
|
|
337
344
|
/>
|
|
338
345
|
|
|
339
346
|
{/* The pointer is a triangle on top */}
|
|
340
|
-
<View
|
|
347
|
+
<View
|
|
348
|
+
style={[
|
|
349
|
+
styles.pointerPosition,
|
|
350
|
+
wheelBorderWidth ? { top: wheelBorderWidth } : {},
|
|
351
|
+
]}
|
|
352
|
+
>
|
|
341
353
|
<View
|
|
342
354
|
style={[
|
|
343
355
|
styles.pointer,
|