@umituz/react-native-settings 4.6.0 → 4.7.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 +1 -3
- package/src/presentation/components/SettingsErrorBoundary.tsx +3 -3
- package/src/presentation/screens/SettingsScreen.tsx +5 -2
- package/src/presentation/screens/components/SettingsContent.tsx +14 -2
- package/src/presentation/screens/components/SettingsHeader.tsx +1 -1
- package/src/presentation/screens/hooks/useFeatureDetection.ts +3 -12
- package/src/presentation/screens/types/FeatureConfig.ts +15 -5
- package/src/presentation/screens/types/SettingsConfig.ts +7 -35
- package/src/presentation/screens/types/index.ts +1 -5
- package/src/presentation/screens/utils/normalizeConfig.ts +4 -16
- package/src/presentation/screens/types/ExtendedConfig.ts +0 -68
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-settings",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.7.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",
|
|
@@ -39,7 +39,6 @@
|
|
|
39
39
|
"@umituz/react-native-design-system-theme": "*",
|
|
40
40
|
"@umituz/react-native-design-system-typography": "*",
|
|
41
41
|
"@umituz/react-native-legal": "*",
|
|
42
|
-
"@umituz/react-native-disclaimer": "*",
|
|
43
42
|
"@umituz/react-native-localization": "*",
|
|
44
43
|
"@umituz/react-native-storage": "*",
|
|
45
44
|
"react": ">=18.2.0",
|
|
@@ -70,7 +69,6 @@
|
|
|
70
69
|
"@umituz/react-native-design-system-theme": "latest",
|
|
71
70
|
"@umituz/react-native-design-system-typography": "latest",
|
|
72
71
|
"@umituz/react-native-legal": "^2.0.3",
|
|
73
|
-
"@umituz/react-native-disclaimer": "latest",
|
|
74
72
|
"@umituz/react-native-localization": "latest",
|
|
75
73
|
"@umituz/react-native-notifications": "latest",
|
|
76
74
|
"@umituz/react-native-storage": "latest",
|
|
@@ -76,9 +76,9 @@ const ErrorBoundaryFallback: React.FC<ErrorBoundaryFallbackProps> = ({
|
|
|
76
76
|
return (
|
|
77
77
|
<View style={[styles.container, { backgroundColor: tokens.colors.backgroundPrimary }]}>
|
|
78
78
|
<View style={[styles.content, { backgroundColor: tokens.colors.surface }]}>
|
|
79
|
-
<AtomicIcon
|
|
80
|
-
name="
|
|
81
|
-
color="warning"
|
|
79
|
+
<AtomicIcon
|
|
80
|
+
name="alert-triangle"
|
|
81
|
+
color="warning"
|
|
82
82
|
size="lg"
|
|
83
83
|
style={styles.icon}
|
|
84
84
|
/>
|
|
@@ -52,7 +52,7 @@ export interface SettingsScreenProps {
|
|
|
52
52
|
|
|
53
53
|
export const SettingsScreen: React.FC<SettingsScreenProps> = ({
|
|
54
54
|
config = {},
|
|
55
|
-
showUserProfile
|
|
55
|
+
showUserProfile,
|
|
56
56
|
userProfile,
|
|
57
57
|
showFooter = true,
|
|
58
58
|
footerText,
|
|
@@ -72,6 +72,9 @@ export const SettingsScreen: React.FC<SettingsScreenProps> = ({
|
|
|
72
72
|
const normalizedConfig = normalizeSettingsConfig(config);
|
|
73
73
|
const features = useFeatureDetection(normalizedConfig, navigation, featureOptions);
|
|
74
74
|
|
|
75
|
+
// Determine if user profile should be shown (explicit prop takes priority, then config)
|
|
76
|
+
const shouldShowUserProfile = showUserProfile ?? features.userProfile;
|
|
77
|
+
|
|
75
78
|
return (
|
|
76
79
|
<View style={[styles.container, { backgroundColor: colors.backgroundPrimary }]}>
|
|
77
80
|
<StatusBar barStyle={isDark ? "light-content" : "dark-content"} />
|
|
@@ -82,7 +85,7 @@ export const SettingsScreen: React.FC<SettingsScreenProps> = ({
|
|
|
82
85
|
<SettingsContent
|
|
83
86
|
normalizedConfig={normalizedConfig}
|
|
84
87
|
features={features}
|
|
85
|
-
showUserProfile={
|
|
88
|
+
showUserProfile={shouldShowUserProfile}
|
|
86
89
|
userProfile={userProfile}
|
|
87
90
|
showFooter={showFooter}
|
|
88
91
|
footerText={footerText}
|
|
@@ -16,10 +16,21 @@ import { AboutSection } from "@umituz/react-native-about";
|
|
|
16
16
|
import { LegalSection } from "@umituz/react-native-legal";
|
|
17
17
|
import { AppearanceSection } from "@umituz/react-native-appearance";
|
|
18
18
|
import { LanguageSection } from "@umituz/react-native-localization";
|
|
19
|
-
import { DisclaimerSetting } from "@umituz/react-native-disclaimer";
|
|
20
19
|
import type { NormalizedConfig } from "../utils/normalizeConfig";
|
|
21
20
|
import type { CustomSettingsSection } from "../types";
|
|
22
21
|
|
|
22
|
+
// Optional disclaimer component
|
|
23
|
+
let DisclaimerSetting: React.ComponentType<any> | null = null;
|
|
24
|
+
try {
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
26
|
+
const module = require("@umituz/react-native-disclaimer");
|
|
27
|
+
if (module?.DisclaimerSetting) {
|
|
28
|
+
DisclaimerSetting = module.DisclaimerSetting;
|
|
29
|
+
}
|
|
30
|
+
} catch {
|
|
31
|
+
// Package not available
|
|
32
|
+
}
|
|
33
|
+
|
|
23
34
|
interface SettingsContentProps {
|
|
24
35
|
normalizedConfig: NormalizedConfig;
|
|
25
36
|
config?: any; // Original config for emptyStateText
|
|
@@ -30,6 +41,7 @@ interface SettingsContentProps {
|
|
|
30
41
|
about: boolean;
|
|
31
42
|
legal: boolean;
|
|
32
43
|
disclaimer: boolean;
|
|
44
|
+
userProfile: boolean;
|
|
33
45
|
};
|
|
34
46
|
showUserProfile?: boolean;
|
|
35
47
|
userProfile?: {
|
|
@@ -129,7 +141,7 @@ export const SettingsContent: React.FC<SettingsContentProps> = ({
|
|
|
129
141
|
<LegalSection config={normalizedConfig.legal.config} />
|
|
130
142
|
)}
|
|
131
143
|
|
|
132
|
-
{features.disclaimer && (
|
|
144
|
+
{features.disclaimer && DisclaimerSetting && (
|
|
133
145
|
<DisclaimerSetting />
|
|
134
146
|
)}
|
|
135
147
|
|
|
@@ -55,7 +55,7 @@ export const SettingsHeader: React.FC<SettingsHeaderProps> = ({
|
|
|
55
55
|
]}
|
|
56
56
|
hitSlop={{ top: 10, bottom: 10, left: 10, right: 10 }}
|
|
57
57
|
>
|
|
58
|
-
<AtomicIcon name="
|
|
58
|
+
<AtomicIcon name="x" size="lg" color="primary" />
|
|
59
59
|
</TouchableOpacity>
|
|
60
60
|
</View>
|
|
61
61
|
);
|
|
@@ -61,9 +61,9 @@ export function useFeatureDetection(
|
|
|
61
61
|
},
|
|
62
62
|
) {
|
|
63
63
|
return useMemo(() => {
|
|
64
|
-
const { appearance, language, notifications, about, legal, disclaimer,
|
|
64
|
+
const { appearance, language, notifications, about, legal, disclaimer, userProfile } =
|
|
65
65
|
normalizedConfig;
|
|
66
|
-
|
|
66
|
+
|
|
67
67
|
const notificationServiceAvailable = options?.notificationServiceAvailable ?? notificationService !== null;
|
|
68
68
|
|
|
69
69
|
return {
|
|
@@ -107,16 +107,7 @@ export function useFeatureDetection(
|
|
|
107
107
|
(disclaimer.config?.enabled === true ||
|
|
108
108
|
(disclaimer.config?.enabled !== false &&
|
|
109
109
|
hasNavigationScreen(navigation, disclaimer.config?.route || "Disclaimer"))),
|
|
110
|
-
|
|
111
|
-
account.enabled &&
|
|
112
|
-
(account.config?.enabled === true ||
|
|
113
|
-
(account.config?.enabled !== false &&
|
|
114
|
-
hasNavigationScreen(
|
|
115
|
-
navigation,
|
|
116
|
-
account.config?.route || "AccountSettings",
|
|
117
|
-
))),
|
|
118
|
-
support: support.enabled,
|
|
119
|
-
developer: developer.enabled && __DEV__,
|
|
110
|
+
userProfile: userProfile.enabled,
|
|
120
111
|
};
|
|
121
112
|
}, [normalizedConfig, navigation, options]);
|
|
122
113
|
}
|
|
@@ -113,8 +113,18 @@ export interface DisclaimerConfig {
|
|
|
113
113
|
title?: string;
|
|
114
114
|
/** Custom disclaimer description */
|
|
115
115
|
description?: string;
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* User Profile Settings Configuration
|
|
120
|
+
*/
|
|
121
|
+
export interface UserProfileConfig {
|
|
122
|
+
/** Show user profile header */
|
|
123
|
+
enabled?: boolean;
|
|
124
|
+
/** Custom display name for anonymous users */
|
|
125
|
+
anonymousDisplayName?: string;
|
|
126
|
+
/** Custom avatar service URL */
|
|
127
|
+
avatarServiceUrl?: string;
|
|
128
|
+
/** Navigation route for account settings (shows chevron if set) */
|
|
129
|
+
accountSettingsRoute?: string;
|
|
130
|
+
}
|
|
@@ -11,21 +11,17 @@ import type {
|
|
|
11
11
|
AboutConfig,
|
|
12
12
|
LegalConfig,
|
|
13
13
|
DisclaimerConfig,
|
|
14
|
+
UserProfileConfig,
|
|
14
15
|
} from "./FeatureConfig";
|
|
15
|
-
import type {
|
|
16
|
-
AccountConfig,
|
|
17
|
-
SupportConfig,
|
|
18
|
-
DeveloperConfig,
|
|
19
|
-
} from "./ExtendedConfig";
|
|
20
16
|
|
|
21
17
|
/**
|
|
22
18
|
* Main Settings Configuration
|
|
23
|
-
*
|
|
19
|
+
*
|
|
24
20
|
* Controls which settings features are visible in the SettingsScreen.
|
|
25
21
|
* Each feature can be configured with:
|
|
26
22
|
* - Simple: boolean | 'auto' (quick setup)
|
|
27
23
|
* - Advanced: Detailed config object (full control)
|
|
28
|
-
*
|
|
24
|
+
*
|
|
29
25
|
* @example
|
|
30
26
|
* // Simple configuration
|
|
31
27
|
* const config: SettingsConfig = {
|
|
@@ -33,31 +29,19 @@ import type {
|
|
|
33
29
|
* notifications: 'auto',
|
|
34
30
|
* about: false,
|
|
35
31
|
* };
|
|
36
|
-
*
|
|
32
|
+
*
|
|
37
33
|
* @example
|
|
38
34
|
* // Advanced configuration
|
|
39
35
|
* const config: SettingsConfig = {
|
|
40
36
|
* appearance: {
|
|
41
37
|
* enabled: true,
|
|
42
38
|
* route: 'CustomAppearance',
|
|
43
|
-
* showLanguage: true,
|
|
44
39
|
* showTheme: true,
|
|
45
40
|
* },
|
|
46
41
|
* notifications: {
|
|
47
42
|
* enabled: 'auto',
|
|
48
43
|
* showToggle: true,
|
|
49
44
|
* initialValue: false,
|
|
50
|
-
* onToggleChange: (value) => console.log(value),
|
|
51
|
-
* },
|
|
52
|
-
* support: {
|
|
53
|
-
* enabled: true,
|
|
54
|
-
* items: {
|
|
55
|
-
* liveSupport: {
|
|
56
|
-
* enabled: true,
|
|
57
|
-
* route: 'ChatSupport',
|
|
58
|
-
* title: 'Live Chat',
|
|
59
|
-
* },
|
|
60
|
-
* },
|
|
61
45
|
* },
|
|
62
46
|
* };
|
|
63
47
|
*/
|
|
@@ -93,28 +77,16 @@ export interface SettingsConfig {
|
|
|
93
77
|
legal?: FeatureVisibility | LegalConfig;
|
|
94
78
|
|
|
95
79
|
/**
|
|
96
|
-
* Disclaimer settings (Important notices
|
|
80
|
+
* Disclaimer settings (Important notices)
|
|
97
81
|
* @default false
|
|
98
82
|
*/
|
|
99
83
|
disclaimer?: FeatureVisibility | DisclaimerConfig;
|
|
100
84
|
|
|
101
85
|
/**
|
|
102
|
-
*
|
|
103
|
-
* @default false
|
|
104
|
-
*/
|
|
105
|
-
account?: FeatureVisibility | AccountConfig;
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Support settings
|
|
109
|
-
* @default false
|
|
110
|
-
*/
|
|
111
|
-
support?: FeatureVisibility | SupportConfig;
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Developer settings (only shown in __DEV__ mode)
|
|
86
|
+
* User profile header settings
|
|
115
87
|
* @default false
|
|
116
88
|
*/
|
|
117
|
-
|
|
89
|
+
userProfile?: boolean | UserProfileConfig;
|
|
118
90
|
|
|
119
91
|
/**
|
|
120
92
|
* Custom empty state text when no settings are available
|
|
@@ -11,11 +11,7 @@ export type {
|
|
|
11
11
|
AboutConfig,
|
|
12
12
|
LegalConfig,
|
|
13
13
|
DisclaimerConfig,
|
|
14
|
+
UserProfileConfig,
|
|
14
15
|
} from "./FeatureConfig";
|
|
15
|
-
export type {
|
|
16
|
-
AccountConfig,
|
|
17
|
-
SupportConfig,
|
|
18
|
-
DeveloperConfig,
|
|
19
|
-
} from "./ExtendedConfig";
|
|
20
16
|
export type { SettingsConfig } from "./SettingsConfig";
|
|
21
17
|
export type { CustomSettingsSection } from "./CustomSection";
|
|
@@ -11,9 +11,7 @@ import type {
|
|
|
11
11
|
AboutConfig,
|
|
12
12
|
LegalConfig,
|
|
13
13
|
DisclaimerConfig,
|
|
14
|
-
|
|
15
|
-
SupportConfig,
|
|
16
|
-
DeveloperConfig,
|
|
14
|
+
UserProfileConfig,
|
|
17
15
|
SettingsConfig,
|
|
18
16
|
} from "../types";
|
|
19
17
|
|
|
@@ -42,17 +40,9 @@ export interface NormalizedConfig {
|
|
|
42
40
|
enabled: boolean;
|
|
43
41
|
config?: DisclaimerConfig;
|
|
44
42
|
};
|
|
45
|
-
|
|
43
|
+
userProfile: {
|
|
46
44
|
enabled: boolean;
|
|
47
|
-
config?:
|
|
48
|
-
};
|
|
49
|
-
support: {
|
|
50
|
-
enabled: boolean;
|
|
51
|
-
config?: SupportConfig;
|
|
52
|
-
};
|
|
53
|
-
developer: {
|
|
54
|
-
enabled: boolean;
|
|
55
|
-
config?: DeveloperConfig;
|
|
45
|
+
config?: UserProfileConfig;
|
|
56
46
|
};
|
|
57
47
|
}
|
|
58
48
|
|
|
@@ -94,9 +84,7 @@ export function normalizeSettingsConfig(
|
|
|
94
84
|
about: normalizeConfigValue(config?.about, "auto"),
|
|
95
85
|
legal: normalizeConfigValue(config?.legal, "auto"),
|
|
96
86
|
disclaimer: normalizeConfigValue(config?.disclaimer, false),
|
|
97
|
-
|
|
98
|
-
support: normalizeConfigValue(config?.support, false),
|
|
99
|
-
developer: normalizeConfigValue(config?.developer, false),
|
|
87
|
+
userProfile: normalizeConfigValue(config?.userProfile, false),
|
|
100
88
|
};
|
|
101
89
|
}
|
|
102
90
|
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Extended Configuration Types
|
|
3
|
-
* Account, Support, and Developer configurations
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import type { ComponentType } from "react";
|
|
7
|
-
import type { FeatureVisibility } from "./FeatureConfig";
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Account Settings Configuration
|
|
11
|
-
*/
|
|
12
|
-
export interface AccountConfig {
|
|
13
|
-
/** Show account section */
|
|
14
|
-
enabled?: FeatureVisibility;
|
|
15
|
-
/** Custom navigation route for account screen */
|
|
16
|
-
route?: string;
|
|
17
|
-
/** Custom account title */
|
|
18
|
-
title?: string;
|
|
19
|
-
/** Custom account description */
|
|
20
|
-
description?: string;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Support Settings Configuration
|
|
25
|
-
*/
|
|
26
|
-
export interface SupportConfig {
|
|
27
|
-
/** Show support section */
|
|
28
|
-
enabled?: FeatureVisibility;
|
|
29
|
-
/** Support items configuration */
|
|
30
|
-
items?: {
|
|
31
|
-
/** Live support configuration */
|
|
32
|
-
liveSupport?: {
|
|
33
|
-
enabled?: boolean;
|
|
34
|
-
route?: string;
|
|
35
|
-
title?: string;
|
|
36
|
-
description?: string;
|
|
37
|
-
};
|
|
38
|
-
/** Help support configuration */
|
|
39
|
-
helpSupport?: {
|
|
40
|
-
enabled?: boolean;
|
|
41
|
-
route?: string;
|
|
42
|
-
title?: string;
|
|
43
|
-
description?: string;
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
/** Custom support section title */
|
|
47
|
-
title?: string;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Developer Settings Configuration
|
|
52
|
-
*/
|
|
53
|
-
export interface DeveloperConfig {
|
|
54
|
-
/** Show developer section (only in __DEV__ mode) */
|
|
55
|
-
enabled?: boolean;
|
|
56
|
-
/** Developer settings items */
|
|
57
|
-
items?: Array<{
|
|
58
|
-
title: string;
|
|
59
|
-
description?: string;
|
|
60
|
-
route?: string;
|
|
61
|
-
onPress?: () => void;
|
|
62
|
-
icon?: ComponentType<{ size?: number; color?: string }>;
|
|
63
|
-
iconColor?: string;
|
|
64
|
-
titleColor?: string;
|
|
65
|
-
}>;
|
|
66
|
-
/** Custom developer section title */
|
|
67
|
-
title?: string;
|
|
68
|
-
}
|