@umituz/react-native-settings 4.23.24 → 4.23.26

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.24",
3
+ "version": "4.23.26",
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",
package/src/index.ts CHANGED
@@ -59,6 +59,7 @@ export type {
59
59
  UserProfileConfig,
60
60
  AdditionalScreen,
61
61
  FAQData,
62
+ AccountConfig,
62
63
  } from './presentation/navigation/types';
63
64
 
64
65
  // =============================================================================
@@ -31,11 +31,15 @@ export const ProfileSectionLoader: React.FC<ProfileSectionLoaderProps> = ({ user
31
31
  }
32
32
  };
33
33
 
34
+ const anonymousDisplayName = userProfile.isAnonymous && userProfile.userId
35
+ ? `${t("profile.guest", "Guest")} ${userProfile.userId.substring(0, 8)}`
36
+ : t("settings.profile.anonymousName", "Anonymous User");
37
+
34
38
  return (
35
39
  <View style={styles.profileContainer}>
36
40
  <ProfileSection
37
41
  profile={{
38
- displayName: userProfile.displayName || "",
42
+ displayName: userProfile.displayName || anonymousDisplayName,
39
43
  userId: userProfile.userId,
40
44
  isAnonymous: userProfile.isAnonymous ?? true,
41
45
  avatarUrl: userProfile.avatarUrl,
@@ -44,8 +48,8 @@ export const ProfileSectionLoader: React.FC<ProfileSectionLoaderProps> = ({ user
44
48
  }}
45
49
  onPress={handlePress}
46
50
  onSignIn={userProfile.onPress}
47
- signInText={t("auth.signIn")}
48
- anonymousText={t("settings.profile.anonymousName")}
51
+ signInText={t("auth.signIn", "Sign In")}
52
+ anonymousText={anonymousDisplayName}
49
53
  />
50
54
  </View>
51
55
  );
@@ -8,32 +8,22 @@ import type { NormalizedConfig } from "../utils/normalizeConfig";
8
8
 
9
9
 
10
10
  /**
11
- * Check if navigation screen exists
11
+ * Check if navigation screen exists or is likely available
12
12
  */
13
- function hasNavigationScreen(
13
+ function isFeatureAvailable(
14
14
  navigation: any,
15
- screenName: string,
15
+ route?: string,
16
+ onPress?: any
16
17
  ): boolean {
17
- try {
18
- const state = navigation.getState();
19
- if (!state) return false;
20
-
21
- const checkRoutes = (routes: any[]): boolean => {
22
- if (!routes || !Array.isArray(routes)) return false;
23
-
24
- for (const route of routes) {
25
- if (route.name === screenName) return true;
26
- if (route.state?.routes && checkRoutes(route.state.routes)) {
27
- return true;
28
- }
29
- }
30
- return false;
31
- };
32
-
33
- return checkRoutes(state.routes || []);
34
- } catch {
35
- return false;
36
- }
18
+ // If we have an onPress, it's definitely available
19
+ if (onPress) return true;
20
+
21
+ // If we have a navigation and a route, we assume it's available
22
+ // since most apps won't provide a route that doesn't exist.
23
+ // The previous getState check was unreliable.
24
+ if (navigation && route) return true;
25
+
26
+ return false;
37
27
  }
38
28
 
39
29
  /**
@@ -70,44 +60,56 @@ export function useFeatureDetection(
70
60
  appearance.enabled &&
71
61
  (appearance.config?.enabled === true ||
72
62
  (appearance.config?.enabled !== false &&
73
- hasNavigationScreen(
63
+ isFeatureAvailable(
74
64
  navigation,
75
65
  appearance.config?.route || "Appearance",
66
+ appearance.config?.onPress,
76
67
  ))),
77
68
  language:
78
69
  language.enabled &&
79
70
  (language.config?.enabled === true ||
80
71
  (language.config?.enabled !== false &&
81
- hasNavigationScreen(
72
+ isFeatureAvailable(
82
73
  navigation,
83
74
  language.config?.route || "LanguageSelection",
75
+ language.config?.onPress,
84
76
  ))),
85
77
  notifications:
86
78
  notifications.enabled &&
87
79
  (notifications.config?.enabled === true ||
88
80
  (notifications.config?.enabled !== false &&
89
- notificationServiceAvailable &&
90
- hasNavigationScreen(
91
- navigation,
92
- notifications.config?.route || "Notifications",
93
- ))),
81
+ (notificationServiceAvailable ||
82
+ isFeatureAvailable(
83
+ navigation,
84
+ notifications.config?.route || "Notifications",
85
+ notifications.config?.onPress,
86
+ )))),
94
87
  about:
95
88
  about.enabled &&
96
89
  (about.config?.enabled === true ||
97
90
  (about.config?.enabled !== false &&
98
- hasNavigationScreen(navigation, about.config?.route || "About"))),
91
+ isFeatureAvailable(
92
+ navigation,
93
+ about.config?.route || "About",
94
+ about.config?.onPress,
95
+ ))),
99
96
  legal:
100
97
  legal.enabled &&
101
98
  (legal.config?.enabled === true ||
102
99
  (legal.config?.enabled !== false &&
103
- hasNavigationScreen(navigation, legal.config?.route || "Legal"))),
100
+ isFeatureAvailable(
101
+ navigation,
102
+ legal.config?.route || "Legal",
103
+ legal.config?.onPress,
104
+ ))),
104
105
  disclaimer:
105
106
  disclaimer.enabled &&
106
107
  (disclaimer.config?.enabled === true ||
107
108
  (disclaimer.config?.enabled !== false &&
108
- hasNavigationScreen(
109
+ isFeatureAvailable(
109
110
  navigation,
110
111
  disclaimer.config?.route || "Disclaimer",
112
+ disclaimer.config?.onPress,
111
113
  ))),
112
114
  userProfile: userProfile.enabled,
113
115
  feedback: feedback.enabled,
@@ -117,6 +119,6 @@ export function useFeatureDetection(
117
119
  wallet: wallet.enabled,
118
120
  gamification: gamification.enabled,
119
121
  };
120
- }, [normalizedConfig, navigation, options]);
122
+ }, [normalizedConfig, navigation, options, notificationServiceAvailable]);
121
123
  }
122
124
 
@@ -84,19 +84,20 @@ function normalizeConfigValue<T>(
84
84
  defaultValue: FeatureVisibility,
85
85
  ): { enabled: boolean; config?: T } {
86
86
  if (value === undefined) {
87
- return { enabled: defaultValue === true };
87
+ return { enabled: defaultValue === true || defaultValue === "auto" };
88
88
  }
89
89
 
90
90
  if (typeof value === "boolean" || value === "auto") {
91
- return { enabled: value === true };
91
+ return { enabled: value === true || value === "auto" };
92
92
  }
93
93
 
94
94
  // It's a config object
95
95
  const config = value as T;
96
- const enabled =
97
- (config as { enabled?: FeatureVisibility })?.enabled ?? defaultValue;
96
+ const enabledValue = (config as { enabled?: FeatureVisibility })?.enabled;
97
+ const enabled = enabledValue !== undefined ? enabledValue : defaultValue;
98
+
98
99
  return {
99
- enabled: enabled === true,
100
+ enabled: enabled === true || enabled === "auto",
100
101
  config,
101
102
  };
102
103
  }