@test-web/react-native-sdk 2.2.0 → 2.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@test-web/react-native-sdk",
3
- "version": "2.2.0",
3
+ "version": "2.3.0",
4
4
  "description": "Dynamic React Native SDK for document verification with API-driven configuration",
5
5
  "main": "src/index.tsx",
6
6
  "types": "src/index.tsx",
@@ -1,30 +1,30 @@
1
- import React, { memo } from 'react';
2
- import { View, Text, StyleSheet } from 'react-native';
1
+ import { StyleProp, Text, View, ViewStyle } from 'react-native';
3
2
  import { useTheme } from '../../context/ThemeContext';
3
+ import { useOrientation } from '../../hooks/useOrientation';
4
+ import { useIDM } from '../../context/IDMConfigurationContext';
5
+ import { useEffect, useState } from 'react';
6
+ import getStyles from '../../styles/FooterStyles';
4
7
 
5
- function Footer() {
8
+ interface FooterProps {
9
+ style?: StyleProp<ViewStyle>;
10
+ }
11
+
12
+ export default function Footer({ style }: FooterProps) {
6
13
  const { theme } = useTheme();
14
+ const orientation = useOrientation();
15
+ const styles = getStyles(theme, orientation);
16
+ const { idmConf } = useIDM();
17
+ const [showFooterTenantName, setShowFooterTenantName] = useState<string>('IDMERIT');
18
+
19
+ useEffect(() => {
20
+ if (idmConf.configuration?.showFooterTenantName && idmConf.configuration?.tenantName) {
21
+ setShowFooterTenantName(idmConf.configuration?.tenantName);
22
+ }
23
+ }, [idmConf.configuration]);
7
24
 
8
25
  return (
9
- <View style={[styles.container, { backgroundColor: theme.colors.background }]}>
10
- <Text style={[styles.text, { color: theme.colors.subtitle }]}>
11
- Powered by IDMerit
12
- </Text>
26
+ <View style={[styles.footer, style]}>
27
+ <Text style={styles.text}>Powered by {showFooterTenantName}</Text>
13
28
  </View>
14
29
  );
15
30
  }
16
-
17
- const styles = StyleSheet.create({
18
- container: {
19
- height: 50,
20
- justifyContent: 'center',
21
- alignItems: 'center',
22
- borderTopWidth: 1,
23
- borderTopColor: '#e0e0e0',
24
- },
25
- text: {
26
- fontSize: 12,
27
- },
28
- });
29
-
30
- export default memo(Footer);
@@ -1,29 +1,33 @@
1
- import React, { memo } from 'react';
2
- import { View, Text, StyleSheet } from 'react-native';
1
+ import { Image, StyleProp, View, ViewStyle, ImageSourcePropType } from 'react-native';
3
2
  import { useTheme } from '../../context/ThemeContext';
3
+ import { useOrientation } from '../../hooks/useOrientation';
4
+ import { useIDM } from '../../context/IDMConfigurationContext';
5
+ import { useEffect, useState } from 'react';
6
+ import getStyles from '../../styles/HeaderStyles';
4
7
 
5
- function Header() {
8
+ interface HeaderProps {
9
+ style?: StyleProp<ViewStyle>;
10
+ }
11
+
12
+ export default function Header({ style }: HeaderProps) {
6
13
  const { theme } = useTheme();
14
+ const orientation = useOrientation();
15
+ const { idmConf } = useIDM();
16
+ const styles = getStyles(theme, orientation);
17
+
18
+ const defaultLogo = require('../../../assets/images/logo.png');
19
+ const [logoSource, setLogoSource] = useState<ImageSourcePropType>(defaultLogo);
20
+
21
+ useEffect(() => {
22
+ const logo = idmConf?.configuration?.logo;
23
+ if (logo?.startsWith('data:image')) {
24
+ setLogoSource({ uri: logo });
25
+ }
26
+ }, [idmConf]);
7
27
 
8
28
  return (
9
- <View style={[styles.container, { backgroundColor: theme.colors.primary }]}>
10
- <Text style={[styles.text, { color: theme.colors.buttonText }]}>
11
- IDM Scan SDK
12
- </Text>
29
+ <View style={[styles.container, style]}>
30
+ <Image source={logoSource} style={styles.logo} resizeMode="contain" />
13
31
  </View>
14
32
  );
15
33
  }
16
-
17
- const styles = StyleSheet.create({
18
- container: {
19
- height: 60,
20
- justifyContent: 'center',
21
- alignItems: 'center',
22
- },
23
- text: {
24
- fontSize: 18,
25
- fontWeight: 'bold',
26
- },
27
- });
28
-
29
- export default memo(Header);
@@ -1,37 +1,18 @@
1
- import React, { memo } from 'react';
2
- import { View, ActivityIndicator, StyleSheet, Text } from 'react-native';
1
+ import { View, ActivityIndicator } from 'react-native';
3
2
  import { useTheme } from '../../context/ThemeContext';
3
+ import { useOrientation } from '../../hooks/useOrientation';
4
+ import getStyles from '../../styles/LoaderStyles';
4
5
 
5
- interface LoaderProps {
6
- message?: string;
7
- }
8
-
9
- function Loader({ message }: LoaderProps) {
6
+ const Loader = () => {
10
7
  const { theme } = useTheme();
8
+ const orientation = useOrientation();
9
+ const styles = getStyles(theme, orientation);
11
10
 
12
11
  return (
13
- <View style={[styles.container, { backgroundColor: theme.colors.background }]}>
12
+ <View style={styles.loadingContainer}>
14
13
  <ActivityIndicator size="large" color={theme.colors.primary} />
15
- {message && (
16
- <Text style={[styles.message, { color: theme.colors.text }]}>
17
- {message}
18
- </Text>
19
- )}
20
14
  </View>
21
15
  );
22
- }
23
-
24
- const styles = StyleSheet.create({
25
- container: {
26
- flex: 1,
27
- justifyContent: 'center',
28
- alignItems: 'center',
29
- },
30
- message: {
31
- marginTop: 16,
32
- fontSize: 16,
33
- textAlign: 'center',
34
- },
35
- });
16
+ };
36
17
 
37
- export default memo(Loader);
18
+ export default Loader;
@@ -1,41 +1,33 @@
1
- import React, { memo } from 'react';
2
- import { TouchableOpacity, Text, StyleSheet, ViewStyle, TextStyle } from 'react-native';
1
+ import { Pressable, StyleProp, Text, TextStyle, ViewStyle } from 'react-native';
2
+ import { useTheme } from '../../context/ThemeContext';
3
3
 
4
4
  interface ButtonProps {
5
5
  title: string;
6
- onPress: () => void;
7
- style?: ViewStyle;
8
- textStyle?: TextStyle;
6
+ style?: StyleProp<ViewStyle>;
7
+ textStyle?: StyleProp<TextStyle>;
8
+ onPress?: () => void;
9
9
  disabled?: boolean;
10
10
  }
11
11
 
12
- function Button({ title, onPress, style, textStyle, disabled }: ButtonProps) {
13
- return (
14
- <TouchableOpacity
15
- style={[styles.button, style]}
16
- onPress={onPress}
17
- disabled={disabled}
18
- activeOpacity={0.7}
19
- >
20
- <Text style={[styles.text, textStyle]}>{title}</Text>
21
- </TouchableOpacity>
22
- );
23
- }
12
+ export default function Button({ title, style, textStyle, onPress, disabled = false }: ButtonProps) {
13
+ const { theme } = useTheme();
24
14
 
25
- const styles = StyleSheet.create({
26
- button: {
27
- backgroundColor: '#007AFF',
28
- paddingVertical: 12,
29
- paddingHorizontal: 24,
30
- borderRadius: 8,
15
+ const defaultStyle: ViewStyle = {
16
+ backgroundColor: theme.colors.buttonBackground,
17
+ padding: theme.button.padding,
18
+ borderRadius: theme.button.borderRadius,
31
19
  alignItems: 'center',
32
- justifyContent: 'center',
33
- },
34
- text: {
35
- color: '#fff',
20
+ };
21
+
22
+ const defaultTextStyle: TextStyle = {
23
+ color: theme.colors.buttonText,
36
24
  fontSize: 16,
37
- fontWeight: '600',
38
- },
39
- });
25
+ fontWeight: 'bold',
26
+ };
40
27
 
41
- export default memo(Button);
28
+ return (
29
+ <Pressable style={[defaultStyle, style]} onPress={onPress} disabled={disabled}>
30
+ <Text style={[defaultTextStyle, textStyle]}>{title}</Text>
31
+ </Pressable>
32
+ );
33
+ }
@@ -1,42 +1,31 @@
1
- import React, { memo, useMemo } from 'react';
2
- import { Text, TextStyle, StyleSheet } from 'react-native';
1
+ import { Text, StyleProp, TextStyle } from 'react-native';
3
2
  import { useTheme } from '../../context/ThemeContext';
4
3
 
5
4
  interface ThemedTextProps {
5
+ type?: 'title' | 'subtitle' | 'default';
6
+ style?: StyleProp<TextStyle>;
6
7
  children: React.ReactNode;
7
- style?: TextStyle;
8
- type?: 'default' | 'title' | 'subtitle';
9
8
  }
10
9
 
11
- function ThemedText({ children, style, type = 'default' }: ThemedTextProps) {
10
+ export default function ThemedText({ type = 'default', style, children }: ThemedTextProps) {
12
11
  const { theme } = useTheme();
13
12
 
14
- const textStyle = useMemo(
15
- () => [
16
- styles.default,
17
- type === 'title' && styles.title,
18
- type === 'subtitle' && styles.subtitle,
19
- { color: theme.colors.text },
20
- style,
21
- ],
22
- [theme.colors.text, type, style]
23
- );
13
+ const defaultStyles: { [key: string]: TextStyle } = {
14
+ title: {
15
+ fontSize: 24,
16
+ fontWeight: '300',
17
+ color: theme.colors.text,
18
+ },
19
+ subtitle: {
20
+ fontSize: 18,
21
+ fontWeight: '400',
22
+ color: theme.colors.subtitle,
23
+ },
24
+ default: {
25
+ fontSize: 16,
26
+ color: theme.colors.text,
27
+ },
28
+ };
24
29
 
25
- return <Text style={textStyle}>{children}</Text>;
30
+ return <Text style={[defaultStyles[type], style]}>{children}</Text>;
26
31
  }
27
-
28
- const styles = StyleSheet.create({
29
- default: {
30
- fontSize: 16,
31
- },
32
- title: {
33
- fontSize: 28,
34
- fontWeight: 'bold',
35
- },
36
- subtitle: {
37
- fontSize: 18,
38
- fontWeight: '500',
39
- },
40
- });
41
-
42
- export default memo(ThemedText);
@@ -10,6 +10,8 @@ export const lightTheme: Theme = {
10
10
  buttonText: '#ffffff',
11
11
  buttonBackground: '#007bff',
12
12
  },
13
+ fonts: { regular: 'System', bold: 'System-Bold' },
14
+ button: { borderRadius: 8, padding: 12 },
13
15
  };
14
16
 
15
17
  // 🌑 Dark (default)
@@ -22,6 +24,8 @@ export const darkTheme: Theme = {
22
24
  buttonText: '#111827',
23
25
  buttonBackground: '#3b82f6',
24
26
  },
27
+ fonts: { regular: 'System', bold: 'System-Bold' },
28
+ button: { borderRadius: 8, padding: 12 },
25
29
  };
26
30
 
27
31
  // 🌅 Sunset (warm oranges)
@@ -34,6 +38,8 @@ export const sunsetTheme: Theme = {
34
38
  buttonText: '#ffffff',
35
39
  buttonBackground: '#f97316',
36
40
  },
41
+ fonts: { regular: 'System', bold: 'System-Bold' },
42
+ button: { borderRadius: 12, padding: 14 },
37
43
  };
