@onairos/react-native 3.1.15 → 3.1.17

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 (191) hide show
  1. package/README.md +404 -0
  2. package/lib/commonjs/assets/images/Checkbox.svg +3 -3
  3. package/lib/commonjs/assets/images/EnochE.svg +19 -19
  4. package/lib/commonjs/assets/images/Personalityprofile.svg +3 -3
  5. package/lib/commonjs/assets/images/Personalitytraits.svg +3 -3
  6. package/lib/commonjs/assets/images/Userpreferences.svg +3 -3
  7. package/lib/commonjs/assets/images/arrow.svg +20 -20
  8. package/lib/commonjs/assets/images/basicproficon.svg +43 -43
  9. package/lib/commonjs/assets/images/basicprofile.svg +3 -3
  10. package/lib/commonjs/assets/images/checkmark.svg +4 -4
  11. package/lib/commonjs/assets/images/contentanalysis.svg +3 -3
  12. package/lib/commonjs/assets/images/contenticon.svg +23 -23
  13. package/lib/commonjs/assets/images/personalityicon.svg +18 -18
  14. package/lib/commonjs/assets/images/x-close.svg +3 -3
  15. package/lib/commonjs/components/OnairosSignInButton.js +32 -74
  16. package/lib/commonjs/components/OnairosSignInButton.js.map +1 -1
  17. package/lib/commonjs/components/UniversalOnboarding.js +4 -4
  18. package/lib/commonjs/config/api.js +2 -2
  19. package/lib/commonjs/hooks/useConnections.js +6 -6
  20. package/lib/commonjs/hooks/useUserConnections.js +10 -10
  21. package/lib/commonjs/index.js +5 -12
  22. package/lib/commonjs/index.js.map +1 -1
  23. package/lib/commonjs/services/apiClient.js +35 -35
  24. package/lib/commonjs/services/apiKeyService.js +99 -99
  25. package/lib/commonjs/services/authService.js +82 -82
  26. package/lib/commonjs/services/biometricPinService.js +10 -10
  27. package/lib/commonjs/services/connectedAccountsService.js +32 -32
  28. package/lib/commonjs/services/googleAuthService.js +15 -15
  29. package/lib/commonjs/services/imageCompressionService.js +15 -15
  30. package/lib/commonjs/services/jwtStorageService.js +59 -59
  31. package/lib/commonjs/services/mobileTrainingService.js +14 -14
  32. package/lib/commonjs/services/pinEncryptionService.js +10 -10
  33. package/lib/commonjs/services/pinStorageUtils.js +15 -15
  34. package/lib/commonjs/services/platformAuthService.js +47 -47
  35. package/lib/commonjs/services/storageService.js +31 -31
  36. package/lib/commonjs/services/trainingApiHelpers.js +33 -33
  37. package/lib/commonjs/services/userConnectionsService.js +24 -24
  38. package/lib/commonjs/utils/Portal.js +4 -4
  39. package/lib/commonjs/utils/api.js +24 -24
  40. package/lib/commonjs/utils/auth.js +18 -18
  41. package/lib/commonjs/utils/crypto.js +13 -13
  42. package/lib/commonjs/utils/encryption.js +12 -12
  43. package/lib/commonjs/utils/eventUtils.js +52 -52
  44. package/lib/commonjs/utils/programmaticFlow.js +16 -16
  45. package/lib/commonjs/utils/retryHelper.js +27 -27
  46. package/lib/module/assets/images/Checkbox.svg +3 -3
  47. package/lib/module/assets/images/EnochE.svg +19 -19
  48. package/lib/module/assets/images/Personalityprofile.svg +3 -3
  49. package/lib/module/assets/images/Personalitytraits.svg +3 -3
  50. package/lib/module/assets/images/Userpreferences.svg +3 -3
  51. package/lib/module/assets/images/arrow.svg +20 -20
  52. package/lib/module/assets/images/basicproficon.svg +43 -43
  53. package/lib/module/assets/images/basicprofile.svg +3 -3
  54. package/lib/module/assets/images/checkmark.svg +4 -4
  55. package/lib/module/assets/images/contentanalysis.svg +3 -3
  56. package/lib/module/assets/images/contenticon.svg +23 -23
  57. package/lib/module/assets/images/personalityicon.svg +18 -18
  58. package/lib/module/assets/images/x-close.svg +3 -3
  59. package/lib/module/components/OnairosSignInButton.js +32 -74
  60. package/lib/module/components/OnairosSignInButton.js.map +1 -1
  61. package/lib/module/components/UniversalOnboarding.js +4 -4
  62. package/lib/module/config/api.js +2 -2
  63. package/lib/module/hooks/useConnections.js +6 -6
  64. package/lib/module/hooks/useUserConnections.js +10 -10
  65. package/lib/module/index.js +5 -6
  66. package/lib/module/index.js.map +1 -1
  67. package/lib/module/services/apiClient.js +35 -35
  68. package/lib/module/services/apiKeyService.js +99 -99
  69. package/lib/module/services/authService.js +82 -82
  70. package/lib/module/services/biometricPinService.js +10 -10
  71. package/lib/module/services/connectedAccountsService.js +32 -32
  72. package/lib/module/services/googleAuthService.js +15 -15
  73. package/lib/module/services/imageCompressionService.js +15 -15
  74. package/lib/module/services/jwtStorageService.js +59 -59
  75. package/lib/module/services/mobileTrainingService.js +14 -14
  76. package/lib/module/services/pinEncryptionService.js +10 -10
  77. package/lib/module/services/pinStorageUtils.js +15 -15
  78. package/lib/module/services/platformAuthService.js +47 -47
  79. package/lib/module/services/storageService.js +31 -31
  80. package/lib/module/services/trainingApiHelpers.js +33 -33
  81. package/lib/module/services/userConnectionsService.js +24 -24
  82. package/lib/module/utils/Portal.js +4 -4
  83. package/lib/module/utils/api.js +24 -24
  84. package/lib/module/utils/auth.js +18 -18
  85. package/lib/module/utils/crypto.js +13 -13
  86. package/lib/module/utils/encryption.js +12 -12
  87. package/lib/module/utils/eventUtils.js +52 -52
  88. package/lib/module/utils/programmaticFlow.js +16 -16
  89. package/lib/module/utils/retryHelper.js +27 -27
  90. package/lib/typescript/components/OnairosSignInButton.d.ts.map +1 -1
  91. package/lib/typescript/index.d.ts +0 -1
  92. package/lib/typescript/index.d.ts.map +1 -1
  93. package/package.json +163 -163
  94. package/src/api/index.ts +151 -151
  95. package/src/assets/images/Checkbox.svg +3 -3
  96. package/src/assets/images/EnochE.svg +19 -19
  97. package/src/assets/images/Personalityprofile.svg +3 -3
  98. package/src/assets/images/Personalitytraits.svg +3 -3
  99. package/src/assets/images/Userpreferences.svg +3 -3
  100. package/src/assets/images/arrow.svg +20 -20
  101. package/src/assets/images/basicproficon.svg +43 -43
  102. package/src/assets/images/basicprofile.svg +3 -3
  103. package/src/assets/images/checkmark.svg +4 -4
  104. package/src/assets/images/contentanalysis.svg +3 -3
  105. package/src/assets/images/contenticon.svg +23 -23
  106. package/src/assets/images/personalityicon.svg +18 -18
  107. package/src/assets/images/x-close.svg +3 -3
  108. package/src/components/BodyText.tsx +33 -33
  109. package/src/components/BrandMark.tsx +62 -62
  110. package/src/components/CodeInput.tsx +32 -32
  111. package/src/components/DataRequestScreen.tsx +355 -355
  112. package/src/components/EmailInput.tsx +31 -31
  113. package/src/components/EmailVerificationModal.tsx +363 -363
  114. package/src/components/ExistingUserDataConfirmation.tsx +506 -506
  115. package/src/components/GoogleButton.tsx +55 -55
  116. package/src/components/HeadingGroup.tsx +49 -49
  117. package/src/components/ModalHeader.tsx +125 -125
  118. package/src/components/ModalSheet.tsx +57 -57
  119. package/src/components/Onairos.tsx +422 -422
  120. package/src/components/OnairosButton.tsx +339 -339
  121. package/src/components/OnairosSignInButton.tsx +130 -166
  122. package/src/components/Overlay.tsx +506 -506
  123. package/src/components/PersonaImage.tsx +79 -79
  124. package/src/components/PersonaLoadingScreen.tsx +201 -201
  125. package/src/components/PersonalizationConsentScreen.tsx +410 -410
  126. package/src/components/PinCreationScreen.tsx +492 -492
  127. package/src/components/PinInput.tsx +555 -555
  128. package/src/components/PlatformConnectorsStep.tsx +891 -891
  129. package/src/components/PlatformList.tsx +144 -144
  130. package/src/components/PlatformToggle.tsx +226 -226
  131. package/src/components/PrimaryButton.tsx +213 -213
  132. package/src/components/SignInMatchAnimation.tsx +225 -225
  133. package/src/components/SignInStep.tsx +217 -217
  134. package/src/components/TrainingModal.tsx +1047 -1047
  135. package/src/components/UniversalOnboarding.tsx +2887 -2887
  136. package/src/components/VerificationStep.tsx +198 -198
  137. package/src/components/WelcomeScreen.tsx +473 -473
  138. package/src/components/icons/Basicproficon.tsx +30 -30
  139. package/src/components/icons/Basicprofile.tsx +17 -17
  140. package/src/components/icons/Checkbox.tsx +17 -17
  141. package/src/components/icons/Checkmark.tsx +24 -24
  142. package/src/components/icons/Contentanalysis.tsx +17 -17
  143. package/src/components/icons/Contenticon.tsx +30 -30
  144. package/src/components/icons/EnochE.tsx +39 -39
  145. package/src/components/icons/Personalityicon.tsx +22 -22
  146. package/src/components/icons/Personalityprofile.tsx +17 -17
  147. package/src/components/icons/Personalitytraits.tsx +17 -17
  148. package/src/components/icons/Userpreferences.tsx +17 -17
  149. package/src/components/icons/index.ts +12 -12
  150. package/src/components/onboarding/OAuthWebView.tsx +232 -232
  151. package/src/config/api.ts +25 -25
  152. package/src/context/AuthContext.tsx +393 -393
  153. package/src/hooks/useConnectedAccounts.ts +138 -138
  154. package/src/hooks/useConnections.ts +161 -161
  155. package/src/hooks/useCredentials.ts +174 -174
  156. package/src/hooks/useUserConnections.ts +165 -165
  157. package/src/index.js +14 -14
  158. package/src/index.ts +94 -95
  159. package/src/services/apiClient.ts +336 -336
  160. package/src/services/apiKeyService.ts +919 -919
  161. package/src/services/authService.ts +1008 -1008
  162. package/src/services/biometricPinService.ts +192 -192
  163. package/src/services/connectedAccountsService.ts +289 -289
  164. package/src/services/googleAuthService.ts +279 -279
  165. package/src/services/imageCompressionService.ts +302 -302
  166. package/src/services/jwtStorageService.ts +256 -256
  167. package/src/services/mobileTrainingService.ts +203 -203
  168. package/src/services/pinEncryptionService.ts +75 -75
  169. package/src/services/pinStorageUtils.ts +96 -96
  170. package/src/services/platformAuthService.ts +1346 -1346
  171. package/src/services/storageService.ts +451 -451
  172. package/src/services/trainingApiHelpers.ts +66 -66
  173. package/src/services/userConnectionsService.ts +556 -556
  174. package/src/services/youtubeMigrationService.ts +453 -453
  175. package/src/theme/index.ts +239 -239
  176. package/src/types/ambient.d.ts +28 -28
  177. package/src/types/index.ts +265 -265
  178. package/src/types/node-fix.d.ts +18 -18
  179. package/src/types/node-override.d.ts +23 -23
  180. package/src/types/opacity.d.ts +15 -15
  181. package/src/types/types.d.ts +17 -17
  182. package/src/utils/Portal.tsx +82 -82
  183. package/src/utils/api.js +111 -111
  184. package/src/utils/auth.js +103 -103
  185. package/src/utils/crypto.js +59 -59
  186. package/src/utils/encryption.ts +68 -68
  187. package/src/utils/eventUtils.ts +302 -302
  188. package/src/utils/haptics.ts +58 -58
  189. package/src/utils/imagePreloader.ts +2 -2
  190. package/src/utils/programmaticFlow.ts +112 -112
  191. package/src/utils/retryHelper.ts +274 -274
