@umituz/react-native-firebase 2.0.3 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-firebase",
3
- "version": "2.0.3",
3
+ "version": "2.1.0",
4
4
  "description": "Unified Firebase package for React Native apps - Auth and Firestore services using Firebase JS SDK (no native modules).",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -26,3 +26,9 @@ export {
26
26
  reauthenticateWithApple,
27
27
  getAppleReauthCredential,
28
28
  } from './infrastructure/services/reauthentication.service';
29
+
30
+ export { PasswordPromptModal } from './presentation/components/PasswordPromptModal';
31
+ export type { PasswordPromptModalProps } from './presentation/components/PasswordPromptModal';
32
+
33
+ export { usePasswordPrompt } from './presentation/hooks/usePasswordPrompt';
34
+ export type { UsePasswordPromptOptions, UsePasswordPromptReturn } from './presentation/hooks/usePasswordPrompt';
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Password Prompt Modal
3
+ * Modal for password input during account deletion reauthentication
4
+ */
5
+
6
+ import React, { useState } from 'react';
7
+ import { View, StyleSheet } from 'react-native';
8
+ import {
9
+ BaseModal,
10
+ AtomicInput,
11
+ AtomicButton,
12
+ useAppDesignTokens
13
+ } from '@umituz/react-native-design-system';
14
+
15
+ export interface PasswordPromptModalProps {
16
+ visible: boolean;
17
+ onConfirm: (password: string) => void;
18
+ onCancel: () => void;
19
+ title?: string;
20
+ message?: string;
21
+ confirmText?: string;
22
+ cancelText?: string;
23
+ }
24
+
25
+ export const PasswordPromptModal: React.FC<PasswordPromptModalProps> = ({
26
+ visible,
27
+ onConfirm,
28
+ onCancel,
29
+ title = 'Password Required',
30
+ message = 'Enter your password to continue',
31
+ confirmText = 'Confirm',
32
+ cancelText = 'Cancel',
33
+ }) => {
34
+ const tokens = useAppDesignTokens();
35
+ const [password, setPassword] = useState('');
36
+ const [error, setError] = useState('');
37
+
38
+ const handleConfirm = () => {
39
+ if (!password.trim()) {
40
+ setError('Password is required');
41
+ return;
42
+ }
43
+ onConfirm(password);
44
+ setPassword('');
45
+ setError('');
46
+ };
47
+
48
+ const handleCancel = () => {
49
+ setPassword('');
50
+ setError('');
51
+ onCancel();
52
+ };
53
+
54
+ return (
55
+ <BaseModal
56
+ visible={visible}
57
+ onClose={handleCancel}
58
+ title={title}
59
+ subtitle={message}
60
+ dismissOnBackdrop={false}
61
+ >
62
+ <View style={[styles.container, { padding: tokens.spacing.md }]}>
63
+ <AtomicInput
64
+ value={password}
65
+ onChangeText={(text: string) => {
66
+ setPassword(text);
67
+ setError('');
68
+ }}
69
+ placeholder="Password"
70
+ secureTextEntry
71
+ autoFocus
72
+ state={error ? 'error' : 'default'}
73
+ helperText={error}
74
+ style={{ marginBottom: tokens.spacing.md }}
75
+ />
76
+
77
+ <View style={[styles.buttons, { gap: tokens.spacing.sm }]}>
78
+ <AtomicButton
79
+ title={cancelText}
80
+ onPress={handleCancel}
81
+ variant="secondary"
82
+ style={styles.button}
83
+ />
84
+ <AtomicButton
85
+ title={confirmText}
86
+ onPress={handleConfirm}
87
+ variant="primary"
88
+ style={styles.button}
89
+ />
90
+ </View>
91
+ </View>
92
+ </BaseModal>
93
+ );
94
+ };
95
+
96
+ const styles = StyleSheet.create({
97
+ container: {
98
+ width: '100%',
99
+ },
100
+ buttons: {
101
+ flexDirection: 'row',
102
+ },
103
+ button: {
104
+ flex: 1,
105
+ },
106
+ });
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Password Prompt Hook
3
+ * Manages password prompt modal state and logic
4
+ */
5
+
6
+ import React, { useState, useCallback, useMemo } from 'react';
7
+ import { PasswordPromptModal } from '../components/PasswordPromptModal';
8
+
9
+ export interface UsePasswordPromptOptions {
10
+ title?: string;
11
+ message?: string;
12
+ confirmText?: string;
13
+ cancelText?: string;
14
+ }
15
+
16
+ export interface UsePasswordPromptReturn {
17
+ showPasswordPrompt: () => Promise<string | null>;
18
+ PasswordPromptComponent: React.ReactNode;
19
+ }
20
+
21
+ export const usePasswordPrompt = (options: UsePasswordPromptOptions = {}): UsePasswordPromptReturn => {
22
+ const [isVisible, setIsVisible] = useState(false);
23
+ const [resolvePromise, setResolvePromise] = useState<((value: string | null) => void) | null>(null);
24
+
25
+ const showPasswordPrompt = useCallback((): Promise<string | null> => {
26
+ return new Promise((resolve) => {
27
+ setResolvePromise(() => resolve);
28
+ setIsVisible(true);
29
+ });
30
+ }, []);
31
+
32
+ const handleConfirm = useCallback((password: string) => {
33
+ if (resolvePromise) {
34
+ resolvePromise(password);
35
+ }
36
+ setIsVisible(false);
37
+ setResolvePromise(null);
38
+ }, [resolvePromise]);
39
+
40
+ const handleCancel = useCallback(() => {
41
+ if (resolvePromise) {
42
+ resolvePromise(null);
43
+ }
44
+ setIsVisible(false);
45
+ setResolvePromise(null);
46
+ }, [resolvePromise]);
47
+
48
+ const PasswordPromptComponent = useMemo(() => (
49
+ <PasswordPromptModal
50
+ visible={isVisible}
51
+ onConfirm={handleConfirm}
52
+ onCancel={handleCancel}
53
+ title={options.title}
54
+ message={options.message}
55
+ confirmText={options.confirmText}
56
+ cancelText={options.cancelText}
57
+ />
58
+ ), [isVisible, handleConfirm, handleCancel, options]);
59
+
60
+ return {
61
+ showPasswordPrompt,
62
+ PasswordPromptComponent,
63
+ };
64
+ };