38
44
 
39
45
  // 🌊 Ocean (blues & teal)
@@ -46,6 +52,8 @@ export const oceanTheme: Theme = {
46
52
  buttonText: '#ffffff',
47
53
  buttonBackground: '#0284c7',
48
54
  },
55
+ fonts: { regular: 'System', bold: 'System-Bold' },
56
+ button: { borderRadius: 16, padding: 14 },
49
57
  };
50
58
 
51
59
  // 🌿 Forest (greens)
@@ -58,6 +66,8 @@ export const forestTheme: Theme = {
58
66
  buttonText: '#ffffff',
59
67
  buttonBackground: '#3fa564',
60
68
  },
69
+ fonts: { regular: 'System', bold: 'System-Bold' },
70
+ button: { borderRadius: 20, padding: 16 },
61
71
  };
62
72
 
63
73
  // 🎨 Pastel (lavender & purple)
@@ -70,6 +80,8 @@ export const pastelTheme: Theme = {
70
80
  buttonText: '#ffffff',
71
81
  buttonBackground: '#a78bfa',
72
82
  },
83
+ fonts: { regular: 'System', bold: 'System-Bold' },
84
+ button: { borderRadius: 24, padding: 14 },
73
85
  };
74
86
 
75
87
  // ⚡ High Contrast (accessibility)
