@umituz/react-native-settings 4.1.3 → 4.1.5
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 +12 -7
- package/src/presentation/screens/components/SettingsContent.tsx +12 -12
- package/src/presentation/screens/components/index.ts +4 -4
- package/src/presentation/screens/components/AboutLegalSection.tsx +0 -75
- package/src/presentation/screens/components/AppearanceSection.tsx +0 -39
- package/src/presentation/screens/components/LanguageSection.tsx +0 -44
- package/src/presentation/screens/components/NotificationsSection.tsx +0 -97
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-settings",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.5",
|
|
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",
|
|
@@ -26,9 +26,10 @@
|
|
|
26
26
|
"url": "https://github.com/umituz/react-native-settings"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
|
+
"@expo/vector-icons": ">=14.0.0",
|
|
29
30
|
"@react-navigation/native": ">=6.0.0",
|
|
30
31
|
"@react-navigation/stack": ">=6.0.0",
|
|
31
|
-
"@umituz/react-native-about": "
|
|
32
|
+
"@umituz/react-native-about": "^1.11.3",
|
|
32
33
|
"@umituz/react-native-appearance": "*",
|
|
33
34
|
"@umituz/react-native-design-system": "*",
|
|
34
35
|
"@umituz/react-native-design-system-atoms": "*",
|
|
@@ -40,7 +41,6 @@
|
|
|
40
41
|
"@umituz/react-native-legal": "*",
|
|
41
42
|
"@umituz/react-native-localization": "*",
|
|
42
43
|
"@umituz/react-native-storage": "*",
|
|
43
|
-
"@expo/vector-icons": ">=14.0.0",
|
|
44
44
|
"react": ">=18.2.0",
|
|
45
45
|
"react-native": ">=0.74.0",
|
|
46
46
|
"react-native-safe-area-context": "~5.6.0",
|
|
@@ -49,14 +49,18 @@
|
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@babel/plugin-transform-runtime": "^7.28.5",
|
|
52
|
+
"@expo/vector-icons": "^14.0.0",
|
|
52
53
|
"@react-native/babel-preset": "^0.83.0",
|
|
54
|
+
"@react-navigation/stack": "^7.6.12",
|
|
53
55
|
"@testing-library/jest-native": "^5.4.3",
|
|
54
56
|
"@testing-library/react-hooks": "^8.0.1",
|
|
55
57
|
"@testing-library/react-native": "^12.9.0",
|
|
56
58
|
"@types/jest": "^29.5.14",
|
|
57
59
|
"@types/react": "^18.2.45",
|
|
58
60
|
"@types/react-native": "^0.73.0",
|
|
59
|
-
"@umituz/react-native-
|
|
61
|
+
"@umituz/react-native-about": "^1.11.4",
|
|
62
|
+
"@umituz/react-native-alert": "latest",
|
|
63
|
+
"@umituz/react-native-appearance": "^2.0.2",
|
|
60
64
|
"@umituz/react-native-design-system": "latest",
|
|
61
65
|
"@umituz/react-native-design-system-atoms": "latest",
|
|
62
66
|
"@umituz/react-native-design-system-molecules": "latest",
|
|
@@ -64,12 +68,13 @@
|
|
|
64
68
|
"@umituz/react-native-design-system-responsive": "latest",
|
|
65
69
|
"@umituz/react-native-design-system-theme": "latest",
|
|
66
70
|
"@umituz/react-native-design-system-typography": "latest",
|
|
71
|
+
"@umituz/react-native-legal": "^2.0.3",
|
|
67
72
|
"@umituz/react-native-localization": "latest",
|
|
68
|
-
"@expo/vector-icons": "^14.0.0",
|
|
69
|
-
"@umituz/react-native-alert": "latest",
|
|
70
73
|
"@umituz/react-native-notifications": "latest",
|
|
71
74
|
"@umituz/react-native-storage": "latest",
|
|
72
75
|
"babel-plugin-module-resolver": "^5.0.2",
|
|
76
|
+
"expo-constants": "^18.0.12",
|
|
77
|
+
"lucide-react-native": "^0.561.0",
|
|
73
78
|
"metro-react-native-babel-preset": "^0.77.0",
|
|
74
79
|
"react": "^18.2.0",
|
|
75
80
|
"react-native": "^0.74.0",
|
|
@@ -85,4 +90,4 @@
|
|
|
85
90
|
"README.md",
|
|
86
91
|
"LICENSE"
|
|
87
92
|
]
|
|
88
|
-
}
|
|
93
|
+
}
|
|
@@ -11,10 +11,11 @@ import { useLocalization } from "@umituz/react-native-localization";
|
|
|
11
11
|
import { SettingsFooter } from "../../components/SettingsFooter";
|
|
12
12
|
import { UserProfileHeader } from "../../components/UserProfileHeader";
|
|
13
13
|
import { SettingsSection } from "../../components/SettingsSection";
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
14
|
+
import { NotificationsSection } from "@umituz/react-native-notifications";
|
|
15
|
+
import { AboutSection } from "@umituz/react-native-about";
|
|
16
|
+
import { LegalSection } from "@umituz/react-native-legal";
|
|
17
|
+
import { AppearanceSection } from "@umituz/react-native-appearance";
|
|
18
|
+
import { LanguageSection } from "@umituz/react-native-localization";
|
|
18
19
|
import type { NormalizedConfig } from "../utils/normalizeConfig";
|
|
19
20
|
import type { CustomSettingsSection } from "../types";
|
|
20
21
|
|
|
@@ -60,7 +61,7 @@ export const SettingsContent: React.FC<SettingsContentProps> = ({
|
|
|
60
61
|
const insets = useSafeAreaInsets();
|
|
61
62
|
const { t } = useLocalization();
|
|
62
63
|
|
|
63
|
-
const hasAnyFeatures = useMemo(() =>
|
|
64
|
+
const hasAnyFeatures = useMemo(() =>
|
|
64
65
|
features.appearance ||
|
|
65
66
|
features.language ||
|
|
66
67
|
features.notifications ||
|
|
@@ -113,13 +114,12 @@ export const SettingsContent: React.FC<SettingsContentProps> = ({
|
|
|
113
114
|
<NotificationsSection config={normalizedConfig.notifications.config} />
|
|
114
115
|
)}
|
|
115
116
|
|
|
116
|
-
{
|
|
117
|
-
<
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
/>
|
|
117
|
+
{features.about && (
|
|
118
|
+
<AboutSection config={normalizedConfig.about.config} />
|
|
119
|
+
)}
|
|
120
|
+
|
|
121
|
+
{features.legal && (
|
|
122
|
+
<LegalSection config={normalizedConfig.legal.config} />
|
|
123
123
|
)}
|
|
124
124
|
|
|
125
125
|
{customSections && customSections.length > 0 && (
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* Barrel export for all section components
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
10
|
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* About & Legal Section Component
|
|
3
|
-
* Single Responsibility: Render about and legal settings section
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import React from "react";
|
|
7
|
-
import { Feather } from "@expo/vector-icons";
|
|
8
|
-
import { useNavigation } from "@react-navigation/native";
|
|
9
|
-
import { useLocalization } from "@umituz/react-native-localization";
|
|
10
|
-
import type { NavigationProp } from "@react-navigation/native";
|
|
11
|
-
import { SettingItem } from "../../components/SettingItem";
|
|
12
|
-
import { SettingsSection } from "../../components/SettingsSection";
|
|
13
|
-
import type { AboutConfig, LegalConfig } from "../types";
|
|
14
|
-
|
|
15
|
-
interface AboutLegalSectionProps {
|
|
16
|
-
showAbout: boolean;
|
|
17
|
-
showLegal: boolean;
|
|
18
|
-
aboutConfig?: AboutConfig;
|
|
19
|
-
legalConfig?: LegalConfig;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
type RootStackParamList = {
|
|
23
|
-
About: undefined;
|
|
24
|
-
Legal: undefined;
|
|
25
|
-
[key: string]: undefined;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
type NavigationType = NavigationProp<RootStackParamList>;
|
|
29
|
-
|
|
30
|
-
export const AboutLegalSection: React.FC<AboutLegalSectionProps> = ({
|
|
31
|
-
showAbout,
|
|
32
|
-
showLegal,
|
|
33
|
-
aboutConfig,
|
|
34
|
-
legalConfig,
|
|
35
|
-
}) => {
|
|
36
|
-
const navigation = useNavigation<NavigationType>();
|
|
37
|
-
const { t } = useLocalization();
|
|
38
|
-
|
|
39
|
-
if (!showAbout && !showLegal) {
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const aboutRoute = aboutConfig?.route || aboutConfig?.defaultRoute || "About";
|
|
44
|
-
const aboutTitle = aboutConfig?.title || t("settings.about.title");
|
|
45
|
-
const aboutDescription =
|
|
46
|
-
aboutConfig?.description || t("settings.about.description");
|
|
47
|
-
|
|
48
|
-
const legalRoute = legalConfig?.route || legalConfig?.defaultRoute || "Legal";
|
|
49
|
-
const legalTitle = legalConfig?.title || t("settings.legal.title");
|
|
50
|
-
const legalDescription =
|
|
51
|
-
legalConfig?.description || t("settings.legal.description");
|
|
52
|
-
|
|
53
|
-
return (
|
|
54
|
-
<SettingsSection title={t("settings.sections.about")}>
|
|
55
|
-
{showAbout && (
|
|
56
|
-
<SettingItem
|
|
57
|
-
icon={(props) => <Feather name={"info" as any} {...props} />}
|
|
58
|
-
title={aboutTitle}
|
|
59
|
-
value={aboutDescription}
|
|
60
|
-
onPress={() => navigation.navigate(aboutRoute as string)}
|
|
61
|
-
/>
|
|
62
|
-
)}
|
|
63
|
-
{showLegal && (
|
|
64
|
-
<SettingItem
|
|
65
|
-
icon={(props) => <Feather name={"file-text" as any} {...props} />}
|
|
66
|
-
title={legalTitle}
|
|
67
|
-
value={legalDescription}
|
|
68
|
-
onPress={() => navigation.navigate(legalRoute as string)}
|
|
69
|
-
isLast={true}
|
|
70
|
-
/>
|
|
71
|
-
)}
|
|
72
|
-
</SettingsSection>
|
|
73
|
-
);
|
|
74
|
-
};
|
|
75
|
-
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Appearance Section Component
|
|
3
|
-
* Single Responsibility: Render appearance settings section (theme customization)
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import React from "react";
|
|
7
|
-
import { Feather } from "@expo/vector-icons";
|
|
8
|
-
import { useNavigation } from "@react-navigation/native";
|
|
9
|
-
import { useLocalization } from "@umituz/react-native-localization";
|
|
10
|
-
import { SettingItem } from "../../components/SettingItem";
|
|
11
|
-
import { SettingsSection } from "../../components/SettingsSection";
|
|
12
|
-
import type { AppearanceConfig } from "../types";
|
|
13
|
-
|
|
14
|
-
interface AppearanceSectionProps {
|
|
15
|
-
config?: AppearanceConfig;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export const AppearanceSection: React.FC<AppearanceSectionProps> = ({
|
|
19
|
-
config,
|
|
20
|
-
}) => {
|
|
21
|
-
const navigation = useNavigation();
|
|
22
|
-
const { t } = useLocalization();
|
|
23
|
-
|
|
24
|
-
const route = config?.route || config?.defaultRoute || "Appearance";
|
|
25
|
-
const title = config?.title || t("settings.appearance.title");
|
|
26
|
-
const description = config?.description || t("settings.appearance.description");
|
|
27
|
-
|
|
28
|
-
return (
|
|
29
|
-
<SettingsSection title={t("settings.sections.app.title")}>
|
|
30
|
-
<SettingItem
|
|
31
|
-
icon={(props) => <Feather name={"droplet" as any} {...props} />}
|
|
32
|
-
title={title}
|
|
33
|
-
value={description}
|
|
34
|
-
onPress={() => navigation.navigate(route as never)}
|
|
35
|
-
/>
|
|
36
|
-
</SettingsSection>
|
|
37
|
-
);
|
|
38
|
-
};
|
|
39
|
-
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Language Section Component
|
|
3
|
-
* Single Responsibility: Render language settings section
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import React from "react";
|
|
7
|
-
import { Feather } from "@expo/vector-icons";
|
|
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 defaultLanguageDisplay = config?.defaultLanguageDisplay || "English";
|
|
30
|
-
const languageDisplay = currentLang
|
|
31
|
-
? `${currentLang.flag} ${currentLang.nativeName}`
|
|
32
|
-
: defaultLanguageDisplay;
|
|
33
|
-
|
|
34
|
-
return (
|
|
35
|
-
<SettingsSection title={t("settings.sections.app.title")}>
|
|
36
|
-
<SettingItem
|
|
37
|
-
icon={(props) => <Feather name={"globe" as any} {...props} />}
|
|
38
|
-
title={title}
|
|
39
|
-
value={languageDisplay}
|
|
40
|
-
onPress={() => navigation.navigate(route as never)}
|
|
41
|
-
/>
|
|
42
|
-
</SettingsSection>
|
|
43
|
-
);
|
|
44
|
-
};
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Notifications Section Component
|
|
3
|
-
* Single Responsibility: Render notifications settings section
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import React, { useState, useEffect, useCallback } from "react";
|
|
7
|
-
import { Feather } from "@expo/vector-icons";
|
|
8
|
-
import { useNavigation } from "@react-navigation/native";
|
|
9
|
-
import { useLocalization } from "@umituz/react-native-localization";
|
|
10
|
-
import { SettingItem } from "../../components/SettingItem";
|
|
11
|
-
import { SettingsSection } from "../../components/SettingsSection";
|
|
12
|
-
import type { NotificationsConfig } from "../types";
|
|
13
|
-
|
|
14
|
-
// Optional notification service
|
|
15
|
-
let notificationService: {
|
|
16
|
-
hasPermissions?: () => Promise<boolean>;
|
|
17
|
-
requestPermissions?: () => Promise<void>;
|
|
18
|
-
} | null = null;
|
|
19
|
-
try {
|
|
20
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
21
|
-
const module = require("@umituz/react-native-notifications");
|
|
22
|
-
if (module?.notificationService && typeof module.notificationService === 'object') {
|
|
23
|
-
notificationService = module.notificationService;
|
|
24
|
-
}
|
|
25
|
-
} catch {
|
|
26
|
-
// Package not available
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
interface NotificationsSectionProps {
|
|
30
|
-
config?: NotificationsConfig;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export const NotificationsSection: React.FC<NotificationsSectionProps> = ({
|
|
34
|
-
config,
|
|
35
|
-
}) => {
|
|
36
|
-
const navigation = useNavigation<any>();
|
|
37
|
-
const { t } = useLocalization();
|
|
38
|
-
const [notificationsEnabled, setNotificationsEnabled] = useState(
|
|
39
|
-
config?.initialValue ?? true,
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
useEffect(() => {
|
|
43
|
-
if (config?.initialValue !== undefined) {
|
|
44
|
-
setNotificationsEnabled(config.initialValue);
|
|
45
|
-
}
|
|
46
|
-
}, [config?.initialValue]);
|
|
47
|
-
|
|
48
|
-
const handleToggle = useCallback(async (value: boolean) => {
|
|
49
|
-
if (notificationService && !value) {
|
|
50
|
-
const hasPermissions = await notificationService.hasPermissions?.();
|
|
51
|
-
if (!hasPermissions) {
|
|
52
|
-
await notificationService.requestPermissions?.();
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
setNotificationsEnabled(value);
|
|
57
|
-
config?.onToggleChange?.(value);
|
|
58
|
-
}, [config?.onToggleChange]);
|
|
59
|
-
|
|
60
|
-
const handlePress = useCallback(async () => {
|
|
61
|
-
if (notificationService) {
|
|
62
|
-
const hasPermissions = await notificationService.hasPermissions?.();
|
|
63
|
-
if (!hasPermissions) {
|
|
64
|
-
await notificationService.requestPermissions?.();
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
navigation.navigate(config?.route || config?.defaultRoute || "Notifications" as any);
|
|
68
|
-
}, [navigation, config?.route, config?.defaultRoute]);
|
|
69
|
-
|
|
70
|
-
const title = config?.title || t("settings.notifications.title");
|
|
71
|
-
const description = config?.description || t("settings.notifications.description");
|
|
72
|
-
const showToggle = config?.showToggle ?? true;
|
|
73
|
-
|
|
74
|
-
return (
|
|
75
|
-
<SettingsSection title={t("settings.sections.general")}>
|
|
76
|
-
{showToggle ? (
|
|
77
|
-
<SettingItem
|
|
78
|
-
icon={(props) => <Feather name={"bell" as any} {...props} />}
|
|
79
|
-
title={title}
|
|
80
|
-
showSwitch={true}
|
|
81
|
-
switchValue={notificationsEnabled}
|
|
82
|
-
onSwitchChange={handleToggle}
|
|
83
|
-
isLast={true}
|
|
84
|
-
/>
|
|
85
|
-
) : (
|
|
86
|
-
<SettingItem
|
|
87
|
-
icon={(props) => <Feather name={"bell" as any} {...props} />}
|
|
88
|
-
title={title}
|
|
89
|
-
value={description}
|
|
90
|
-
onPress={handlePress}
|
|
91
|
-
isLast={true}
|
|
92
|
-
/>
|
|
93
|
-
)}
|
|
94
|
-
</SettingsSection>
|
|
95
|
-
);
|
|
96
|
-
};
|
|
97
|
-
|