@onairos/react-native 3.0.28 → 3.0.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/components/OnairosButton.js +1 -1
- package/lib/commonjs/components/OnairosButton.js.map +1 -1
- package/lib/commonjs/components/PinInput.js +1 -1
- package/lib/commonjs/components/PinInput.js.map +1 -1
- package/lib/commonjs/components/UniversalOnboarding.js +14 -3
- package/lib/commonjs/components/UniversalOnboarding.js.map +1 -1
- package/lib/commonjs/components/onboarding/OAuthWebView.js +140 -94
- package/lib/commonjs/components/onboarding/OAuthWebView.js.map +1 -1
- package/lib/module/components/OnairosButton.js +1 -1
- package/lib/module/components/OnairosButton.js.map +1 -1
- package/lib/module/components/PinInput.js +1 -1
- package/lib/module/components/PinInput.js.map +1 -1
- package/lib/module/components/UniversalOnboarding.js +14 -3
- package/lib/module/components/UniversalOnboarding.js.map +1 -1
- package/lib/module/components/onboarding/OAuthWebView.js +141 -95
- package/lib/module/components/onboarding/OAuthWebView.js.map +1 -1
- package/lib/typescript/components/UniversalOnboarding.d.ts.map +1 -1
- package/lib/typescript/components/onboarding/OAuthWebView.d.ts +7 -1
- package/lib/typescript/components/onboarding/OAuthWebView.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/OnairosButton.tsx +1 -1
- package/src/components/PinInput.tsx +1 -1
- package/src/components/UniversalOnboarding.tsx +16 -3
- package/src/components/onboarding/OAuthWebView.tsx +181 -115
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","
|
|
1
|
+
{"version":3,"names":["React","useState","View","Text","StyleSheet","TouchableOpacity","ActivityIndicator","SafeAreaView","Dimensions","WebView","Icon","COLORS","width","height","get","OAuthWebView","url","onClose","onSuccess","platform","onComplete","isLoading","setIsLoading","console","log","handleNavigationStateChange","navState","isFinalRedirect","includes","setTimeout","platformSuccessPatterns","reddit","pinterest","linkedin","email","instagram","isPlatformSuccess","some","pattern","test","isCallbackUrl","authCode","codeMatch","match","tokenMatch","handleLoadEnd","getPlatformIcon","getPlatformColor","primary","createElement","style","styles","container","header","onPress","closeButton","name","size","color","titleContainer","titleText","charAt","toUpperCase","slice","source","uri","onNavigationStateChange","onLoadEnd","webView","javaScriptEnabled","domStorageEnabled","sharedCookiesEnabled","thirdPartyCookiesEnabled","userAgent","loadingContainer","loadingText","create","flex","backgroundColor","flexDirection","alignItems","borderBottomWidth","borderBottomColor","paddingHorizontal","justifyContent","marginLeft","fontSize","fontWeight","padding","position","left","zIndex","absoluteFillObject","marginTop"],"sourceRoot":"..\\..\\..\\..\\src","sources":["components/onboarding/OAuthWebView.tsx"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,QAAQ,OAAO;AACvC,SACEC,IAAI,EACJC,IAAI,EACJC,UAAU,EACVC,gBAAgB,EAChBC,iBAAiB,EACjBC,YAAY,EACZC,UAAU,QACL,cAAc;AACrB,SAASC,OAAO,QAAQ,sBAAsB;AAC9C,OAAOC,IAAI,MAAM,yCAAyC;AAC1D,SAASC,MAAM,QAAQ,iBAAiB;AAExC,MAAM;EAAEC,KAAK;EAAEC;AAAO,CAAC,GAAGL,UAAU,CAACM,GAAG,CAAC,QAAQ,CAAC;AAUlD,OAAO,MAAMC,YAAyC,GAAGA,CAAC;EACxDC,GAAG;EACHC,OAAO;EACPC,SAAS;EACTC,QAAQ,GAAG,UAAU;EACrBC;AACF,CAAC,KAAK;EACJ,MAAM,CAACC,SAAS,EAAEC,YAAY,CAAC,GAAGrB,QAAQ,CAAC,IAAI,CAAC;EAEhDsB,OAAO,CAACC,GAAG,CAAC,iCAAiC,EAAER,GAAG,CAAC,CAAC,CAAC;;EAErD,MAAMS,2BAA2B,GAAIC,QAAa,IAAK;IACrDH,OAAO,CAACC,GAAG,CAAC,gCAAgCL,QAAQ,GAAG,EAAEO,QAAQ,CAACV,GAAG,CAAC;;IAEtE;IACA,MAAMW,eAAe,GACnBD,QAAQ,CAACV,GAAG,CAACY,QAAQ,CAAC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,iBAAiB,EAAE;EACrB,CAAC;EACDxB,cAAc,EAAE;IACdkB,IAAI,EAAE,CAAC;IACPE,aAAa,EAAE,KAAK;IACpBC,UAAU,EAAE,QAAQ;IACpBI,cAAc,EAAE;EAClB,CAAC;EACDxB,SAAS,EAAE;IACTyB,UAAU,EAAE,CAAC;IACbC,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE,KAAK;IACjB7B,KAAK,EAAE;EACT,CAAC;EACDH,WAAW,EAAE;IACXiC,OAAO,EAAE,CAAC;IACVC,QAAQ,EAAE,UAAU;IACpBC,IAAI,EAAE,EAAE;IACRC,MAAM,EAAE;EACV,CAAC;EACDvB,OAAO,EAAE;IACPS,IAAI,EAAE;EACR,CAAC;EACDH,gBAAgB,EAAE;IAChB,GAAGtE,UAAU,CAACwF,kBAAkB;IAChCd,eAAe,EAAE,0BAA0B;IAC3CE,UAAU,EAAE,QAAQ;IACpBI,cAAc,EAAE;EAClB,CAAC;EACDT,WAAW,EAAE;IACXkB,SAAS,EAAE,EAAE;IACbP,QAAQ,EAAE,EAAE;IACZ5B,KAAK,EAAE;EACT;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UniversalOnboarding.d.ts","sourceRoot":"","sources":["../../../src/components/UniversalOnboarding.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmD,MAAM,OAAO,CAAC;AA0BxE,OAAO,KAAK,EAAE,wBAAwB,EAAoB,MAAM,UAAU,CAAC;AAI3E,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,wBAAwB,
|
|
1
|
+
{"version":3,"file":"UniversalOnboarding.d.ts","sourceRoot":"","sources":["../../../src/components/UniversalOnboarding.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmD,MAAM,OAAO,CAAC;AA0BxE,OAAO,KAAK,EAAE,wBAAwB,EAAoB,MAAM,UAAU,CAAC;AAI3E,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,wBAAwB,CAwblE,CAAC"}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
2
|
+
export interface OAuthWebViewProps {
|
|
3
|
+
url: string;
|
|
4
|
+
onClose: () => void;
|
|
5
|
+
onSuccess: (code: string) => void;
|
|
6
|
+
platform?: string;
|
|
7
|
+
onComplete?: () => void;
|
|
8
|
+
}
|
|
3
9
|
export declare const OAuthWebView: React.FC<OAuthWebViewProps>;
|
|
4
10
|
//# sourceMappingURL=OAuthWebView.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OAuthWebView.d.ts","sourceRoot":"","sources":["../../../../src/components/onboarding/OAuthWebView.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"OAuthWebView.d.ts","sourceRoot":"","sources":["../../../../src/components/onboarding/OAuthWebView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAgBxC,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;CACzB;AAED,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAmMpD,CAAC"}
|
package/package.json
CHANGED
|
@@ -60,7 +60,7 @@ export const PinInput: React.FC<PinInputProps> = ({
|
|
|
60
60
|
<View style={styles.header}>
|
|
61
61
|
{onBack && (
|
|
62
62
|
<TouchableOpacity style={styles.backButton} onPress={onBack}>
|
|
63
|
-
|
|
63
|
+
<Icon name="arrow-back" size={24} color={COLORS.text.primary} />
|
|
64
64
|
</TouchableOpacity>
|
|
65
65
|
)}
|
|
66
66
|
<Text style={styles.title}>Create your PIN</Text>
|
|
@@ -346,18 +346,26 @@ export const UniversalOnboarding: React.FC<UniversalOnboardingProps> = ({
|
|
|
346
346
|
{AppName.charAt(0)}
|
|
347
347
|
</Text>
|
|
348
348
|
</View>
|
|
349
|
-
<Icon name="
|
|
349
|
+
<Icon name="arrow-forward" size={24} color="#666" style={styles.arrow} />
|
|
350
350
|
<View style={styles.onairosIcon}>
|
|
351
351
|
<Text style={styles.onairosIconText}>O</Text>
|
|
352
352
|
</View>
|
|
353
353
|
</View>
|
|
354
354
|
</View>
|
|
355
355
|
|
|
356
|
-
<ScrollView
|
|
356
|
+
<ScrollView
|
|
357
|
+
style={styles.content}
|
|
358
|
+
contentContainerStyle={styles.scrollContent}
|
|
359
|
+
showsVerticalScrollIndicator={true}
|
|
360
|
+
bounces={true}
|
|
361
|
+
scrollEnabled={true}
|
|
362
|
+
nestedScrollEnabled={true}
|
|
363
|
+
keyboardShouldPersistTaps="handled"
|
|
364
|
+
>
|
|
357
365
|
{/* Main title and description */}
|
|
358
366
|
<View style={styles.titleContainer}>
|
|
359
367
|
<Text style={styles.mainTitle}>
|
|
360
|
-
|
|
368
|
+
Let {AppName} learn about you from your data and apps
|
|
361
369
|
</Text>
|
|
362
370
|
<Text style={styles.privacyMessage}>
|
|
363
371
|
None of your app data is shared with ANYONE
|
|
@@ -550,6 +558,11 @@ const styles = StyleSheet.create({
|
|
|
550
558
|
flex: 1,
|
|
551
559
|
paddingHorizontal: 24,
|
|
552
560
|
},
|
|
561
|
+
scrollContent: {
|
|
562
|
+
flexGrow: 1,
|
|
563
|
+
paddingBottom: 40,
|
|
564
|
+
minHeight: '100%',
|
|
565
|
+
},
|
|
553
566
|
platformsContainer: {
|
|
554
567
|
marginTop: 16,
|
|
555
568
|
},
|
|
@@ -1,89 +1,183 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
View,
|
|
4
|
+
Text,
|
|
5
|
+
StyleSheet,
|
|
6
|
+
TouchableOpacity,
|
|
7
|
+
ActivityIndicator,
|
|
8
|
+
SafeAreaView,
|
|
9
|
+
Dimensions,
|
|
10
|
+
} from 'react-native';
|
|
11
|
+
import { WebView } from 'react-native-webview';
|
|
4
12
|
import Icon from 'react-native-vector-icons/MaterialIcons';
|
|
5
13
|
import { COLORS } from '../../constants';
|
|
6
|
-
|
|
14
|
+
|
|
15
|
+
const { width, height } = Dimensions.get('window');
|
|
16
|
+
|
|
17
|
+
export interface OAuthWebViewProps {
|
|
18
|
+
url: string;
|
|
19
|
+
onClose: () => void;
|
|
20
|
+
onSuccess: (code: string) => void;
|
|
21
|
+
platform?: string;
|
|
22
|
+
onComplete?: () => void;
|
|
23
|
+
}
|
|
7
24
|
|
|
8
25
|
export const OAuthWebView: React.FC<OAuthWebViewProps> = ({
|
|
9
26
|
url,
|
|
10
|
-
platform,
|
|
11
|
-
onComplete,
|
|
12
27
|
onClose,
|
|
13
28
|
onSuccess,
|
|
29
|
+
platform = 'platform',
|
|
30
|
+
onComplete,
|
|
14
31
|
}) => {
|
|
15
|
-
const [
|
|
32
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
33
|
+
|
|
34
|
+
console.log('Opening OAuth WebView with URL:', url); // Add logging
|
|
16
35
|
|
|
17
|
-
const handleNavigationStateChange =
|
|
18
|
-
(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const isYouTubeSuccess = (
|
|
34
|
-
platform === 'youtube' &&
|
|
35
|
-
navState.url.includes('accounts.google.com/o/oauth2/approval')
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
const isLinkedInSuccess = (
|
|
39
|
-
platform === 'linkedin' &&
|
|
40
|
-
navState.url.includes('linkedin.com/oauth/v2/authorization/success')
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
// Check for callback URLs with authorization codes
|
|
44
|
-
const isCallbackUrl = navState.url.includes('/callback') || navState.url.includes('code=');
|
|
45
|
-
|
|
46
|
-
// If we detect success, close the window and update connection status
|
|
47
|
-
if (isFinalRedirect || isInstagramSuccess || isYouTubeSuccess || isLinkedInSuccess) {
|
|
36
|
+
const handleNavigationStateChange = (navState: any) => {
|
|
37
|
+
console.log(`Navigation state changed for ${platform}:`, navState.url);
|
|
38
|
+
|
|
39
|
+
// Check for the final redirect to onairos.uk domain (this means backend callback completed)
|
|
40
|
+
const isFinalRedirect = (
|
|
41
|
+
navState.url.includes('onairos.uk/Home') ||
|
|
42
|
+
navState.url.includes('onairos.uk/home') ||
|
|
43
|
+
navState.url.includes('onairos.uk/success')
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
// For YouTube specifically, we need to be more careful about when to close
|
|
47
|
+
// Only close after the backend callback redirects to onairos.uk/Home
|
|
48
|
+
if (platform === 'youtube') {
|
|
49
|
+
// Only trigger success when we see the final redirect from the backend
|
|
50
|
+
if (isFinalRedirect) {
|
|
51
|
+
console.log('YouTube OAuth completed - backend callback finished and redirected to Home');
|
|
48
52
|
onSuccess('success');
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return;
|
|
53
|
-
} else if (isCallbackUrl) {
|
|
54
|
-
// Extract the authorization code
|
|
55
|
-
const authCode = extractAuthCode(navState.url);
|
|
56
|
-
if (authCode) {
|
|
57
|
-
onSuccess(authCode);
|
|
53
|
+
|
|
54
|
+
// Close the OAuth window after a small delay to ensure redirect is processed
|
|
55
|
+
setTimeout(() => {
|
|
58
56
|
if (onComplete) {
|
|
57
|
+
console.log('Closing YouTube OAuth window after callback completion');
|
|
59
58
|
onComplete();
|
|
60
59
|
}
|
|
61
|
-
}
|
|
62
|
-
return;
|
|
60
|
+
}, 500);
|
|
63
61
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
62
|
+
return; // Exit early for YouTube to avoid other triggers
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Platform-specific success patterns (for non-YouTube platforms)
|
|
66
|
+
const platformSuccessPatterns: Record<string, RegExp[]> = {
|
|
67
|
+
reddit: [
|
|
68
|
+
/reddit\.com\/api\/v1\/authorize\?done=true/,
|
|
69
|
+
/reddit\.com\/api\/v1\/authorize\/success/
|
|
70
|
+
],
|
|
71
|
+
pinterest: [
|
|
72
|
+
/pinterest\.com\/oauth\/success/,
|
|
73
|
+
/pinterest\.com\/oauth\/complete/
|
|
74
|
+
],
|
|
75
|
+
linkedin: [
|
|
76
|
+
/linkedin\.com\/oauth\/success/,
|
|
77
|
+
/linkedin\.com\/oauth\/complete/,
|
|
78
|
+
/linkedin\.com\/uas\/oauth2\/authorization\/success/
|
|
79
|
+
],
|
|
80
|
+
email: [/success/], // Generic success pattern for email
|
|
81
|
+
instagram: [
|
|
82
|
+
/instagram\.com\/oauth\/authorize\?done=true/,
|
|
83
|
+
/instagram\.com\/oauth\/success/
|
|
84
|
+
]
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
// Check for platform-specific success patterns
|
|
88
|
+
const isPlatformSuccess = platform && platformSuccessPatterns[platform] ?
|
|
89
|
+
platformSuccessPatterns[platform].some(pattern => pattern.test(navState.url)) :
|
|
90
|
+
false;
|
|
91
|
+
|
|
92
|
+
// Check for callback URLs that might contain the authorization code
|
|
93
|
+
const isCallbackUrl = (
|
|
94
|
+
navState.url.includes('/callback') ||
|
|
95
|
+
navState.url.includes('code=') ||
|
|
96
|
+
navState.url.includes('token=') ||
|
|
97
|
+
navState.url.includes('access_token=')
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
// Extract authorization code or token if present
|
|
101
|
+
let authCode = null;
|
|
102
|
+
if (isCallbackUrl) {
|
|
103
|
+
console.log('Detected callback URL with possible code/token');
|
|
104
|
+
|
|
105
|
+
// Try to extract code or token using different patterns
|
|
106
|
+
const codeMatch = navState.url.match(/code=([^&]+)/);
|
|
107
|
+
const tokenMatch = navState.url.match(/(?:token|access_token)=([^&]+)/);
|
|
108
|
+
|
|
77
109
|
if (codeMatch && codeMatch[1]) {
|
|
78
|
-
|
|
110
|
+
authCode = codeMatch[1];
|
|
111
|
+
console.log('OAuth code extracted:', authCode);
|
|
112
|
+
} else if (tokenMatch && tokenMatch[1]) {
|
|
113
|
+
authCode = tokenMatch[1];
|
|
114
|
+
console.log('OAuth token extracted:', authCode);
|
|
79
115
|
}
|
|
80
116
|
|
|
81
|
-
//
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
117
|
+
// Call onSuccess with the extracted code/token
|
|
118
|
+
if (authCode) {
|
|
119
|
+
onSuccess(authCode);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// If we see the final redirect or platform-specific success, close the OAuth window
|
|
124
|
+
if (isFinalRedirect || isPlatformSuccess) {
|
|
125
|
+
console.log(`Detected success for ${platform}`);
|
|
126
|
+
|
|
127
|
+
// If we haven't already extracted a code/token, consider this a generic success
|
|
128
|
+
if (!authCode) {
|
|
129
|
+
onSuccess('success');
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Close the OAuth window
|
|
133
|
+
if (onComplete) {
|
|
134
|
+
console.log('Calling onComplete to close OAuth window');
|
|
135
|
+
onComplete();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
const handleLoadEnd = () => {
|
|
141
|
+
setIsLoading(false);
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Get platform-specific icon
|
|
146
|
+
*/
|
|
147
|
+
const getPlatformIcon = (platform: string): string => {
|
|
148
|
+
switch (platform) {
|
|
149
|
+
case 'instagram':
|
|
150
|
+
return 'photo-camera';
|
|
151
|
+
case 'youtube':
|
|
152
|
+
return 'smart-display';
|
|
153
|
+
case 'pinterest':
|
|
154
|
+
return 'push-pin';
|
|
155
|
+
case 'reddit':
|
|
156
|
+
return 'forum';
|
|
157
|
+
case 'email':
|
|
158
|
+
return 'email';
|
|
159
|
+
default:
|
|
160
|
+
return 'link';
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Get platform-specific color
|
|
166
|
+
*/
|
|
167
|
+
const getPlatformColor = (platform: string): string => {
|
|
168
|
+
switch (platform) {
|
|
169
|
+
case 'instagram':
|
|
170
|
+
return '#E1306C';
|
|
171
|
+
case 'youtube':
|
|
172
|
+
return '#FF0000';
|
|
173
|
+
case 'pinterest':
|
|
174
|
+
return '#E60023';
|
|
175
|
+
case 'reddit':
|
|
176
|
+
return '#FF4500';
|
|
177
|
+
case 'email':
|
|
178
|
+
return '#4285F4';
|
|
179
|
+
default:
|
|
180
|
+
return COLORS.primary;
|
|
87
181
|
}
|
|
88
182
|
};
|
|
89
183
|
|
|
@@ -95,10 +189,11 @@ export const OAuthWebView: React.FC<OAuthWebViewProps> = ({
|
|
|
95
189
|
</TouchableOpacity>
|
|
96
190
|
<View style={styles.titleContainer}>
|
|
97
191
|
<Icon
|
|
98
|
-
name={getPlatformIcon(platform
|
|
192
|
+
name={getPlatformIcon(platform)}
|
|
99
193
|
size={20}
|
|
100
|
-
color={getPlatformColor(platform
|
|
194
|
+
color={getPlatformColor(platform)}
|
|
101
195
|
/>
|
|
196
|
+
<Text style={styles.titleText}>{platform.charAt(0).toUpperCase() + platform.slice(1)} OAuth</Text>
|
|
102
197
|
</View>
|
|
103
198
|
</View>
|
|
104
199
|
|
|
@@ -106,66 +201,24 @@ export const OAuthWebView: React.FC<OAuthWebViewProps> = ({
|
|
|
106
201
|
source={{ uri: url }}
|
|
107
202
|
onNavigationStateChange={handleNavigationStateChange}
|
|
108
203
|
onLoadEnd={handleLoadEnd}
|
|
109
|
-
startInLoadingState={true}
|
|
110
|
-
renderLoading={() => <View />}
|
|
111
204
|
style={styles.webView}
|
|
112
205
|
javaScriptEnabled={true}
|
|
113
206
|
domStorageEnabled={true}
|
|
114
|
-
cacheEnabled={false}
|
|
115
|
-
incognito={false}
|
|
116
207
|
sharedCookiesEnabled={true}
|
|
117
208
|
thirdPartyCookiesEnabled={true}
|
|
118
|
-
allowsInlineMediaPlayback={true}
|
|
119
|
-
mediaPlaybackRequiresUserAction={false}
|
|
120
|
-
allowsBackForwardNavigationGestures={true}
|
|
121
209
|
userAgent="Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1"
|
|
122
210
|
/>
|
|
123
211
|
|
|
124
|
-
{
|
|
212
|
+
{isLoading && (
|
|
125
213
|
<View style={styles.loadingContainer}>
|
|
126
214
|
<ActivityIndicator size="large" color={COLORS.primary} />
|
|
215
|
+
<Text style={styles.loadingText}>Loading {platform}...</Text>
|
|
127
216
|
</View>
|
|
128
217
|
)}
|
|
129
218
|
</SafeAreaView>
|
|
130
219
|
);
|
|
131
220
|
};
|
|
132
221
|
|
|
133
|
-
/**
|
|
134
|
-
* Get platform-specific icon
|
|
135
|
-
*/
|
|
136
|
-
const getPlatformIcon = (platform: string): string => {
|
|
137
|
-
switch (platform) {
|
|
138
|
-
case 'instagram':
|
|
139
|
-
return 'photo-camera';
|
|
140
|
-
case 'youtube':
|
|
141
|
-
return 'smart-display';
|
|
142
|
-
case 'pinterest':
|
|
143
|
-
return 'push-pin';
|
|
144
|
-
case 'reddit':
|
|
145
|
-
return 'forum';
|
|
146
|
-
default:
|
|
147
|
-
return 'link';
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Get platform-specific color
|
|
153
|
-
*/
|
|
154
|
-
const getPlatformColor = (platform: string): string => {
|
|
155
|
-
switch (platform) {
|
|
156
|
-
case 'instagram':
|
|
157
|
-
return '#E1306C';
|
|
158
|
-
case 'youtube':
|
|
159
|
-
return '#FF0000';
|
|
160
|
-
case 'pinterest':
|
|
161
|
-
return '#E60023';
|
|
162
|
-
case 'reddit':
|
|
163
|
-
return '#FF4500';
|
|
164
|
-
default:
|
|
165
|
-
return COLORS.primary;
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
|
-
|
|
169
222
|
const styles = StyleSheet.create({
|
|
170
223
|
container: {
|
|
171
224
|
flex: 1,
|
|
@@ -182,7 +235,15 @@ const styles = StyleSheet.create({
|
|
|
182
235
|
},
|
|
183
236
|
titleContainer: {
|
|
184
237
|
flex: 1,
|
|
238
|
+
flexDirection: 'row',
|
|
185
239
|
alignItems: 'center',
|
|
240
|
+
justifyContent: 'center',
|
|
241
|
+
},
|
|
242
|
+
titleText: {
|
|
243
|
+
marginLeft: 8,
|
|
244
|
+
fontSize: 16,
|
|
245
|
+
fontWeight: '500',
|
|
246
|
+
color: '#000',
|
|
186
247
|
},
|
|
187
248
|
closeButton: {
|
|
188
249
|
padding: 8,
|
|
@@ -199,4 +260,9 @@ const styles = StyleSheet.create({
|
|
|
199
260
|
alignItems: 'center',
|
|
200
261
|
justifyContent: 'center',
|
|
201
262
|
},
|
|
263
|
+
loadingText: {
|
|
264
|
+
marginTop: 10,
|
|
265
|
+
fontSize: 16,
|
|
266
|
+
color: '#666',
|
|
267
|
+
},
|
|
202
268
|
});
|