@rocapine/react-native-onboarding-ui 1.0.0
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/dist/UI/Components/CircularProgress.d.ts +8 -0
- package/dist/UI/Components/CircularProgress.d.ts.map +1 -0
- package/dist/UI/Components/CircularProgress.js +104 -0
- package/dist/UI/Components/CircularProgress.js.map +1 -0
- package/dist/UI/Components/ProgressBar.d.ts +12 -0
- package/dist/UI/Components/ProgressBar.d.ts.map +1 -0
- package/dist/UI/Components/ProgressBar.js +121 -0
- package/dist/UI/Components/ProgressBar.js.map +1 -0
- package/dist/UI/Components/StaggeredTextList.d.ts +11 -0
- package/dist/UI/Components/StaggeredTextList.d.ts.map +1 -0
- package/dist/UI/Components/StaggeredTextList.js +111 -0
- package/dist/UI/Components/StaggeredTextList.js.map +1 -0
- package/dist/UI/Components/index.d.ts +4 -0
- package/dist/UI/Components/index.d.ts.map +1 -0
- package/dist/UI/Components/index.js +20 -0
- package/dist/UI/Components/index.js.map +1 -0
- package/dist/UI/ErrorBoundary/ErrorBoundary.d.ts +19 -0
- package/dist/UI/ErrorBoundary/ErrorBoundary.d.ts.map +1 -0
- package/dist/UI/ErrorBoundary/ErrorBoundary.js +123 -0
- package/dist/UI/ErrorBoundary/ErrorBoundary.js.map +1 -0
- package/dist/UI/ErrorBoundary/index.d.ts +3 -0
- package/dist/UI/ErrorBoundary/index.d.ts.map +1 -0
- package/dist/UI/ErrorBoundary/index.js +8 -0
- package/dist/UI/ErrorBoundary/index.js.map +1 -0
- package/dist/UI/ErrorBoundary/withErrorBoundary.d.ts +6 -0
- package/dist/UI/ErrorBoundary/withErrorBoundary.d.ts.map +1 -0
- package/dist/UI/ErrorBoundary/withErrorBoundary.js +13 -0
- package/dist/UI/ErrorBoundary/withErrorBoundary.js.map +1 -0
- package/dist/UI/OnboardingPage.d.ts +16 -0
- package/dist/UI/OnboardingPage.d.ts.map +1 -0
- package/dist/UI/OnboardingPage.js +38 -0
- package/dist/UI/OnboardingPage.js.map +1 -0
- package/dist/UI/Pages/Carousel/Renderer.d.ts +13 -0
- package/dist/UI/Pages/Carousel/Renderer.d.ts.map +1 -0
- package/dist/UI/Pages/Carousel/Renderer.js +121 -0
- package/dist/UI/Pages/Carousel/Renderer.js.map +1 -0
- package/dist/UI/Pages/Carousel/index.d.ts +3 -0
- package/dist/UI/Pages/Carousel/index.d.ts.map +1 -0
- package/dist/UI/Pages/Carousel/index.js +19 -0
- package/dist/UI/Pages/Carousel/index.js.map +1 -0
- package/dist/UI/Pages/Carousel/types.d.ts +32 -0
- package/dist/UI/Pages/Carousel/types.d.ts.map +1 -0
- package/dist/UI/Pages/Carousel/types.js +24 -0
- package/dist/UI/Pages/Carousel/types.js.map +1 -0
- package/dist/UI/Pages/Commitment/Renderer.d.ts +13 -0
- package/dist/UI/Pages/Commitment/Renderer.d.ts.map +1 -0
- package/dist/UI/Pages/Commitment/Renderer.js +173 -0
- package/dist/UI/Pages/Commitment/Renderer.js.map +1 -0
- package/dist/UI/Pages/Commitment/index.d.ts +3 -0
- package/dist/UI/Pages/Commitment/index.d.ts.map +1 -0
- package/dist/UI/Pages/Commitment/index.js +19 -0
- package/dist/UI/Pages/Commitment/index.js.map +1 -0
- package/dist/UI/Pages/Commitment/types.d.ts +41 -0
- package/dist/UI/Pages/Commitment/types.d.ts.map +1 -0
- package/dist/UI/Pages/Commitment/types.js +27 -0
- package/dist/UI/Pages/Commitment/types.js.map +1 -0
- package/dist/UI/Pages/Loader/Renderer.d.ts +10 -0
- package/dist/UI/Pages/Loader/Renderer.d.ts.map +1 -0
- package/dist/UI/Pages/Loader/Renderer.js +215 -0
- package/dist/UI/Pages/Loader/Renderer.js.map +1 -0
- package/dist/UI/Pages/Loader/index.d.ts +3 -0
- package/dist/UI/Pages/Loader/index.d.ts.map +1 -0
- package/dist/UI/Pages/Loader/index.js +19 -0
- package/dist/UI/Pages/Loader/index.js.map +1 -0
- package/dist/UI/Pages/Loader/types.d.ts +57 -0
- package/dist/UI/Pages/Loader/types.d.ts.map +1 -0
- package/dist/UI/Pages/Loader/types.js +30 -0
- package/dist/UI/Pages/Loader/types.js.map +1 -0
- package/dist/UI/Pages/MediaContent/Renderer.d.ts +13 -0
- package/dist/UI/Pages/MediaContent/Renderer.d.ts.map +1 -0
- package/dist/UI/Pages/MediaContent/Renderer.js +76 -0
- package/dist/UI/Pages/MediaContent/Renderer.js.map +1 -0
- package/dist/UI/Pages/MediaContent/index.d.ts +3 -0
- package/dist/UI/Pages/MediaContent/index.d.ts.map +1 -0
- package/dist/UI/Pages/MediaContent/index.js +19 -0
- package/dist/UI/Pages/MediaContent/index.js.map +1 -0
- package/dist/UI/Pages/MediaContent/types.d.ts +44 -0
- package/dist/UI/Pages/MediaContent/types.d.ts.map +1 -0
- package/dist/UI/Pages/MediaContent/types.js +22 -0
- package/dist/UI/Pages/MediaContent/types.js.map +1 -0
- package/dist/UI/Pages/Picker/Renderer.d.ts +13 -0
- package/dist/UI/Pages/Picker/Renderer.d.ts.map +1 -0
- package/dist/UI/Pages/Picker/Renderer.js +268 -0
- package/dist/UI/Pages/Picker/Renderer.js.map +1 -0
- package/dist/UI/Pages/Picker/index.d.ts +3 -0
- package/dist/UI/Pages/Picker/index.d.ts.map +1 -0
- package/dist/UI/Pages/Picker/index.js +19 -0
- package/dist/UI/Pages/Picker/index.js.map +1 -0
- package/dist/UI/Pages/Picker/types.d.ts +49 -0
- package/dist/UI/Pages/Picker/types.d.ts.map +1 -0
- package/dist/UI/Pages/Picker/types.js +30 -0
- package/dist/UI/Pages/Picker/types.js.map +1 -0
- package/dist/UI/Pages/Question/Renderer.d.ts +18 -0
- package/dist/UI/Pages/Question/Renderer.d.ts.map +1 -0
- package/dist/UI/Pages/Question/Renderer.js +128 -0
- package/dist/UI/Pages/Question/Renderer.js.map +1 -0
- package/dist/UI/Pages/Question/components.d.ts +57 -0
- package/dist/UI/Pages/Question/components.d.ts.map +1 -0
- package/dist/UI/Pages/Question/components.js +57 -0
- package/dist/UI/Pages/Question/components.js.map +1 -0
- package/dist/UI/Pages/Question/index.d.ts +4 -0
- package/dist/UI/Pages/Question/index.d.ts.map +1 -0
- package/dist/UI/Pages/Question/index.js +20 -0
- package/dist/UI/Pages/Question/index.js.map +1 -0
- package/dist/UI/Pages/Question/types.d.ts +47 -0
- package/dist/UI/Pages/Question/types.d.ts.map +1 -0
- package/dist/UI/Pages/Question/types.js +28 -0
- package/dist/UI/Pages/Question/types.js.map +1 -0
- package/dist/UI/Pages/Ratings/Renderer.d.ts +13 -0
- package/dist/UI/Pages/Ratings/Renderer.d.ts.map +1 -0
- package/dist/UI/Pages/Ratings/Renderer.js +201 -0
- package/dist/UI/Pages/Ratings/Renderer.js.map +1 -0
- package/dist/UI/Pages/Ratings/index.d.ts +3 -0
- package/dist/UI/Pages/Ratings/index.d.ts.map +1 -0
- package/dist/UI/Pages/Ratings/index.js +19 -0
- package/dist/UI/Pages/Ratings/index.js.map +1 -0
- package/dist/UI/Pages/Ratings/types.d.ts +32 -0
- package/dist/UI/Pages/Ratings/types.d.ts.map +1 -0
- package/dist/UI/Pages/Ratings/types.js +25 -0
- package/dist/UI/Pages/Ratings/types.js.map +1 -0
- package/dist/UI/Pages/index.d.ts +9 -0
- package/dist/UI/Pages/index.d.ts.map +1 -0
- package/dist/UI/Pages/index.js +26 -0
- package/dist/UI/Pages/index.js.map +1 -0
- package/dist/UI/Pages/types.d.ts +19 -0
- package/dist/UI/Pages/types.d.ts.map +1 -0
- package/dist/UI/Pages/types.js +25 -0
- package/dist/UI/Pages/types.js.map +1 -0
- package/dist/UI/Provider/OnboardingProgressProvider.d.ts +18 -0
- package/dist/UI/Provider/OnboardingProgressProvider.d.ts.map +1 -0
- package/dist/UI/Provider/OnboardingProgressProvider.js +23 -0
- package/dist/UI/Provider/OnboardingProgressProvider.js.map +1 -0
- package/dist/UI/Provider/index.d.ts +2 -0
- package/dist/UI/Provider/index.d.ts.map +1 -0
- package/dist/UI/Provider/index.js +7 -0
- package/dist/UI/Provider/index.js.map +1 -0
- package/dist/UI/Templates/OnboardingTemplate.d.ts +15 -0
- package/dist/UI/Templates/OnboardingTemplate.d.ts.map +1 -0
- package/dist/UI/Templates/OnboardingTemplate.js +48 -0
- package/dist/UI/Templates/OnboardingTemplate.js.map +1 -0
- package/dist/UI/Templates/index.d.ts +2 -0
- package/dist/UI/Templates/index.d.ts.map +1 -0
- package/dist/UI/Templates/index.js +6 -0
- package/dist/UI/Templates/index.js.map +1 -0
- package/dist/UI/Theme/ThemeProvider.d.ts +27 -0
- package/dist/UI/Theme/ThemeProvider.d.ts.map +1 -0
- package/dist/UI/Theme/ThemeProvider.js +49 -0
- package/dist/UI/Theme/ThemeProvider.js.map +1 -0
- package/dist/UI/Theme/defaultTheme.d.ts +7 -0
- package/dist/UI/Theme/defaultTheme.d.ts.map +1 -0
- package/dist/UI/Theme/defaultTheme.js +14 -0
- package/dist/UI/Theme/defaultTheme.js.map +1 -0
- package/dist/UI/Theme/helpers.d.ts +12 -0
- package/dist/UI/Theme/helpers.d.ts.map +1 -0
- package/dist/UI/Theme/helpers.js +21 -0
- package/dist/UI/Theme/helpers.js.map +1 -0
- package/dist/UI/Theme/index.d.ts +8 -0
- package/dist/UI/Theme/index.d.ts.map +1 -0
- package/dist/UI/Theme/index.js +24 -0
- package/dist/UI/Theme/index.js.map +1 -0
- package/dist/UI/Theme/token.d.ts +107 -0
- package/dist/UI/Theme/token.d.ts.map +1 -0
- package/dist/UI/Theme/token.js +108 -0
- package/dist/UI/Theme/token.js.map +1 -0
- package/dist/UI/Theme/tokens/darkTokens.d.ts +24 -0
- package/dist/UI/Theme/tokens/darkTokens.d.ts.map +1 -0
- package/dist/UI/Theme/tokens/darkTokens.js +27 -0
- package/dist/UI/Theme/tokens/darkTokens.js.map +1 -0
- package/dist/UI/Theme/tokens/index.d.ts +4 -0
- package/dist/UI/Theme/tokens/index.d.ts.map +1 -0
- package/dist/UI/Theme/tokens/index.js +20 -0
- package/dist/UI/Theme/tokens/index.js.map +1 -0
- package/dist/UI/Theme/tokens/lightTokens.d.ts +24 -0
- package/dist/UI/Theme/tokens/lightTokens.d.ts.map +1 -0
- package/dist/UI/Theme/tokens/lightTokens.js +27 -0
- package/dist/UI/Theme/tokens/lightTokens.js.map +1 -0
- package/dist/UI/Theme/tokens/typography.d.ts +65 -0
- package/dist/UI/Theme/tokens/typography.d.ts.map +1 -0
- package/dist/UI/Theme/tokens/typography.js +68 -0
- package/dist/UI/Theme/tokens/typography.js.map +1 -0
- package/dist/UI/Theme/types.d.ts +65 -0
- package/dist/UI/Theme/types.d.ts.map +1 -0
- package/dist/UI/Theme/types.js +3 -0
- package/dist/UI/Theme/types.js.map +1 -0
- package/dist/UI/Theme/useTheme.d.ts +7 -0
- package/dist/UI/Theme/useTheme.d.ts.map +1 -0
- package/dist/UI/Theme/useTheme.js +23 -0
- package/dist/UI/Theme/useTheme.js.map +1 -0
- package/dist/UI/Theme/utils.d.ts +12 -0
- package/dist/UI/Theme/utils.d.ts.map +1 -0
- package/dist/UI/Theme/utils.js +55 -0
- package/dist/UI/Theme/utils.js.map +1 -0
- package/dist/UI/index.d.ts +8 -0
- package/dist/UI/index.d.ts.map +1 -0
- package/dist/UI/index.js +24 -0
- package/dist/UI/index.js.map +1 -0
- package/dist/UI/types.d.ts +23 -0
- package/dist/UI/types.d.ts.map +1 -0
- package/dist/UI/types.js +3 -0
- package/dist/UI/types.js.map +1 -0
- package/dist/assets/laurel-left.png +0 -0
- package/dist/assets/laurel-right.png +0 -0
- package/dist/assets/star-filled.png +0 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +33 -0
- package/dist/index.js.map +1 -0
- package/dist/provider/CustomComponentsContext.d.ts +57 -0
- package/dist/provider/CustomComponentsContext.d.ts.map +1 -0
- package/dist/provider/CustomComponentsContext.js +19 -0
- package/dist/provider/CustomComponentsContext.js.map +1 -0
- package/dist/provider/OnboardingUIProvider.d.ts +44 -0
- package/dist/provider/OnboardingUIProvider.d.ts.map +1 -0
- package/dist/provider/OnboardingUIProvider.js +33 -0
- package/dist/provider/OnboardingUIProvider.js.map +1 -0
- package/dist/provider/OnboardingUIProvider.old.d.ts +60 -0
- package/dist/provider/OnboardingUIProvider.old.d.ts.map +1 -0
- package/dist/provider/OnboardingUIProvider.old.js +53 -0
- package/dist/provider/OnboardingUIProvider.old.js.map +1 -0
- package/package.json +77 -0
- package/src/UI/Components/CircularProgress.tsx +146 -0
- package/src/UI/Components/ProgressBar.tsx +143 -0
- package/src/UI/Components/StaggeredTextList.tsx +152 -0
- package/src/UI/Components/index.ts +3 -0
- package/src/UI/ErrorBoundary/ErrorBoundary.tsx +181 -0
- package/src/UI/ErrorBoundary/README.md +71 -0
- package/src/UI/ErrorBoundary/index.ts +2 -0
- package/src/UI/ErrorBoundary/withErrorBoundary.tsx +19 -0
- package/src/UI/OnboardingPage.tsx +53 -0
- package/src/UI/Pages/Carousel/Renderer.tsx +210 -0
- package/src/UI/Pages/Carousel/index.ts +2 -0
- package/src/UI/Pages/Carousel/types.ts +26 -0
- package/src/UI/Pages/Commitment/Renderer.tsx +312 -0
- package/src/UI/Pages/Commitment/index.ts +2 -0
- package/src/UI/Pages/Commitment/types.ts +28 -0
- package/src/UI/Pages/Loader/Renderer.tsx +417 -0
- package/src/UI/Pages/Loader/index.ts +2 -0
- package/src/UI/Pages/Loader/types.ts +32 -0
- package/src/UI/Pages/MediaContent/Renderer.tsx +130 -0
- package/src/UI/Pages/MediaContent/index.ts +2 -0
- package/src/UI/Pages/MediaContent/types.ts +26 -0
- package/src/UI/Pages/Picker/Renderer.tsx +618 -0
- package/src/UI/Pages/Picker/index.ts +2 -0
- package/src/UI/Pages/Picker/types.ts +34 -0
- package/src/UI/Pages/Question/Renderer.tsx +208 -0
- package/src/UI/Pages/Question/components.tsx +130 -0
- package/src/UI/Pages/Question/index.ts +3 -0
- package/src/UI/Pages/Question/types.ts +29 -0
- package/src/UI/Pages/Ratings/Renderer.tsx +282 -0
- package/src/UI/Pages/Ratings/index.ts +2 -0
- package/src/UI/Pages/Ratings/types.ts +22 -0
- package/src/UI/Pages/index.ts +10 -0
- package/src/UI/Pages/types.ts +25 -0
- package/src/UI/Provider/OnboardingProgressProvider.tsx +40 -0
- package/src/UI/Provider/index.ts +1 -0
- package/src/UI/Templates/OnboardingTemplate.tsx +86 -0
- package/src/UI/Templates/index.ts +1 -0
- package/src/UI/Theme/ThemeProvider.tsx +100 -0
- package/src/UI/Theme/defaultTheme.ts +12 -0
- package/src/UI/Theme/helpers.ts +24 -0
- package/src/UI/Theme/index.ts +7 -0
- package/src/UI/Theme/token.ts +106 -0
- package/src/UI/Theme/tokens/darkTokens.ts +25 -0
- package/src/UI/Theme/tokens/index.ts +3 -0
- package/src/UI/Theme/tokens/lightTokens.ts +25 -0
- package/src/UI/Theme/tokens/typography.ts +66 -0
- package/src/UI/Theme/types.ts +72 -0
- package/src/UI/Theme/useTheme.ts +22 -0
- package/src/UI/Theme/utils.ts +67 -0
- package/src/UI/index.ts +7 -0
- package/src/UI/types.ts +41 -0
- package/src/assets/laurel-left.png +0 -0
- package/src/assets/laurel-right.png +0 -0
- package/src/assets/star-filled.png +0 -0
- package/src/index.ts +28 -0
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { OnboardingTemplate } from "../../Templates/OnboardingTemplate";
|
|
2
|
+
import {
|
|
3
|
+
CarouselStepType,
|
|
4
|
+
CarouselStepTypeSchema,
|
|
5
|
+
CarouselScreenType,
|
|
6
|
+
} from "./types";
|
|
7
|
+
import {
|
|
8
|
+
View,
|
|
9
|
+
Text,
|
|
10
|
+
StyleSheet,
|
|
11
|
+
ScrollView,
|
|
12
|
+
useWindowDimensions,
|
|
13
|
+
Image,
|
|
14
|
+
NativeSyntheticEvent,
|
|
15
|
+
NativeScrollEvent,
|
|
16
|
+
} from "react-native";
|
|
17
|
+
import { useRef, useState } from "react";
|
|
18
|
+
import { Theme } from "../../Theme/types";
|
|
19
|
+
import { defaultTheme } from "../../Theme/defaultTheme";
|
|
20
|
+
import { getTextStyle } from "../../Theme/helpers";
|
|
21
|
+
|
|
22
|
+
type ContentProps = {
|
|
23
|
+
step: CarouselStepType;
|
|
24
|
+
onContinue: () => void;
|
|
25
|
+
theme?: Theme;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const CarouselRendererBase = ({ step, onContinue, theme = defaultTheme }: ContentProps) => {
|
|
29
|
+
const validatedData = CarouselStepTypeSchema.parse(step);
|
|
30
|
+
const { screens } = validatedData.payload;
|
|
31
|
+
const { width } = useWindowDimensions();
|
|
32
|
+
const scrollViewRef = useRef<ScrollView>(null);
|
|
33
|
+
const [currentPage, setCurrentPage] = useState(0);
|
|
34
|
+
|
|
35
|
+
const handleScroll = (event: NativeSyntheticEvent<NativeScrollEvent>) => {
|
|
36
|
+
const newPage = Math.round(event.nativeEvent.contentOffset.x / width);
|
|
37
|
+
if (newPage !== currentPage) {
|
|
38
|
+
setCurrentPage(newPage);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const handleButtonPress = () => {
|
|
43
|
+
const isLastPage = currentPage === screens.length - 1;
|
|
44
|
+
|
|
45
|
+
if (isLastPage) {
|
|
46
|
+
onContinue();
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const nextPage = currentPage + 1;
|
|
51
|
+
scrollViewRef.current?.scrollTo({
|
|
52
|
+
x: nextPage * width,
|
|
53
|
+
animated: true,
|
|
54
|
+
});
|
|
55
|
+
setCurrentPage(nextPage);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const isLastPage = currentPage === screens.length - 1;
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<OnboardingTemplate
|
|
62
|
+
step={step}
|
|
63
|
+
onContinue={handleButtonPress}
|
|
64
|
+
theme={theme}
|
|
65
|
+
button={{
|
|
66
|
+
text: isLastPage ? validatedData.continueButtonLabel : "Next",
|
|
67
|
+
}}
|
|
68
|
+
>
|
|
69
|
+
<View style={styles.container}>
|
|
70
|
+
<ScrollView
|
|
71
|
+
ref={scrollViewRef}
|
|
72
|
+
horizontal
|
|
73
|
+
pagingEnabled
|
|
74
|
+
showsHorizontalScrollIndicator={false}
|
|
75
|
+
scrollEventThrottle={16}
|
|
76
|
+
onMomentumScrollEnd={handleScroll}
|
|
77
|
+
style={styles.scrollView}
|
|
78
|
+
>
|
|
79
|
+
{screens.map((screen, index) => (
|
|
80
|
+
<CarouselScreen key={index} width={width} screen={screen} theme={theme} />
|
|
81
|
+
))}
|
|
82
|
+
</ScrollView>
|
|
83
|
+
|
|
84
|
+
{/* Page Indicators */}
|
|
85
|
+
<View style={styles.indicatorContainer}>
|
|
86
|
+
{screens.map((_, index) => (
|
|
87
|
+
<View
|
|
88
|
+
key={index}
|
|
89
|
+
style={[
|
|
90
|
+
styles.indicator,
|
|
91
|
+
{
|
|
92
|
+
backgroundColor: index === currentPage ? theme.colors.primary : theme.colors.neutral.lower
|
|
93
|
+
},
|
|
94
|
+
index === currentPage && styles.indicatorActive,
|
|
95
|
+
]}
|
|
96
|
+
/>
|
|
97
|
+
))}
|
|
98
|
+
</View>
|
|
99
|
+
</View>
|
|
100
|
+
</OnboardingTemplate>
|
|
101
|
+
);
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
type CarouselScreenProps = {
|
|
105
|
+
width: number;
|
|
106
|
+
screen: CarouselScreenType;
|
|
107
|
+
theme: Theme;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const CarouselScreen = ({ width, screen, theme }: CarouselScreenProps) => {
|
|
111
|
+
const renderMedia = () => {
|
|
112
|
+
const { mediaUrl } = screen;
|
|
113
|
+
|
|
114
|
+
if (mediaUrl.includes(".riv")) {
|
|
115
|
+
return (
|
|
116
|
+
<View style={[styles.mediaPlaceholder, { backgroundColor: theme.colors.neutral.lowest }]}>
|
|
117
|
+
<Text style={[getTextStyle(theme, "body"), styles.placeholderText, { color: theme.colors.text.disable }]}>Rive Animation</Text>
|
|
118
|
+
</View>
|
|
119
|
+
);
|
|
120
|
+
} else if (mediaUrl.includes(".json")) {
|
|
121
|
+
return <View style={[styles.mediaPlaceholder, { backgroundColor: theme.colors.neutral.lowest }]}>
|
|
122
|
+
<Text style={[getTextStyle(theme, "body"), styles.placeholderText, { color: theme.colors.text.disable }]}>Lottie Animation</Text>
|
|
123
|
+
</View>
|
|
124
|
+
} else {
|
|
125
|
+
return (
|
|
126
|
+
<Image
|
|
127
|
+
source={{ uri: mediaUrl }}
|
|
128
|
+
style={styles.mediaImage}
|
|
129
|
+
resizeMode="contain"
|
|
130
|
+
/>
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
return (
|
|
136
|
+
<View style={[styles.screenContainer, { width }]}>
|
|
137
|
+
{/* Media */}
|
|
138
|
+
<View style={styles.mediaContainer}>{renderMedia()}</View>
|
|
139
|
+
|
|
140
|
+
{/* Text Content */}
|
|
141
|
+
<View style={styles.textContainer}>
|
|
142
|
+
<Text style={[getTextStyle(theme, "heading1"), styles.title, { color: theme.colors.text.primary }]}>{screen.title}</Text>
|
|
143
|
+
{screen.subtitle && (
|
|
144
|
+
<Text style={[getTextStyle(theme, "heading3"), styles.subtitle, { color: theme.colors.text.secondary }]}>{screen.subtitle}</Text>
|
|
145
|
+
)}
|
|
146
|
+
</View>
|
|
147
|
+
</View>
|
|
148
|
+
);
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
const styles = StyleSheet.create({
|
|
152
|
+
container: {
|
|
153
|
+
flex: 1,
|
|
154
|
+
},
|
|
155
|
+
scrollView: {
|
|
156
|
+
flex: 1,
|
|
157
|
+
},
|
|
158
|
+
screenContainer: {
|
|
159
|
+
flex: 1,
|
|
160
|
+
paddingHorizontal: 24,
|
|
161
|
+
gap: 32,
|
|
162
|
+
},
|
|
163
|
+
mediaContainer: {
|
|
164
|
+
flex: 1,
|
|
165
|
+
justifyContent: "center",
|
|
166
|
+
alignItems: "center",
|
|
167
|
+
minHeight: 300,
|
|
168
|
+
},
|
|
169
|
+
mediaImage: {
|
|
170
|
+
width: "100%",
|
|
171
|
+
height: "100%",
|
|
172
|
+
},
|
|
173
|
+
mediaPlaceholder: {
|
|
174
|
+
width: "100%",
|
|
175
|
+
height: "100%",
|
|
176
|
+
borderRadius: 32,
|
|
177
|
+
justifyContent: "center",
|
|
178
|
+
alignItems: "center",
|
|
179
|
+
},
|
|
180
|
+
placeholderText: {},
|
|
181
|
+
textContainer: {
|
|
182
|
+
gap: 16,
|
|
183
|
+
paddingBottom: 24,
|
|
184
|
+
},
|
|
185
|
+
title: {
|
|
186
|
+
textAlign: "center",
|
|
187
|
+
letterSpacing: -0.76,
|
|
188
|
+
},
|
|
189
|
+
subtitle: {
|
|
190
|
+
textAlign: "center",
|
|
191
|
+
},
|
|
192
|
+
indicatorContainer: {
|
|
193
|
+
flexDirection: "row",
|
|
194
|
+
justifyContent: "center",
|
|
195
|
+
gap: 8,
|
|
196
|
+
paddingVertical: 20,
|
|
197
|
+
},
|
|
198
|
+
indicator: {
|
|
199
|
+
width: 8,
|
|
200
|
+
height: 8,
|
|
201
|
+
borderRadius: 4,
|
|
202
|
+
},
|
|
203
|
+
indicatorActive: {
|
|
204
|
+
width: 24,
|
|
205
|
+
},
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
import { withErrorBoundary } from '../../ErrorBoundary';
|
|
209
|
+
|
|
210
|
+
export const CarouselRenderer = withErrorBoundary(CarouselRendererBase, 'Carousel');
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { CustomPayloadSchema } from "../types";
|
|
3
|
+
|
|
4
|
+
export const CarouselScreenSchema = z.object({
|
|
5
|
+
mediaUrl: z.string(),
|
|
6
|
+
title: z.string(),
|
|
7
|
+
subtitle: z.string().nullish(),
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export const CarouselStepPayloadSchema = z.object({
|
|
11
|
+
screens: z.array(CarouselScreenSchema),
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export const CarouselStepTypeSchema = z.object({
|
|
15
|
+
id: z.string(),
|
|
16
|
+
type: z.literal("Carousel"),
|
|
17
|
+
name: z.string(),
|
|
18
|
+
displayProgressHeader: z.boolean(),
|
|
19
|
+
payload: CarouselStepPayloadSchema,
|
|
20
|
+
customPayload: CustomPayloadSchema,
|
|
21
|
+
continueButtonLabel: z.string().optional().default("Continue"),
|
|
22
|
+
figmaUrl: z.string().nullish(),
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export type CarouselStepType = z.infer<typeof CarouselStepTypeSchema>;
|
|
26
|
+
export type CarouselScreenType = z.infer<typeof CarouselScreenSchema>;
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import React, { useState, useRef, useCallback } from "react";
|
|
2
|
+
import {
|
|
3
|
+
View,
|
|
4
|
+
Text,
|
|
5
|
+
StyleSheet,
|
|
6
|
+
ScrollView,
|
|
7
|
+
TouchableOpacity,
|
|
8
|
+
} from "react-native";
|
|
9
|
+
import { CommitmentStepType, CommitmentStepTypeSchema } from "./types";
|
|
10
|
+
import { OnboardingTemplate } from "../../Templates/OnboardingTemplate";
|
|
11
|
+
import {
|
|
12
|
+
Gesture,
|
|
13
|
+
GestureDetector,
|
|
14
|
+
GestureHandlerRootView,
|
|
15
|
+
} from "react-native-gesture-handler";
|
|
16
|
+
import { runOnJS } from "react-native-reanimated";
|
|
17
|
+
import { Theme } from "../../Theme/types";
|
|
18
|
+
import { defaultTheme } from "../../Theme/defaultTheme";
|
|
19
|
+
import { getTextStyle } from "../../Theme/helpers";
|
|
20
|
+
|
|
21
|
+
// Lazy load Skia - only needed for signature variant
|
|
22
|
+
let SkiaModule: any;
|
|
23
|
+
try {
|
|
24
|
+
SkiaModule = require("@shopify/react-native-skia");
|
|
25
|
+
} catch (e) {
|
|
26
|
+
// Skia not installed - will show error if signature variant is used
|
|
27
|
+
SkiaModule = null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
type ContentProps = {
|
|
31
|
+
step: CommitmentStepType;
|
|
32
|
+
onContinue: () => void;
|
|
33
|
+
theme?: Theme;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const CommitmentRendererBase = ({ step, onContinue, theme = defaultTheme }: ContentProps) => {
|
|
37
|
+
const validatedData = CommitmentStepTypeSchema.parse(step);
|
|
38
|
+
const { payload } = validatedData;
|
|
39
|
+
|
|
40
|
+
// Check if Skia is needed and available
|
|
41
|
+
const needsSkia = payload.variant === "signature";
|
|
42
|
+
if (needsSkia && !SkiaModule) {
|
|
43
|
+
throw new Error(
|
|
44
|
+
"Commitment screens with signature variant require @shopify/react-native-skia. Install it with: npm install @shopify/react-native-skia"
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const Skia = SkiaModule?.Skia;
|
|
49
|
+
const currentPath = useRef<any>(null);
|
|
50
|
+
const [paths, setPaths] = useState<any[]>([]);
|
|
51
|
+
const [hasSignature, setHasSignature] = useState(false);
|
|
52
|
+
|
|
53
|
+
const updatePaths = useCallback((newPath: any) => {
|
|
54
|
+
setPaths((prevState) => [...prevState, newPath]);
|
|
55
|
+
}, []);
|
|
56
|
+
|
|
57
|
+
const panGesture = Gesture.Pan()
|
|
58
|
+
.runOnJS(true)
|
|
59
|
+
.onBegin(({ x, y }: { x: number; y: number }) => {
|
|
60
|
+
if (Skia) {
|
|
61
|
+
currentPath.current = Skia.Path.Make();
|
|
62
|
+
currentPath.current.moveTo(x, y);
|
|
63
|
+
runOnJS(updatePaths)(currentPath.current);
|
|
64
|
+
runOnJS(setHasSignature)(true);
|
|
65
|
+
}
|
|
66
|
+
})
|
|
67
|
+
.onUpdate(({ x, y }: { x: number; y: number }) => {
|
|
68
|
+
if (currentPath.current) {
|
|
69
|
+
currentPath.current.lineTo(x, y);
|
|
70
|
+
setPaths((prev) => [...prev]);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
const handleClearSignature = () => {
|
|
75
|
+
setPaths([]);
|
|
76
|
+
currentPath.current = null;
|
|
77
|
+
setHasSignature(false);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const isButtonDisabled = payload.variant === "signature" && !hasSignature;
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<OnboardingTemplate
|
|
84
|
+
step={validatedData}
|
|
85
|
+
onContinue={onContinue}
|
|
86
|
+
theme={theme}
|
|
87
|
+
button={{
|
|
88
|
+
text: validatedData.continueButtonLabel,
|
|
89
|
+
disabled: isButtonDisabled,
|
|
90
|
+
}}
|
|
91
|
+
>
|
|
92
|
+
<ScrollView
|
|
93
|
+
style={styles.scrollView}
|
|
94
|
+
contentContainerStyle={styles.contentContainer}
|
|
95
|
+
showsVerticalScrollIndicator={false}
|
|
96
|
+
alwaysBounceVertical={false}
|
|
97
|
+
>
|
|
98
|
+
<View style={styles.container}>
|
|
99
|
+
{/* Title */}
|
|
100
|
+
<Text style={[getTextStyle(theme, "heading1"), styles.title, { color: theme.colors.text.primary }]}>
|
|
101
|
+
{payload.title}
|
|
102
|
+
</Text>
|
|
103
|
+
|
|
104
|
+
{/* Content Section */}
|
|
105
|
+
<View style={styles.contentSection}>
|
|
106
|
+
{/* Subtitle */}
|
|
107
|
+
{payload.subtitle && (
|
|
108
|
+
<Text
|
|
109
|
+
style={[
|
|
110
|
+
getTextStyle(theme, "heading3"),
|
|
111
|
+
styles.subtitle,
|
|
112
|
+
{ color: theme.colors.text.secondary },
|
|
113
|
+
]}
|
|
114
|
+
>
|
|
115
|
+
{payload.subtitle}
|
|
116
|
+
</Text>
|
|
117
|
+
)}
|
|
118
|
+
|
|
119
|
+
{/* Description or Commitments List */}
|
|
120
|
+
{payload.description ? (
|
|
121
|
+
<Text
|
|
122
|
+
style={[
|
|
123
|
+
getTextStyle(theme, "body"),
|
|
124
|
+
styles.description,
|
|
125
|
+
{ color: theme.colors.text.secondary },
|
|
126
|
+
]}
|
|
127
|
+
>
|
|
128
|
+
{payload.description}
|
|
129
|
+
</Text>
|
|
130
|
+
) : (
|
|
131
|
+
payload.commitments && (
|
|
132
|
+
<View style={styles.commitmentsContainer}>
|
|
133
|
+
{payload.commitments.map(
|
|
134
|
+
(commitment: { text: string }, index: number) => (
|
|
135
|
+
<View key={index} style={styles.commitmentRow}>
|
|
136
|
+
<View
|
|
137
|
+
style={[
|
|
138
|
+
styles.checkmark,
|
|
139
|
+
{ backgroundColor: theme.colors.primary },
|
|
140
|
+
]}
|
|
141
|
+
>
|
|
142
|
+
<Text style={[styles.checkmarkText, { color: theme.colors.text.opposite }]}>✓</Text>
|
|
143
|
+
</View>
|
|
144
|
+
<Text
|
|
145
|
+
style={[
|
|
146
|
+
getTextStyle(theme, "body"),
|
|
147
|
+
styles.commitmentText,
|
|
148
|
+
{ color: theme.colors.text.secondary },
|
|
149
|
+
]}
|
|
150
|
+
>
|
|
151
|
+
{commitment.text}
|
|
152
|
+
</Text>
|
|
153
|
+
</View>
|
|
154
|
+
)
|
|
155
|
+
)}
|
|
156
|
+
</View>
|
|
157
|
+
)
|
|
158
|
+
)}
|
|
159
|
+
</View>
|
|
160
|
+
|
|
161
|
+
{/* Signature Canvas */}
|
|
162
|
+
{payload.variant === "signature" && (
|
|
163
|
+
<View style={styles.signatureSection}>
|
|
164
|
+
<GestureHandlerRootView style={styles.gestureRoot}>
|
|
165
|
+
<View
|
|
166
|
+
style={[
|
|
167
|
+
styles.signatureContainer,
|
|
168
|
+
{ borderColor: theme.colors.primary },
|
|
169
|
+
]}
|
|
170
|
+
>
|
|
171
|
+
{/* Clear button */}
|
|
172
|
+
{hasSignature && (
|
|
173
|
+
<TouchableOpacity
|
|
174
|
+
style={[
|
|
175
|
+
styles.clearButton,
|
|
176
|
+
{ backgroundColor: theme.colors.neutral.higher },
|
|
177
|
+
]}
|
|
178
|
+
onPress={handleClearSignature}
|
|
179
|
+
activeOpacity={0.8}
|
|
180
|
+
>
|
|
181
|
+
<Text style={[styles.clearButtonText, { color: theme.colors.text.opposite }]}>✕</Text>
|
|
182
|
+
</TouchableOpacity>
|
|
183
|
+
)}
|
|
184
|
+
|
|
185
|
+
{/* Canvas */}
|
|
186
|
+
<GestureDetector gesture={panGesture}>
|
|
187
|
+
{SkiaModule && (
|
|
188
|
+
<SkiaModule.Canvas style={styles.canvas}>
|
|
189
|
+
{paths.map((path: any, index: number) => (
|
|
190
|
+
<SkiaModule.Path
|
|
191
|
+
key={index}
|
|
192
|
+
path={path}
|
|
193
|
+
color={theme.colors.text.primary}
|
|
194
|
+
style="stroke"
|
|
195
|
+
strokeWidth={2}
|
|
196
|
+
strokeCap="round"
|
|
197
|
+
strokeJoin="round"
|
|
198
|
+
/>
|
|
199
|
+
))}
|
|
200
|
+
</SkiaModule.Canvas>
|
|
201
|
+
)}
|
|
202
|
+
</GestureDetector>
|
|
203
|
+
</View>
|
|
204
|
+
</GestureHandlerRootView>
|
|
205
|
+
|
|
206
|
+
{/* Caption */}
|
|
207
|
+
<Text
|
|
208
|
+
style={[
|
|
209
|
+
getTextStyle(theme, "caption"),
|
|
210
|
+
styles.signatureCaption,
|
|
211
|
+
{ color: theme.colors.text.secondary },
|
|
212
|
+
]}
|
|
213
|
+
>
|
|
214
|
+
{payload.signatureCaption}
|
|
215
|
+
</Text>
|
|
216
|
+
</View>
|
|
217
|
+
)}
|
|
218
|
+
</View>
|
|
219
|
+
</ScrollView>
|
|
220
|
+
</OnboardingTemplate>
|
|
221
|
+
);
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
const styles = StyleSheet.create({
|
|
225
|
+
scrollView: {
|
|
226
|
+
flex: 1,
|
|
227
|
+
},
|
|
228
|
+
contentContainer: {
|
|
229
|
+
flexGrow: 1,
|
|
230
|
+
},
|
|
231
|
+
container: {
|
|
232
|
+
flex: 1,
|
|
233
|
+
paddingHorizontal: 24,
|
|
234
|
+
paddingTop: 24,
|
|
235
|
+
gap: 48,
|
|
236
|
+
},
|
|
237
|
+
title: {
|
|
238
|
+
letterSpacing: -0.76,
|
|
239
|
+
},
|
|
240
|
+
contentSection: {
|
|
241
|
+
gap: 24,
|
|
242
|
+
},
|
|
243
|
+
subtitle: {},
|
|
244
|
+
description: {
|
|
245
|
+
paddingVertical: 8,
|
|
246
|
+
},
|
|
247
|
+
commitmentsContainer: {
|
|
248
|
+
gap: 16,
|
|
249
|
+
},
|
|
250
|
+
commitmentRow: {
|
|
251
|
+
flexDirection: "row",
|
|
252
|
+
alignItems: "center",
|
|
253
|
+
gap: 16,
|
|
254
|
+
},
|
|
255
|
+
checkmark: {
|
|
256
|
+
width: 24,
|
|
257
|
+
height: 24,
|
|
258
|
+
borderRadius: 30,
|
|
259
|
+
alignItems: "center",
|
|
260
|
+
justifyContent: "center",
|
|
261
|
+
padding: 6,
|
|
262
|
+
},
|
|
263
|
+
checkmarkText: {
|
|
264
|
+
fontSize: 12,
|
|
265
|
+
fontWeight: "600",
|
|
266
|
+
},
|
|
267
|
+
commitmentText: {
|
|
268
|
+
flex: 1,
|
|
269
|
+
},
|
|
270
|
+
signatureSection: {
|
|
271
|
+
gap: 8,
|
|
272
|
+
},
|
|
273
|
+
gestureRoot: {
|
|
274
|
+
width: "100%",
|
|
275
|
+
},
|
|
276
|
+
signatureContainer: {
|
|
277
|
+
borderWidth: 2,
|
|
278
|
+
borderRadius: 32,
|
|
279
|
+
padding: 12,
|
|
280
|
+
height: 169,
|
|
281
|
+
position: "relative",
|
|
282
|
+
},
|
|
283
|
+
clearButton: {
|
|
284
|
+
position: "absolute",
|
|
285
|
+
top: 12,
|
|
286
|
+
right: 12,
|
|
287
|
+
zIndex: 1,
|
|
288
|
+
width: 32,
|
|
289
|
+
height: 32,
|
|
290
|
+
borderRadius: 20,
|
|
291
|
+
alignItems: "center",
|
|
292
|
+
justifyContent: "center",
|
|
293
|
+
},
|
|
294
|
+
clearButtonText: {
|
|
295
|
+
fontSize: 16,
|
|
296
|
+
fontWeight: "400",
|
|
297
|
+
},
|
|
298
|
+
canvas: {
|
|
299
|
+
flex: 1,
|
|
300
|
+
borderRadius: 20,
|
|
301
|
+
},
|
|
302
|
+
signatureCaption: {
|
|
303
|
+
marginBottom: 32,
|
|
304
|
+
},
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
import { withErrorBoundary } from "../../ErrorBoundary";
|
|
308
|
+
|
|
309
|
+
export const CommitmentRenderer = withErrorBoundary(
|
|
310
|
+
CommitmentRendererBase,
|
|
311
|
+
"Commitment"
|
|
312
|
+
);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { CustomPayloadSchema } from "../types";
|
|
3
|
+
|
|
4
|
+
export const CommitmentItemSchema = z.object({
|
|
5
|
+
text: z.string(),
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
export const CommitmentStepPayloadSchema = z.object({
|
|
9
|
+
title: z.string(),
|
|
10
|
+
subtitle: z.string().nullish(),
|
|
11
|
+
description: z.string().nullish(),
|
|
12
|
+
commitments: z.array(CommitmentItemSchema).nullish(),
|
|
13
|
+
signatureCaption: z.string().default("Your signature is not recorded"),
|
|
14
|
+
variant: z.enum(["signature", "simple"]).default("signature"),
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export const CommitmentStepTypeSchema = z.object({
|
|
18
|
+
id: z.string(),
|
|
19
|
+
type: z.literal("Commitment"),
|
|
20
|
+
name: z.string(),
|
|
21
|
+
displayProgressHeader: z.boolean(),
|
|
22
|
+
payload: CommitmentStepPayloadSchema,
|
|
23
|
+
customPayload: CustomPayloadSchema,
|
|
24
|
+
continueButtonLabel: z.string().optional().default("Continue"),
|
|
25
|
+
figmaUrl: z.string().nullish(),
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
export type CommitmentStepType = z.infer<typeof CommitmentStepTypeSchema>;
|