@umituz/react-native-settings 4.21.18 → 4.21.19
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/screens/SettingsScreen.tsx +4 -0
- package/src/presentation/screens/components/GamificationSettingsItem.tsx +48 -0
- package/src/presentation/screens/components/SettingsContent.tsx +17 -41
- package/src/presentation/screens/components/SubscriptionSettingsItem.tsx +30 -0
- package/src/presentation/screens/components/WalletSettingsItem.tsx +28 -0
- package/src/presentation/screens/hooks/useFeatureDetection.ts +2 -0
- package/src/presentation/screens/types/SettingsConfig.ts +7 -0
- package/src/presentation/screens/types/UserFeatureConfig.ts +21 -0
- package/src/presentation/screens/utils/normalizeConfig.ts +6 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-settings",
|
|
3
|
-
"version": "4.21.
|
|
3
|
+
"version": "4.21.19",
|
|
4
4
|
"description": "Complete settings hub for React Native apps - consolidated package with settings, about, legal, appearance, feedback, FAQs, rating, and gamification",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -51,6 +51,8 @@ export interface SettingsScreenProps {
|
|
|
51
51
|
};
|
|
52
52
|
/** Dev settings (only shown in __DEV__ mode) */
|
|
53
53
|
devSettings?: DevSettingsProps;
|
|
54
|
+
/** Gamification configuration */
|
|
55
|
+
gamificationConfig?: import("../../domains/gamification").GamificationSettingsConfig;
|
|
54
56
|
/** Show header (default: true) */
|
|
55
57
|
showHeader?: boolean;
|
|
56
58
|
}
|
|
@@ -68,6 +70,7 @@ export const SettingsScreen: React.FC<SettingsScreenProps> = ({
|
|
|
68
70
|
onClose,
|
|
69
71
|
featureOptions,
|
|
70
72
|
devSettings,
|
|
73
|
+
gamificationConfig,
|
|
71
74
|
}) => {
|
|
72
75
|
const navigation = useNavigation();
|
|
73
76
|
const tokens = useAppDesignTokens();
|
|
@@ -94,6 +97,7 @@ export const SettingsScreen: React.FC<SettingsScreenProps> = ({
|
|
|
94
97
|
customSections={customSections}
|
|
95
98
|
showCloseButton={showCloseButton}
|
|
96
99
|
devSettings={devSettings}
|
|
100
|
+
gamificationConfig={gamificationConfig}
|
|
97
101
|
/>
|
|
98
102
|
</SettingsErrorBoundary>
|
|
99
103
|
</ScreenLayout>
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
// @ts-ignore - Optional peer dependency
|
|
3
|
+
import { useNavigation } from "@react-navigation/native";
|
|
4
|
+
import { SettingsItemCard } from "../../components/SettingsItemCard";
|
|
5
|
+
import type { IconName } from "@umituz/react-native-design-system";
|
|
6
|
+
import { useGamification } from "../../../domains/gamification";
|
|
7
|
+
|
|
8
|
+
export interface GamificationSettingsItemProps {
|
|
9
|
+
config: any;
|
|
10
|
+
gamificationConfig?: any;
|
|
11
|
+
t: (key: string) => string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const GamificationSettingsItem: React.FC<GamificationSettingsItemProps> = ({
|
|
15
|
+
config,
|
|
16
|
+
gamificationConfig,
|
|
17
|
+
t
|
|
18
|
+
}) => {
|
|
19
|
+
const navigation = useNavigation();
|
|
20
|
+
const { level } = useGamification(gamificationConfig);
|
|
21
|
+
|
|
22
|
+
const handlePress = () => {
|
|
23
|
+
if (config.route) {
|
|
24
|
+
navigation.navigate(config.route as never);
|
|
25
|
+
} else {
|
|
26
|
+
navigation.navigate("Gamification" as never);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const icon = (config.icon || "trophy-outline") as IconName;
|
|
31
|
+
const title = config.title || t("settings.gamification.title");
|
|
32
|
+
|
|
33
|
+
// Dynamic description showing current level and points
|
|
34
|
+
const description = config.description ||
|
|
35
|
+
t("settings.gamification.description")
|
|
36
|
+
.replace("{level}", level.currentLevel.toString())
|
|
37
|
+
.replace("{points}", level.currentPoints.toString());
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<SettingsItemCard
|
|
41
|
+
title={title}
|
|
42
|
+
description={description}
|
|
43
|
+
icon={icon}
|
|
44
|
+
onPress={handlePress}
|
|
45
|
+
sectionTitle={config.sectionTitle}
|
|
46
|
+
/>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React, { useMemo } from "react";
|
|
2
2
|
import { View, StyleSheet } from "react-native";
|
|
3
|
-
import { useNavigation } from "@react-navigation/native";
|
|
4
3
|
import { useLocalization } from "@umituz/react-native-localization";
|
|
5
4
|
import { SettingsFooter } from "../../components/SettingsFooter";
|
|
6
5
|
import { SettingsSection } from "../../components/SettingsSection";
|
|
@@ -10,49 +9,14 @@ import { ProfileSectionLoader } from "./sections/ProfileSectionLoader";
|
|
|
10
9
|
import { FeatureSettingsSection } from "./sections/FeatureSettingsSection";
|
|
11
10
|
import { IdentitySettingsSection } from "./sections/IdentitySettingsSection";
|
|
12
11
|
import { SupportSettingsSection } from "./sections/SupportSettingsSection";
|
|
13
|
-
import { SettingsItemCard } from "../../components/SettingsItemCard";
|
|
14
|
-
import type { IconName } from "@umituz/react-native-design-system";
|
|
15
12
|
import { CustomSettingsList } from "./sections/CustomSettingsList";
|
|
16
13
|
import type { NormalizedConfig } from "../utils/normalizeConfig";
|
|
17
|
-
import type { CustomSettingsSection
|
|
18
|
-
|
|
19
|
-
const WalletSettingsItem: React.FC<{ config: WalletConfig; t: (key: string) => string }> = ({ config, t }) => {
|
|
20
|
-
const navigation = useNavigation();
|
|
21
|
-
const handlePress = () => {
|
|
22
|
-
if (config.route) {
|
|
23
|
-
navigation.navigate(config.route as never);
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
return (
|
|
27
|
-
<SettingsItemCard
|
|
28
|
-
title={config.title || t("wallet.title")}
|
|
29
|
-
description={config.description || t("wallet.description")}
|
|
30
|
-
icon={(config.icon || "wallet") as IconName}
|
|
31
|
-
onPress={handlePress}
|
|
32
|
-
sectionTitle={config.sectionTitle}
|
|
33
|
-
/>
|
|
34
|
-
);
|
|
35
|
-
};
|
|
14
|
+
import type { CustomSettingsSection } from "../types";
|
|
36
15
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
navigation.navigate(config.route as never);
|
|
42
|
-
} else if (config.onPress) {
|
|
43
|
-
config.onPress();
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
return (
|
|
47
|
-
<SettingsItemCard
|
|
48
|
-
title={config.title || t("settings.subscription.title")}
|
|
49
|
-
description={config.description || t("settings.subscription.description")}
|
|
50
|
-
icon={(config.icon || "star") as IconName}
|
|
51
|
-
onPress={handlePress}
|
|
52
|
-
sectionTitle={config.sectionTitle}
|
|
53
|
-
/>
|
|
54
|
-
);
|
|
55
|
-
};
|
|
16
|
+
// Extracted Item Components
|
|
17
|
+
import { SubscriptionSettingsItem } from "./SubscriptionSettingsItem";
|
|
18
|
+
import { WalletSettingsItem } from "./WalletSettingsItem";
|
|
19
|
+
import { GamificationSettingsItem } from "./GamificationSettingsItem";
|
|
56
20
|
|
|
57
21
|
interface SettingsContentProps {
|
|
58
22
|
normalizedConfig: NormalizedConfig;
|
|
@@ -70,6 +34,7 @@ interface SettingsContentProps {
|
|
|
70
34
|
faqs: boolean;
|
|
71
35
|
subscription: boolean;
|
|
72
36
|
wallet: boolean;
|
|
37
|
+
gamification: boolean;
|
|
73
38
|
};
|
|
74
39
|
showUserProfile?: boolean;
|
|
75
40
|
userProfile?: any;
|
|
@@ -79,6 +44,7 @@ interface SettingsContentProps {
|
|
|
79
44
|
customSections?: CustomSettingsSection[];
|
|
80
45
|
showCloseButton?: boolean;
|
|
81
46
|
devSettings?: DevSettingsProps;
|
|
47
|
+
gamificationConfig?: import("../../../domains/gamification").GamificationSettingsConfig;
|
|
82
48
|
}
|
|
83
49
|
|
|
84
50
|
export const SettingsContent: React.FC<SettingsContentProps> = ({
|
|
@@ -93,6 +59,7 @@ export const SettingsContent: React.FC<SettingsContentProps> = ({
|
|
|
93
59
|
customSections = [],
|
|
94
60
|
showCloseButton = false,
|
|
95
61
|
devSettings,
|
|
62
|
+
gamificationConfig,
|
|
96
63
|
}) => {
|
|
97
64
|
const { t } = useLocalization();
|
|
98
65
|
|
|
@@ -108,6 +75,7 @@ export const SettingsContent: React.FC<SettingsContentProps> = ({
|
|
|
108
75
|
features.faqs ||
|
|
109
76
|
features.subscription ||
|
|
110
77
|
features.wallet ||
|
|
78
|
+
features.gamification ||
|
|
111
79
|
customSections.length > 0,
|
|
112
80
|
[features, customSections.length]
|
|
113
81
|
);
|
|
@@ -129,6 +97,14 @@ export const SettingsContent: React.FC<SettingsContentProps> = ({
|
|
|
129
97
|
/>
|
|
130
98
|
)}
|
|
131
99
|
|
|
100
|
+
{features.gamification && (
|
|
101
|
+
<GamificationSettingsItem
|
|
102
|
+
config={normalizedConfig.gamification.config || {}}
|
|
103
|
+
gamificationConfig={gamificationConfig}
|
|
104
|
+
t={t}
|
|
105
|
+
/>
|
|
106
|
+
)}
|
|
107
|
+
|
|
132
108
|
<FeatureSettingsSection normalizedConfig={normalizedConfig} features={features} />
|
|
133
109
|
|
|
134
110
|
<IdentitySettingsSection normalizedConfig={normalizedConfig} features={features} />
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
// @ts-ignore - Optional peer dependency
|
|
3
|
+
import { useNavigation } from "@react-navigation/native";
|
|
4
|
+
import { SettingsItemCard } from "../../components/SettingsItemCard";
|
|
5
|
+
import type { IconName } from "@umituz/react-native-design-system";
|
|
6
|
+
|
|
7
|
+
export interface SubscriptionSettingsItemProps {
|
|
8
|
+
config: any;
|
|
9
|
+
t: (key: string) => string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const SubscriptionSettingsItem: React.FC<SubscriptionSettingsItemProps> = ({ config, t }) => {
|
|
13
|
+
const navigation = useNavigation();
|
|
14
|
+
const handlePress = () => {
|
|
15
|
+
if (config.route) {
|
|
16
|
+
navigation.navigate(config.route as never);
|
|
17
|
+
} else if (config.onPress) {
|
|
18
|
+
config.onPress();
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
return (
|
|
22
|
+
<SettingsItemCard
|
|
23
|
+
title={config.title || t("settings.subscription.title")}
|
|
24
|
+
description={config.description || t("settings.subscription.description")}
|
|
25
|
+
icon={(config.icon || "star") as IconName}
|
|
26
|
+
onPress={handlePress}
|
|
27
|
+
sectionTitle={config.sectionTitle}
|
|
28
|
+
/>
|
|
29
|
+
);
|
|
30
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
// @ts-ignore - Optional peer dependency
|
|
3
|
+
import { useNavigation } from "@react-navigation/native";
|
|
4
|
+
import { SettingsItemCard } from "../../components/SettingsItemCard";
|
|
5
|
+
import type { IconName } from "@umituz/react-native-design-system";
|
|
6
|
+
|
|
7
|
+
export interface WalletSettingsItemProps {
|
|
8
|
+
config: any;
|
|
9
|
+
t: (key: string) => string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const WalletSettingsItem: React.FC<WalletSettingsItemProps> = ({ config, t }) => {
|
|
13
|
+
const navigation = useNavigation();
|
|
14
|
+
const handlePress = () => {
|
|
15
|
+
if (config.route) {
|
|
16
|
+
navigation.navigate(config.route as never);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
return (
|
|
20
|
+
<SettingsItemCard
|
|
21
|
+
title={config.title || t("wallet.title")}
|
|
22
|
+
description={config.description || t("wallet.description")}
|
|
23
|
+
icon={(config.icon || "wallet") as IconName}
|
|
24
|
+
onPress={handlePress}
|
|
25
|
+
sectionTitle={config.sectionTitle}
|
|
26
|
+
/>
|
|
27
|
+
);
|
|
28
|
+
};
|
|
@@ -60,6 +60,7 @@ export function useFeatureDetection(
|
|
|
60
60
|
faqs,
|
|
61
61
|
subscription,
|
|
62
62
|
wallet,
|
|
63
|
+
gamification,
|
|
63
64
|
} = normalizedConfig;
|
|
64
65
|
|
|
65
66
|
const notificationServiceAvailable = !!options?.notificationServiceAvailable;
|
|
@@ -114,6 +115,7 @@ export function useFeatureDetection(
|
|
|
114
115
|
faqs: faqs.enabled,
|
|
115
116
|
subscription: subscription.enabled,
|
|
116
117
|
wallet: wallet.enabled,
|
|
118
|
+
gamification: gamification.enabled,
|
|
117
119
|
};
|
|
118
120
|
}, [normalizedConfig, navigation, options]);
|
|
119
121
|
}
|
|
@@ -20,6 +20,7 @@ import type {
|
|
|
20
20
|
CloudSyncConfig,
|
|
21
21
|
SubscriptionConfig,
|
|
22
22
|
WalletConfig,
|
|
23
|
+
GamificationConfig,
|
|
23
24
|
} from "./UserFeatureConfig";
|
|
24
25
|
|
|
25
26
|
/**
|
|
@@ -130,6 +131,12 @@ export interface SettingsConfig {
|
|
|
130
131
|
*/
|
|
131
132
|
wallet?: FeatureVisibility | WalletConfig;
|
|
132
133
|
|
|
134
|
+
/**
|
|
135
|
+
* Gamification settings configuration
|
|
136
|
+
* @default false
|
|
137
|
+
*/
|
|
138
|
+
gamification?: FeatureVisibility | GamificationConfig;
|
|
139
|
+
|
|
133
140
|
/**
|
|
134
141
|
* Custom empty state text when no settings are available
|
|
135
142
|
*/
|
|
@@ -139,3 +139,24 @@ export interface WalletConfig {
|
|
|
139
139
|
/** Current balance to display */
|
|
140
140
|
balance?: number;
|
|
141
141
|
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Gamification Settings Configuration
|
|
145
|
+
*/
|
|
146
|
+
export interface GamificationConfig {
|
|
147
|
+
/** Show gamification section */
|
|
148
|
+
enabled?: FeatureVisibility;
|
|
149
|
+
/** Custom title for the gamification section */
|
|
150
|
+
title?: string;
|
|
151
|
+
/** Custom label for the gamification item */
|
|
152
|
+
description?: string;
|
|
153
|
+
/** Custom icon name (Ionicons) */
|
|
154
|
+
icon?: string;
|
|
155
|
+
/** Custom section title for grouping */
|
|
156
|
+
sectionTitle?: string;
|
|
157
|
+
/** Navigation route for gamification screen */
|
|
158
|
+
route?: string;
|
|
159
|
+
/** Achievements to display */
|
|
160
|
+
achievementsCount?: number;
|
|
161
|
+
}
|
|
162
|
+
|
|
@@ -17,6 +17,7 @@ import type {
|
|
|
17
17
|
FAQConfig,
|
|
18
18
|
SubscriptionConfig,
|
|
19
19
|
WalletConfig,
|
|
20
|
+
GamificationConfig,
|
|
20
21
|
SettingsConfig,
|
|
21
22
|
} from "../types";
|
|
22
23
|
|
|
@@ -69,6 +70,10 @@ export interface NormalizedConfig {
|
|
|
69
70
|
enabled: boolean;
|
|
70
71
|
config?: WalletConfig;
|
|
71
72
|
};
|
|
73
|
+
gamification: {
|
|
74
|
+
enabled: boolean;
|
|
75
|
+
config?: GamificationConfig;
|
|
76
|
+
};
|
|
72
77
|
}
|
|
73
78
|
|
|
74
79
|
/**
|
|
@@ -115,5 +120,6 @@ export function normalizeSettingsConfig(
|
|
|
115
120
|
faqs: normalizeConfigValue(config?.faqs, false),
|
|
116
121
|
subscription: normalizeConfigValue(config?.subscription, false),
|
|
117
122
|
wallet: normalizeConfigValue(config?.wallet, false),
|
|
123
|
+
gamification: normalizeConfigValue(config?.gamification, false),
|
|
118
124
|
};
|
|
119
125
|
}
|