@umituz/react-native-settings 4.21.2 → 4.21.3

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": "4.21.2",
3
+ "version": "4.21.3",
4
4
  "description": "Complete settings hub for React Native apps - consolidated package with settings, about, legal, appearance, feedback, FAQs, rating, and gamification",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -5,11 +5,12 @@
5
5
  * Receives appInfo and legalUrls from app.
6
6
  */
7
7
 
8
- import React from "react";
8
+ import React, { useCallback } from "react";
9
9
  import { createStackNavigator } from "@react-navigation/stack";
10
10
  import { useLocalization, LanguageSelectionScreen } from "@umituz/react-native-localization";
11
11
  import { NotificationSettingsScreen } from "@umituz/react-native-notifications";
12
- import { useAppDesignTokens } from "@umituz/react-native-design-system";
12
+ import { AccountScreen, useAuth, useAuthModalStore } from "@umituz/react-native-auth";
13
+ import { useAppDesignTokens, AlertService } from "@umituz/react-native-design-system";
13
14
  import { AppearanceScreen } from "../screens/AppearanceScreen";
14
15
  import { FAQScreen } from "../../domains/faqs";
15
16
  import { useNavigationHandlers } from "./hooks";
@@ -30,6 +31,7 @@ import {
30
31
  createFAQScreenOptions,
31
32
  createLanguageSelectionScreenOptions,
32
33
  createGamificationScreenOptions,
34
+ createAccountScreenOptions,
33
35
  } from "./utils";
34
36
  import type { SettingsStackParamList, SettingsStackNavigatorProps } from "./types";
35
37
  import { GamificationScreenWrapper } from "../../domains/gamification";
@@ -51,9 +53,53 @@ export const SettingsStackNavigator: React.FC<SettingsStackNavigatorProps> = ({
51
53
  }) => {
52
54
  const tokens = useAppDesignTokens();
53
55
  const { t } = useLocalization();
56
+ const { user, deleteAccount, signOut } = useAuth();
57
+ const { showAuthModal } = useAuthModalStore();
54
58
  const { handlePrivacyPress, handleTermsPress, handleEulaPress, aboutConfig } =
55
59
  useNavigationHandlers(appInfo, legalUrls);
56
60
 
61
+ const handleSignOut = useCallback(async () => {
62
+ try {
63
+ await signOut();
64
+ } catch (error) {
65
+ AlertService.createErrorAlert(t("common.error"), t("auth.errors.unknownError"));
66
+ }
67
+ }, [signOut, t]);
68
+
69
+ const handleDeleteAccount = useCallback(async () => {
70
+ try {
71
+ await deleteAccount();
72
+ } catch (error) {
73
+ AlertService.createErrorAlert(t("common.error"), t("account.deleteErrorMessage"));
74
+ }
75
+ }, [deleteAccount, t]);
76
+
77
+ const handleSignIn = useCallback(() => {
78
+ showAuthModal(() => {}, "login");
79
+ }, [showAuthModal]);
80
+
81
+ const isAnonymous = user?.isAnonymous ?? true;
82
+
83
+ const accountConfig = {
84
+ profile: {
85
+ displayName: userProfile?.displayName || user?.displayName || t("settings.profile.anonymousName"),
86
+ userId: userProfile?.userId || user?.uid,
87
+ isAnonymous,
88
+ avatarUrl: userProfile?.avatarUrl || user?.photoURL || undefined,
89
+ },
90
+ isAnonymous,
91
+ editProfileText: t("settings.account.editProfile"),
92
+ onSignIn: handleSignIn,
93
+ accountActions: {
94
+ onSignOut: handleSignOut,
95
+ onDeleteAccount: handleDeleteAccount,
96
+ signOutText: t("auth.signOut"),
97
+ deleteAccountText: t("account.deleteAccount"),
98
+ confirmDeleteTitle: t("auth.deleteAccountConfirmTitle"),
99
+ confirmDeleteMessage: t("auth.deleteAccountConfirmMessage"),
100
+ },
101
+ };
102
+
57
103
  const screenOptions = React.useMemo(() => createScreenOptions(tokens), [tokens]);
58
104
  const notificationTranslations = React.useMemo(() => createNotificationTranslations(t), [t]);
59
105
  const quietHoursTranslations = React.useMemo(() => createQuietHoursTranslations(t), [t]);
@@ -165,6 +211,13 @@ export const SettingsStackNavigator: React.FC<SettingsStackNavigatorProps> = ({
165
211
  />
166
212
  )}
167
213
  </Stack.Screen>
214
+
215
+ <Stack.Screen
216
+ name="Account"
217
+ options={createAccountScreenOptions(t)}
218
+ >
219
+ {() => <AccountScreen config={accountConfig} />}
220
+ </Stack.Screen>
168
221
  </Stack.Navigator>
169
222
  );
170
223
  };
@@ -43,6 +43,7 @@ export type SettingsStackParamList = {
43
43
  FAQ: undefined;
44
44
  LanguageSelection: undefined;
45
45
  Gamification: undefined;
46
+ Account: undefined;
46
47
  };
47
48
 
48
49
  /**
@@ -61,3 +61,9 @@ export const createGamificationScreenOptions = (t: any) => ({
61
61
  headerTitleAlign: "center" as const,
62
62
  });
63
63
 
64
+ export const createAccountScreenOptions = (t: any) => ({
65
+ headerShown: true,
66
+ headerTitle: t("settings.account.title"),
67
+ headerTitleAlign: "center" as const,
68
+ });
69
+