@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.
Files changed (275) hide show
  1. package/dist/UI/Components/CircularProgress.d.ts +8 -0
  2. package/dist/UI/Components/CircularProgress.d.ts.map +1 -0
  3. package/dist/UI/Components/CircularProgress.js +104 -0
  4. package/dist/UI/Components/CircularProgress.js.map +1 -0
  5. package/dist/UI/Components/ProgressBar.d.ts +12 -0
  6. package/dist/UI/Components/ProgressBar.d.ts.map +1 -0
  7. package/dist/UI/Components/ProgressBar.js +121 -0
  8. package/dist/UI/Components/ProgressBar.js.map +1 -0
  9. package/dist/UI/Components/StaggeredTextList.d.ts +11 -0
  10. package/dist/UI/Components/StaggeredTextList.d.ts.map +1 -0
  11. package/dist/UI/Components/StaggeredTextList.js +111 -0
  12. package/dist/UI/Components/StaggeredTextList.js.map +1 -0
  13. package/dist/UI/Components/index.d.ts +4 -0
  14. package/dist/UI/Components/index.d.ts.map +1 -0
  15. package/dist/UI/Components/index.js +20 -0
  16. package/dist/UI/Components/index.js.map +1 -0
  17. package/dist/UI/ErrorBoundary/ErrorBoundary.d.ts +19 -0
  18. package/dist/UI/ErrorBoundary/ErrorBoundary.d.ts.map +1 -0
  19. package/dist/UI/ErrorBoundary/ErrorBoundary.js +123 -0
  20. package/dist/UI/ErrorBoundary/ErrorBoundary.js.map +1 -0
  21. package/dist/UI/ErrorBoundary/index.d.ts +3 -0
  22. package/dist/UI/ErrorBoundary/index.d.ts.map +1 -0
  23. package/dist/UI/ErrorBoundary/index.js +8 -0
  24. package/dist/UI/ErrorBoundary/index.js.map +1 -0
  25. package/dist/UI/ErrorBoundary/withErrorBoundary.d.ts +6 -0
  26. package/dist/UI/ErrorBoundary/withErrorBoundary.d.ts.map +1 -0
  27. package/dist/UI/ErrorBoundary/withErrorBoundary.js +13 -0
  28. package/dist/UI/ErrorBoundary/withErrorBoundary.js.map +1 -0
  29. package/dist/UI/OnboardingPage.d.ts +16 -0
  30. package/dist/UI/OnboardingPage.d.ts.map +1 -0
  31. package/dist/UI/OnboardingPage.js +38 -0
  32. package/dist/UI/OnboardingPage.js.map +1 -0
  33. package/dist/UI/Pages/Carousel/Renderer.d.ts +13 -0
  34. package/dist/UI/Pages/Carousel/Renderer.d.ts.map +1 -0
  35. package/dist/UI/Pages/Carousel/Renderer.js +121 -0
  36. package/dist/UI/Pages/Carousel/Renderer.js.map +1 -0
  37. package/dist/UI/Pages/Carousel/index.d.ts +3 -0
  38. package/dist/UI/Pages/Carousel/index.d.ts.map +1 -0
  39. package/dist/UI/Pages/Carousel/index.js +19 -0
  40. package/dist/UI/Pages/Carousel/index.js.map +1 -0
  41. package/dist/UI/Pages/Carousel/types.d.ts +32 -0
  42. package/dist/UI/Pages/Carousel/types.d.ts.map +1 -0
  43. package/dist/UI/Pages/Carousel/types.js +24 -0
  44. package/dist/UI/Pages/Carousel/types.js.map +1 -0
  45. package/dist/UI/Pages/Commitment/Renderer.d.ts +13 -0
  46. package/dist/UI/Pages/Commitment/Renderer.d.ts.map +1 -0
  47. package/dist/UI/Pages/Commitment/Renderer.js +173 -0
  48. package/dist/UI/Pages/Commitment/Renderer.js.map +1 -0
  49. package/dist/UI/Pages/Commitment/index.d.ts +3 -0
  50. package/dist/UI/Pages/Commitment/index.d.ts.map +1 -0
  51. package/dist/UI/Pages/Commitment/index.js +19 -0
  52. package/dist/UI/Pages/Commitment/index.js.map +1 -0
  53. package/dist/UI/Pages/Commitment/types.d.ts +41 -0
  54. package/dist/UI/Pages/Commitment/types.d.ts.map +1 -0
  55. package/dist/UI/Pages/Commitment/types.js +27 -0
  56. package/dist/UI/Pages/Commitment/types.js.map +1 -0
  57. package/dist/UI/Pages/Loader/Renderer.d.ts +10 -0
  58. package/dist/UI/Pages/Loader/Renderer.d.ts.map +1 -0
  59. package/dist/UI/Pages/Loader/Renderer.js +215 -0
  60. package/dist/UI/Pages/Loader/Renderer.js.map +1 -0
  61. package/dist/UI/Pages/Loader/index.d.ts +3 -0
  62. package/dist/UI/Pages/Loader/index.d.ts.map +1 -0
  63. package/dist/UI/Pages/Loader/index.js +19 -0
  64. package/dist/UI/Pages/Loader/index.js.map +1 -0
  65. package/dist/UI/Pages/Loader/types.d.ts +57 -0
  66. package/dist/UI/Pages/Loader/types.d.ts.map +1 -0
  67. package/dist/UI/Pages/Loader/types.js +30 -0
  68. package/dist/UI/Pages/Loader/types.js.map +1 -0
  69. package/dist/UI/Pages/MediaContent/Renderer.d.ts +13 -0
  70. package/dist/UI/Pages/MediaContent/Renderer.d.ts.map +1 -0
  71. package/dist/UI/Pages/MediaContent/Renderer.js +76 -0
  72. package/dist/UI/Pages/MediaContent/Renderer.js.map +1 -0
  73. package/dist/UI/Pages/MediaContent/index.d.ts +3 -0
  74. package/dist/UI/Pages/MediaContent/index.d.ts.map +1 -0
  75. package/dist/UI/Pages/MediaContent/index.js +19 -0
  76. package/dist/UI/Pages/MediaContent/index.js.map +1 -0
  77. package/dist/UI/Pages/MediaContent/types.d.ts +44 -0
  78. package/dist/UI/Pages/MediaContent/types.d.ts.map +1 -0
  79. package/dist/UI/Pages/MediaContent/types.js +22 -0
  80. package/dist/UI/Pages/MediaContent/types.js.map +1 -0
  81. package/dist/UI/Pages/Picker/Renderer.d.ts +13 -0
  82. package/dist/UI/Pages/Picker/Renderer.d.ts.map +1 -0
  83. package/dist/UI/Pages/Picker/Renderer.js +268 -0
  84. package/dist/UI/Pages/Picker/Renderer.js.map +1 -0
  85. package/dist/UI/Pages/Picker/index.d.ts +3 -0
  86. package/dist/UI/Pages/Picker/index.d.ts.map +1 -0
  87. package/dist/UI/Pages/Picker/index.js +19 -0
  88. package/dist/UI/Pages/Picker/index.js.map +1 -0
  89. package/dist/UI/Pages/Picker/types.d.ts +49 -0
  90. package/dist/UI/Pages/Picker/types.d.ts.map +1 -0
  91. package/dist/UI/Pages/Picker/types.js +30 -0
  92. package/dist/UI/Pages/Picker/types.js.map +1 -0
  93. package/dist/UI/Pages/Question/Renderer.d.ts +18 -0
  94. package/dist/UI/Pages/Question/Renderer.d.ts.map +1 -0
  95. package/dist/UI/Pages/Question/Renderer.js +128 -0
  96. package/dist/UI/Pages/Question/Renderer.js.map +1 -0
  97. package/dist/UI/Pages/Question/components.d.ts +57 -0
  98. package/dist/UI/Pages/Question/components.d.ts.map +1 -0
  99. package/dist/UI/Pages/Question/components.js +57 -0
  100. package/dist/UI/Pages/Question/components.js.map +1 -0
  101. package/dist/UI/Pages/Question/index.d.ts +4 -0
  102. package/dist/UI/Pages/Question/index.d.ts.map +1 -0
  103. package/dist/UI/Pages/Question/index.js +20 -0
  104. package/dist/UI/Pages/Question/index.js.map +1 -0
  105. package/dist/UI/Pages/Question/types.d.ts +47 -0
  106. package/dist/UI/Pages/Question/types.d.ts.map +1 -0
  107. package/dist/UI/Pages/Question/types.js +28 -0
  108. package/dist/UI/Pages/Question/types.js.map +1 -0
  109. package/dist/UI/Pages/Ratings/Renderer.d.ts +13 -0
  110. package/dist/UI/Pages/Ratings/Renderer.d.ts.map +1 -0
  111. package/dist/UI/Pages/Ratings/Renderer.js +201 -0
  112. package/dist/UI/Pages/Ratings/Renderer.js.map +1 -0
  113. package/dist/UI/Pages/Ratings/index.d.ts +3 -0
  114. package/dist/UI/Pages/Ratings/index.d.ts.map +1 -0
  115. package/dist/UI/Pages/Ratings/index.js +19 -0
  116. package/dist/UI/Pages/Ratings/index.js.map +1 -0
  117. package/dist/UI/Pages/Ratings/types.d.ts +32 -0
  118. package/dist/UI/Pages/Ratings/types.d.ts.map +1 -0
  119. package/dist/UI/Pages/Ratings/types.js +25 -0
  120. package/dist/UI/Pages/Ratings/types.js.map +1 -0
  121. package/dist/UI/Pages/index.d.ts +9 -0
  122. package/dist/UI/Pages/index.d.ts.map +1 -0
  123. package/dist/UI/Pages/index.js +26 -0
  124. package/dist/UI/Pages/index.js.map +1 -0
  125. package/dist/UI/Pages/types.d.ts +19 -0
  126. package/dist/UI/Pages/types.d.ts.map +1 -0
  127. package/dist/UI/Pages/types.js +25 -0
  128. package/dist/UI/Pages/types.js.map +1 -0
  129. package/dist/UI/Provider/OnboardingProgressProvider.d.ts +18 -0
  130. package/dist/UI/Provider/OnboardingProgressProvider.d.ts.map +1 -0
  131. package/dist/UI/Provider/OnboardingProgressProvider.js +23 -0
  132. package/dist/UI/Provider/OnboardingProgressProvider.js.map +1 -0
  133. package/dist/UI/Provider/index.d.ts +2 -0
  134. package/dist/UI/Provider/index.d.ts.map +1 -0
  135. package/dist/UI/Provider/index.js +7 -0
  136. package/dist/UI/Provider/index.js.map +1 -0
  137. package/dist/UI/Templates/OnboardingTemplate.d.ts +15 -0
  138. package/dist/UI/Templates/OnboardingTemplate.d.ts.map +1 -0
  139. package/dist/UI/Templates/OnboardingTemplate.js +48 -0
  140. package/dist/UI/Templates/OnboardingTemplate.js.map +1 -0
  141. package/dist/UI/Templates/index.d.ts +2 -0
  142. package/dist/UI/Templates/index.d.ts.map +1 -0
  143. package/dist/UI/Templates/index.js +6 -0
  144. package/dist/UI/Templates/index.js.map +1 -0
  145. package/dist/UI/Theme/ThemeProvider.d.ts +27 -0
  146. package/dist/UI/Theme/ThemeProvider.d.ts.map +1 -0
  147. package/dist/UI/Theme/ThemeProvider.js +49 -0
  148. package/dist/UI/Theme/ThemeProvider.js.map +1 -0
  149. package/dist/UI/Theme/defaultTheme.d.ts +7 -0
  150. package/dist/UI/Theme/defaultTheme.d.ts.map +1 -0
  151. package/dist/UI/Theme/defaultTheme.js +14 -0
  152. package/dist/UI/Theme/defaultTheme.js.map +1 -0
  153. package/dist/UI/Theme/helpers.d.ts +12 -0
  154. package/dist/UI/Theme/helpers.d.ts.map +1 -0
  155. package/dist/UI/Theme/helpers.js +21 -0
  156. package/dist/UI/Theme/helpers.js.map +1 -0
  157. package/dist/UI/Theme/index.d.ts +8 -0
  158. package/dist/UI/Theme/index.d.ts.map +1 -0
  159. package/dist/UI/Theme/index.js +24 -0
  160. package/dist/UI/Theme/index.js.map +1 -0
  161. package/dist/UI/Theme/token.d.ts +107 -0
  162. package/dist/UI/Theme/token.d.ts.map +1 -0
  163. package/dist/UI/Theme/token.js +108 -0
  164. package/dist/UI/Theme/token.js.map +1 -0
  165. package/dist/UI/Theme/tokens/darkTokens.d.ts +24 -0
  166. package/dist/UI/Theme/tokens/darkTokens.d.ts.map +1 -0
  167. package/dist/UI/Theme/tokens/darkTokens.js +27 -0
  168. package/dist/UI/Theme/tokens/darkTokens.js.map +1 -0
  169. package/dist/UI/Theme/tokens/index.d.ts +4 -0
  170. package/dist/UI/Theme/tokens/index.d.ts.map +1 -0
  171. package/dist/UI/Theme/tokens/index.js +20 -0
  172. package/dist/UI/Theme/tokens/index.js.map +1 -0
  173. package/dist/UI/Theme/tokens/lightTokens.d.ts +24 -0
  174. package/dist/UI/Theme/tokens/lightTokens.d.ts.map +1 -0
  175. package/dist/UI/Theme/tokens/lightTokens.js +27 -0
  176. package/dist/UI/Theme/tokens/lightTokens.js.map +1 -0
  177. package/dist/UI/Theme/tokens/typography.d.ts +65 -0
  178. package/dist/UI/Theme/tokens/typography.d.ts.map +1 -0
  179. package/dist/UI/Theme/tokens/typography.js +68 -0
  180. package/dist/UI/Theme/tokens/typography.js.map +1 -0
  181. package/dist/UI/Theme/types.d.ts +65 -0
  182. package/dist/UI/Theme/types.d.ts.map +1 -0
  183. package/dist/UI/Theme/types.js +3 -0
  184. package/dist/UI/Theme/types.js.map +1 -0
  185. package/dist/UI/Theme/useTheme.d.ts +7 -0
  186. package/dist/UI/Theme/useTheme.d.ts.map +1 -0
  187. package/dist/UI/Theme/useTheme.js +23 -0
  188. package/dist/UI/Theme/useTheme.js.map +1 -0
  189. package/dist/UI/Theme/utils.d.ts +12 -0
  190. package/dist/UI/Theme/utils.d.ts.map +1 -0
  191. package/dist/UI/Theme/utils.js +55 -0
  192. package/dist/UI/Theme/utils.js.map +1 -0
  193. package/dist/UI/index.d.ts +8 -0
  194. package/dist/UI/index.d.ts.map +1 -0
  195. package/dist/UI/index.js +24 -0
  196. package/dist/UI/index.js.map +1 -0
  197. package/dist/UI/types.d.ts +23 -0
  198. package/dist/UI/types.d.ts.map +1 -0
  199. package/dist/UI/types.js +3 -0
  200. package/dist/UI/types.js.map +1 -0
  201. package/dist/assets/laurel-left.png +0 -0
  202. package/dist/assets/laurel-right.png +0 -0
  203. package/dist/assets/star-filled.png +0 -0
  204. package/dist/index.d.ts +9 -0
  205. package/dist/index.d.ts.map +1 -0
  206. package/dist/index.js +33 -0
  207. package/dist/index.js.map +1 -0
  208. package/dist/provider/CustomComponentsContext.d.ts +57 -0
  209. package/dist/provider/CustomComponentsContext.d.ts.map +1 -0
  210. package/dist/provider/CustomComponentsContext.js +19 -0
  211. package/dist/provider/CustomComponentsContext.js.map +1 -0
  212. package/dist/provider/OnboardingUIProvider.d.ts +44 -0
  213. package/dist/provider/OnboardingUIProvider.d.ts.map +1 -0
  214. package/dist/provider/OnboardingUIProvider.js +33 -0
  215. package/dist/provider/OnboardingUIProvider.js.map +1 -0
  216. package/dist/provider/OnboardingUIProvider.old.d.ts +60 -0
  217. package/dist/provider/OnboardingUIProvider.old.d.ts.map +1 -0
  218. package/dist/provider/OnboardingUIProvider.old.js +53 -0
  219. package/dist/provider/OnboardingUIProvider.old.js.map +1 -0
  220. package/package.json +77 -0
  221. package/src/UI/Components/CircularProgress.tsx +146 -0
  222. package/src/UI/Components/ProgressBar.tsx +143 -0
  223. package/src/UI/Components/StaggeredTextList.tsx +152 -0
  224. package/src/UI/Components/index.ts +3 -0
  225. package/src/UI/ErrorBoundary/ErrorBoundary.tsx +181 -0
  226. package/src/UI/ErrorBoundary/README.md +71 -0
  227. package/src/UI/ErrorBoundary/index.ts +2 -0
  228. package/src/UI/ErrorBoundary/withErrorBoundary.tsx +19 -0
  229. package/src/UI/OnboardingPage.tsx +53 -0
  230. package/src/UI/Pages/Carousel/Renderer.tsx +210 -0
  231. package/src/UI/Pages/Carousel/index.ts +2 -0
  232. package/src/UI/Pages/Carousel/types.ts +26 -0
  233. package/src/UI/Pages/Commitment/Renderer.tsx +312 -0
  234. package/src/UI/Pages/Commitment/index.ts +2 -0
  235. package/src/UI/Pages/Commitment/types.ts +28 -0
  236. package/src/UI/Pages/Loader/Renderer.tsx +417 -0
  237. package/src/UI/Pages/Loader/index.ts +2 -0
  238. package/src/UI/Pages/Loader/types.ts +32 -0
  239. package/src/UI/Pages/MediaContent/Renderer.tsx +130 -0
  240. package/src/UI/Pages/MediaContent/index.ts +2 -0
  241. package/src/UI/Pages/MediaContent/types.ts +26 -0
  242. package/src/UI/Pages/Picker/Renderer.tsx +618 -0
  243. package/src/UI/Pages/Picker/index.ts +2 -0
  244. package/src/UI/Pages/Picker/types.ts +34 -0
  245. package/src/UI/Pages/Question/Renderer.tsx +208 -0
  246. package/src/UI/Pages/Question/components.tsx +130 -0
  247. package/src/UI/Pages/Question/index.ts +3 -0
  248. package/src/UI/Pages/Question/types.ts +29 -0
  249. package/src/UI/Pages/Ratings/Renderer.tsx +282 -0
  250. package/src/UI/Pages/Ratings/index.ts +2 -0
  251. package/src/UI/Pages/Ratings/types.ts +22 -0
  252. package/src/UI/Pages/index.ts +10 -0
  253. package/src/UI/Pages/types.ts +25 -0
  254. package/src/UI/Provider/OnboardingProgressProvider.tsx +40 -0
  255. package/src/UI/Provider/index.ts +1 -0
  256. package/src/UI/Templates/OnboardingTemplate.tsx +86 -0
  257. package/src/UI/Templates/index.ts +1 -0
  258. package/src/UI/Theme/ThemeProvider.tsx +100 -0
  259. package/src/UI/Theme/defaultTheme.ts +12 -0
  260. package/src/UI/Theme/helpers.ts +24 -0
  261. package/src/UI/Theme/index.ts +7 -0
  262. package/src/UI/Theme/token.ts +106 -0
  263. package/src/UI/Theme/tokens/darkTokens.ts +25 -0
  264. package/src/UI/Theme/tokens/index.ts +3 -0
  265. package/src/UI/Theme/tokens/lightTokens.ts +25 -0
  266. package/src/UI/Theme/tokens/typography.ts +66 -0
  267. package/src/UI/Theme/types.ts +72 -0
  268. package/src/UI/Theme/useTheme.ts +22 -0
  269. package/src/UI/Theme/utils.ts +67 -0
  270. package/src/UI/index.ts +7 -0
  271. package/src/UI/types.ts +41 -0
  272. package/src/assets/laurel-left.png +0 -0
  273. package/src/assets/laurel-right.png +0 -0
  274. package/src/assets/star-filled.png +0 -0
  275. 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,2 @@
1
+ export * from "./Renderer";
2
+ export * from "./types";
@@ -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,2 @@
1
+ export * from "./Renderer";
2
+ export * from "./types";
@@ -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>;