@umituz/react-native-settings 4.23.53 → 4.23.55

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.53",
3
+ "version": "4.23.55",
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,7 +38,6 @@
38
38
  "url": "https://github.com/umituz/react-native-settings"
39
39
  },
40
40
  "dependencies": {
41
- "@umituz/react-native-localization": "^3.7.24",
42
41
  "firebase": "^12.7.0"
43
42
  },
44
43
  "peerDependencies": {
@@ -1,3 +1,6 @@
1
+ // Providers
2
+ export { LocalizationProvider } from './presentation/providers/LocalizationProvider';
3
+
1
4
  // Hooks
2
5
  export { useLocalization } from './infrastructure/hooks/useLocalization';
3
6
  export { useLocalizationStore } from './infrastructure/storage/LocalizationStore';
@@ -0,0 +1,39 @@
1
+ /**
2
+ * LocalizationProvider
3
+ * Initializes i18n with app translations and manages language state
4
+ */
5
+
6
+ import React, { useEffect, useState } from "react";
7
+ import { I18nInitializer } from "../../infrastructure/config/I18nInitializer";
8
+ import { useLocalizationStore } from "../../infrastructure/storage/LocalizationStore";
9
+
10
+ interface LocalizationProviderProps {
11
+ children: React.ReactNode;
12
+ translations: Record<string, Record<string, unknown>>;
13
+ defaultLanguage?: string;
14
+ }
15
+
16
+ export const LocalizationProvider: React.FC<LocalizationProviderProps> = ({
17
+ children,
18
+ translations,
19
+ defaultLanguage = "en-US",
20
+ }) => {
21
+ const [isI18nReady, setIsI18nReady] = useState(false);
22
+ const initialize = useLocalizationStore((state) => state.initialize);
23
+
24
+ useEffect(() => {
25
+ const initializeLocalization = async () => {
26
+ I18nInitializer.initialize(translations, defaultLanguage);
27
+ await initialize();
28
+ setIsI18nReady(true);
29
+ };
30
+
31
+ initializeLocalization();
32
+ }, [translations, defaultLanguage, initialize]);
33
+
34
+ if (!isI18nReady) {
35
+ return null;
36
+ }
37
+
38
+ return <>{children}</>;
39
+ };
package/src/index.ts CHANGED
@@ -41,6 +41,7 @@ export { useSettingsScreenConfig } from './presentation/hooks/useSettingsScreenC
41
41
  export type {
42
42
  UseSettingsScreenConfigParams,
43
43
  SettingsScreenConfigResult,
44
+ SettingsFeatures,
44
45
  } from './presentation/hooks/useSettingsScreenConfig';
45
46
 
46
47
 
@@ -32,12 +32,24 @@ import type { FeedbackFormData } from "../utils/config-creators";
32
32
  import type { AppInfo, FAQData, UserProfileConfig, AdditionalScreen } from "../navigation/types";
33
33
  import type { AccountScreenConfig } from "@umituz/react-native-auth";
34
34
 
35
+ export interface SettingsFeatures {
36
+ notifications?: boolean;
37
+ appearance?: boolean;
38
+ language?: boolean;
39
+ feedback?: boolean;
40
+ rating?: boolean;
41
+ faqs?: boolean;
42
+ about?: boolean;
43
+ legal?: boolean;
44
+ }
45
+
35
46
  export interface UseSettingsScreenConfigParams {
36
47
  appInfo: AppInfo;
37
48
  faqData?: FAQData;
38
49
  isPremium: boolean;
39
50
  onFeedbackSubmit: (data: FeedbackFormData) => Promise<void>;
40
51
  additionalScreens?: AdditionalScreen[];
52
+ features?: SettingsFeatures;
41
53
  }
42
54
 
43
55
  export interface SettingsScreenConfigResult {
@@ -52,7 +64,18 @@ export interface SettingsScreenConfigResult {
52
64
  export const useSettingsScreenConfig = (
53
65
  params: UseSettingsScreenConfigParams
54
66
  ): SettingsScreenConfigResult => {
55
- const { appInfo, faqData, isPremium, onFeedbackSubmit } = params;
67
+ const { appInfo, faqData, isPremium, onFeedbackSubmit, features = {} } = params;
68
+
69
+ const {
70
+ notifications: showNotifications = true,
71
+ appearance: showAppearance = true,
72
+ language: showLanguage = true,
73
+ feedback: showFeedback = true,
74
+ rating: showRating = true,
75
+ faqs: showFaqs = true,
76
+ about: showAbout = true,
77
+ legal: showLegal = true,
78
+ } = features;
56
79
 
57
80
  const { t } = useLocalization();
58
81
  const { user, loading, isAuthReady, signOut } = useAuth();
@@ -88,17 +111,21 @@ export const useSettingsScreenConfig = (
88
111
  }, [showAuthModal]);
89
112
 
90
113
  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 || ""),
114
+ appearance: showAppearance ? createAppearanceConfig(t) : false,
115
+ language: showLanguage ? createLanguageConfig(t) : false,
116
+ notifications: showNotifications ? createNotificationsConfig(t) : false,
117
+ feedback: showFeedback ? createFeedbackConfig(t, onFeedbackSubmit) : false,
118
+ about: showAbout ? createAboutConfig(t) : false,
119
+ legal: showLegal ? createLegalConfig(t) : false,
120
+ faqs: showFaqs ? createFAQConfig(t) : false,
121
+ rating: showRating ? createRatingConfig(t, handleRatePress, appInfo.appStoreUrl || "") : false,
99
122
  subscription: createSubscriptionConfig(t, isPremium, "SubscriptionDetail"),
100
123
  disclaimer: false,
101
- }), [t, onFeedbackSubmit, handleRatePress, appInfo.appStoreUrl, isPremium]);
124
+ }), [
125
+ t, onFeedbackSubmit, handleRatePress, appInfo.appStoreUrl, isPremium,
126
+ showAppearance, showLanguage, showNotifications, showFeedback,
127
+ showAbout, showLegal, showFaqs, showRating,
128
+ ]);
102
129
 
103
130
  const userProfile = useMemo((): UserProfileConfig => {
104
131
  const isAnonymous = userProfileData?.isAnonymous ?? true;