@rownd/react-native 0.2.5 → 2.1.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/LICENSE +1 -2
- package/README.md +15 -52
- package/android/build.gradle +127 -37
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +1 -1
- package/android/src/main/java/com/reactnativerowndplugin/RowndPluginModule.kt +98 -0
- package/android/src/main/java/com/reactnativerowndplugin/RowndPluginPackage.kt +16 -0
- package/ios/{ReactNative.xcodeproj → Rownd.xcodeproj}/project.pbxproj +13 -12
- package/ios/Rownd.xcodeproj/project.xcworkspace/contents.xcworkspacedata +4 -0
- package/ios/RowndPlugin-Bridging-Header.h +3 -0
- package/ios/RowndPlugin.m +26 -0
- package/ios/RowndPlugin.swift +83 -0
- package/ios/RowndPluginEventEmitter.m +12 -0
- package/ios/RowndPluginEventEmitter.swift +19 -0
- package/lib/commonjs/components/GlobalContext.js +30 -298
- package/lib/commonjs/components/GlobalContext.js.map +1 -1
- package/lib/commonjs/components/{BottomSheetTextInput/types.js → GlobalContext.types.js} +1 -1
- package/lib/commonjs/components/GlobalContext.types.js.map +1 -0
- package/lib/commonjs/constants/action.js +13 -0
- package/lib/commonjs/constants/action.js.map +1 -0
- package/lib/commonjs/hooks/rownd.js +15 -146
- package/lib/commonjs/hooks/rownd.js.map +1 -1
- package/lib/commonjs/index.js +2 -12
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/reducer/rowndReducer.js +89 -0
- package/lib/commonjs/reducer/rowndReducer.js.map +1 -0
- package/lib/commonjs/utils/config.js +0 -26
- package/lib/commonjs/utils/config.js.map +1 -1
- package/lib/commonjs/utils/nativeModule.js +72 -0
- package/lib/commonjs/utils/nativeModule.js.map +1 -0
- package/lib/module/components/GlobalContext.js +29 -293
- package/lib/module/components/GlobalContext.js.map +1 -1
- package/lib/module/components/GlobalContext.types.js +2 -0
- package/lib/module/components/GlobalContext.types.js.map +1 -0
- package/lib/module/constants/action.js +6 -0
- package/lib/module/constants/action.js.map +1 -0
- package/lib/module/hooks/rownd.js +12 -137
- package/lib/module/hooks/rownd.js.map +1 -1
- package/lib/module/index.js +2 -4
- package/lib/module/index.js.map +1 -1
- package/lib/module/reducer/rowndReducer.js +78 -0
- package/lib/module/reducer/rowndReducer.js.map +1 -0
- package/lib/module/utils/config.js +1 -16
- package/lib/module/utils/config.js.map +1 -1
- package/lib/module/utils/nativeModule.js +48 -0
- package/lib/module/utils/nativeModule.js.map +1 -0
- package/lib/typescript/components/GlobalContext.d.ts +13 -0
- package/lib/typescript/{src/components/GlobalContext.d.ts → components/GlobalContext.types.d.ts} +9 -35
- package/lib/typescript/constants/action.d.ts +7 -0
- package/lib/typescript/{src/hooks → hooks}/rownd.d.ts +10 -13
- package/lib/typescript/index.d.ts +3 -0
- package/lib/typescript/reducer/rowndReducer.d.ts +4 -0
- package/lib/typescript/utils/config.d.ts +10 -0
- package/lib/typescript/utils/nativeModule.d.ts +10 -0
- package/package.json +36 -56
- package/rownd-react-native.podspec +36 -0
- package/src/components/GlobalContext.tsx +44 -457
- package/src/components/GlobalContext.types.ts +105 -0
- package/src/constants/action.ts +8 -0
- package/src/hooks/rownd.ts +29 -147
- package/src/index.tsx +2 -4
- package/src/reducer/rowndReducer.ts +78 -0
- package/src/utils/config.ts +0 -27
- package/src/utils/nativeModule.ts +69 -0
- package/android/src/main/java/com/reactnative/ReactNativePackage.java +0 -22
- package/android/src/main/java/com/reactnative/ReactNativeViewManager.java +0 -31
- package/ios/ReactNativeViewManager.m +0 -34
- package/lib/commonjs/assets/images/checkmark--filled.svg +0 -12
- package/lib/commonjs/assets/images/email-verify-waiting.svg +0 -36
- package/lib/commonjs/assets/images/error-icon-material.svg +0 -1
- package/lib/commonjs/assets/images/phone-verify-waiting.svg +0 -26
- package/lib/commonjs/components/AuthenticatedComponent.js +0 -35
- package/lib/commonjs/components/AuthenticatedComponent.js.map +0 -1
- package/lib/commonjs/components/AutoSigninDialog.js +0 -132
- package/lib/commonjs/components/AutoSigninDialog.js.map +0 -1
- package/lib/commonjs/components/BottomSheetTextInput/BottomSheetTextInput.js +0 -65
- package/lib/commonjs/components/BottomSheetTextInput/BottomSheetTextInput.js.map +0 -1
- package/lib/commonjs/components/BottomSheetTextInput/index.js +0 -24
- package/lib/commonjs/components/BottomSheetTextInput/index.js.map +0 -1
- package/lib/commonjs/components/BottomSheetTextInput/types.js.map +0 -1
- package/lib/commonjs/components/DarkText.js +0 -35
- package/lib/commonjs/components/DarkText.js.map +0 -1
- package/lib/commonjs/components/DefaultContext.js +0 -266
- package/lib/commonjs/components/DefaultContext.js.map +0 -1
- package/lib/commonjs/components/RowndComponents.js +0 -25
- package/lib/commonjs/components/RowndComponents.js.map +0 -1
- package/lib/commonjs/components/RowndProvider.js +0 -55
- package/lib/commonjs/components/RowndProvider.js.map +0 -1
- package/lib/commonjs/components/SignIn.js +0 -644
- package/lib/commonjs/components/SignIn.js.map +0 -1
- package/lib/commonjs/components/images/CheckmarkFilled.js +0 -40
- package/lib/commonjs/components/images/CheckmarkFilled.js.map +0 -1
- package/lib/commonjs/components/images/EmailVerifyWaiting.js +0 -100
- package/lib/commonjs/components/images/EmailVerifyWaiting.js.map +0 -1
- package/lib/commonjs/components/images/ErrorIcon.js +0 -31
- package/lib/commonjs/components/images/ErrorIcon.js.map +0 -1
- package/lib/commonjs/components/images/PhoneVerifyWaiting.js +0 -91
- package/lib/commonjs/components/images/PhoneVerifyWaiting.js.map +0 -1
- package/lib/commonjs/data/actions.js +0 -26
- package/lib/commonjs/data/actions.js.map +0 -1
- package/lib/commonjs/hooks/api.js +0 -155
- package/lib/commonjs/hooks/api.js.map +0 -1
- package/lib/commonjs/hooks/debounce.js +0 -38
- package/lib/commonjs/hooks/debounce.js.map +0 -1
- package/lib/commonjs/hooks/fingerprint.js +0 -176
- package/lib/commonjs/hooks/fingerprint.js.map +0 -1
- package/lib/commonjs/hooks/index.js +0 -48
- package/lib/commonjs/hooks/index.js.map +0 -1
- package/lib/commonjs/hooks/interval.js +0 -31
- package/lib/commonjs/hooks/interval.js.map +0 -1
- package/lib/commonjs/hooks/nav.js +0 -39
- package/lib/commonjs/hooks/nav.js.map +0 -1
- package/lib/commonjs/index.tsx.bak +0 -26
- package/lib/commonjs/types.js +0 -2
- package/lib/commonjs/types.js.map +0 -1
- package/lib/commonjs/utils/events.js +0 -57
- package/lib/commonjs/utils/events.js.map +0 -1
- package/lib/commonjs/utils/form.js +0 -46
- package/lib/commonjs/utils/form.js.map +0 -1
- package/lib/commonjs/utils/queue.js +0 -117
- package/lib/commonjs/utils/queue.js.map +0 -1
- package/lib/commonjs/utils/storage.js +0 -15
- package/lib/commonjs/utils/storage.js.map +0 -1
- package/lib/commonjs/utils/tokens.js +0 -35
- package/lib/commonjs/utils/tokens.js.map +0 -1
- package/lib/commonjs/utils/user-data.js +0 -21
- package/lib/commonjs/utils/user-data.js.map +0 -1
- package/lib/module/assets/images/checkmark--filled.svg +0 -12
- package/lib/module/assets/images/email-verify-waiting.svg +0 -36
- package/lib/module/assets/images/error-icon-material.svg +0 -1
- package/lib/module/assets/images/phone-verify-waiting.svg +0 -26
- package/lib/module/components/AuthenticatedComponent.js +0 -24
- package/lib/module/components/AuthenticatedComponent.js.map +0 -1
- package/lib/module/components/AutoSigninDialog.js +0 -110
- package/lib/module/components/AutoSigninDialog.js.map +0 -1
- package/lib/module/components/BottomSheetTextInput/BottomSheetTextInput.js +0 -52
- package/lib/module/components/BottomSheetTextInput/BottomSheetTextInput.js.map +0 -1
- package/lib/module/components/BottomSheetTextInput/index.js +0 -5
- package/lib/module/components/BottomSheetTextInput/index.js.map +0 -1
- package/lib/module/components/BottomSheetTextInput/types.js +0 -2
- package/lib/module/components/BottomSheetTextInput/types.js.map +0 -1
- package/lib/module/components/DarkText.js +0 -24
- package/lib/module/components/DarkText.js.map +0 -1
- package/lib/module/components/DefaultContext.js +0 -244
- package/lib/module/components/DefaultContext.js.map +0 -1
- package/lib/module/components/RowndComponents.js +0 -12
- package/lib/module/components/RowndComponents.js.map +0 -1
- package/lib/module/components/RowndProvider.js +0 -39
- package/lib/module/components/RowndProvider.js.map +0 -1
- package/lib/module/components/SignIn.js +0 -616
- package/lib/module/components/SignIn.js.map +0 -1
- package/lib/module/components/images/CheckmarkFilled.js +0 -27
- package/lib/module/components/images/CheckmarkFilled.js.map +0 -1
- package/lib/module/components/images/EmailVerifyWaiting.js +0 -87
- package/lib/module/components/images/EmailVerifyWaiting.js.map +0 -1
- package/lib/module/components/images/ErrorIcon.js +0 -18
- package/lib/module/components/images/ErrorIcon.js.map +0 -1
- package/lib/module/components/images/PhoneVerifyWaiting.js +0 -78
- package/lib/module/components/images/PhoneVerifyWaiting.js.map +0 -1
- package/lib/module/data/actions.js +0 -19
- package/lib/module/data/actions.js.map +0 -1
- package/lib/module/hooks/api.js +0 -135
- package/lib/module/hooks/api.js.map +0 -1
- package/lib/module/hooks/debounce.js +0 -29
- package/lib/module/hooks/debounce.js.map +0 -1
- package/lib/module/hooks/fingerprint.js +0 -157
- package/lib/module/hooks/fingerprint.js.map +0 -1
- package/lib/module/hooks/index.js +0 -7
- package/lib/module/hooks/index.js.map +0 -1
- package/lib/module/hooks/interval.js +0 -23
- package/lib/module/hooks/interval.js.map +0 -1
- package/lib/module/hooks/nav.js +0 -30
- package/lib/module/hooks/nav.js.map +0 -1
- package/lib/module/index.tsx.bak +0 -26
- package/lib/module/types.js +0 -2
- package/lib/module/types.js.map +0 -1
- package/lib/module/utils/events.js +0 -45
- package/lib/module/utils/events.js.map +0 -1
- package/lib/module/utils/form.js +0 -34
- package/lib/module/utils/form.js.map +0 -1
- package/lib/module/utils/queue.js +0 -109
- package/lib/module/utils/queue.js.map +0 -1
- package/lib/module/utils/storage.js +0 -6
- package/lib/module/utils/storage.js.map +0 -1
- package/lib/module/utils/tokens.js +0 -24
- package/lib/module/utils/tokens.js.map +0 -1
- package/lib/module/utils/user-data.js +0 -14
- package/lib/module/utils/user-data.js.map +0 -1
- package/lib/package.json +0 -173
- package/lib/typescript/src/components/AuthenticatedComponent.d.ts +0 -7
- package/lib/typescript/src/components/AutoSigninDialog.d.ts +0 -2
- package/lib/typescript/src/components/BottomSheetTextInput/BottomSheetTextInput.d.ts +0 -4
- package/lib/typescript/src/components/BottomSheetTextInput/index.d.ts +0 -2
- package/lib/typescript/src/components/BottomSheetTextInput/types.d.ts +0 -3
- package/lib/typescript/src/components/DarkText.d.ts +0 -3
- package/lib/typescript/src/components/DefaultContext.d.ts +0 -12
- package/lib/typescript/src/components/RowndComponents.d.ts +0 -2
- package/lib/typescript/src/components/RowndProvider.d.ts +0 -8
- package/lib/typescript/src/components/SignIn.d.ts +0 -2
- package/lib/typescript/src/components/images/CheckmarkFilled.d.ts +0 -4
- package/lib/typescript/src/components/images/EmailVerifyWaiting.d.ts +0 -4
- package/lib/typescript/src/components/images/ErrorIcon.d.ts +0 -4
- package/lib/typescript/src/components/images/PhoneVerifyWaiting.d.ts +0 -4
- package/lib/typescript/src/data/actions.d.ts +0 -20
- package/lib/typescript/src/hooks/api.d.ts +0 -12
- package/lib/typescript/src/hooks/debounce.d.ts +0 -5
- package/lib/typescript/src/hooks/fingerprint.d.ts +0 -12
- package/lib/typescript/src/hooks/index.d.ts +0 -6
- package/lib/typescript/src/hooks/interval.d.ts +0 -2
- package/lib/typescript/src/hooks/nav.d.ts +0 -6
- package/lib/typescript/src/index.d.ts +0 -4
- package/lib/typescript/src/types.d.ts +0 -26
- package/lib/typescript/src/utils/config.d.ts +0 -18
- package/lib/typescript/src/utils/events.d.ts +0 -22
- package/lib/typescript/src/utils/form.d.ts +0 -18
- package/lib/typescript/src/utils/queue.d.ts +0 -21
- package/lib/typescript/src/utils/storage.d.ts +0 -3
- package/lib/typescript/src/utils/tokens.d.ts +0 -4
- package/lib/typescript/src/utils/user-data.d.ts +0 -3
- package/react-native.podspec +0 -19
- package/src/assets/images/checkmark--filled.svg +0 -12
- package/src/assets/images/email-verify-waiting.svg +0 -36
- package/src/assets/images/error-icon-material.svg +0 -1
- package/src/assets/images/phone-verify-waiting.svg +0 -26
- package/src/components/AuthenticatedComponent.tsx +0 -30
- package/src/components/AutoSigninDialog.tsx +0 -131
- package/src/components/BottomSheetTextInput/BottomSheetTextInput.tsx +0 -57
- package/src/components/BottomSheetTextInput/index.ts +0 -5
- package/src/components/BottomSheetTextInput/types.ts +0 -3
- package/src/components/DarkText.tsx +0 -16
- package/src/components/DefaultContext.tsx +0 -278
- package/src/components/RowndComponents.tsx +0 -18
- package/src/components/RowndProvider.tsx +0 -56
- package/src/components/SignIn.tsx +0 -797
- package/src/components/images/CheckmarkFilled.tsx +0 -30
- package/src/components/images/EmailVerifyWaiting.tsx +0 -95
- package/src/components/images/ErrorIcon.tsx +0 -11
- package/src/components/images/PhoneVerifyWaiting.tsx +0 -74
- package/src/data/actions.ts +0 -21
- package/src/hooks/api.ts +0 -162
- package/src/hooks/debounce.ts +0 -36
- package/src/hooks/fingerprint.ts +0 -217
- package/src/hooks/index.ts +0 -7
- package/src/hooks/interval.ts +0 -25
- package/src/hooks/nav.tsx +0 -29
- package/src/index.tsx.bak +0 -26
- package/src/types.ts +0 -27
- package/src/utils/events.ts +0 -54
- package/src/utils/form.tsx +0 -64
- package/src/utils/queue.ts +0 -75
- package/src/utils/storage.ts +0 -7
- package/src/utils/tokens.ts +0 -26
- package/src/utils/user-data.ts +0 -15
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import React, { useMemo, useCallback, useEffect, useRef } from 'react';
|
|
2
|
-
import { View, Text, StyleSheet, ActivityIndicator } from 'react-native';
|
|
3
|
-
import {
|
|
4
|
-
BottomSheetBackdrop,
|
|
5
|
-
BottomSheetBackdropProps,
|
|
6
|
-
BottomSheetModal,
|
|
7
|
-
} from '@gorhom/bottom-sheet';
|
|
8
|
-
import bottomSheetMeta from '@gorhom/bottom-sheet/package.json';
|
|
9
|
-
import { useTimeout } from 'usehooks-ts';
|
|
10
|
-
|
|
11
|
-
import { useNav } from '../hooks';
|
|
12
|
-
import { useGlobalContext } from './GlobalContext';
|
|
13
|
-
|
|
14
|
-
import ErrorIcon from './images/ErrorIcon';
|
|
15
|
-
|
|
16
|
-
export function AutoSigninDialog() {
|
|
17
|
-
const navTo = useNav();
|
|
18
|
-
const { state } = useGlobalContext();
|
|
19
|
-
|
|
20
|
-
// Let the user know they're auto signing-in, then close when done
|
|
21
|
-
useTimeout(() => {
|
|
22
|
-
if (state?.nav?.options?.type === 'error') {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
handleClose();
|
|
27
|
-
}, 3000);
|
|
28
|
-
|
|
29
|
-
const bottomSheetModalRef = useRef<BottomSheetModal>(null);
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
if (bottomSheetModalRef.current) {
|
|
32
|
-
bottomSheetModalRef.current.present();
|
|
33
|
-
}
|
|
34
|
-
}, []);
|
|
35
|
-
|
|
36
|
-
const handleClose = useCallback(() => {
|
|
37
|
-
setTimeout(() => {
|
|
38
|
-
navTo({ hide: true });
|
|
39
|
-
}, 150);
|
|
40
|
-
}, [navTo]);
|
|
41
|
-
|
|
42
|
-
const snapPoints = useMemo(() => ['30%', '60%'], []);
|
|
43
|
-
|
|
44
|
-
const renderBackdrop = useCallback(
|
|
45
|
-
(props: BottomSheetBackdropProps) => (
|
|
46
|
-
<BottomSheetBackdrop {...props} pressBehavior="none" />
|
|
47
|
-
),
|
|
48
|
-
[]
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
let extraBottomSheetProps: any = {};
|
|
52
|
-
if (bottomSheetMeta.version.startsWith('4')) {
|
|
53
|
-
extraBottomSheetProps.keyboardBehavior = 'fillParent';
|
|
54
|
-
extraBottomSheetProps.android_keyboardInputMode = 'adjustResize';
|
|
55
|
-
extraBottomSheetProps.enablePanDownToClose =
|
|
56
|
-
state?.nav?.options?.type === 'error';
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return (
|
|
60
|
-
<BottomSheetModal
|
|
61
|
-
snapPoints={snapPoints}
|
|
62
|
-
index={0}
|
|
63
|
-
backdropComponent={renderBackdrop}
|
|
64
|
-
onDismiss={handleClose}
|
|
65
|
-
style={styles.bottomSheet}
|
|
66
|
-
ref={bottomSheetModalRef}
|
|
67
|
-
{...extraBottomSheetProps}
|
|
68
|
-
>
|
|
69
|
-
<View style={styles.innerContainer}>
|
|
70
|
-
{state?.nav?.options?.type === 'error' && (
|
|
71
|
-
<>
|
|
72
|
-
<ErrorIcon />
|
|
73
|
-
<Text style={styles.errorMessage}>
|
|
74
|
-
{state.nav.options.message ||
|
|
75
|
-
'An error occurred. Please try again.'}
|
|
76
|
-
</Text>
|
|
77
|
-
</>
|
|
78
|
-
)}
|
|
79
|
-
|
|
80
|
-
{state?.nav?.options?.type === 'sign-in' && (
|
|
81
|
-
<>
|
|
82
|
-
<ActivityIndicator size="large" color="#5b0ae0" />
|
|
83
|
-
<Text style={styles.signInMessage}>
|
|
84
|
-
Automatically signing you in. Just a sec...
|
|
85
|
-
</Text>
|
|
86
|
-
</>
|
|
87
|
-
)}
|
|
88
|
-
</View>
|
|
89
|
-
</BottomSheetModal>
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
const styles = StyleSheet.create({
|
|
94
|
-
modal: {
|
|
95
|
-
// flex: 1,
|
|
96
|
-
},
|
|
97
|
-
bottomSheet: {
|
|
98
|
-
shadowColor: '#000',
|
|
99
|
-
shadowOffset: {
|
|
100
|
-
width: 0,
|
|
101
|
-
height: 12,
|
|
102
|
-
},
|
|
103
|
-
shadowOpacity: 0.58,
|
|
104
|
-
shadowRadius: 16.0,
|
|
105
|
-
|
|
106
|
-
elevation: 24,
|
|
107
|
-
},
|
|
108
|
-
innerContainer: {
|
|
109
|
-
borderRadius: 20,
|
|
110
|
-
borderColor: 'transparent',
|
|
111
|
-
borderWidth: 0,
|
|
112
|
-
padding: 25,
|
|
113
|
-
textAlign: 'center',
|
|
114
|
-
},
|
|
115
|
-
signInMessage: {
|
|
116
|
-
textAlign: 'center',
|
|
117
|
-
fontSize: 24,
|
|
118
|
-
padding: 20,
|
|
119
|
-
},
|
|
120
|
-
errorMessage: {
|
|
121
|
-
textAlign: 'center',
|
|
122
|
-
fontSize: 24,
|
|
123
|
-
padding: 20,
|
|
124
|
-
},
|
|
125
|
-
errorIcon: {
|
|
126
|
-
textAlign: 'center',
|
|
127
|
-
color: '#DA1E28',
|
|
128
|
-
height: 24,
|
|
129
|
-
width: 24,
|
|
130
|
-
},
|
|
131
|
-
});
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import React, { memo, useCallback, forwardRef } from 'react';
|
|
2
|
-
import { TextInput } from 'react-native-gesture-handler';
|
|
3
|
-
import { BottomSheetTextInputProps } from './types';
|
|
4
|
-
|
|
5
|
-
// @ts-ignore
|
|
6
|
-
const {
|
|
7
|
-
useBottomSheetInternal,
|
|
8
|
-
} = require('@gorhom/bottom-sheet/src/hooks/useBottomSheetInternal');
|
|
9
|
-
|
|
10
|
-
const BottomSheetTextInputComponent = forwardRef<
|
|
11
|
-
TextInput,
|
|
12
|
-
BottomSheetTextInputProps
|
|
13
|
-
>(({ onFocus, onBlur, ...rest }, ref) => {
|
|
14
|
-
//#region hooks
|
|
15
|
-
// @ts-ignore
|
|
16
|
-
let { shouldHandleKeyboardEvents } = useBottomSheetInternal();
|
|
17
|
-
//#endregion
|
|
18
|
-
|
|
19
|
-
if (!shouldHandleKeyboardEvents) {
|
|
20
|
-
shouldHandleKeyboardEvents = {};
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
//#region callbacks
|
|
24
|
-
const handleOnFocus = useCallback(
|
|
25
|
-
(args) => {
|
|
26
|
-
shouldHandleKeyboardEvents.value = true;
|
|
27
|
-
if (onFocus) {
|
|
28
|
-
onFocus(args);
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
[onFocus, shouldHandleKeyboardEvents]
|
|
32
|
-
);
|
|
33
|
-
const handleOnBlur = useCallback(
|
|
34
|
-
(args) => {
|
|
35
|
-
shouldHandleKeyboardEvents.value = false;
|
|
36
|
-
if (onBlur) {
|
|
37
|
-
onBlur(args);
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
[onBlur, shouldHandleKeyboardEvents]
|
|
41
|
-
);
|
|
42
|
-
//#endregion
|
|
43
|
-
|
|
44
|
-
return (
|
|
45
|
-
<TextInput
|
|
46
|
-
ref={ref}
|
|
47
|
-
onFocus={handleOnFocus}
|
|
48
|
-
onBlur={handleOnBlur}
|
|
49
|
-
{...rest}
|
|
50
|
-
/>
|
|
51
|
-
);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
const BottomSheetTextInput = memo(BottomSheetTextInputComponent);
|
|
55
|
-
BottomSheetTextInput.displayName = 'BottomSheetTextInput';
|
|
56
|
-
|
|
57
|
-
export default BottomSheetTextInput;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Text, TextProps, TextStyle } from 'react-native';
|
|
3
|
-
|
|
4
|
-
export default function DarkText({ style, children, ...rest }: TextProps) {
|
|
5
|
-
if (style) {
|
|
6
|
-
(style as TextStyle).color = '#000000';
|
|
7
|
-
} else {
|
|
8
|
-
style = { color: '#000000' };
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
return (
|
|
12
|
-
<Text style={style} {...rest}>
|
|
13
|
-
{children}
|
|
14
|
-
</Text>
|
|
15
|
-
);
|
|
16
|
-
}
|
|
@@ -1,278 +0,0 @@
|
|
|
1
|
-
import { useEffect, useCallback, useRef } from 'react';
|
|
2
|
-
import isEqual from 'lodash-es/isEqual';
|
|
3
|
-
import { useDebounce, useApi, useDeviceFingerprint } from '../hooks';
|
|
4
|
-
import { DEFAULT_USER_AGENT } from '../hooks/api';
|
|
5
|
-
import { IConfig } from '../utils/config';
|
|
6
|
-
import { useGlobalContext } from './GlobalContext';
|
|
7
|
-
import { ActionType } from '../data/actions';
|
|
8
|
-
import ky from 'ky';
|
|
9
|
-
import Clipboard from '@react-native-clipboard/clipboard';
|
|
10
|
-
import base64 from 'react-native-base64';
|
|
11
|
-
import { Linking } from 'react-native';
|
|
12
|
-
import { events, EventType } from '../utils/events';
|
|
13
|
-
|
|
14
|
-
export type UserInfoResp = {
|
|
15
|
-
data: {
|
|
16
|
-
[key: string]: any;
|
|
17
|
-
};
|
|
18
|
-
redacted: string[];
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
interface UserAclsResponse {
|
|
22
|
-
acls: Record<string, { shared: boolean }>;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
type DefaultContextProps = {
|
|
26
|
-
config: IConfig;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export function DefaultContext({ config }: DefaultContextProps) {
|
|
30
|
-
const { state, dispatch } = useGlobalContext();
|
|
31
|
-
const { client: api } = useApi();
|
|
32
|
-
useDeviceFingerprint();
|
|
33
|
-
|
|
34
|
-
// Fetch app schema and config
|
|
35
|
-
useEffect(() => {
|
|
36
|
-
(async () => {
|
|
37
|
-
try {
|
|
38
|
-
const resp: any = await api
|
|
39
|
-
.get('hub/app-config', {
|
|
40
|
-
headers: {
|
|
41
|
-
'x-rownd-app-key': config.appKey,
|
|
42
|
-
},
|
|
43
|
-
})
|
|
44
|
-
.json();
|
|
45
|
-
|
|
46
|
-
if (resp?.app?.icon) {
|
|
47
|
-
const iconMeta = await ky.get(resp.app.icon);
|
|
48
|
-
resp.app.icon_content_type = iconMeta.headers.get('content-type');
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
dispatch({
|
|
52
|
-
type: ActionType.SET_APP_CONFIG,
|
|
53
|
-
payload: resp.app,
|
|
54
|
-
});
|
|
55
|
-
} catch (err) {
|
|
56
|
-
console.error('Failed to fetch app config:', err);
|
|
57
|
-
}
|
|
58
|
-
})();
|
|
59
|
-
}, [api, config.appKey, dispatch]);
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* If not signed in, check the clipboard for an init hash or auth link we can use to auto-auth the user
|
|
63
|
-
*/
|
|
64
|
-
useEffect(() => {
|
|
65
|
-
if (state.auth.access_token || !state.app.id) {
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
(async () => {
|
|
70
|
-
try {
|
|
71
|
-
let authData = null;
|
|
72
|
-
|
|
73
|
-
let authLink =
|
|
74
|
-
(await Linking.getInitialURL()) || (await Clipboard.getString());
|
|
75
|
-
if (authLink.includes('rownd.link')) {
|
|
76
|
-
dispatch({
|
|
77
|
-
type: ActionType.CHANGE_ROUTE,
|
|
78
|
-
payload: {
|
|
79
|
-
route: '/account/auto-signin',
|
|
80
|
-
opts: {
|
|
81
|
-
type: 'sign-in',
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
authData = await ky
|
|
87
|
-
.get(authLink, {
|
|
88
|
-
headers: {
|
|
89
|
-
'User-Agent': DEFAULT_USER_AGENT,
|
|
90
|
-
},
|
|
91
|
-
})
|
|
92
|
-
.json();
|
|
93
|
-
} else if (authLink.startsWith('rph_init=')) {
|
|
94
|
-
const authStr = authLink.split('rph_init=')[1];
|
|
95
|
-
authData = JSON.parse(base64.decode(authStr));
|
|
96
|
-
} else {
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// Clear the clipboard value so we don't leak any creds
|
|
101
|
-
Clipboard.setString('');
|
|
102
|
-
|
|
103
|
-
dispatch({
|
|
104
|
-
type: ActionType.LOGIN_SUCCESS,
|
|
105
|
-
payload: authData,
|
|
106
|
-
});
|
|
107
|
-
} catch (err) {
|
|
108
|
-
console.error(
|
|
109
|
-
'We found an auth link or string, but failed to authenticate with it because:',
|
|
110
|
-
err
|
|
111
|
-
);
|
|
112
|
-
}
|
|
113
|
-
})();
|
|
114
|
-
}, [state.auth.access_token, state.app.id, dispatch]);
|
|
115
|
-
|
|
116
|
-
const retrieveUserInfo = useCallback(() => {
|
|
117
|
-
if (!state.auth.access_token || !state.app.id) {
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
(async () => {
|
|
122
|
-
const userInfo: UserInfoResp = await api
|
|
123
|
-
.get(`me/applications/${state.app.id}/data`, {
|
|
124
|
-
headers: {
|
|
125
|
-
Authorization: `Bearer ${state.auth.access_token}`,
|
|
126
|
-
},
|
|
127
|
-
})
|
|
128
|
-
.json();
|
|
129
|
-
dispatch({
|
|
130
|
-
type: ActionType.LOAD_USER,
|
|
131
|
-
payload: userInfo,
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
dispatch({
|
|
135
|
-
type: ActionType.UPDATE_LOCAL_ACLS,
|
|
136
|
-
payload: userInfo.redacted.reduce(
|
|
137
|
-
(acc: Record<string, any>, field: string) => {
|
|
138
|
-
acc[field] = { shared: false };
|
|
139
|
-
return acc;
|
|
140
|
-
},
|
|
141
|
-
{}
|
|
142
|
-
),
|
|
143
|
-
});
|
|
144
|
-
})();
|
|
145
|
-
}, [api, dispatch, state.app.id, state.auth.access_token]);
|
|
146
|
-
|
|
147
|
-
const retrieveAcls = useCallback(() => {
|
|
148
|
-
if (!state.app.id || !state.auth.access_token) {
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
(async () => {
|
|
153
|
-
try {
|
|
154
|
-
const appUserAcls: UserAclsResponse = await api
|
|
155
|
-
.get(`me/applications/${state.app.id}/acls`, {
|
|
156
|
-
headers: {
|
|
157
|
-
Authorization: `Bearer ${state.auth.access_token}`,
|
|
158
|
-
},
|
|
159
|
-
})
|
|
160
|
-
.json();
|
|
161
|
-
dispatch({
|
|
162
|
-
type: ActionType.UPDATE_LOCAL_ACLS,
|
|
163
|
-
payload: appUserAcls.acls,
|
|
164
|
-
});
|
|
165
|
-
} catch (err) {
|
|
166
|
-
if (err instanceof Error) {
|
|
167
|
-
// const unsharedAcls = reduceSchemaToUnsharedAcls();
|
|
168
|
-
dispatch({
|
|
169
|
-
type: ActionType.UPDATE_LOCAL_ACLS,
|
|
170
|
-
payload: {},
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
})();
|
|
175
|
-
}, [api, dispatch, state.app.id, state.auth.access_token]);
|
|
176
|
-
|
|
177
|
-
useEffect(retrieveUserInfo, [retrieveUserInfo]);
|
|
178
|
-
useEffect(retrieveAcls, [retrieveAcls]);
|
|
179
|
-
|
|
180
|
-
useEffect(() => {
|
|
181
|
-
if (!state.user.needs_refresh) {
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
retrieveUserInfo();
|
|
185
|
-
dispatch({
|
|
186
|
-
type: ActionType.SET_REFRESH_USER_DATA,
|
|
187
|
-
payload: { needs_refresh: false },
|
|
188
|
-
});
|
|
189
|
-
}, [dispatch, retrieveUserInfo, state.user.needs_refresh]);
|
|
190
|
-
|
|
191
|
-
const saveAclsDebounced = useDebounce(saveAcls, 2000); // 2s
|
|
192
|
-
|
|
193
|
-
async function saveAcls() {
|
|
194
|
-
if (state.app.id && state.local_acls) {
|
|
195
|
-
await api
|
|
196
|
-
.put(`me/applications/${state.app.id}/acls`, {
|
|
197
|
-
headers: {
|
|
198
|
-
Authorization: `Bearer ${state.auth.access_token}`,
|
|
199
|
-
},
|
|
200
|
-
json: {
|
|
201
|
-
acls: state.local_acls,
|
|
202
|
-
},
|
|
203
|
-
})
|
|
204
|
-
.json();
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
const localAclsRef = useRef(state.local_acls);
|
|
209
|
-
useEffect(() => {
|
|
210
|
-
// Don't save acls if they were just loaded for the first time or they haven't changed
|
|
211
|
-
if (
|
|
212
|
-
!localAclsRef.current ||
|
|
213
|
-
isEqual(localAclsRef.current, state.local_acls)
|
|
214
|
-
) {
|
|
215
|
-
return;
|
|
216
|
-
}
|
|
217
|
-
saveAclsDebounced();
|
|
218
|
-
}, [saveAclsDebounced, state.local_acls]);
|
|
219
|
-
|
|
220
|
-
const saveUserDataDebounced = useDebounce(saveUserData, 2000); // 2s
|
|
221
|
-
|
|
222
|
-
// Save user data in the application state to the API server
|
|
223
|
-
async function saveUserData() {
|
|
224
|
-
if (state.app.id && state.user.data && state.auth.access_token) {
|
|
225
|
-
dispatch({
|
|
226
|
-
type: ActionType.SET_IS_SAVING_USER_DATA,
|
|
227
|
-
payload: {
|
|
228
|
-
saving: true,
|
|
229
|
-
},
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
const eventDetails: Record<string, any> = {};
|
|
233
|
-
try {
|
|
234
|
-
eventDetails.data = await api
|
|
235
|
-
.put(`me/applications/${state.app.id}/data`, {
|
|
236
|
-
headers: {
|
|
237
|
-
Authorization: `Bearer ${state.auth.access_token}`,
|
|
238
|
-
},
|
|
239
|
-
json: {
|
|
240
|
-
data: state.user.data,
|
|
241
|
-
},
|
|
242
|
-
})
|
|
243
|
-
.json();
|
|
244
|
-
} catch (err) {
|
|
245
|
-
eventDetails.error = err;
|
|
246
|
-
// Get the latest user info from Rownd. Something was probably bad
|
|
247
|
-
// with the data we just tried to save.
|
|
248
|
-
// This is a bit hacky. We should be able to reset the state without
|
|
249
|
-
// calling rownd again by rolling back to a previously good state...
|
|
250
|
-
retrieveUserInfo();
|
|
251
|
-
// TODO: Set some error state
|
|
252
|
-
} finally {
|
|
253
|
-
events.dispatch(EventType.USER_DATA_SAVED, eventDetails);
|
|
254
|
-
dispatch({
|
|
255
|
-
type: ActionType.SET_IS_SAVING_USER_DATA,
|
|
256
|
-
payload: {
|
|
257
|
-
saving: false,
|
|
258
|
-
},
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
const userDataRef = useRef(state.user.data);
|
|
265
|
-
useEffect(() => {
|
|
266
|
-
// Don't update the user data in the API server if the email is unknown or the data hasn't changed
|
|
267
|
-
if (
|
|
268
|
-
(!state.user.data?.email && !state.user.data.phone_number) ||
|
|
269
|
-
isEqual(userDataRef.current, state.user.data)
|
|
270
|
-
) {
|
|
271
|
-
return;
|
|
272
|
-
}
|
|
273
|
-
saveUserDataDebounced();
|
|
274
|
-
userDataRef.current = state.user.data;
|
|
275
|
-
}, [dispatch, saveUserDataDebounced, state.user.data]);
|
|
276
|
-
|
|
277
|
-
return null;
|
|
278
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { SignIn } from './SignIn';
|
|
3
|
-
import { AutoSigninDialog } from './AutoSigninDialog';
|
|
4
|
-
import { useGlobalContext } from './GlobalContext';
|
|
5
|
-
|
|
6
|
-
export function RowndComponents() {
|
|
7
|
-
const { state } = useGlobalContext();
|
|
8
|
-
// useDeviceContext(tw);
|
|
9
|
-
|
|
10
|
-
return (
|
|
11
|
-
<>
|
|
12
|
-
{state.nav.current_route === '/account/login' && <SignIn />}
|
|
13
|
-
{state.nav.current_route === '/account/auto-signin' && (
|
|
14
|
-
<AutoSigninDialog />
|
|
15
|
-
)}
|
|
16
|
-
</>
|
|
17
|
-
);
|
|
18
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { View, StyleSheet } from 'react-native';
|
|
3
|
-
import { GlobalContextProvider } from './GlobalContext';
|
|
4
|
-
import { DefaultContext } from './DefaultContext';
|
|
5
|
-
import { createConfig } from '../utils/config';
|
|
6
|
-
import { RowndComponents } from './RowndComponents';
|
|
7
|
-
import { BottomSheetModalProvider } from '@gorhom/bottom-sheet';
|
|
8
|
-
|
|
9
|
-
// const RowndContext = createContext<TRowndContext | undefined>(undefined);
|
|
10
|
-
|
|
11
|
-
interface IRowndProviderProps {
|
|
12
|
-
appKey: string;
|
|
13
|
-
apiUrl?: string;
|
|
14
|
-
children: React.ReactNode;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function RowndProvider({
|
|
18
|
-
appKey,
|
|
19
|
-
apiUrl,
|
|
20
|
-
children,
|
|
21
|
-
}: IRowndProviderProps) {
|
|
22
|
-
// const [isSigningIn, setIsSigningIn] = useState<boolean>(false);
|
|
23
|
-
|
|
24
|
-
// const requestSignIn = useRef(function () {
|
|
25
|
-
// setIsSigningIn(true);
|
|
26
|
-
// });
|
|
27
|
-
|
|
28
|
-
// const [rowndState, setRowndState] = useState<any>({
|
|
29
|
-
// requestSignIn: requestSignIn.current,
|
|
30
|
-
// });
|
|
31
|
-
|
|
32
|
-
const config = createConfig({
|
|
33
|
-
appKey,
|
|
34
|
-
apiUrl,
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
return (
|
|
38
|
-
<GlobalContextProvider config={config}>
|
|
39
|
-
<DefaultContext config={config} />
|
|
40
|
-
<BottomSheetModalProvider>
|
|
41
|
-
<View style={styles.container}>
|
|
42
|
-
<>
|
|
43
|
-
{children}
|
|
44
|
-
<RowndComponents />
|
|
45
|
-
</>
|
|
46
|
-
</View>
|
|
47
|
-
</BottomSheetModalProvider>
|
|
48
|
-
</GlobalContextProvider>
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const styles = StyleSheet.create({
|
|
53
|
-
container: {
|
|
54
|
-
flex: 1,
|
|
55
|
-
},
|
|
56
|
-
});
|