@@ -82,6 +94,8 @@ export const highContrastTheme: Theme = {
82
94
  buttonText: '#000000',
83
95
  buttonBackground: '#ffcc00',
84
96
  },
97
+ fonts: { regular: 'System', bold: 'System-Bold' },
98
+ button: { borderRadius: 0, padding: 14 },
85
99
  };
86
100
 
87
101
  // 💼 Professional (neutral + blue accent)
@@ -94,6 +108,8 @@ export const professionalTheme: Theme = {
94
108
  buttonText: '#ffffff',
95
109
  buttonBackground: '#2563eb',
96
110
  },
111
+ fonts: { regular: 'System', bold: 'System-Bold' },
112
+ button: { borderRadius: 6, padding: 12 },
97
113
  };
98
114
 
99
115
  // 🌸 Sakura (soft pink)
@@ -106,6 +122,8 @@ export const sakuraTheme: Theme = {
106
122
  buttonText: '#ffffff',
107
123
  buttonBackground: '#ec4899',
108
124
  },
125
+ fonts: { regular: 'System', bold: 'System-Bold' },
126
+ button: { borderRadius: 18, padding: 14 },
109
127
  };
110
128
 
111
129
  // 🌌 Midnight (deep purples)
@@ -118,6 +136,8 @@ export const midnightTheme: Theme = {
118
136
  buttonText: '#1e1b4b',
119
137
  buttonBackground: '#7c3aed',
120
138
  },
