@umituz/react-native-settings 5.3.62 → 5.3.64

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.3.62",
3
+ "version": "5.3.64",
4
4
  "description": "Complete settings hub for React Native apps - consolidated package with settings, localization, about, legal, appearance, feedback, FAQs, rating, and gamification - expo-store-review and expo-device now lazy loaded",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./dist/index.d.ts",
@@ -25,13 +25,6 @@ interface ThemeOptionProps {
25
25
  // Valid theme modes for validation
26
26
  const VALID_THEME_MODES: readonly ThemeMode[] = ["light", "dark", "auto"];
27
27
 
28
- // Icon names mapping for type safety
29
- const THEME_ICONS: Record<ThemeMode, string> = {
30
- light: "sunny-outline",
31
- dark: "moon-outline",
32
- auto: "desktop-outline",
33
- };
34
-
35
28
  // Utility function to add opacity to hex color
36
29
  const addOpacityToHex = (hexColor: string, opacity: string): string => {
37
30
  // Remove # if present
@@ -54,14 +47,6 @@ export const ThemeOption: React.FC<ThemeOptionProps> = React.memo(({
54
47
  // Memoize styles to prevent unnecessary re-creation
55
48
  const styles = useMemo(() => getStyles(tokens), [tokens]);
56
49
 
57
- // Type-safe icon name selection with validation
58
- const iconName: string = useMemo(() => {
59
- if (VALID_THEME_MODES.includes(mode)) {
60
- return THEME_ICONS[mode];
61
- }
62
- // Fallback for invalid mode
63
- return THEME_ICONS.auto;
64
- }, [mode]);
65
50
 
66
51
  return (
67
52
  <TouchableOpacity
@@ -72,9 +57,6 @@ export const ThemeOption: React.FC<ThemeOptionProps> = React.memo(({
72
57
  accessibilityState={{ selected: isSelected }}
73
58
  >
74
59
  <View style={styles.header}>
75
- <View style={styles.iconContainer}>
76
- <AtomicIcon name={iconName} customSize={24} customColor={tokens.colors.primary} />
77
- </View>
78
60
  <View style={styles.textContainer}>
79
61
  <AtomicText type="titleLarge" color="primary">
80
62
  {title}
@@ -149,15 +131,6 @@ const getStyles = (tokens: ReturnType<typeof useAppDesignTokens>) =>
149
131
  alignItems: "center",
150
132
  marginBottom: 12,
151
133
  },
152
- iconContainer: {
153
- width: 48,
154
- height: 48,
155
- borderRadius: 24,
156
- backgroundColor: addOpacityToHex(tokens.colors.primary, "15"),
157
- justifyContent: "center",
158
- alignItems: "center",
159
- marginRight: 12,
160
- },
161
134
  textContainer: {
162
135
  flex: 1,
163
136
  },
@@ -44,12 +44,21 @@ export const useTranslationFunction = () => {
44
44
  ? `${key.substring(0, firstDotIndex)}:${key.substring(firstDotIndex + 1)}`
45
45
  : key;
46
46
 
47
+ // Check if key exists in either format
48
+ const keyToUse = i18n.exists(i18nextKey) ? i18nextKey : key;
49
+
47
50
  // Missing translation is a critical issue — warn in development
48
- if (!i18n.exists(i18nextKey)) {
51
+ if (!i18n.exists(keyToUse)) {
49
52
  devWarn(`[i18n] Missing translation: "${key}"`);
50
53
  }
51
54
 
52
- const result = i18nextT(i18nextKey, options);
55
+ const result = i18nextT(keyToUse, options);
56
+
57
+ // Support returnObjects (for appearance texts etc)
58
+ if (options.returnObjects) {
59
+ return result as any;
60
+ }
61
+
53
62
  return typeof result === 'string' ? result : (options.defaultValue ?? key);
54
63
  }, [i18nextT, ready]);
55
64
 
@@ -42,19 +42,20 @@ export const LanguageItem: React.FC<LanguageItemProps> = ({
42
42
  const themedStyles = useMemo(() => ({
43
43
  languageItem: {
44
44
  padding: tokens.spacing.md,
45
- borderRadius: tokens.borders.radius.md,
46
- backgroundColor: tokens.colors.backgroundSecondary,
45
+ borderRadius: tokens.borders.radius.lg,
46
+ backgroundColor: tokens.colors.surface,
47
47
  borderColor: tokens.colors.border,
48
- marginBottom: tokens.spacing.sm,
48
+ borderWidth: 1,
49
+ marginBottom: tokens.spacing.md,
49
50
  } as ViewStyle,
50
51
  selectedLanguageItem: {
51
52
  borderColor: tokens.colors.primary,
52
- backgroundColor: tokens.colors.primaryContainer,
53
- borderWidth: 2,
53
+ backgroundColor: tokens.colors.surfaceVariant,
54
+ borderWidth: 1.5,
54
55
  } as ViewStyle,
55
56
  nativeName: {
56
- color: tokens.colors.textPrimary,
57
- marginBottom: tokens.spacing.xs / 2,
57
+ color: "#FFFFFF",
58
+ marginBottom: 2,
58
59
  } as TextStyle,
59
60
  languageName: {
60
61
  color: tokens.colors.textSecondary,
@@ -76,19 +77,18 @@ export const LanguageItem: React.FC<LanguageItemProps> = ({
76
77
  activeOpacity={0.7}
77
78
  >
78
79
  <View style={[styles.languageContent, customStyles?.languageContent]}>
79
- <AtomicText style={[styles.flag, customStyles?.flag]}>
80
+ <AtomicText style={[styles.flag, { fontSize: 28 }, customStyles?.flag]}>
80
81
  {item.flag || '🌐'}
81
82
  </AtomicText>
82
- <View style={[styles.languageText, { gap: tokens.spacing.xs / 2 }, customStyles?.languageText]}>
83
+ <View style={[styles.languageText, { gap: 4 }, customStyles?.languageText]}>
83
84
  <AtomicText
84
- type="bodyMedium"
85
- style={[themedStyles.nativeName, { fontWeight: '700' }, customStyles?.nativeName]}
85
+ style={[themedStyles.nativeName, { fontWeight: '700', fontSize: 17, color: '#FFFFFF' }, customStyles?.nativeName]}
86
86
  >
87
87
  {item.nativeName}
88
88
  </AtomicText>
89
89
  <AtomicText
90
90
  type="labelMedium"
91
- style={[themedStyles.languageName, customStyles?.nativeName]}
91
+ style={[themedStyles.languageName, { fontSize: 13, color: '#E8B4B8', opacity: 0.8 }, customStyles?.nativeName]}
92
92
  >
93
93
  {item.name}
94
94
  </AtomicText>
@@ -4,7 +4,7 @@
4
4
  */
5
5
 
6
6
  import React from 'react';
7
- import { FlatList } from 'react-native';
7
+ import { FlatList, View } from 'react-native';
8
8
  import { ScreenLayout } from '@umituz/react-native-design-system/layouts';
9
9
  import { SearchBar, NavigationHeader, useAppNavigation } from '@umituz/react-native-design-system/molecules';
10
10
  import { useAppDesignTokens } from '@umituz/react-native-design-system/theme';
@@ -14,6 +14,10 @@ import type { Language } from '../../infrastructure/storage/types/Language';
14
14
  import type { LanguageSelectionScreenProps } from './LanguageSelectionScreen.types';
15
15
  import { styles } from './LanguageSelectionScreen.styles';
16
16
 
17
+ export interface LanguageSelectionProps extends LanguageSelectionScreenProps {
18
+ showHeader?: boolean;
19
+ }
20
+
17
21
  interface LanguageListItemProps {
18
22
  item: Language;
19
23
  selectedCode: string;
@@ -67,26 +71,45 @@ const LanguageSearchComponent: React.FC<LanguageSearchComponentProps> = ({
67
71
  }
68
72
 
69
73
  return (
70
- <SearchBar
71
- value={searchQuery}
72
- onChangeText={setSearchQuery}
73
- placeholder={searchPlaceholder}
74
- containerStyle={[
75
- { marginBottom: tokens.spacing.md },
76
- customStyles?.searchContainer
77
- ]}
78
- inputStyle={customStyles?.searchInput}
79
- />
74
+ <View style={{ paddingHorizontal: 20 }}>
75
+ <SearchBar
76
+ value={searchQuery}
77
+ onChangeText={setSearchQuery}
78
+ placeholder={searchPlaceholder}
79
+ containerStyle={[
80
+ {
81
+ marginBottom: 20,
82
+ backgroundColor: 'transparent',
83
+ borderBottomWidth: 0,
84
+ paddingHorizontal: 0,
85
+ },
86
+ customStyles?.searchContainer
87
+ ]}
88
+ inputStyle={[
89
+ {
90
+ backgroundColor: '#2D1518',
91
+ borderRadius: 24,
92
+ color: '#FFFFFF',
93
+ paddingHorizontal: 16,
94
+ height: 52,
95
+ borderWidth: 1,
96
+ borderColor: '#3D2022',
97
+ },
98
+ customStyles?.searchInput
99
+ ]}
100
+ />
101
+ </View>
80
102
  );
81
103
  };
82
104
 
83
- export const LanguageSelectionScreen: React.FC<LanguageSelectionScreenProps> = ({
105
+ export const LanguageSelectionScreen: React.FC<LanguageSelectionProps> = ({
84
106
  renderLanguageItem,
85
107
  renderSearchInput,
86
108
  headerTitle,
87
109
  onBackPress,
88
110
  styles: customStyles,
89
111
  searchPlaceholder,
112
+ showHeader = true,
90
113
  testID = 'language-selection-screen',
91
114
  }) => {
92
115
  const tokens = useAppDesignTokens();
@@ -130,10 +153,12 @@ export const LanguageSelectionScreen: React.FC<LanguageSelectionScreenProps> = (
130
153
  edges={['top', 'bottom', 'left', 'right']}
131
154
  backgroundColor={tokens.colors.backgroundPrimary}
132
155
  header={
133
- <NavigationHeader
134
- title={headerTitle || ""}
135
- onBackPress={handleBack}
136
- />
156
+ showHeader ? (
157
+ <NavigationHeader
158
+ title={headerTitle || ""}
159
+ onBackPress={handleBack}
160
+ />
161
+ ) : null
137
162
  }
138
163
  containerStyle={customStyles?.container}
139
164
  >
@@ -21,7 +21,7 @@ export interface BaseConfigType {
21
21
  * Configuration parameters for creating a settings item config
22
22
  */
23
23
  export interface ConfigCreatorParams {
24
- icon: string;
24
+ icon?: string;
25
25
  routeOrOnPress?: string | (() => void);
26
26
  defaultRoute?: string;
27
27
  }
@@ -12,7 +12,7 @@ import { SettingsItemCardSection } from "./settings/SettingsItemCardSection";
12
12
  export interface SettingsItemCardProps {
13
13
  title: string;
14
14
  description?: string;
15
- icon: IconName;
15
+ icon?: IconName;
16
16
  onPress?: () => void;
17
17
  containerStyle?: StyleProp<ViewStyle>;
18
18
  sectionTitle?: string;
@@ -4,7 +4,7 @@ import { AtomicIcon, AtomicText, type IconName } from "@umituz/react-native-desi
4
4
  import { useAppDesignTokens } from "@umituz/react-native-design-system/theme";
5
5
 
6
6
  export interface SettingsItemCardContentProps {
7
- icon: IconName;
7
+ icon?: IconName;
8
8
  title: string;
9
9
  description?: string;
10
10
  iconBgColor: string;
@@ -26,9 +26,11 @@ export const SettingsItemCardContent: React.FC<SettingsItemCardContentProps> = R
26
26
 
27
27
  return (
28
28
  <View style={styles.content}>
29
- <View style={[styles.iconContainer, { backgroundColor: iconBgColor, borderRadius: tokens.borders.radius.md }]}>
30
- <AtomicIcon name={icon} size="lg" customColor={iconColor} />
31
- </View>
29
+ {!!icon && (
30
+ <View style={[styles.iconContainer, { backgroundColor: iconBgColor, borderRadius: tokens.borders.radius.md }]}>
31
+ <AtomicIcon name={icon} size="lg" customColor={iconColor} />
32
+ </View>
33
+ )}
32
34
  <View style={styles.textContainer}>
33
35
  <AtomicText
34
36
  type="bodyLarge"
@@ -35,6 +35,21 @@ export interface UseSettingsScreenConfigParams {
35
35
  additionalScreens?: AdditionalScreen[];
36
36
  features?: SettingsFeatures;
37
37
  translations?: SettingsTranslations;
38
+ /** Optional auth data for apps that use authentication */
39
+ auth?: {
40
+ user: {
41
+ displayName?: string;
42
+ userId?: string;
43
+ photoURL?: string;
44
+ isAnonymous?: boolean;
45
+ } | null;
46
+ isLoading?: boolean;
47
+ isAuthReady?: boolean;
48
+ onSignIn: () => void;
49
+ onLogout: () => Promise<void>;
50
+ onDeleteAccount: () => Promise<void>;
51
+ accountTranslations?: AccountTranslations;
52
+ };
38
53
  }
39
54
 
40
55
  export interface SettingsScreenConfigResult {
@@ -49,7 +64,15 @@ export interface SettingsScreenConfigResult {
49
64
  export const useSettingsScreenConfig = (
50
65
  params: UseSettingsScreenConfigParams
51
66
  ): SettingsScreenConfigResult => {
52
- const { appInfo, faqData, isPremium, onFeedbackSubmit, features = {}, translations } = params;
67
+ const {
68
+ appInfo,
69
+ faqData,
70
+ isPremium,
71
+ onFeedbackSubmit,
72
+ features = {},
73
+ translations,
74
+ auth
75
+ } = params;
53
76
 
54
77
  const {
55
78
  notifications: showNotifications = true,
@@ -65,26 +88,13 @@ export const useSettingsScreenConfig = (
65
88
  subscription: showSubscription = true,
66
89
  } = features;
67
90
 
68
- // No-auth version - always ready
69
- const loading = false;
70
- const isAuthReady = true;
91
+ // Auth orchestration
92
+ const loading = auth?.isLoading ?? false;
93
+ const isAuthReady = auth?.isAuthReady ?? true;
71
94
 
72
- // Default handlers (no-ops for no-auth version)
73
95
  const handleRatePress = useMemo(() => async () => {
74
- // Default rate behavior - could be implemented with expo-store-review
75
- console.warn("[useSettingsScreenConfig] Rate press handler not implemented in no-auth version");
76
- }, []);
77
-
78
- const handleSignOut = useMemo(() => async () => {
79
- // No-op in no-auth version
80
- }, []);
81
-
82
- const handleDeleteAccount = useMemo(() => async () => {
83
- // No-op in no-auth version
84
- }, []);
85
-
86
- const handleSignIn = useMemo(() => async () => {
87
- // No-op in no-auth version
96
+ // Default rate behavior - typically handled by app or a separate rating hook
97
+ console.log("[useSettingsScreenConfig] Rate pressed");
88
98
  }, []);
89
99
 
90
100
  // Use settings config factory
@@ -114,11 +124,11 @@ export const useSettingsScreenConfig = (
114
124
  translations,
115
125
  };
116
126
 
127
+ // Apply translations to specific features if available
117
128
  if (config.subscription && typeof config.subscription === 'object') {
118
129
  config.subscription = {
119
130
  ...config.subscription,
120
- enabled: true,
121
- title: translations?.features?.subscription?.title || config.subscription.title || "Subscription",
131
+ title: translations?.features?.subscription?.title || config.subscription.title,
122
132
  description: translations?.features?.subscription?.description || config.subscription.description,
123
133
  };
124
134
  }
@@ -127,8 +137,7 @@ export const useSettingsScreenConfig = (
127
137
  const existingConfig = typeof config.gamification === 'object' ? config.gamification : { enabled: true };
128
138
  config.gamification = {
129
139
  ...existingConfig,
130
- enabled: true,
131
- title: translations?.features?.gamification?.title || existingConfig.title || "Your Progress",
140
+ title: translations?.features?.gamification?.title || existingConfig.title,
132
141
  description: translations?.features?.gamification?.description || existingConfig.description,
133
142
  };
134
143
  }
@@ -137,8 +146,7 @@ export const useSettingsScreenConfig = (
137
146
  const existingConfig = typeof config.videoTutorial === 'object' ? config.videoTutorial : { enabled: true };
138
147
  config.videoTutorial = {
139
148
  ...existingConfig,
140
- enabled: true,
141
- title: translations?.features?.videoTutorial?.title || existingConfig.title || "Video Tutorials",
149
+ title: translations?.features?.videoTutorial?.title || existingConfig.title,
142
150
  description: translations?.features?.videoTutorial?.description || existingConfig.description,
143
151
  };
144
152
  }
@@ -146,24 +154,28 @@ export const useSettingsScreenConfig = (
146
154
  return config;
147
155
  }, [baseSettingsConfig, translations]);
148
156
 
149
- // Empty user profile (no-auth version)
157
+ // User profile display configuration
150
158
  const userProfile = useMemo(() => createUserProfileDisplay({
151
- profileData: null,
152
- onSignIn: handleSignIn,
153
- }), [handleSignIn]);
154
-
155
- // Minimal account config (no-auth version)
159
+ profileData: auth?.user ? {
160
+ displayName: auth.user.displayName,
161
+ userId: auth.user.userId,
162
+ isAnonymous: auth.user.isAnonymous,
163
+ avatarUrl: auth.user.photoURL,
164
+ } : null,
165
+ onSignIn: auth?.onSignIn || (() => {}),
166
+ }), [auth?.user, auth?.onSignIn]);
167
+
168
+ // Account screen configuration
156
169
  const accountConfig = useMemo(() => createAccountConfig({
157
- displayName: undefined,
158
- userId: undefined,
159
- photoURL: undefined,
160
- isAnonymous: true,
161
- avatarUrl: undefined,
162
- onSignIn: handleSignIn,
163
- onLogout: handleSignOut,
164
- onDeleteAccount: handleDeleteAccount,
165
- translations: undefined,
166
- }), [handleSignIn, handleSignOut, handleDeleteAccount]);
170
+ displayName: auth?.user?.displayName,
171
+ userId: auth?.user?.userId,
172
+ photoURL: auth?.user?.photoURL,
173
+ isAnonymous: auth?.user?.isAnonymous,
174
+ onSignIn: auth?.onSignIn || (() => {}),
175
+ onLogout: auth?.onLogout || (async () => {}),
176
+ onDeleteAccount: auth?.onDeleteAccount || (async () => {}),
177
+ translations: auth?.accountTranslations,
178
+ }), [auth?.user, auth?.onSignIn, auth?.onLogout, auth?.onDeleteAccount, auth?.accountTranslations]);
167
179
 
168
180
  return {
169
181
  settingsConfig,
@@ -20,7 +20,6 @@ export const createAppearanceConfig = (
20
20
  routeOrOnPress?: string | (() => void),
21
21
  ): AppearanceConfig => {
22
22
  return createBaseConfig<AppearanceConfig>({
23
- icon: "color-palette-outline",
24
23
  routeOrOnPress,
25
24
  });
26
25
  };
@@ -32,7 +31,6 @@ export const createLanguageConfig = (
32
31
  routeOrOnPress?: string | (() => void),
33
32
  ): LanguageConfig => {
34
33
  return createBaseConfig<LanguageConfig>({
35
- icon: "globe-outline",
36
34
  routeOrOnPress,
37
35
  });
38
36
  };
@@ -45,7 +43,6 @@ export const createNotificationsConfig = (
45
43
  ): NotificationsConfig => {
46
44
  return createConfigWithExtensions<NotificationsConfig>(
47
45
  {
48
- icon: "notifications-outline",
49
46
  routeOrOnPress,
50
47
  defaultRoute: "Notifications",
51
48
  },
@@ -62,7 +59,6 @@ export const createAboutConfig = (
62
59
  routeOrOnPress?: string | (() => void),
63
60
  ): AboutConfig => {
64
61
  return createBaseConfig<AboutConfig>({
65
- icon: "information-circle-outline",
66
62
  routeOrOnPress,
67
63
  });
68
64
  };
@@ -74,7 +70,6 @@ export const createLegalConfig = (
74
70
  routeOrOnPress?: string | (() => void),
75
71
  ): LegalConfig => {
76
72
  return createBaseConfig<LegalConfig>({
77
- icon: "document-text-outline",
78
73
  routeOrOnPress,
79
74
  });
80
75
  };
@@ -21,7 +21,6 @@ export const createSubscriptionConfig = (
21
21
  routeOrOnPress: keyof SettingsStackParamList | (() => void),
22
22
  ): SubscriptionConfig => ({
23
23
  enabled: true,
24
- icon: "diamond",
25
24
  route: typeof routeOrOnPress === "function" ? undefined : routeOrOnPress,
26
25
  onPress: typeof routeOrOnPress === "function" ? routeOrOnPress : undefined,
27
26
  isPremium,
@@ -17,7 +17,6 @@ export const createFeedbackConfig = (
17
17
  onSubmit: (data: FeedbackFormData) => Promise<void>,
18
18
  ): FeedbackConfig => ({
19
19
  enabled: true,
20
- icon: "chatbubble-outline",
21
20
  onSubmit,
22
21
  });
23
22
 
@@ -39,5 +38,4 @@ export const createRatingConfig = (
39
38
  */
40
39
  export const createFAQConfig = (): FAQConfig => ({
41
40
  enabled: true,
42
- icon: "help-circle-outline",
43
41
  });