@@ -1,339 +1,339 @@
1
- import React, { useState, useCallback, forwardRef, useImperativeHandle, useEffect } from 'react';
2
- import {
3
- TouchableOpacity,
4
- Text,
5
- StyleSheet,
6
- View,
7
- ActivityIndicator,
8
- Dimensions,
9
- Image,
10
- } from 'react-native';
11
- import LinearGradient from 'react-native-linear-gradient';
12
- import { UniversalOnboarding } from './UniversalOnboarding';
13
- import WelcomeScreen from './WelcomeScreen';
14
-
15
- export interface OnairosButtonProps {
16
- AppName: string;
17
- buttonType?: 'normal' | 'pill';
18
- buttonWidth?: number;
19
- buttonHeight?: number;
20
- hasStroke?: boolean;
21
- enabled?: boolean;
22
- buttonForm?: 'default' | 'login' | 'signup' | 'connect';
23
- onResolved?: (token: string, email?: string) => void;
24
- onRejection?: (error: any) => void;
25
- preCheck?: () => Promise<boolean>;
26
- color?: string;
27
- swerv?: boolean;
28
- darkMode?: boolean;
29
- returnLink?: string;
30
- preferredPlatform?: string;
31
- autoFetch?: boolean;
32
- inferenceData?: any;
33
- textLayout?: 'left' | 'right' | 'center';
34
- textColor?: string;
35
- proofMode?: boolean;
36
- webpageName?: string;
37
- debug?: boolean;
38
- testMode?: boolean;
39
- requestData?: any;
40
- onPress?: () => void;
41
- primaryAuthOnly?: boolean;
42
- useNewWelcomeFlow?: boolean; // NEW: Enable the refreshed welcome screen experience
43
- }
44
-
45
- export interface OnairosButtonRef {
46
- trigger: () => Promise<void>;
47
- reset: () => Promise<void>;
48
- }
49
-
50
- const { width } = Dimensions.get('window');
51
-
52
- export const OnairosButton = forwardRef<OnairosButtonRef, OnairosButtonProps>(({
53
- AppName,
54
- buttonType = 'normal',
55
- buttonWidth = 180,
56
- buttonHeight = 48,
57
- hasStroke = false,
58
- enabled = true,
59
- buttonForm = 'default',
60
- onResolved,
61
- onRejection,
62
- preCheck,
63
- color = '#1BA9D4',
64
- swerv = false,
65
- darkMode = false,
66
- returnLink,
67
- preferredPlatform,
68
- autoFetch = false,
69
- inferenceData,
70
- textLayout = 'right',
71
- textColor = 'black',
72
- proofMode = false,
73
- webpageName,
74
- debug = false,
75
- testMode = false,
76
- requestData,
77
- onPress,
78
- primaryAuthOnly = false,
79
- useNewWelcomeFlow = false,
80
- }, ref) => {
81
- const [isLoading, setIsLoading] = useState(false);
82
- const [isPressed, setIsPressed] = useState(false);
83
- const [showOnboarding, setShowOnboarding] = useState(false);
84
- console.log('[OnairosButton] Initializing. Initial showOnboarding:', showOnboarding);
85
-
86
- useEffect(() => {
87
- console.log('[OnairosButton] LogEffect: showOnboarding state changed to:', showOnboarding);
88
- }, [showOnboarding]);
89
-
90
- // Expose methods via ref
91
- useImperativeHandle(ref, () => ({
92
- trigger: async () => {
93
- await handlePress();
94
- return Promise.resolve();
95
- },
96
- reset: async () => {
97
- return Promise.resolve();
98
- }
99
- }));
100
-
101
- const handlePress = async () => {
102
- console.log('[OnairosButton] handlePress called.');
103
- if (!enabled || isLoading) return;
104
-
105
- setIsLoading(true);
106
-
107
- try {
108
- if (preCheck) {
109
- const shouldProceed = await preCheck();
110
- if (!shouldProceed) {
111
- console.log('[OnairosButton] Precheck failed. Setting showOnboarding to false (indirectly, by not setting to true).');
112
- onRejection?.('Precheck validation failed');
113
- setIsLoading(false);
114
- return;
115
- }
116
- }
117
-
118
- console.log('[OnairosButton] handlePress: Setting showOnboarding to true.');
119
- setShowOnboarding(true);
120
- setIsLoading(false);
121
- } catch (error) {
122
- console.error('[OnairosButton] Error in handlePress:', error);
123
- onRejection?.(error instanceof Error ? error.message : 'Unknown error');
124
- setIsLoading(false);
125
- }
126
- };
127
-
128
- // Compute button text based on buttonForm
129
- const getButtonText = () => {
130
- switch (buttonForm) {
131
- case 'connect':
132
- return 'Connect Onairos';
133
- case 'login':
134
- return 'Sign in with Onairos';
135
- case 'signup':
136
- return 'Sign up with Onairos';
137
- default:
138
- return 'Connect Onairos';
139
- }
140
- };
141
-
142
- // Handle onboarding completion
143
- const handleOnboardingComplete = useCallback((token: string, email?: string) => {
144
- console.log('[OnairosButton] handleOnboardingComplete: Setting showOnboarding to false.');
145
- setShowOnboarding(false);
146
-
147
- if (onResolved) {
148
- // Call onResolved with the token and email
149
- onResolved(token, email);
150
- }
151
-
152
- if (onPress) {
153
- onPress();
154
- }
155
- }, [onResolved, onPress]);
156
-
157
- // Handle onboarding close
158
- const handleOnboardingClose = useCallback(() => {
159
- console.log('[OnairosButton] handleOnboardingClose: Setting showOnboarding to false.');
160
- setShowOnboarding(false);
161
- if (onRejection) {
162
- onRejection('User closed onboarding');
163
- }
164
- }, [onRejection]);
165
-
166
- console.log('[OnairosButton] Rendering JSX with props:', {
167
- AppName,
168
- buttonType,
169
- buttonWidth,
170
- buttonHeight,
171
- hasStroke,
172
- enabled,
173
- buttonForm,
174
- onResolved,
175
- onRejection,
176
- preCheck,
177
- color,
178
- swerv,
179
- darkMode,
180
- returnLink,
181
- preferredPlatform,
182
- autoFetch,
183
- inferenceData,
184
- textLayout,
185
- textColor,
186
- proofMode,
187
- webpageName,
188
- debug,
189
- testMode,
190
- requestData,
191
- onPress,
192
- primaryAuthOnly,
193
- useNewWelcomeFlow,
194
- });
195
-
196
- return (
197
- <>
198
- <View>
199
- <TouchableOpacity
200
- style={[
201
- styles.button,
202
- buttonType === 'pill' && styles.pillButton,
203
- hasStroke && styles.strokedButton,
204
- {
205
- width: buttonWidth,
206
- height: buttonHeight,
207
- },
208
- swerv && styles.swervButton,
209
- !enabled && styles.disabledButton
210
- ]}
211
- onPress={handlePress}
212
- disabled={!enabled || isLoading}
213
- onPressIn={() => setIsPressed(true)}
214
- onPressOut={() => setIsPressed(false)}
215
- >
216
- <LinearGradient
217
- colors={['#f5e7c1', '#C7A047', '#8B6914']}
218
- start={{x: 0, y: 0}}
219
- end={{x: 1, y: 0}}
220
- style={{
221
- position: 'absolute',
222
- left: 0,
223
- right: 0,
224
- top: 0,
225
- bottom: 0,
226
- borderRadius: buttonType === 'pill' ? 24 : 8,
227
- }}
228
- />
229
-
230
- {isLoading ? (
231
- <ActivityIndicator
232
- size="small"
233
- color="#FFFFFF"
234
- />
235
- ) : (
236
- <View style={styles.buttonContent}>
237
- <View style={styles.logoContainer}>
238
- <Image
239
- source={require('../assets/images/onairos_logo.png')}
240
- style={styles.logoImage}
241
- resizeMode="contain"
242
- />
243
- </View>
244
- <Text style={[styles.buttonText, { color: '#FFFFFF' }]}>
245
- {getButtonText()}
246
- </Text>
247
- </View>
248
- )}
249
- </TouchableOpacity>
250
- </View>
251
-
252
- {/* Onboarding Modal - Choose between new WelcomeScreen or legacy UniversalOnboarding */}
253
- {useNewWelcomeFlow ? (
254
- <WelcomeScreen
255
- visible={showOnboarding}
256
- onClose={handleOnboardingClose}
257
- onComplete={handleOnboardingComplete}
258
- />
259
- ) : (
260
- <UniversalOnboarding
261
- visible={showOnboarding}
262
- onClose={handleOnboardingClose}
263
- AppName={AppName}
264
- requestData={requestData || {
265
- Small: { type: 'Small', descriptions: 'Basic tier', reward: 'Free access' },
266
- Medium: { type: 'Medium', descriptions: 'Standard tier', reward: 'Premium features' },
267
- Large: { type: 'Large', descriptions: 'Premium tier', reward: 'Full personalization' }
268
- }}
269
- returnLink={returnLink || 'onairosevents://auth/callback'}
270
- onComplete={handleOnboardingComplete}
271
- debug={debug}
272
- test={testMode}
273
- preferredPlatform={preferredPlatform}
274
- primaryAuthOnly={primaryAuthOnly}
275
- />
276
- )}
277
- </>
278
- );
279
- });
280
-
281
- const styles = StyleSheet.create({
282
- button: {
283
- flexDirection: 'row',
284
- alignItems: 'center',
285
- justifyContent: 'center',
286
- paddingVertical: 12,
287
- paddingHorizontal: 16,
288
- borderRadius: 8,
289
- shadowColor: '#000',
290
- shadowOffset: { width: 0, height: 2 },
291
- shadowOpacity: 0.2,
292
- shadowRadius: 4,
293
- elevation: 3,
294
- overflow: 'hidden',
295
- },
296
- buttonContent: {
297
- flexDirection: 'row',
298
- alignItems: 'center',
299
- justifyContent: 'center',
300
- },
301
- logoContainer: {
302
- width: 24,
303
- height: 24,
304
- // borderRadius: 12, // Removed to eliminate circle shape
305
- // backgroundColor: '#FFFFFF', // Removed to eliminate white background
306
- alignItems: 'center',
307
- justifyContent: 'center',
308
- marginRight: 4,
309
- },
310
- logoText: {
311
- color: '#C7A047',
312
- fontWeight: 'bold',
313
- fontSize: 14,
314
- },
315
- logoImage: {
316
- width: 20,
317
- height: 20,
318
- },
319
- pillButton: {
320
- borderRadius: 24,
321
- },
322
- strokedButton: {
323
- backgroundColor: 'transparent',
324
- borderWidth: 1,
325
- },
326
- swervButton: {
327
- transform: [{ rotate: '-2deg' }],
328
- },
329
- disabledButton: {
330
- opacity: 0.6,
331
- },
332
- buttonText: {
333
- fontSize: 16,
334
- fontWeight: '600',
335
- textAlign: 'center',
336
- },
337
- });
338
-
339
- export default OnairosButton;
1
+ import React, { useState, useCallback, forwardRef, useImperativeHandle, useEffect } from 'react';
2
+ import {
3
+ TouchableOpacity,
4
+ Text,
5
+ StyleSheet,
6
+ View,
7
+ ActivityIndicator,
8
+ Dimensions,
9
+ Image,
10
+ } from 'react-native';
11
+ import LinearGradient from 'react-native-linear-gradient';
12
+ import { UniversalOnboarding } from './UniversalOnboarding';
13
+ import WelcomeScreen from './WelcomeScreen';
14
+
15
+ export interface OnairosButtonProps {
16
+ AppName: string;
17
+ buttonType?: 'normal' | 'pill';
18
+ buttonWidth?: number;
19
+ buttonHeight?: number;
20
+ hasStroke?: boolean;
21
+ enabled?: boolean;
22
+ buttonForm?: 'default' | 'login' | 'signup' | 'connect';
23
+ onResolved?: (token: string, email?: string) => void;
24
+ onRejection?: (error: any) => void;
25
+ preCheck?: () => Promise<boolean>;
26
+ color?: string;
27
+ swerv?: boolean;
28
+ darkMode?: boolean;
29
+ returnLink?: string;
30
+ preferredPlatform?: string;
31
+ autoFetch?: boolean;
32
+ inferenceData?: any;
33
+ textLayout?: 'left' | 'right' | 'center';
34
+ textColor?: string;
35
+ proofMode?: boolean;
36
+ webpageName?: string;
37
+ debug?: boolean;
38
+ testMode?: boolean;
39
+ requestData?: any;
40
+ onPress?: () => void;
41
+ primaryAuthOnly?: boolean;
42
+ useNewWelcomeFlow?: boolean; // NEW: Enable the refreshed welcome screen experience
43
+ }
44
+
45
+ export interface OnairosButtonRef {
46
+ trigger: () => Promise<void>;
47
+ reset: () => Promise<void>;
48
+ }
49
+
50
+ const { width } = Dimensions.get('window');
51
+
52
+ export const OnairosButton = forwardRef<OnairosButtonRef, OnairosButtonProps>(({
53
+ AppName,
54
+ buttonType = 'normal',
55
+ buttonWidth = 180,
56
+ buttonHeight = 48,
57
+ hasStroke = false,
58
+ enabled = true,
59
+ buttonForm = 'default',
60
+ onResolved,
61
+ onRejection,
62
+ preCheck,
63
+ color = '#1BA9D4',
64
+ swerv = false,
65
+ darkMode = false,
66
+ returnLink,
67
+ preferredPlatform,
68
+ autoFetch = false,
69
+ inferenceData,
70
+ textLayout = 'right',
71
+ textColor = 'black',
72
+ proofMode = false,
73
+ webpageName,
74
+ debug = false,
75
+ testMode = false,
76
+ requestData,
77
+ onPress,
78
+ primaryAuthOnly = false,
79
+ useNewWelcomeFlow = false,
80
+ }, ref) => {
81
+ const [isLoading, setIsLoading] = useState(false);
82
+ const [isPressed, setIsPressed] = useState(false);
83
+ const [showOnboarding, setShowOnboarding] = useState(false);
84
+ console.log('[OnairosButton] Initializing. Initial showOnboarding:', showOnboarding);
85
+
86
+ useEffect(() => {
87
+ console.log('[OnairosButton] LogEffect: showOnboarding state changed to:', showOnboarding);
88
+ }, [showOnboarding]);
89
+
90
+ // Expose methods via ref
91
+ useImperativeHandle(ref, () => ({
92
+ trigger: async () => {
93
+ await handlePress();
94
+ return Promise.resolve();
95
+ },
96
+ reset: async () => {
97
+ return Promise.resolve();
98
+ }
99
+ }));
100
+
101
+ const handlePress = async () => {
102
+ console.log('[OnairosButton] handlePress called.');
103
+ if (!enabled || isLoading) return;
104
+
105
+ setIsLoading(true);
106
+
107
+ try {
108
+ if (preCheck) {
109
+ const shouldProceed = await preCheck();
110
+ if (!shouldProceed) {
111
+ console.log('[OnairosButton] Precheck failed. Setting showOnboarding to false (indirectly, by not setting to true).');
112
+ onRejection?.('Precheck validation failed');
113
+ setIsLoading(false);
114
+ return;
115
+ }
116
+ }
117
+
118
+ console.log('[OnairosButton] handlePress: Setting showOnboarding to true.');
119
+ setShowOnboarding(true);
120
+ setIsLoading(false);
121
+ } catch (error) {
122
+ console.error('[OnairosButton] Error in handlePress:', error);
123
+ onRejection?.(error instanceof Error ? error.message : 'Unknown error');
124
+ setIsLoading(false);
125
+ }
126
+ };
127
+
128
+ // Compute button text based on buttonForm
129
+ const getButtonText = () => {
130
+ switch (buttonForm) {
131
+ case 'connect':
132
+ return 'Connect Onairos';
133
+ case 'login':
134
+ return 'Sign in with Onairos';
135
+ case 'signup':
136
+ return 'Sign up with Onairos';
137
+ default:
138
+ return 'Connect Onairos';
139
+ }
140
+ };
141
+
142
+ // Handle onboarding completion
143
+ const handleOnboardingComplete = useCallback((token: string, email?: string) => {
144
+ console.log('[OnairosButton] handleOnboardingComplete: Setting showOnboarding to false.');
145
+ setShowOnboarding(false);
146
+
147
+ if (onResolved) {
148
+ // Call onResolved with the token and email
149
+ onResolved(token, email);
150
+ }
151
+
152
+ if (onPress) {
153
+ onPress();
154
+ }
155
+ }, [onResolved, onPress]);
156
+
157
+ // Handle onboarding close
158
+ const handleOnboardingClose = useCallback(() => {
159
+ console.log('[OnairosButton] handleOnboardingClose: Setting showOnboarding to false.');
160
+ setShowOnboarding(false);
161
+ if (onRejection) {
162
+ onRejection('User closed onboarding');
163
+ }
164
+ }, [onRejection]);
165
+
166
+ console.log('[OnairosButton] Rendering JSX with props:', {
167
+ AppName,
168
+ buttonType,
169
+ buttonWidth,
170
+ buttonHeight,
171
+ hasStroke,
172
+ enabled,
173
+ buttonForm,
174
+ onResolved,
175
+ onRejection,
176
+ preCheck,
177
+ color,
178
+ swerv,
179
+ darkMode,
180
+ returnLink,
181
+ preferredPlatform,
182
+ autoFetch,
183
+ inferenceData,
184
+ textLayout,
185
+ textColor,
186
+ proofMode,
187
+ webpageName,
188
+ debug,
189
+ testMode,
190
+ requestData,
191
+ onPress,
192
+ primaryAuthOnly,
193
+ useNewWelcomeFlow,
194
+ });
195
+
196
+ return (
197
+ <>
198
+ <View>
199
+ <TouchableOpacity
200
+ style={[
201
+ styles.button,
202
+ buttonType === 'pill' && styles.pillButton,
203
+ hasStroke && styles.strokedButton,
204
+ {
205
+ width: buttonWidth,
206
+ height: buttonHeight,
207
+ },
208
+ swerv && styles.swervButton,
209
+ !enabled && styles.disabledButton
210
+ ]}
211
+ onPress={handlePress}
212
+ disabled={!enabled || isLoading}
213
+ onPressIn={() => setIsPressed(true)}
214
+ onPressOut={() => setIsPressed(false)}
215
+ >
216
+ <LinearGradient
217
+ colors={['#f5e7c1', '#C7A047', '#8B6914']}
218
+ start={{x: 0, y: 0}}
219
+ end={{x: 1, y: 0}}
220
+ style={{
221
+ position: 'absolute',
222
+ left: 0,
223
+ right: 0,
224
+ top: 0,
225
+ bottom: 0,
226
+ borderRadius: buttonType === 'pill' ? 24 : 8,
227
+ }}
228
+ />
229
+
230
+ {isLoading ? (
231
+ <ActivityIndicator
232
+ size="small"
233
+ color="#FFFFFF"
234
+ />
235
+ ) : (
236
+ <View style={styles.buttonContent}>
237
+ <View style={styles.logoContainer}>
238
+ <Image
239
+ source={require('../assets/images/onairos_logo.png')}
240
+ style={styles.logoImage}
241
+ resizeMode="contain"
242
+ />
243
+ </View>
244
+ <Text style={[styles.buttonText, { color: '#FFFFFF' }]}>
245
+ {getButtonText()}
246
+ </Text>
247
+ </View>
248
+ )}
249
+ </TouchableOpacity>
250
+ </View>
251
+
252
+ {/* Onboarding Modal - Choose between new WelcomeScreen or legacy UniversalOnboarding */}
253
+ {useNewWelcomeFlow ? (
254
+ <WelcomeScreen
255
+ visible={showOnboarding}
256
+ onClose={handleOnboardingClose}
257
+ onComplete={handleOnboardingComplete}
258
+ />
259
+ ) : (
260
+ <UniversalOnboarding
261
+ visible={showOnboarding}
262
+ onClose={handleOnboardingClose}
263
+ AppName={AppName}
264
+ requestData={requestData || {
265
+ Small: { type: 'Small', descriptions: 'Basic tier', reward: 'Free access' },
266
+ Medium: { type: 'Medium', descriptions: 'Standard tier', reward: 'Premium features' },
267
+ Large: { type: 'Large', descriptions: 'Premium tier', reward: 'Full personalization' }
268
+ }}
269
+ returnLink={returnLink || 'onairosevents://auth/callback'}
270
+ onComplete={handleOnboardingComplete}
271
+ debug={debug}
272
+ test={testMode}
273
+ preferredPlatform={preferredPlatform}
274
+ primaryAuthOnly={primaryAuthOnly}
275
+ />
276
+ )}
277
+ </>
278
+ );
279
+ });
280
+
281
+ const styles = StyleSheet.create({
282
+ button: {
283
+ flexDirection: 'row',
284
+ alignItems: 'center',
285
+ justifyContent: 'center',
286
+ paddingVertical: 12,
287
+ paddingHorizontal: 16,
288
+ borderRadius: 8,
289
+ shadowColor: '#000',
290
+ shadowOffset: { width: 0, height: 2 },
291
+ shadowOpacity: 0.2,
292
+ shadowRadius: 4,
293
+ elevation: 3,
294
+ overflow: 'hidden',
295
+ },
296
+ buttonContent: {
297
+ flexDirection: 'row',
298
+ alignItems: 'center',
299
+ justifyContent: 'center',
300
+ },
301
+ logoContainer: {
302
+ width: 24,
303
+ height: 24,
304
+ // borderRadius: 12, // Removed to eliminate circle shape
305
+ // backgroundColor: '#FFFFFF', // Removed to eliminate white background
306
+ alignItems: 'center',
307
+ justifyContent: 'center',
308
+ marginRight: 4,
309
+ },
310
+ logoText: {
311
+ color: '#C7A047',
312
+ fontWeight: 'bold',
313
+ fontSize: 14,
314
+ },
315
+ logoImage: {
316
+ width: 20,
317
+ height: 20,
318
+ },
319
+ pillButton: {
320
+ borderRadius: 24,
321
+ },
322
+ strokedButton: {
323
+ backgroundColor: 'transparent',
324
+ borderWidth: 1,
325
+ },
326
+ swervButton: {
327
+ transform: [{ rotate: '-2deg' }],
328
+ },
329
+ disabledButton: {
330
+ opacity: 0.6,
331
+ },
332
+ buttonText: {
333
+ fontSize: 16,
334
+ fontWeight: '600',
335
+ textAlign: 'center',
336
+ },
337
+ });
338
+
339
+ export default OnairosButton;