139
+ fonts: { regular: 'System', bold: 'System-Bold' },
140
+ button: { borderRadius: 10, padding: 12 },
121
141
  };
122
142
 
123
143
  export const themes: Record<string, Theme> = {
package/src/index.tsx CHANGED
@@ -191,7 +191,7 @@ function IDMScanContent() {
191
191
  if (error) {
192
192
  return (
193
193
  <ThemeProvider theme={theme}>
194
- <Loader message={`Error: ${error}`} />
194
+ <Loader />
195
195
  </ThemeProvider>
196
196
  );
197
197
  }
@@ -190,7 +190,7 @@ export default function BarcodeCapture() {
190
190
  }}
191
191
  />
192
192
 
193
- {loading && <Loader message="Processing barcode..." />}
193
+ {loading && <Loader />}
194
194
  </View>
195
195
  );
196
196
  }
@@ -247,7 +247,7 @@ export default function MrzCapture() {
247
247
  }}
248
248
  />
249
249
 
250
- {loading && <Loader message="Processing MRZ..." />}
250
+ {loading && <Loader />}
251
251
  </View>
252
252
  );
253
253
  }
@@ -17,12 +17,11 @@ export default function SelfieAdvice() {
17
17
  <ThemedText style={styles.maintitle} type="title">
18
18
  Take a Selfie
19
19
  </ThemedText>
20
- {/* Add selfie.jpg image to assets/images/ */}
21
- {/* <Image
20
+ <Image
22
21
  source={require('../../assets/images/selfie.jpg')}
23
22
  style={styles.selfie}
24
23
  resizeMode="contain"
25
- /> */}
24
+ />
26
25
  <Text style={styles.text}>You have to allow Camera Permission.</Text>
27
26
  <Button
28
27
  title="Take a Selfie"
@@ -50,7 +50,7 @@ export default function ThankYou() {
50
50
  <ThemedText style={styles.subtitle} type="title">
51
51
  Your information{'\n'}has been uploaded
52
52
  </ThemedText>
53
- {loading && <Loader message="Finalizing verification..." />}
53
+ {loading && <Loader />}
54
54
  </View>
55
55
  );
56
56
  }
