@umituz/react-native-settings 1.11.0 → 1.11.2

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.2",
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": {
@@ -1,11 +1,11 @@
1
1
  /**
2
2
  * Setting Item Component
3
3
  * Single Responsibility: Render a single settings item
4
- * Modern design with Lucide icons and switch support
4
+ * Material Design 3 style with hover effects and modern spacing
5
5
  */
6
6
 
7
7
  import React from "react";
8
- import { View, Text, TouchableOpacity, StyleSheet, Switch } from "react-native";
8
+ import { View, Text, Pressable, StyleSheet, Switch } from "react-native";
9
9
  import { ChevronRight, type LucideIcon } from "lucide-react-native";
10
10
  import { useAppDesignTokens } from "@umituz/react-native-design-system-theme";
11
11
 
@@ -56,14 +56,17 @@ export const SettingItem: React.FC<SettingItemProps> = ({
56
56
 
57
57
  return (
58
58
  <>
59
- <TouchableOpacity
60
- style={[
59
+ <Pressable
60
+ style={({ pressed }) => [
61
61
  styles.container,
62
- { backgroundColor: colors.backgroundPrimary },
62
+ {
63
+ backgroundColor: pressed && !disabled && !showSwitch
64
+ ? `${colors.primary}08`
65
+ : 'transparent',
66
+ },
63
67
  ]}
64
68
  onPress={onPress}
65
69
  disabled={showSwitch || disabled}
66
- activeOpacity={disabled ? 1 : 0.7}
67
70
  testID={testID}
68
71
  >
69
72
  <View style={styles.content}>
@@ -77,7 +80,7 @@ export const SettingItem: React.FC<SettingItemProps> = ({
77
80
  },
78
81
  ]}
79
82
  >
80
- <Icon size={20} color={iconColor || colors.primary} />
83
+ <Icon size={24} color={iconColor || colors.primary} />
81
84
  </View>
82
85
  <View style={styles.textContainer}>
83
86
  <Text
@@ -97,7 +100,7 @@ export const SettingItem: React.FC<SettingItemProps> = ({
97
100
  {value && !showSwitch && (
98
101
  <Text
99
102
  style={[styles.value, { color: colors.textSecondary }]}
100
- numberOfLines={1}
103
+ numberOfLines={2}
101
104
  >
102
105
  {value}
103
106
  </Text>
@@ -115,12 +118,13 @@ export const SettingItem: React.FC<SettingItemProps> = ({
115
118
  true: colors.primary,
116
119
  }}
117
120
  thumbColor="#FFFFFF"
121
+ ios_backgroundColor={`${colors.textSecondary}30`}
118
122
  />
119
123
  ) : (
120
- <ChevronRight size={18} color={colors.textSecondary} />
124
+ <ChevronRight size={20} color={colors.textSecondary} />
121
125
  )}
122
126
  </View>
123
- </TouchableOpacity>
127
+ </Pressable>
124
128
 
125
129
  {!isLast && (
126
130
  <View
@@ -139,9 +143,9 @@ const styles = StyleSheet.create({
139
143
  flexDirection: "row",
140
144
  alignItems: "center",
141
145
  justifyContent: "space-between",
142
- paddingHorizontal: 20,
143
- paddingVertical: 18,
144
- minHeight: 64,
146
+ paddingHorizontal: 16,
147
+ paddingVertical: 16,
148
+ minHeight: 72,
145
149
  },
146
150
  content: {
147
151
  flexDirection: "row",
@@ -149,8 +153,8 @@ const styles = StyleSheet.create({
149
153
  flex: 1,
150
154
  },
151
155
  iconContainer: {
152
- width: 44,
153
- height: 44,
156
+ width: 48,
157
+ height: 48,
154
158
  borderRadius: 12,
155
159
  justifyContent: "center",
156
160
  alignItems: "center",
@@ -163,11 +167,13 @@ const styles = StyleSheet.create({
163
167
  title: {
164
168
  fontSize: 16,
165
169
  fontWeight: "500",
170
+ lineHeight: 20,
166
171
  },
167
172
  value: {
168
- fontSize: 12,
173
+ fontSize: 14,
169
174
  fontWeight: "400",
170
- marginTop: 2,
175
+ marginTop: 4,
176
+ lineHeight: 18,
171
177
  },
172
178
  rightContainer: {
173
179
  flexDirection: "row",
@@ -20,19 +20,13 @@ export const SettingsSection: React.FC<SettingsSectionProps> = ({
20
20
  }) => {
21
21
  const tokens = useAppDesignTokens();
22
22
  const colors = tokens.colors;
23
- const spacing = tokens.spacing;
24
23
 
25
24
  return (
26
- <View style={styles.container}>
27
- <Text style={[styles.title, { color: colors.textSecondary }]}>
25
+ <View style={[styles.container, { backgroundColor: colors.surface }]}>
26
+ <Text style={[styles.title, { color: colors.textPrimary }]}>
28
27
  {title}
29
28
  </Text>
30
- <View
31
- style={[
32
- styles.content,
33
- { backgroundColor: `${colors.textSecondary}10` },
34
- ]}
35
- >
29
+ <View style={styles.content}>
36
30
  {children}
37
31
  </View>
38
32
  </View>
@@ -41,22 +35,19 @@ export const SettingsSection: React.FC<SettingsSectionProps> = ({
41
35
 
42
36
  const styles = StyleSheet.create({
43
37
  container: {
44
- marginTop: 0,
45
- marginBottom: 32,
38
+ marginBottom: 16,
39
+ borderRadius: 12,
40
+ overflow: "hidden",
46
41
  },
47
42
  title: {
48
- fontSize: 11,
49
- fontWeight: "700",
50
- textTransform: "uppercase",
51
- letterSpacing: 1.2,
43
+ fontSize: 18,
44
+ fontWeight: "600",
52
45
  paddingHorizontal: 16,
53
- paddingBottom: 12,
54
- marginBottom: 0,
46
+ paddingTop: 16,
47
+ paddingBottom: 8,
55
48
  },
56
49
  content: {
57
- borderRadius: 16,
58
- marginHorizontal: 16,
59
- overflow: "hidden",
50
+ borderRadius: 0,
60
51
  },
61
52
  });
62
53
 
@@ -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"),