@umituz/react-native-settings 1.11.0 → 1.11.1

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": "1.11.0",
3
+ "version": "1.11.1",
4
4
  "description": "Settings management for React Native apps - user preferences, theme, language, notifications",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -34,6 +34,7 @@
34
34
  "@umituz/react-native-design-system": "latest",
35
35
  "@umituz/react-native-design-system-theme": "latest",
36
36
  "@umituz/react-native-localization": "latest",
37
+ "@umituz/react-native-appearance": "latest",
37
38
  "expo-linear-gradient": "~14.0.0"
38
39
  },
39
40
  "devDependencies": {
@@ -31,7 +31,7 @@ export const UserProfileHeader: React.FC<UserProfileHeaderProps> = ({
31
31
  userId,
32
32
  isGuest = false,
33
33
  avatarUrl,
34
- accountSettingsRoute = "AccountSettings",
34
+ accountSettingsRoute,
35
35
  onPress,
36
36
  }) => {
37
37
  const tokens = useAppDesignTokens();
@@ -40,7 +40,6 @@ export const UserProfileHeader: React.FC<UserProfileHeaderProps> = ({
40
40
  const spacing = tokens.spacing;
41
41
 
42
42
  const finalDisplayName = displayName || (isGuest ? "Guest" : "User");
43
- const finalUserId = userId || "Unknown";
44
43
  const avatarName = isGuest ? "Guest" : finalDisplayName;
45
44
  const finalAvatarUrl =
46
45
  avatarUrl ||
@@ -54,20 +53,21 @@ export const UserProfileHeader: React.FC<UserProfileHeaderProps> = ({
54
53
  }
55
54
  };
56
55
 
57
- return (
58
- <TouchableOpacity
59
- style={[
60
- styles.container,
61
- {
62
- backgroundColor: colors.surface,
63
- paddingHorizontal: spacing.md,
64
- paddingVertical: spacing.md,
65
- marginHorizontal: spacing.md,
66
- },
67
- ]}
68
- onPress={handlePress}
69
- activeOpacity={0.7}
70
- >
56
+ const shouldShowChevron = !!(onPress || accountSettingsRoute);
57
+ const isPressable = !!(onPress || accountSettingsRoute);
58
+
59
+ const containerStyle = [
60
+ styles.container,
61
+ {
62
+ backgroundColor: colors.surface,
63
+ paddingHorizontal: spacing.md,
64
+ paddingVertical: spacing.md,
65
+ marginHorizontal: spacing.md,
66
+ },
67
+ ];
68
+
69
+ const content = (
70
+ <>
71
71
  <View style={styles.content}>
72
72
  <View style={[styles.avatarContainer, { borderColor: `${colors.primary}30` }]}>
73
73
  <Image
@@ -78,25 +78,34 @@ export const UserProfileHeader: React.FC<UserProfileHeaderProps> = ({
78
78
  <View style={[styles.textContainer, { marginLeft: spacing.md }]}>
79
79
  <AtomicText
80
80
  type="headlineSmall"
81
- style={[styles.name, { color: colors.textPrimary, marginBottom: spacing.xs }]}
81
+ style={[styles.name, { color: colors.textPrimary }]}
82
82
  numberOfLines={1}
83
83
  >
84
84
  {finalDisplayName}
85
85
  </AtomicText>
86
- <AtomicText
87
- type="bodySmall"
88
- style={[styles.id, { color: colors.textSecondary }]}
89
- numberOfLines={1}
90
- >
91
- ID: {finalUserId.substring(0, 10)}...
92
- </AtomicText>
93
86
  </View>
94
87
  </View>
95
- <View style={[styles.chevronContainer, { marginLeft: spacing.sm }]}>
96
- <ChevronRight size={22} color={colors.textSecondary} strokeWidth={2.5} />
97
- </View>
98
- </TouchableOpacity>
88
+ {shouldShowChevron && (
89
+ <View style={[styles.chevronContainer, { marginLeft: spacing.sm }]}>
90
+ <ChevronRight size={22} color={colors.textSecondary} strokeWidth={2.5} />
91
+ </View>
92
+ )}
93
+ </>
99
94
  );
95
+
96
+ if (isPressable) {
97
+ return (
98
+ <TouchableOpacity
99
+ style={containerStyle}
100
+ onPress={handlePress}
101
+ activeOpacity={0.7}
102
+ >
103
+ {content}
104
+ </TouchableOpacity>
105
+ );
106
+ }
107
+
108
+ return <View style={containerStyle}>{content}</View>;
100
109
  };
101
110
 
102
111
  const styles = StyleSheet.create({
@@ -1,70 +1,13 @@
1
1
  /**
2
2
  * Appearance Settings Screen
3
- * Modern appearance settings with language and theme controls
3
+ * Advanced appearance settings with theme customization and custom colors
4
+ * Uses @umituz/react-native-appearance package
4
5
  */
5
6
 
6
7
  import React from "react";
7
- import { View, StyleSheet } from "react-native";
8
- import { Languages, Moon, Sun } from "lucide-react-native";
9
- import { useNavigation } from "@react-navigation/native";
10
- import {
11
- useDesignSystemTheme,
12
- useAppDesignTokens,
13
- type DesignTokens,
14
- } from "@umituz/react-native-design-system-theme";
15
- import { ScreenLayout } from "@umituz/react-native-design-system-organisms";
16
- import { useLocalization, getLanguageByCode } from "@umituz/react-native-localization";
17
- import { SettingItem } from "../components/SettingItem";
18
- import { SettingsSection } from "../components/SettingsSection";
8
+ import { AppearanceScreen } from "@umituz/react-native-appearance";
19
9
 
20
- export const AppearanceScreen: React.FC = () => {
21
- const { t, currentLanguage } = useLocalization();
22
- const navigation = useNavigation();
23
- const { themeMode, setThemeMode } = useDesignSystemTheme();
24
- const tokens = useAppDesignTokens();
25
- const styles = getStyles(tokens);
26
-
27
- const currentLang = getLanguageByCode(currentLanguage);
28
- const languageDisplay = currentLang
29
- ? `${currentLang.flag} ${currentLang.nativeName}`
30
- : "English";
31
- const themeDisplay =
32
- themeMode === "dark" ? t("settings.darkMode") : t("settings.lightMode");
33
-
34
- const handleLanguagePress = () => {
35
- navigation.navigate("LanguageSelection" as never);
36
- };
37
-
38
- const handleThemeToggle = () => {
39
- const newMode = themeMode === "dark" ? "light" : "dark";
40
- setThemeMode(newMode);
41
- };
42
-
43
- return (
44
- <ScreenLayout testID="appearance-screen" hideScrollIndicator>
45
- {/* Language Section */}
46
- <SettingsSection title={t("settings.language")}>
47
- <SettingItem
48
- icon={Languages}
49
- title={t("settings.language")}
50
- value={languageDisplay}
51
- onPress={handleLanguagePress}
52
- />
53
- </SettingsSection>
54
-
55
- {/* Theme Section */}
56
- <SettingsSection title={t("settings.appearance.darkMode")}>
57
- <SettingItem
58
- icon={themeMode === "dark" ? Moon : Sun}
59
- title={t("settings.appearance.darkMode")}
60
- value={themeDisplay}
61
- onPress={handleThemeToggle}
62
- isLast={true}
63
- />
64
- </SettingsSection>
65
- </ScreenLayout>
66
- );
67
- };
10
+ export { AppearanceScreen };
68
11
 
69
12
  const getStyles = (tokens: DesignTokens) =>
70
13
  StyleSheet.create({
@@ -17,6 +17,7 @@ import { SettingsFooter } from "../components/SettingsFooter";
17
17
  import { UserProfileHeader } from "../components/UserProfileHeader";
18
18
  import { SettingsSection } from "../components/SettingsSection";
19
19
  import { AppearanceSection } from "./components/AppearanceSection";
20
+ import { LanguageSection } from "./components/LanguageSection";
20
21
  import { NotificationsSection } from "./components/NotificationsSection";
21
22
  import { AboutLegalSection } from "./components/AboutLegalSection";
22
23
  import { normalizeSettingsConfig } from "./utils/normalizeConfig";
@@ -73,6 +74,7 @@ export const SettingsScreen: React.FC<SettingsScreenProps> = ({
73
74
 
74
75
  const hasAnyFeatures =
75
76
  features.appearance ||
77
+ features.language ||
76
78
  features.notifications ||
77
79
  features.about ||
78
80
  features.legal ||
@@ -144,6 +146,10 @@ export const SettingsScreen: React.FC<SettingsScreenProps> = ({
144
146
  <AppearanceSection config={normalizedConfig.appearance.config} />
145
147
  )}
146
148
 
149
+ {features.language && (
150
+ <LanguageSection config={normalizedConfig.language.config} />
151
+ )}
152
+
147
153
  {features.notifications && (
148
154
  <NotificationsSection config={normalizedConfig.notifications.config} />
149
155
  )}
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Appearance Section Component
3
- * Single Responsibility: Render appearance settings section
3
+ * Single Responsibility: Render appearance settings section (theme customization)
4
4
  */
5
5
 
6
6
  import React from "react";
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Language Section Component
3
+ * Single Responsibility: Render language settings section
4
+ */
5
+
6
+ import React from "react";
7
+ import { Languages } from "lucide-react-native";
8
+ import { useNavigation } from "@react-navigation/native";
9
+ import { useLocalization, getLanguageByCode } from "@umituz/react-native-localization";
10
+ import { SettingItem } from "../../components/SettingItem";
11
+ import { SettingsSection } from "../../components/SettingsSection";
12
+ import type { LanguageConfig } from "../types";
13
+
14
+ interface LanguageSectionProps {
15
+ config?: LanguageConfig;
16
+ }
17
+
18
+ export const LanguageSection: React.FC<LanguageSectionProps> = ({
19
+ config,
20
+ }) => {
21
+ const navigation = useNavigation();
22
+ const { t, currentLanguage } = useLocalization();
23
+
24
+ const route = config?.route || "LanguageSelection";
25
+ const title = config?.title || t("settings.language");
26
+ const description = config?.description || "";
27
+
28
+ const currentLang = getLanguageByCode(currentLanguage);
29
+ const languageDisplay = currentLang
30
+ ? `${currentLang.flag} ${currentLang.nativeName}`
31
+ : "English";
32
+
33
+ return (
34
+ <SettingsSection title={t("settings.sections.app.title")}>
35
+ <SettingItem
36
+ icon={Languages}
37
+ title={title}
38
+ value={languageDisplay}
39
+ onPress={() => navigation.navigate(route as never)}
40
+ />
41
+ </SettingsSection>
42
+ );
43
+ };
@@ -4,6 +4,7 @@
4
4
  */
5
5
 
6
6
  export { AppearanceSection } from "./AppearanceSection";
7
+ export { LanguageSection } from "./LanguageSection";
7
8
  export { NotificationsSection } from "./NotificationsSection";
8
9
  export { AboutLegalSection } from "./AboutLegalSection";
9
10
 
@@ -53,7 +53,7 @@ export function useFeatureDetection(
53
53
  navigation: any,
54
54
  ) {
55
55
  return useMemo(() => {
56
- const { appearance, notifications, about, legal, account, support, developer } =
56
+ const { appearance, language, notifications, about, legal, account, support, developer } =
57
57
  normalizedConfig;
58
58
 
59
59
  return {
@@ -65,6 +65,14 @@ export function useFeatureDetection(
65
65
  navigation,
66
66
  appearance.config?.route || "Appearance",
67
67
  ))),
68
+ language:
69
+ language.enabled &&
70
+ (language.config?.enabled === true ||
71
+ (language.config?.enabled !== false &&
72
+ hasNavigationScreen(
73
+ navigation,
74
+ language.config?.route || "LanguageSelection",
75
+ ))),
68
76
  notifications:
69
77
  notifications.enabled &&
70
78
  (notifications.config?.enabled === true ||
@@ -23,8 +23,6 @@ export interface AppearanceConfig {
23
23
  enabled?: FeatureVisibility;
24
24
  /** Custom navigation route for appearance screen */
25
25
  route?: string;
26
- /** Show language selection */
27
- showLanguage?: boolean;
28
26
  /** Show theme toggle */
29
27
  showTheme?: boolean;
30
28
  /** Custom appearance title */
@@ -33,6 +31,20 @@ export interface AppearanceConfig {
33
31
  description?: string;
34
32
  }
35
33
 
34
+ /**
35
+ * Language Settings Configuration
36
+ */
37
+ export interface LanguageConfig {
38
+ /** Show language section */
39
+ enabled?: FeatureVisibility;
40
+ /** Custom navigation route for language selection screen */
41
+ route?: string;
42
+ /** Custom language title */
43
+ title?: string;
44
+ /** Custom language description */
45
+ description?: string;
46
+ }
47
+
36
48
  /**
37
49
  * Notifications Settings Configuration
38
50
  */
@@ -187,11 +199,17 @@ export interface DeveloperConfig {
187
199
  */
188
200
  export interface SettingsConfig {
189
201
  /**
190
- * Appearance settings (Theme & Language)
202
+ * Appearance settings (Theme customization)
191
203
  * @default 'auto'
192
204
  */
193
205
  appearance?: FeatureVisibility | AppearanceConfig;
194
206
 
207
+ /**
208
+ * Language settings
209
+ * @default 'auto'
210
+ */
211
+ language?: FeatureVisibility | LanguageConfig;
212
+
195
213
  /**
196
214
  * Notifications settings
197
215
  * @default 'auto'
@@ -6,6 +6,7 @@
6
6
  import type {
7
7
  FeatureVisibility,
8
8
  AppearanceConfig,
9
+ LanguageConfig,
9
10
  NotificationsConfig,
10
11
  AboutConfig,
11
12
  LegalConfig,
@@ -19,6 +20,10 @@ export interface NormalizedConfig {
19
20
  enabled: boolean;
20
21
  config?: AppearanceConfig;
21
22
  };
23
+ language: {
24
+ enabled: boolean;
25
+ config?: LanguageConfig;
26
+ };
22
27
  notifications: {
23
28
  enabled: boolean;
24
29
  config?: NotificationsConfig;
@@ -78,6 +83,7 @@ export function normalizeSettingsConfig(
78
83
  ): NormalizedConfig {
79
84
  return {
80
85
  appearance: normalizeConfigValue(config?.appearance, "auto"),
86
+ language: normalizeConfigValue(config?.language, "auto"),
81
87
  notifications: normalizeConfigValue(config?.notifications, "auto"),
82
88
  about: normalizeConfigValue(config?.about, "auto"),
83
89
  legal: normalizeConfigValue(config?.legal, "auto"),