@@ -0,0 +1,18 @@
1
+ import { StyleSheet } from 'react-native';
2
+ import { Theme } from '../types/IDMConf';
3
+ import { Orientation } from '../hooks/useOrientation';
4
+
5
+ export default (theme: Theme, orientation: Orientation) =>
6
+ StyleSheet.create({
7
+ footer: {
8
+ position: 'absolute',
9
+ bottom: 50,
10
+ left: 0,
11
+ right: 0,
12
+ alignItems: 'center',
13
+ },
14
+ text: {
15
+ fontSize: 14,
16
+ color: theme.colors.text,
17
+ },
18
+ });
@@ -0,0 +1,20 @@
1
+ import { StyleSheet } from 'react-native';
2
+ import { Theme } from '../types/IDMConf';
3
+ import { Orientation } from '../hooks/useOrientation';
4
+
5
+ export default (theme: Theme, orientation: Orientation) =>
6
+ StyleSheet.create({
7
+ container: {
8
+ left: 0,
9
+ right: 0,
10
+ alignItems: 'center',
11
+ backgroundColor: theme.colors.background,
12
+ },
13
+ logo: {
14
+ marginHorizontal: 'auto',
15
+ marginTop: '5%',
16
+ marginBottom: 0,
17
+ width: 190,
18
+ height: 76,
19
+ },
20
+ });
@@ -0,0 +1,14 @@
1
+ import { StyleSheet } from 'react-native';
2
+ import { Theme } from '../types/IDMConf';
3
+ import { Orientation } from '../hooks/useOrientation';
4
+
5
+ export default (theme: Theme, orientation: Orientation) =>
6
+ StyleSheet.create({
7
+ loadingContainer: {
8
+ ...StyleSheet.absoluteFillObject,
9
+ backgroundColor: 'rgba(0,0,0,0.5)',
10
+ justifyContent: 'center',
11
+ alignItems: 'center',
12
+ zIndex: 10,
13
+ },
14
+ });
@@ -7,6 +7,14 @@ export interface Theme {
7
7
  buttonBackground: string;
8
8
  buttonText: string;
9
9
  };
10
+ fonts: {
11
+ regular: string;
12
+ bold: string;
13
+ };
14
+ button: {
15
+ borderRadius: number;
16
+ padding: number;
17
+ };
10
18
  }
11
19
 
12
20
  export * from './IDMConf';