@umituz/react-native-settings 4.7.0 → 4.7.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 +1 -1
- package/src/presentation/components/SettingsErrorBoundary.tsx +3 -3
- package/src/presentation/screens/SettingsScreen.tsx +5 -2
- package/src/presentation/screens/components/SettingsContent.tsx +19 -0
- package/src/presentation/screens/components/SettingsHeader.tsx +1 -1
- package/src/presentation/screens/hooks/useFeatureDetection.ts +7 -1
- package/src/presentation/screens/types/FeatureConfig.ts +27 -0
- package/src/presentation/screens/types/SettingsConfig.ts +14 -0
- package/src/presentation/screens/types/index.ts +2 -0
- package/src/presentation/screens/utils/normalizeConfig.ts +12 -0
package/package.json
CHANGED
|
@@ -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}
|
|
@@ -19,6 +19,18 @@ import { LanguageSection } from "@umituz/react-native-localization";
|
|
|
19
19
|
import type { NormalizedConfig } from "../utils/normalizeConfig";
|
|
20
20
|
import type { CustomSettingsSection } from "../types";
|
|
21
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
|
+
|
|
22
34
|
interface SettingsContentProps {
|
|
23
35
|
normalizedConfig: NormalizedConfig;
|
|
24
36
|
config?: any; // Original config for emptyStateText
|
|
@@ -28,6 +40,8 @@ interface SettingsContentProps {
|
|
|
28
40
|
notifications: boolean;
|
|
29
41
|
about: boolean;
|
|
30
42
|
legal: boolean;
|
|
43
|
+
disclaimer: boolean;
|
|
44
|
+
userProfile: boolean;
|
|
31
45
|
};
|
|
32
46
|
showUserProfile?: boolean;
|
|
33
47
|
userProfile?: {
|
|
@@ -69,6 +83,7 @@ export const SettingsContent: React.FC<SettingsContentProps> = ({
|
|
|
69
83
|
features.notifications ||
|
|
70
84
|
features.about ||
|
|
71
85
|
features.legal ||
|
|
86
|
+
features.disclaimer ||
|
|
72
87
|
customSections.length > 0,
|
|
73
88
|
[features, customSections.length]
|
|
74
89
|
);
|
|
@@ -126,6 +141,10 @@ export const SettingsContent: React.FC<SettingsContentProps> = ({
|
|
|
126
141
|
<LegalSection config={normalizedConfig.legal.config} />
|
|
127
142
|
)}
|
|
128
143
|
|
|
144
|
+
{features.disclaimer && DisclaimerSetting && (
|
|
145
|
+
<DisclaimerSetting />
|
|
146
|
+
)}
|
|
147
|
+
|
|
129
148
|
{customSections && customSections.length > 0 && (
|
|
130
149
|
<>
|
|
131
150
|
{sortedSections.map((section, index) => (
|
|
@@ -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,7 +61,7 @@ export function useFeatureDetection(
|
|
|
61
61
|
},
|
|
62
62
|
) {
|
|
63
63
|
return useMemo(() => {
|
|
64
|
-
const { appearance, language, notifications, about, legal } =
|
|
64
|
+
const { appearance, language, notifications, about, legal, disclaimer, userProfile } =
|
|
65
65
|
normalizedConfig;
|
|
66
66
|
|
|
67
67
|
const notificationServiceAvailable = options?.notificationServiceAvailable ?? notificationService !== null;
|
|
@@ -102,6 +102,12 @@ export function useFeatureDetection(
|
|
|
102
102
|
(legal.config?.enabled === true ||
|
|
103
103
|
(legal.config?.enabled !== false &&
|
|
104
104
|
hasNavigationScreen(navigation, legal.config?.route || "Legal"))),
|
|
105
|
+
disclaimer:
|
|
106
|
+
disclaimer.enabled &&
|
|
107
|
+
(disclaimer.config?.enabled === true ||
|
|
108
|
+
(disclaimer.config?.enabled !== false &&
|
|
109
|
+
hasNavigationScreen(navigation, disclaimer.config?.route || "Disclaimer"))),
|
|
110
|
+
userProfile: userProfile.enabled,
|
|
105
111
|
};
|
|
106
112
|
}, [normalizedConfig, navigation, options]);
|
|
107
113
|
}
|
|
@@ -101,3 +101,30 @@ export interface LegalConfig {
|
|
|
101
101
|
defaultRoute?: string;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
+
/**
|
|
105
|
+
* Disclaimer Settings Configuration
|
|
106
|
+
*/
|
|
107
|
+
export interface DisclaimerConfig {
|
|
108
|
+
/** Show disclaimer section */
|
|
109
|
+
enabled?: FeatureVisibility;
|
|
110
|
+
/** Custom navigation route for disclaimer screen */
|
|
111
|
+
route?: string;
|
|
112
|
+
/** Custom disclaimer title */
|
|
113
|
+
title?: string;
|
|
114
|
+
/** Custom disclaimer description */
|
|
115
|
+
description?: string;
|
|
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
|
+
}
|
|
@@ -10,6 +10,8 @@ import type {
|
|
|
10
10
|
NotificationsConfig,
|
|
11
11
|
AboutConfig,
|
|
12
12
|
LegalConfig,
|
|
13
|
+
DisclaimerConfig,
|
|
14
|
+
UserProfileConfig,
|
|
13
15
|
} from "./FeatureConfig";
|
|
14
16
|
|
|
15
17
|
/**
|
|
@@ -74,6 +76,18 @@ export interface SettingsConfig {
|
|
|
74
76
|
*/
|
|
75
77
|
legal?: FeatureVisibility | LegalConfig;
|
|
76
78
|
|
|
79
|
+
/**
|
|
80
|
+
* Disclaimer settings (Important notices)
|
|
81
|
+
* @default false
|
|
82
|
+
*/
|
|
83
|
+
disclaimer?: FeatureVisibility | DisclaimerConfig;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* User profile header settings
|
|
87
|
+
* @default false
|
|
88
|
+
*/
|
|
89
|
+
userProfile?: boolean | UserProfileConfig;
|
|
90
|
+
|
|
77
91
|
/**
|
|
78
92
|
* Custom empty state text when no settings are available
|
|
79
93
|
*/
|
|
@@ -10,6 +10,8 @@ export type {
|
|
|
10
10
|
NotificationsConfig,
|
|
11
11
|
AboutConfig,
|
|
12
12
|
LegalConfig,
|
|
13
|
+
DisclaimerConfig,
|
|
14
|
+
UserProfileConfig,
|
|
13
15
|
} from "./FeatureConfig";
|
|
14
16
|
export type { SettingsConfig } from "./SettingsConfig";
|
|
15
17
|
export type { CustomSettingsSection } from "./CustomSection";
|
|
@@ -10,6 +10,8 @@ import type {
|
|
|
10
10
|
NotificationsConfig,
|
|
11
11
|
AboutConfig,
|
|
12
12
|
LegalConfig,
|
|
13
|
+
DisclaimerConfig,
|
|
14
|
+
UserProfileConfig,
|
|
13
15
|
SettingsConfig,
|
|
14
16
|
} from "../types";
|
|
15
17
|
|
|
@@ -34,6 +36,14 @@ export interface NormalizedConfig {
|
|
|
34
36
|
enabled: boolean;
|
|
35
37
|
config?: LegalConfig;
|
|
36
38
|
};
|
|
39
|
+
disclaimer: {
|
|
40
|
+
enabled: boolean;
|
|
41
|
+
config?: DisclaimerConfig;
|
|
42
|
+
};
|
|
43
|
+
userProfile: {
|
|
44
|
+
enabled: boolean;
|
|
45
|
+
config?: UserProfileConfig;
|
|
46
|
+
};
|
|
37
47
|
}
|
|
38
48
|
|
|
39
49
|
/**
|
|
@@ -73,6 +83,8 @@ export function normalizeSettingsConfig(
|
|
|
73
83
|
notifications: normalizeConfigValue(config?.notifications, "auto"),
|
|
74
84
|
about: normalizeConfigValue(config?.about, "auto"),
|
|
75
85
|
legal: normalizeConfigValue(config?.legal, "auto"),
|
|
86
|
+
disclaimer: normalizeConfigValue(config?.disclaimer, false),
|
|
87
|
+
userProfile: normalizeConfigValue(config?.userProfile, false),
|
|
76
88
|
};
|
|
77
89
|
}
|
|
78
90
|
|