@umituz/react-native-settings 5.2.5 → 5.2.7

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-settings",
3
- "version": "5.2.5",
3
+ "version": "5.2.7",
4
4
  "description": "Complete settings hub for React Native apps - consolidated package with settings, localization, about, legal, appearance, feedback, FAQs, rating, and gamification",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -7,10 +7,9 @@
7
7
  */
8
8
 
9
9
  import { useMemo } from "react";
10
- import { useAuth, useUserProfile } from "@umituz/react-native-auth";
10
+ import { useAuth, useUserProfile, useAuthHandlers } from "@umituz/react-native-auth";
11
11
  import { createUserProfileDisplay } from "../utils/userProfileUtils";
12
12
  import { createAccountConfig } from "../utils/accountConfigUtils";
13
- import { useAuthHandlers } from "../utils/useAuthHandlers";
14
13
  import { translateFAQData } from "../utils/faqTranslator";
15
14
  import { useSettingsConfigFactory } from "../utils/settingsConfigFactory";
16
15
  import type { SettingsConfig, SettingsTranslations } from "../screens/types";
@@ -3,7 +3,6 @@ import type { StackScreen } from "@umituz/react-native-design-system";
3
3
  import { LanguageSelectionScreen } from "../../../domains/localization";
4
4
  import { NotificationSettingsScreen } from "../../../domains/notifications";
5
5
  import { AccountScreen } from "@umituz/react-native-auth";
6
- import { PasswordPromptScreen } from "@umituz/react-native-firebase";
7
6
  import { SettingsScreen } from "../../screens/SettingsScreen";
8
7
  import { AppearanceScreen } from "../../screens/AppearanceScreen";
9
8
  import { FAQScreen } from "../../../domains/faqs";
@@ -129,12 +128,6 @@ export const useSettingsScreens = (props: UseSettingsScreensProps): StackScreen[
129
128
  title: videoTutorialConfig?.title || translations?.videoTutorial?.title || "",
130
129
  });
131
130
 
