@umituz/react-native-settings 4.23.69 → 4.23.70

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": "4.23.69",
3
+ "version": "4.23.70",
4
4
  "description": "Complete settings hub for React Native apps - consolidated package with settings, localization, about, legal, appearance, feedback, FAQs, rating, and gamification",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  /**
3
3
  * GamificationScreen Component
4
- * Full gamification screen - all text via props
4
+ * Full gamification screen with integrated hook
5
5
  * Generic for 100+ apps - NO hardcoded strings
6
6
  */
7
7
 
@@ -13,11 +13,90 @@ import { Header } from "./Header";
13
13
  import { StatsGrid } from "./StatsGrid";
14
14
  import { AchievementsList } from "./AchievementsList";
15
15
  import { styles } from "./styles";
16
- import type { GamificationScreenProps } from "./types";
16
+ import type { GamificationScreenProps, GamificationConfigProps } from "./types";
17
+ import type { Achievement } from "../../types";
17
18
 
18
19
  export type { GamificationScreenProps };
19
20
 
20
- export const GamificationScreen: React.FC<GamificationScreenProps> = ({
21
+ /**
22
+ * GamificationScreen that accepts either detailed props OR a config object
23
+ * When config is provided, a hook consumer component is used
24
+ */
25
+ export const GamificationScreen: React.FC<GamificationScreenProps | GamificationConfigProps> = (props) => {
26
+ // If config is provided, use the hook-based component
27
+ if ('config' in props && props.config) {
28
+ return <GamificationScreenWithConfig config={props.config} />;
29
+ }
30
+
31
+ // Otherwise, render directly with provided props
32
+ return <GamificationScreenInner {...(props as GamificationScreenProps)} />;
33
+ };
34
+
35
+ /**
36
+ * Component that uses the hook - separated to satisfy React Hooks rules
37
+ */
38
+ const GamificationScreenWithConfig: React.FC<GamificationConfigProps> = ({ config }) => {
39
+ // Import hook here to avoid conditional hook usage
40
+ const { useGamification } = require("../../hooks/useGamification");
41
+
42
+ const {
43
+ points,
44
+ level,
45
+ streak,
46
+ achievements,
47
+ } = useGamification(config);
48
+
49
+ // Transform store achievements to UI props
50
+ const achievementItems = achievements.map((a: Achievement) => ({
51
+ ...a,
52
+ title: a.title,
53
+ description: a.description,
54
+ icon: a.icon,
55
+ isUnlocked: a.isUnlocked,
56
+ progress: a.progress,
57
+ threshold: a.threshold,
58
+ id: a.id,
59
+ type: a.type
60
+ }));
61
+
62
+ const screenProps: GamificationScreenProps = {
63
+ title: config.translations.title,
64
+ statsTitle: config.translations.statsTitle,
65
+ achievementsTitle: config.translations.achievementsTitle,
66
+ streakTitle: config.translations.streakTitle,
67
+ levelProps: {
68
+ level: level.currentLevel,
69
+ points: level.currentPoints,
70
+ pointsToNext: level.pointsToNext,
71
+ progress: level.progress,
72
+ levelTitle: config.translations.levelTitle,
73
+ showPoints: true,
74
+ },
75
+ streakProps: {
76
+ current: streak.current,
77
+ longest: streak.longest,
78
+ currentLabel: config.translations.currentStreak,
79
+ bestLabel: config.translations.bestStreak,
80
+ daysLabel: config.translations.days,
81
+ },
82
+ stats: [
83
+ {
84
+ label: config.translations.statsTitle,
85
+ value: points,
86
+ icon: "star",
87
+ },
88
+ ],
89
+ achievements: achievementItems,
90
+ emptyAchievementsText: config.translations.emptyAchievements,
91
+ };
92
+
93
+ return <GamificationScreenInner {...screenProps} />;
94
+ };
95
+
96
+ /**
97
+ * Internal component that renders the screen with all props
98
+ */
99
+ const GamificationScreenInner: React.FC<GamificationScreenProps> = ({
21
100
  title,
22
101
  statsTitle,
23
102
  achievementsTitle,
@@ -9,6 +9,11 @@ import type { StatsCardProps } from "../StatsCard";
9
9
  import type { AchievementItemProps } from "../AchievementItem";
10
10
  import type { StreakDisplayProps } from "../StreakDisplay";
11
11
  import type { ViewStyle, TextStyle } from "react-native";
12
+ import type { GamificationConfig } from "../../types";
13
+
14
+ export interface GamificationConfigProps extends Partial<Omit<GamificationScreenProps, 'config'>> {
15
+ config: GamificationConfig;
16
+ }
12
17
 
13
18
  export interface GamificationScreenProps {
14
19
  // Section titles (all via props)
@@ -11,4 +11,3 @@ export { StreakDisplay, type StreakDisplayProps } from "./StreakDisplay";
11
11
  export { StatsCard, type StatsCardProps } from "./StatsCard";
12
12
  export { AchievementItem, type AchievementItemProps } from "./AchievementItem";
13
13
  export { GamificationScreen, type GamificationScreenProps } from "./GamificationScreen/index";
14
- export { GamificationScreenWrapper } from "./GamificationScreenWrapper";
@@ -54,5 +54,4 @@ export {
54
54
  type AchievementItemProps,
55
55
  GamificationScreen,
56
56
  type GamificationScreenProps,
57
- GamificationScreenWrapper,
58
57
  } from "./components";
@@ -13,18 +13,16 @@ import { AccountScreen } from "@umituz/react-native-auth";
13
13
  import { SettingsScreen } from "../screens/SettingsScreen";
14
14
  import { AppearanceScreen } from "../screens/AppearanceScreen";
15
15
  import { FAQScreen } from "../../domains/faqs";
16
+ import { AboutScreen } from "../../domains/about";
17
+ import { LegalScreen } from "../../domains/legal";
18
+ import { GamificationScreen } from "../../domains/gamification";
16
19
  import { useNavigationHandlers } from "./hooks";
17
- import {
18
- LegalScreenWrapper,
19
- AboutScreenWrapper,
20
- } from "./components/wrappers";
21
20
  import {
22
21
  createNotificationTranslations,
23
22
  createQuietHoursTranslations,
24
23
  createLegalScreenProps,
25
24
  } from "./utils";
26
25
  import type { SettingsStackParamList, SettingsStackNavigatorProps, AdditionalScreen } from "./types";
27
- import { GamificationScreenWrapper } from "../../domains/gamification";
28
26
 
29
27
  export const SettingsStackNavigator: React.FC<SettingsStackNavigatorProps> = ({
30
28
  appInfo,
@@ -100,12 +98,12 @@ export const SettingsStackNavigator: React.FC<SettingsStackNavigatorProps> = ({
100
98
  {
101
99
  name: "About",
102
100
  options: { headerTitle: t("settings.about.title") },
103
- children: () => <AboutScreenWrapper config={aboutConfig} />,
101
+ children: () => <AboutScreen config={aboutConfig} />,
104
102
  },
105
103
  {
106
104
  name: "Legal",
107
105
  options: { headerTitle: t("settings.legal.title") },
108
- children: () => <LegalScreenWrapper {...legalScreenProps} />,
106
+ children: () => <LegalScreen {...legalScreenProps} />,
109
107
  },
110
108
  {
111
109
  name: "Notifications",
@@ -163,7 +161,7 @@ export const SettingsStackNavigator: React.FC<SettingsStackNavigatorProps> = ({
163
161
  ? {
164
162
  name: "Gamification",
165
163
  options: { headerTitle: t("settings.gamification.title") },
166
- children: () => <GamificationScreenWrapper config={gamificationConfig} />,
164
+ children: () => <GamificationScreen config={gamificationConfig} />,
167
165
  }
168
166
  : null;
169
167
 
@@ -1,65 +0,0 @@
1
- import React from 'react';
2
- import { useGamification } from '../hooks/useGamification';
3
- import { GamificationScreen } from './GamificationScreen';
4
- import type { GamificationConfig } from '../types';
5
- import type { AchievementItemProps } from '../components';
6
-
7
- interface GamificationScreenWrapperProps {
8
- config: GamificationConfig;
9
- }
10
-
11
- export const GamificationScreenWrapper: React.FC<GamificationScreenWrapperProps> = ({ config }) => {
12
- const {
13
- points,
14
- totalTasksCompleted: _totalTasksCompleted,
15
- level,
16
- streak,
17
- achievements,
18
- } = useGamification(config);
19
-
20
- // Transform store achievements to UI props
21
- const achievementItems: AchievementItemProps[] = achievements.map(a => ({
22
- ...a,
23
- title: a.title,
24
- description: a.description,
25
- icon: a.icon,
26
- isUnlocked: a.isUnlocked,
27
- progress: a.progress,
28
- threshold: a.threshold,
29
- id: a.id,
30
- type: a.type
31
- }));
32
-
33
- return (
34
- <GamificationScreen
35
- title={config.translations.title}
36
- statsTitle={config.translations.statsTitle}
37
- achievementsTitle={config.translations.achievementsTitle}
38
- streakTitle={config.translations.streakTitle}
39
- levelProps={{
40
- level: level.currentLevel,
41
- points: level.currentPoints,
42
- pointsToNext: level.pointsToNext,
43
- progress: level.progress,
44
- levelTitle: config.translations.levelTitle,
45
- showPoints: true,
46
- }}
47
- streakProps={{
48
- current: streak.current,
49
- longest: streak.longest,
50
- currentLabel: config.translations.currentStreak,
51
- bestLabel: config.translations.bestStreak,
52
- daysLabel: config.translations.days,
53
- }}
54
- stats={[
55
- {
56
- label: config.translations.statsTitle,
57
- value: points, // Pass number directly
58
- icon: "star",
59
- },
60
- ]}
61
- achievements={achievementItems}
62
- emptyAchievementsText={config.translations.emptyAchievements}
63
- />
64
- );
65
- };
@@ -1,14 +0,0 @@
1
- /**
2
- * About Screen Wrapper Component
3
- */
4
- import React from "react";
5
- import { AboutScreen } from "../../../../domains/about";
6
- import type { AboutConfig } from "../../../../domains/about/domain/entities/AppInfo";
7
-
8
- export interface AboutScreenWrapperProps {
9
- config: AboutConfig;
10
- }
11
-
12
- export const AboutScreenWrapper: React.FC<AboutScreenWrapperProps> = ({
13
- config,
14
- }) => <AboutScreen config={config} />;
@@ -1,50 +0,0 @@
1
- /**
2
- * Legal Screen Wrapper Component
3
- */
4
- import React from "react";
5
- import { LegalScreen } from "../../../../domains/legal";
6
-
7
- export interface LegalScreenWrapperProps {
8
- title: string;
9
- description: string;
10
- documentsHeader: string;
11
- privacyTitle: string;
12
- privacyDescription: string;
13
- termsTitle: string;
14
- termsDescription: string;
15
- eulaTitle: string;
16
- eulaDescription: string;
17
- onPrivacyPress: () => void;
18
- onTermsPress: () => void;
19
- onEulaPress: () => void;
20
- }
21
-
22
- export const LegalScreenWrapper: React.FC<LegalScreenWrapperProps> = ({
23
- title,
24
- description,
25
- documentsHeader,
26
- privacyTitle,
27
- privacyDescription,
28
- termsTitle,
29
- termsDescription,
30
- eulaTitle,
31
- eulaDescription,
32
- onPrivacyPress,
33
- onTermsPress,
34
- onEulaPress,
35
- }) => (
36
- <LegalScreen
37
- title={title}
38
- description={description}
39
- documentsHeader={documentsHeader}
40
- privacyTitle={privacyTitle}
41
- privacyDescription={privacyDescription}
42
- termsTitle={termsTitle}
43
- termsDescription={termsDescription}
44
- eulaTitle={eulaTitle}
45
- eulaDescription={eulaDescription}
46
- onPrivacyPress={onPrivacyPress}
47
- onTermsPress={onTermsPress}
48
- onEulaPress={onEulaPress}
49
- />
50
- );
@@ -1,44 +0,0 @@
1
- /**
2
- * Settings Screen Wrapper Component
3
- */
4
- import React from "react";
5
- import { SettingsScreen } from "../../../screens/SettingsScreen";
6
- import type { SettingsConfig, CustomSettingsSection } from "../../../screens/types";
7
- import type { UserProfileDisplay } from "../../types";
8
- import type { DevSettingsProps } from "../../../../domains/dev";
9
-
10
- export interface SettingsScreenWrapperProps {
11
- config?: SettingsConfig;
12
- appVersion: string;
13
- showUserProfile: boolean;
14
- userProfile?: UserProfileDisplay;
15
- devSettings?: DevSettingsProps;
16
- customSections?: CustomSettingsSection[];
17
- showHeader?: boolean;
18
- showCloseButton?: boolean;
19
- onClose?: () => void;
20
- }
21
-
22
- export const SettingsScreenWrapper: React.FC<SettingsScreenWrapperProps> = ({
23
- config,
24
- appVersion,
25
- showUserProfile,
26
- userProfile,
27
- devSettings,
28
- customSections,
29
- showHeader,
30
- showCloseButton,
31
- onClose,
32
- }) => (
33
- <SettingsScreen
34
- config={config}
35
- appVersion={appVersion}
36
- showUserProfile={showUserProfile}
37
- userProfile={userProfile}
38
- devSettings={devSettings}
39
- customSections={customSections}
40
- showHeader={showHeader}
41
- showCloseButton={showCloseButton}
42
- onClose={onClose}
43
- />
44
- );
@@ -1,7 +0,0 @@
1
- /**
2
- * Wrapper Components
3
- */
4
- export { LegalScreenWrapper } from './LegalScreenWrapper';
5
- export type { LegalScreenWrapperProps } from './LegalScreenWrapper';
6
- export { AboutScreenWrapper } from './AboutScreenWrapper';
7
- export type { AboutScreenWrapperProps } from './AboutScreenWrapper';