@umituz/react-native-settings 4.23.40 → 4.23.42
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.23.
|
|
3
|
+
"version": "4.23.42",
|
|
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",
|
|
@@ -38,24 +38,25 @@
|
|
|
38
38
|
"url": "https://github.com/umituz/react-native-settings"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@umituz/react-native-design-system": "
|
|
41
|
+
"@umituz/react-native-design-system": "4.23.44",
|
|
42
|
+
"@umituz/react-native-localization": "^3.7.24",
|
|
42
43
|
"firebase": "^12.7.0"
|
|
43
44
|
},
|
|
44
45
|
"peerDependencies": {
|
|
45
46
|
"@expo/vector-icons": ">=14.0.0",
|
|
46
47
|
"@react-native-async-storage/async-storage": ">=2.0.0",
|
|
48
|
+
"@react-native-community/datetimepicker": ">=8.0.0",
|
|
47
49
|
"@react-navigation/native": ">=6.0.0",
|
|
48
50
|
"@react-navigation/stack": ">=6.0.0",
|
|
49
51
|
"@tanstack/react-query": ">=5.0.0",
|
|
50
|
-
"expo-notifications": ">=0.28.0",
|
|
51
52
|
"expo-device": ">=6.0.0",
|
|
52
53
|
"expo-haptics": ">=15.0.0",
|
|
53
54
|
"expo-localization": ">=16.0.0",
|
|
55
|
+
"expo-notifications": ">=0.28.0",
|
|
54
56
|
"expo-store-review": ">=14.0.0",
|
|
55
57
|
"i18next": ">=23.0.0",
|
|
56
|
-
"react-i18next": ">=15.0.0",
|
|
57
|
-
"@react-native-community/datetimepicker": ">=8.0.0",
|
|
58
58
|
"react": ">=19.0.0",
|
|
59
|
+
"react-i18next": ">=15.0.0",
|
|
59
60
|
"react-native": ">=0.81.0",
|
|
60
61
|
"react-native-safe-area-context": ">=4.0.0",
|
|
61
62
|
"zustand": ">=4.0.0"
|
|
@@ -75,8 +76,8 @@
|
|
|
75
76
|
"@types/react": "~19.1.10",
|
|
76
77
|
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
|
77
78
|
"@typescript-eslint/parser": "^7.18.0",
|
|
78
|
-
"@umituz/react-native-auth": "
|
|
79
|
-
"@umituz/react-native-firebase": "
|
|
79
|
+
"@umituz/react-native-auth": "^3.6.49",
|
|
80
|
+
"@umituz/react-native-firebase": "^1.13.102",
|
|
80
81
|
"@umituz/react-native-sentry": "*",
|
|
81
82
|
"eslint": "^8.57.0",
|
|
82
83
|
"eslint-plugin-react": "^7.37.5",
|
|
@@ -84,21 +85,22 @@
|
|
|
84
85
|
"expo-apple-authentication": "^8.0.8",
|
|
85
86
|
"expo-auth-session": "^5.0.0",
|
|
86
87
|
"expo-clipboard": "^8.0.8",
|
|
88
|
+
"expo-crypto": "^15.0.8",
|
|
87
89
|
"expo-device": "~7.0.0",
|
|
88
90
|
"expo-file-system": "^19.0.21",
|
|
89
|
-
"expo-haptics": "~14.0.0",
|
|
90
|
-
"expo-linear-gradient": "^15.0.2",
|
|
91
|
-
"expo-crypto": "^15.0.8",
|
|
92
91
|
"expo-font": "^14.0.10",
|
|
92
|
+
"expo-haptics": "~14.0.0",
|
|
93
93
|
"expo-image": "^3.0.11",
|
|
94
94
|
"expo-image-manipulator": "^14.0.8",
|
|
95
95
|
"expo-image-picker": "^17.0.10",
|
|
96
|
+
"expo-linear-gradient": "^15.0.2",
|
|
96
97
|
"expo-localization": "^17.0.8",
|
|
97
98
|
"expo-media-library": "^18.2.1",
|
|
99
|
+
"expo-modules-core": "^3.0.29",
|
|
98
100
|
"expo-network": "^8.0.8",
|
|
99
|
-
"expo-sharing": "^14.0.8",
|
|
100
101
|
"expo-notifications": "~0.27.6",
|
|
101
102
|
"expo-secure-store": "^15.0.8",
|
|
103
|
+
"expo-sharing": "^14.0.8",
|
|
102
104
|
"expo-store-review": "^8.0.0",
|
|
103
105
|
"expo-video": "^3.0.15",
|
|
104
106
|
"expo-web-browser": "^12.0.0",
|
|
@@ -110,7 +112,6 @@
|
|
|
110
112
|
"react-native-gesture-handler": "^2.30.0",
|
|
111
113
|
"react-native-reanimated": "^4.2.1",
|
|
112
114
|
"react-native-safe-area-context": "^5.6.2",
|
|
113
|
-
"expo-modules-core": "^3.0.29",
|
|
114
115
|
"react-native-svg": "^15.15.1",
|
|
115
116
|
"rn-emoji-keyboard": "^1.7.0",
|
|
116
117
|
"typescript": "^5.3.0",
|
package/src/index.ts
CHANGED
|
@@ -37,6 +37,12 @@ export {
|
|
|
37
37
|
useResetSettingsMutation
|
|
38
38
|
} from './presentation/hooks/mutations/useSettingsMutations';
|
|
39
39
|
|
|
40
|
+
export { useSettingsScreenConfig } from './presentation/hooks/useSettingsScreenConfig';
|
|
41
|
+
export type {
|
|
42
|
+
UseSettingsScreenConfigParams,
|
|
43
|
+
SettingsScreenConfigResult,
|
|
44
|
+
} from './presentation/hooks/useSettingsScreenConfig';
|
|
45
|
+
|
|
40
46
|
|
|
41
47
|
// =============================================================================
|
|
42
48
|
// PRESENTATION LAYER - Screens
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useSettingsScreenConfig Hook
|
|
3
|
+
*
|
|
4
|
+
* One-stop hook for settings screen configuration.
|
|
5
|
+
* Handles auth, feedback, and all settings config internally.
|
|
6
|
+
* Apps pass subscription config from subscription package.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { useMemo, useCallback } from "react";
|
|
10
|
+
import { Linking } from "react-native";
|
|
11
|
+
import {
|
|
12
|
+
useAuth,
|
|
13
|
+
useAccountManagement,
|
|
14
|
+
useAuthModalStore,
|
|
15
|
+
useUserProfile,
|
|
16
|
+
} from "@umituz/react-native-auth";
|
|
17
|
+
import { AlertService } from "@umituz/react-native-design-system";
|
|
18
|
+
import { useLocalization } from "../../domains/localization";
|
|
19
|
+
import {
|
|
20
|
+
createAppearanceConfig,
|
|
21
|
+
createLanguageConfig,
|
|
22
|
+
createNotificationsConfig,
|
|
23
|
+
createAboutConfig,
|
|
24
|
+
createLegalConfig,
|
|
25
|
+
createFeedbackConfig,
|
|
26
|
+
createRatingConfig,
|
|
27
|
+
createFAQConfig,
|
|
28
|
+
createSubscriptionConfig,
|
|
29
|
+
} from "../utils/config-creators";
|
|
30
|
+
import type { SettingsConfig } from "../screens/types";
|
|
31
|
+
import type { FeedbackFormData } from "../utils/config-creators";
|
|
32
|
+
import type { AppInfo, FAQData, UserProfileConfig, AdditionalScreen } from "../navigation/types";
|
|
33
|
+
import type { AccountScreenConfig } from "@umituz/react-native-auth";
|
|
34
|
+
|
|
35
|
+
export interface UseSettingsScreenConfigParams {
|
|
36
|
+
appInfo: AppInfo;
|
|
37
|
+
faqData?: FAQData;
|
|
38
|
+
isPremium: boolean;
|
|
39
|
+
onFeedbackSubmit: (data: FeedbackFormData) => Promise<void>;
|
|
40
|
+
additionalScreens?: AdditionalScreen[];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface SettingsScreenConfigResult {
|
|
44
|
+
settingsConfig: SettingsConfig;
|
|
45
|
+
userProfile: UserProfileConfig;
|
|
46
|
+
accountConfig: AccountScreenConfig;
|
|
47
|
+
translatedFaqData: FAQData | undefined;
|
|
48
|
+
isLoading: boolean;
|
|
49
|
+
isAuthReady: boolean;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export const useSettingsScreenConfig = (
|
|
53
|
+
params: UseSettingsScreenConfigParams
|
|
54
|
+
): SettingsScreenConfigResult => {
|
|
55
|
+
const { appInfo, faqData, isPremium, onFeedbackSubmit } = params;
|
|
56
|
+
|
|
57
|
+
const { t } = useLocalization();
|
|
58
|
+
const { user, loading, isAuthReady, signOut } = useAuth();
|
|
59
|
+
const { deleteAccount } = useAccountManagement();
|
|
60
|
+
const userProfileData = useUserProfile({});
|
|
61
|
+
const { showAuthModal } = useAuthModalStore();
|
|
62
|
+
|
|
63
|
+
const handleRatePress = useCallback(async () => {
|
|
64
|
+
const url = appInfo.appStoreUrl;
|
|
65
|
+
if (url && (await Linking.canOpenURL(url))) {
|
|
66
|
+
await Linking.openURL(url);
|
|
67
|
+
}
|
|
68
|
+
}, [appInfo.appStoreUrl]);
|
|
69
|
+
|
|
70
|
+
const handleSignOut = useCallback(async () => {
|
|
71
|
+
try {
|
|
72
|
+
await signOut();
|
|
73
|
+
} catch {
|
|
74
|
+
AlertService.createErrorAlert(t("common.error"), t("auth.errors.unknownError"));
|
|
75
|
+
}
|
|
76
|
+
}, [signOut, t]);
|
|
77
|
+
|
|
78
|
+
const handleDeleteAccount = useCallback(async () => {
|
|
79
|
+
try {
|
|
80
|
+
await deleteAccount();
|
|
81
|
+
} catch {
|
|
82
|
+
AlertService.createErrorAlert(t("common.error"), t("settings.account.deleteError"));
|
|
83
|
+
}
|
|
84
|
+
}, [deleteAccount, t]);
|
|
85
|
+
|
|
86
|
+
const handleSignIn = useCallback(() => {
|
|
87
|
+
showAuthModal(() => {}, "login");
|
|
88
|
+
}, [showAuthModal]);
|
|
89
|
+
|
|
90
|
+
const settingsConfig = useMemo((): SettingsConfig => ({
|
|
91
|
+
appearance: createAppearanceConfig(t),
|
|
92
|
+
language: createLanguageConfig(t),
|
|
93
|
+
notifications: createNotificationsConfig(t),
|
|
94
|
+
feedback: createFeedbackConfig(t, onFeedbackSubmit),
|
|
95
|
+
about: createAboutConfig(t),
|
|
96
|
+
legal: createLegalConfig(t),
|
|
97
|
+
faqs: createFAQConfig(t),
|
|
98
|
+
rating: createRatingConfig(t, handleRatePress, appInfo.appStoreUrl || ""),
|
|
99
|
+
subscription: createSubscriptionConfig(t, isPremium, "SubscriptionDetail"),
|
|
100
|
+
disclaimer: false,
|
|
101
|
+
}), [t, onFeedbackSubmit, handleRatePress, appInfo.appStoreUrl, isPremium]);
|
|
102
|
+
|
|
103
|
+
const userProfile = useMemo((): UserProfileConfig => {
|
|
104
|
+
const isAnonymous = userProfileData?.isAnonymous ?? true;
|
|
105
|
+
return {
|
|
106
|
+
displayName: userProfileData?.displayName || t("settings.profile.anonymousName"),
|
|
107
|
+
userId: userProfileData?.userId,
|
|
108
|
+
isAnonymous,
|
|
109
|
+
avatarUrl: userProfileData?.avatarUrl,
|
|
110
|
+
onPress: isAnonymous ? handleSignIn : undefined,
|
|
111
|
+
accountSettingsRoute: isAnonymous ? undefined : "Account",
|
|
112
|
+
};
|
|
113
|
+
}, [userProfileData, t, handleSignIn]);
|
|
114
|
+
|
|
115
|
+
const accountConfig = useMemo((): AccountScreenConfig => {
|
|
116
|
+
const isAnonymous = user?.isAnonymous ?? true;
|
|
117
|
+
return {
|
|
118
|
+
profile: {
|
|
119
|
+
displayName: userProfileData?.displayName || user?.displayName || t("settings.profile.anonymousName"),
|
|
120
|
+
userId: userProfileData?.userId || user?.uid,
|
|
121
|
+
isAnonymous,
|
|
122
|
+
avatarUrl: userProfileData?.avatarUrl || user?.photoURL || undefined,
|
|
123
|
+
benefits: isAnonymous ? [
|
|
124
|
+
t("settings.profile.benefits.freeCredits"),
|
|
125
|
+
t("settings.profile.benefits.saveHistory"),
|
|
126
|
+
t("settings.profile.benefits.syncDevices"),
|
|
127
|
+
t("settings.profile.benefits.cloudSync"),
|
|
128
|
+
t("settings.profile.benefits.secureBackup"),
|
|
129
|
+
] : undefined,
|
|
130
|
+
},
|
|
131
|
+
isAnonymous,
|
|
132
|
+
editProfileText: t("settings.account.editProfile"),
|
|
133
|
+
onSignIn: handleSignIn,
|
|
134
|
+
accountActions: {
|
|
135
|
+
onLogout: handleSignOut,
|
|
136
|
+
onDeleteAccount: handleDeleteAccount,
|
|
137
|
+
logoutText: t("settings.account.logout"),
|
|
138
|
+
logoutConfirmTitle: t("settings.account.logoutConfirmTitle"),
|
|
139
|
+
logoutConfirmMessage: t("settings.account.logoutConfirmMessage"),
|
|
140
|
+
cancelText: t("common.cancel"),
|
|
141
|
+
deleteAccountText: t("settings.account.deleteAccount"),
|
|
142
|
+
deleteConfirmTitle: t("settings.account.deleteConfirmTitle"),
|
|
143
|
+
deleteConfirmMessage: t("settings.account.deleteConfirmMessage"),
|
|
144
|
+
},
|
|
145
|
+
};
|
|
146
|
+
}, [user, userProfileData, handleSignIn, handleSignOut, handleDeleteAccount, t]);
|
|
147
|
+
|
|
148
|
+
const translatedFaqData = useMemo((): FAQData | undefined => {
|
|
149
|
+
if (!faqData) return undefined;
|
|
150
|
+
return {
|
|
151
|
+
categories: faqData.categories.map((category) => ({
|
|
152
|
+
id: category.id,
|
|
153
|
+
title: t(category.title),
|
|
154
|
+
items: category.items.map((item) => ({
|
|
155
|
+
id: item.id,
|
|
156
|
+
question: t(item.question, { appName: appInfo.name }),
|
|
157
|
+
answer: t(item.answer, { appName: appInfo.name }),
|
|
158
|
+
})),
|
|
159
|
+
})),
|
|
160
|
+
};
|
|
161
|
+
}, [faqData, t, appInfo.name]);
|
|
162
|
+
|
|
163
|
+
return {
|
|
164
|
+
settingsConfig,
|
|
165
|
+
userProfile,
|
|
166
|
+
accountConfig,
|
|
167
|
+
translatedFaqData,
|
|
168
|
+
isLoading: loading,
|
|
169
|
+
isAuthReady,
|
|
170
|
+
};
|
|
171
|
+
};
|