132
- const passwordPromptScreen: StackScreen = {
133
- name: "PasswordPrompt",
134
- component: PasswordPromptScreen as any,
135
- options: { headerShown: false },
136
- };
137
-
138
131
  return combineScreens(
139
132
  baseScreens,
140
133
  faqScreen,
@@ -142,8 +135,7 @@ export const useSettingsScreens = (props: UseSettingsScreensProps): StackScreen[
142
135
  gamificationScreen,
143
136
  languageScreen,
144
137
  accountScreen,
145
- videoTutorialScreen,
146
- passwordPromptScreen
138
+ videoTutorialScreen
147
139
  );
148
140
  }, [
149
141
  translations,
@@ -7,4 +7,3 @@ export * from "./userProfileUtils";
7
7
  export * from "./accountConfigUtils";
8
8
  export * from "./faqTranslator";
9
9
  export * from "./settingsConfigFactory";
10
- export * from "./useAuthHandlers";
@@ -1,100 +0,0 @@
1
- /**
2
- * Auth Handlers Hook
3
- * Centralized authentication-related handlers for settings screen
4
- * Uses auth package for all auth operations - no duplication
5
- */
6
-
7
- import { useCallback } from "react";
8
- import { Linking, Alert } from "react-native";
9
- import {
10
- useAuth,
11
- useAuthModalStore,
12
- useAccountManagement,
13
- } from "@umituz/react-native-auth";
14
- import { AlertService } from "@umituz/react-native-design-system";
15
- import type { AppInfo } from "../navigation/types";
16
- import type { SettingsTranslations } from "../screens/types";
17
- import { usePasswordPromptNavigation } from "./usePasswordPromptNavigation";
18
-
19
- declare const __DEV__: boolean;
20
-
21
- /**
22
- * Hook that provides authentication-related handlers
23
- */
24
- export const useAuthHandlers = (appInfo: AppInfo, translations?: SettingsTranslations["account"] & SettingsTranslations["errors"]) => {
25
- const { signOut } = useAuth();
26
- const { showAuthModal } = useAuthModalStore();
27
-
28
- const { showPasswordPrompt } = usePasswordPromptNavigation({
29
- title: translations?.deleteAccountTitle || "Confirm Account Deletion",
30
- message: translations?.deleteAccountMessage || "Please enter your password to permanently delete your account. This action cannot be undone.",
31
- cancelText: translations?.cancel || "Cancel",
32
- confirmText: translations?.delete || "Delete",
33
- });
34
-
35
- const { deleteAccount: deleteAccountFromAuth } = useAccountManagement({
36
- onPasswordRequired: showPasswordPrompt,
37
- });
38
-
39
- const handleRatePress = useCallback(async () => {
40
- const url = appInfo.appStoreUrl;
41
- if (!url) {
42
- Alert.alert(translations?.common || "", translations?.appStoreUrlNotConfigured || "");
43
- return;
44
- }
45
-
46
- try {
47
- const canOpen = await Linking.canOpenURL(url);
48
- if (!canOpen) {
49
- Alert.alert(
50
- translations?.common || "",
51
- translations?.unableToOpenAppStore || ""
52
- );
53
- return;
54
- }
55
- await Linking.openURL(url);
56
- } catch (error) {
57
- if (typeof __DEV__ !== "undefined" && __DEV__) {
58
- console.error("[useAuthHandlers] Failed to open app store:", error);
59
- }
60
- Alert.alert(translations?.common || "", translations?.failedToOpenAppStore || "");
61
- }
62
- }, [appInfo.appStoreUrl, translations]);
63
-
64
- const handleSignOut = useCallback(async () => {
65
- try {
66
- await signOut();
67
- } catch (error) {
68
- if (typeof __DEV__ !== "undefined" && __DEV__) {
69
- console.error("[useAuthHandlers] Sign out failed:", error);
70
- }
71
- AlertService.createErrorAlert(
72
- translations?.common || "",
73
- translations?.unknown || ""
74
- );
75
- }
76
- }, [signOut, translations]);
77
-
78
- const handleDeleteAccount = useCallback(async () => {
79
- try {
80
- await deleteAccountFromAuth();
81
- } catch (error) {
82
- const errorMessage = error instanceof Error ? error.message : String(error);
83
- AlertService.createErrorAlert(
84
- translations?.common || "Error",
85
- errorMessage || translations?.deleteAccountError || "Failed to delete account"
86
- );
87
- }
88
- }, [deleteAccountFromAuth, translations]);
89
-
90
- const handleSignIn = useCallback(() => {
91
- showAuthModal(undefined, "login");
92
- }, [showAuthModal]);
93
-
94
- return {
95
- handleRatePress,
96
- handleSignOut,
97
- handleDeleteAccount,
98
- handleSignIn,
99
- };
100
- };
@@ -1,72 +0,0 @@
1
- /**
2
- * Password Prompt Navigation Hook
3
- * Navigation-based password prompt that maintains Promise interface
4
- * Uses AppNavigation for global navigation access
5
- */
6
-
7
- import { useCallback, useRef, useEffect } from 'react';
8
- import { AppNavigation } from '@umituz/react-native-design-system';
9
-
10
- export interface UsePasswordPromptNavigationOptions {
11
- title?: string;
12
- message?: string;
13
- confirmText?: string;
14
- cancelText?: string;
15
- }
16
-
17
- export interface UsePasswordPromptNavigationReturn {
18
- showPasswordPrompt: () => Promise<string | null>;
19
- }
20
-
21
- export const usePasswordPromptNavigation = (
22
- options: UsePasswordPromptNavigationOptions
23
- ): UsePasswordPromptNavigationReturn => {
24
- const { title, message, confirmText, cancelText } = options;
25
- const resolveRef = useRef<((value: string | null) => void) | null>(null);
26
-
27
- useEffect(() => {
28
- return () => {
29
- if (resolveRef.current) {
30
- resolveRef.current(null);
31
- resolveRef.current = null;
32
- }
33
- };
34
- }, []);
35
-
36
- const showPasswordPrompt = useCallback((): Promise<string | null> => {
37
- return new Promise<string | null>((resolve, reject) => {
38
- if (resolveRef.current) {
39
- resolveRef.current(null);
40
- }
41
-
42
- resolveRef.current = resolve;
43
-
44
- const params = {
45
- onComplete: (password: string | null) => {
46
- if (resolveRef.current) {
47
- resolveRef.current(password);
48
- resolveRef.current = null;
49
- }
50
- },
51
- title,
52
- message,
53
- confirmText,
54
- cancelText,
55
- };
56
-
57
- try {
58
- AppNavigation.navigate('PasswordPrompt', params);
59
- } catch (error) {
60
- if (resolveRef.current) {
61
- resolveRef.current(null);
62
- resolveRef.current = null;
63
- }
64
- reject(error);
65
- }
66
- });
67
- }, [title, message, confirmText, cancelText]);
68
-
69
- return {
70
- showPasswordPrompt,
71
- };
72
- };