@umituz/react-native-settings 4.21.11 → 4.21.13

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.
Files changed (47) hide show
  1. package/package.json +11 -2
  2. package/src/domains/gamification/components/GamificationScreenWrapper.tsx +58 -85
  3. package/src/domains/gamification/components/index.ts +1 -0
  4. package/src/domains/gamification/index.ts +4 -11
  5. package/src/domains/gamification/types/index.ts +18 -0
  6. package/src/domains/notifications/index.ts +139 -0
  7. package/src/domains/notifications/infrastructure/config/notificationsConfig.ts +98 -0
  8. package/src/domains/notifications/infrastructure/hooks/useNotificationSettings.ts +37 -0
  9. package/src/domains/notifications/infrastructure/services/NotificationBadgeManager.ts +28 -0
  10. package/src/domains/notifications/infrastructure/services/NotificationManager.ts +138 -0
  11. package/src/domains/notifications/infrastructure/services/NotificationPermissions.ts +80 -0
  12. package/src/domains/notifications/infrastructure/services/NotificationScheduler.ts +77 -0
  13. package/src/domains/notifications/infrastructure/services/NotificationService.ts +50 -0
  14. package/src/domains/notifications/infrastructure/services/types.ts +176 -0
  15. package/src/domains/notifications/infrastructure/storage/NotificationsStore.ts +45 -0
  16. package/src/domains/notifications/infrastructure/utils/dev.ts +25 -0
  17. package/src/domains/notifications/infrastructure/utils/idGenerator.ts +14 -0
  18. package/src/domains/notifications/infrastructure/utils/triggerBuilder.ts +45 -0
  19. package/src/domains/notifications/presentation/components/NotificationsSection.tsx +84 -0
  20. package/src/domains/notifications/presentation/components/RemindersNavRow.styles.ts +38 -0
  21. package/src/domains/notifications/presentation/components/RemindersNavRow.tsx +51 -0
  22. package/src/domains/notifications/presentation/components/SettingRow.tsx +86 -0
  23. package/src/domains/notifications/presentation/hooks/useNotificationSettingsUI.ts +52 -0
  24. package/src/domains/notifications/presentation/hooks/useTimePicker.ts +71 -0
  25. package/src/domains/notifications/presentation/screens/NotificationSettingsScreen.styles.ts +30 -0
  26. package/src/domains/notifications/presentation/screens/NotificationSettingsScreen.tsx +131 -0
  27. package/src/domains/notifications/presentation/screens/NotificationsScreen.tsx +107 -0
  28. package/src/domains/notifications/quietHours/infrastructure/hooks/useQuietHoursActions.ts +52 -0
  29. package/src/domains/notifications/quietHours/presentation/components/QuietHoursCard.tsx +112 -0
  30. package/src/domains/notifications/reminders/infrastructure/config/reminderPresets.ts +120 -0
  31. package/src/domains/notifications/reminders/infrastructure/hooks/useReminderActions.ts +106 -0
  32. package/src/domains/notifications/reminders/infrastructure/storage/RemindersStore.ts +148 -0
  33. package/src/domains/notifications/reminders/presentation/components/FormButton.tsx +66 -0
  34. package/src/domains/notifications/reminders/presentation/components/FrequencySelector.tsx +72 -0
  35. package/src/domains/notifications/reminders/presentation/components/ReminderForm.tsx +169 -0
  36. package/src/domains/notifications/reminders/presentation/components/ReminderItem.tsx +130 -0
  37. package/src/domains/notifications/reminders/presentation/components/TimePresetSelector.tsx +100 -0
  38. package/src/domains/notifications/reminders/presentation/components/WeekdaySelector.tsx +61 -0
  39. package/src/domains/notifications/reminders/presentation/screens/ReminderListScreen.tsx +131 -0
  40. package/src/index.ts +3 -0
  41. package/src/presentation/navigation/SettingsStackNavigator.tsx +21 -11
  42. package/src/presentation/screens/components/sections/FeatureSettingsSection.tsx +1 -1
  43. package/src/domains/gamification/README.md +0 -343
  44. package/src/domains/gamification/components/GamificationSettingsItem.tsx +0 -33
  45. package/src/domains/gamification/examples/gamification.config.example.ts +0 -70
  46. package/src/domains/gamification/examples/localization.example.json +0 -71
  47. package/src/domains/gamification/types/settings.ts +0 -28
@@ -1,343 +0,0 @@
1
- # Gamification Domain
2
-
3
- Complete gamification integration for React Native Settings package.
4
-
5
- ## Overview
6
-
7
- The gamification domain provides a seamless integration of achievements, levels, streaks, and points into your settings screen. It wraps `@umituz/react-native-gamification` with settings-specific functionality.
8
-
9
- ## Features
10
-
11
- - ✅ **Achievements System** - Track and display user achievements
12
- - ✅ **Level Progression** - Visual level progress with points
13
- - ✅ **Streak Tracking** - Daily streak monitoring
14
- - ✅ **Statistics Display** - Comprehensive stats cards
15
- - ✅ **Localized** - Full i18n support via `@umituz/react-native-localization`
16
- - ✅ **Theme Support** - Automatic dark/light mode integration
17
- - ✅ **Navigation Ready** - Pre-configured navigation integration
18
-
19
- ## Architecture
20
-
21
- ```
22
- src/domains/gamification/
23
- ├── types/
24
- │ └── index.ts # Type definitions
25
- ├── components/
26
- │ ├── GamificationScreenWrapper.tsx # Main screen wrapper
27
- │ └── GamificationSettingsItem.tsx # Menu item component
28
- └── index.ts # Public API
29
- ```
30
-
31
- ## Installation
32
-
33
- The gamification domain is included in `@umituz/react-native-settings`. Ensure you have the peer dependency:
34
-
35
- ```bash
36
- npm install @umituz/react-native-gamification
37
- ```
38
-
39
- ## Usage
40
-
41
- ### 1. Configure Gamification in Settings
42
-
43
- ```typescript
44
- // src/domains/settings/config/gamification.config.ts
45
- import type { GamificationSettingsConfig } from "@umituz/react-native-settings";
46
-
47
- export const createGamificationConfig = ({ t }): GamificationSettingsConfig => ({
48
- enabled: true,
49
- config: {
50
- storageKey: "app_gamification",
51
- achievements: [
52
- { id: "first_task", threshold: 1, type: "count" },
53
- { id: "ten_tasks", threshold: 10, type: "count" },
54
- { id: "week_streak", threshold: 7, type: "streak" },
55
- ],
56
- levels: [
57
- { level: 1, minPoints: 0, maxPoints: 50 },
58
- { level: 2, minPoints: 50, maxPoints: 150 },
59
- { level: 3, minPoints: 150, maxPoints: 300 },
60
- ],
61
- pointsPerAction: 10,
62
- streakBonusMultiplier: 1.5,
63
- },
64
- screenProps: {
65
- title: t("gamification.title"),
66
- statsTitle: t("gamification.stats.title"),
67
- achievementsTitle: t("gamification.achievements.title"),
68
- streakTitle: t("gamification.streak.title"),
69
- },
70
- });
71
- ```
72
-
73
- ### 2. Add to Settings Config
74
-
75
- ```typescript
76
- // src/domains/settings/config/settings.config.ts
77
- import { createGamificationConfig } from "./gamification.config";
78
-
79
- export const createSettingsConfig = ({ t, user, isPremium }) => ({
80
- // ... other configs
81
- gamification: createGamificationConfig({ t }),
82
- });
83
- ```
84
-
85
- ### 3. Pass to SettingsStackNavigator
86
-
87
- ```typescript
88
- // src/domains/settings/presentation/SettingsTab.tsx
89
- import { SettingsStackNavigator } from "@umituz/react-native-settings";
90
-
91
- export const SettingsTab = () => {
92
- const { t } = useLocalization();
93
- const config = useMemo(() => createSettingsConfig({ t }), [t]);
94
-
95
- return (
96
- <SettingsStackNavigator
97
- appInfo={APP_INFO}
98
- legalUrls={LEGAL_URLS}
99
- gamificationConfig={config.gamification}
100
- />
101
- );
102
- };
103
- ```
104
-
105
- ### 4. Add Menu Item (Optional)
106
-
107
- ```typescript
108
- // In your custom settings sections
109
- import { GamificationSettingsItem } from "@umituz/react-native-settings";
110
-
111
- const customSections = [
112
- {
113
- title: t("settings.sections.engagement"),
114
- items: [
115
- <GamificationSettingsItem
116
- config={{
117
- enabled: true,
118
- title: t("settings.gamification.menuTitle"),
119
- subtitle: t("settings.gamification.menuSubtitle"),
120
- icon: "trophy",
121
- onPress: () => navigation.navigate("Gamification"),
122
- }}
123
- />,
124
- ],
125
- },
126
- ];
127
- ```
128
-
129
- ## Localization
130
-
131
- Add these keys to your localization files:
132
-
133
- ```json
134
- {
135
- "settings": {
136
- "gamification": {
137
- "title": "Achievements",
138
- "menuTitle": "Achievements & Progress",
139
- "menuSubtitle": "View your achievements and stats"
140
- }
141
- },
142
- "gamification": {
143
- "title": "Your Progress",
144
- "level": {
145
- "title": "Level {{level}}"
146
- },
147
- "stats": {
148
- "title": "Statistics",
149
- "totalPoints": "Total Points",
150
- "tasksCompleted": "Tasks Completed",
151
- "achievementsUnlocked": "Achievements"
152
- },
153
- "achievements": {
154
- "title": "Achievements",
155
- "empty": "No achievements yet. Keep going!",
156
- "first_task": {
157
- "title": "First Steps",
158
- "description": "Complete your first task"
159
- },
160
- "ten_tasks": {
161
- "title": "Getting Started",
162
- "description": "Complete 10 tasks"
163
- },
164
- "week_streak": {
165
- "title": "Week Warrior",
166
- "description": "Maintain a 7-day streak"
167
- }
168
- },
169
- "streak": {
170
- "title": "Streak",
171
- "current": "Current Streak",
172
- "best": "Best Streak"
173
- }
174
- }
175
- }
176
- ```
177
-
178
- ## API Reference
179
-
180
- ### Types
181
-
182
- #### `GamificationSettingsConfig`
183
-
184
- ```typescript
185
- interface GamificationSettingsConfig {
186
- enabled: boolean;
187
- config: GamificationConfig;
188
- screenProps: Omit<GamificationScreenProps, "levelProps" | "stats" | "achievements">;
189
- onNavigate?: () => void;
190
- }
191
- ```
192
-
193
- #### `GamificationMenuConfig`
194
-
195
- ```typescript
196
- interface GamificationMenuConfig {
197
- enabled: boolean;
198
- title: string;
199
- subtitle?: string;
200
- icon?: string;
201
- onPress?: () => void;
202
- }
203
- ```
204
-
205
- ### Components
206
-
207
- #### `GamificationScreenWrapper`
208
-
209
- Main screen component that displays gamification data.
210
-
211
- **Props:**
212
- - `config: GamificationSettingsConfig` - Configuration object
213
-
214
- #### `GamificationSettingsItem`
215
-
216
- Menu item component for settings list.
217
-
218
- **Props:**
219
- - `config: GamificationMenuConfig` - Menu configuration
220
-
221
- ## Re-exported Components
222
-
223
- All components from `@umituz/react-native-gamification` are re-exported for convenience:
224
-
225
- ```typescript
226
- import {
227
- LevelProgress,
228
- PointsBadge,
229
- AchievementCard,
230
- AchievementToast,
231
- StreakDisplay,
232
- StatsCard,
233
- AchievementItem,
234
- useGamification,
235
- useGamificationStore,
236
- } from "@umituz/react-native-settings";
237
- ```
238
-
239
- ## Example: Complete Integration
240
-
241
- ```typescript
242
- // 1. Create config
243
- const gamificationConfig: GamificationSettingsConfig = {
244
- enabled: true,
245
- config: {
246
- storageKey: "my_app_gamification",
247
- achievements: [
248
- { id: "first_login", threshold: 1, type: "milestone" },
249
- { id: "power_user", threshold: 100, type: "count" },
250
- ],
251
- levels: [
252
- { level: 1, minPoints: 0, maxPoints: 100 },
253
- { level: 2, minPoints: 100, maxPoints: 250 },
254
- ],
255
- pointsPerAction: 5,
256
- },
257
- screenProps: {
258
- title: "Your Achievements",
259
- statsTitle: "Your Stats",
260
- achievementsTitle: "Unlocked Achievements",
261
- streakTitle: "Daily Streak",
262
- },
263
- };
264
-
265
- // 2. Use in navigator
266
- <SettingsStackNavigator
267
- appInfo={APP_INFO}
268
- legalUrls={LEGAL_URLS}
269
- gamificationConfig={gamificationConfig}
270
- />
271
-
272
- // 3. Track actions in your app
273
- import { useGamification } from "@umituz/react-native-settings";
274
-
275
- const MyComponent = () => {
276
- const { completeTask, addPoints } = useGamification();
277
-
278
- const handleTaskComplete = () => {
279
- completeTask(); // Adds points, updates streak, checks achievements
280
- };
281
-
282
- return <Button onPress={handleTaskComplete} title="Complete Task" />;
283
- };
284
- ```
285
-
286
- ## Best Practices
287
-
288
- 1. **Config Files ≤ 80 lines** - Keep gamification config in separate file
289
- 2. **Use i18n** - Never hardcode strings, always use translation keys
290
- 3. **Initialize Early** - Initialize gamification in app startup
291
- 4. **Track Meaningfully** - Only track actions that matter to users
292
- 5. **Test Achievements** - Ensure thresholds are achievable and rewarding
293
-
294
- ## Testing
295
-
296
- ```typescript
297
- import { useGamification } from "@umituz/react-native-settings";
298
-
299
- describe("Gamification", () => {
300
- it("should track task completion", () => {
301
- const { completeTask, totalTasksCompleted } = useGamification();
302
- completeTask();
303
- expect(totalTasksCompleted).toBe(1);
304
- });
305
- });
306
- ```
307
-
308
- ## Troubleshooting
309
-
310
- ### Gamification screen not showing
311
- - Ensure `gamificationConfig.enabled` is `true`
312
- - Check that config is passed to `SettingsStackNavigator`
313
-
314
- ### Achievements not unlocking
315
- - Verify achievement IDs match between config and localization
316
- - Check threshold values are correct
317
- - Ensure `completeTask()` or `addPoints()` is being called
318
-
319
- ### Localization missing
320
- - Add all required translation keys
321
- - Check language files are properly loaded
322
-
323
- ## Migration Guide
324
-
325
- If migrating from standalone gamification package:
326
-
327
- ```typescript
328
- // Before
329
- import { GamificationScreen } from "@umituz/react-native-gamification";
330
-
331
- // After
332
- import { GamificationScreenWrapper } from "@umituz/react-native-settings";
333
- ```
334
-
335
- ## Related Documentation
336
-
337
- - [@umituz/react-native-gamification](../../../react-native-gamification/README.md)
338
- - [Settings Architecture](../../ARCHITECTURE.md)
339
- - [Settings Screen Guide](../../SETTINGS_SCREEN_GUIDE.md)
340
-
341
- ## License
342
-
343
- MIT © Ümit UZ
@@ -1,33 +0,0 @@
1
- /**
2
- * Gamification Settings Item Component
3
- * Menu item to navigate to gamification screen
4
- */
5
-
6
- import React from "react";
7
- import { SettingsItemCard } from "../../../presentation/components/SettingsItemCard";
8
- import type { GamificationMenuConfig } from "../types/settings";
9
-
10
- export interface GamificationSettingsItemProps {
11
- config: GamificationMenuConfig;
12
- }
13
-
14
- /**
15
- * Gamification menu item for settings screen
16
- */
17
- export const GamificationSettingsItem: React.FC<GamificationSettingsItemProps> = ({
18
- config,
19
- }) => {
20
- if (!config.enabled) {
21
- return null;
22
- }
23
-
24
- return (
25
- <SettingsItemCard
26
- title={config.title}
27
- description={config.subtitle}
28
- icon={config.icon || "trophy"}
29
- onPress={config.onPress}
30
- showChevron
31
- />
32
- );
33
- };
@@ -1,70 +0,0 @@
1
- /**
2
- * Gamification Configuration Example
3
- *
4
- * Copy this file to your app's settings config directory:
5
- * src/domains/settings/config/gamification.config.ts
6
- */
7
-
8
- import type { GamificationSettingsConfig } from "../types/settings";
9
-
10
- /**
11
- * Creates gamification configuration for settings
12
- *
13
- * @param t - Translation function from useLocalization
14
- * @returns Gamification settings configuration
15
- */
16
- export const createGamificationConfig = ({ t }): GamificationSettingsConfig => ({
17
- enabled: true,
18
-
19
- // Gamification system configuration
20
- config: {
21
- storageKey: "app_gamification_data",
22
-
23
- // Define achievements
24
- achievements: [
25
- // Count-based achievements
26
- { id: "first_task", threshold: 1, type: "count" },
27
- { id: "five_tasks", threshold: 5, type: "count" },
28
- { id: "ten_tasks", threshold: 10, type: "count" },
29
- { id: "fifty_tasks", threshold: 50, type: "count" },
30
- { id: "hundred_tasks", threshold: 100, type: "count" },
31
-
32
- // Streak-based achievements
33
- { id: "three_day_streak", threshold: 3, type: "streak" },
34
- { id: "week_streak", threshold: 7, type: "streak" },
35
- { id: "month_streak", threshold: 30, type: "streak" },
36
-
37
- // Milestone achievements
38
- { id: "first_login", threshold: 1, type: "milestone" },
39
- { id: "power_user", threshold: 1, type: "milestone" },
40
- ],
41
-
42
- // Define level progression
43
- levels: [
44
- { level: 1, minPoints: 0, maxPoints: 50 },
45
- { level: 2, minPoints: 50, maxPoints: 150 },
46
- { level: 3, minPoints: 150, maxPoints: 300 },
47
- { level: 4, minPoints: 300, maxPoints: 500 },
48
- { level: 5, minPoints: 500, maxPoints: 800 },
49
- { level: 6, minPoints: 800, maxPoints: 1200 },
50
- { level: 7, minPoints: 1200, maxPoints: 1700 },
51
- { level: 8, minPoints: 1700, maxPoints: 2300 },
52
- { level: 9, minPoints: 2300, maxPoints: 3000 },
53
- { level: 10, minPoints: 3000, maxPoints: 999999 },
54
- ],
55
-
56
- // Points awarded per action
57
- pointsPerAction: 10,
58
-
59
- // Streak bonus multiplier (1.5 = 50% bonus)
60
- streakBonusMultiplier: 1.5,
61
- },
62
-
63
- // Screen display configuration
64
- screenProps: {
65
- title: t("gamification.title"),
66
- statsTitle: t("gamification.stats.title"),
67
- achievementsTitle: t("gamification.achievements.title"),
68
- streakTitle: t("gamification.streak.title"),
69
- },
70
- });
@@ -1,71 +0,0 @@
1
- {
2
- "settings": {
3
- "gamification": {
4
- "title": "Achievements",
5
- "menuTitle": "Achievements & Progress",
6
- "menuSubtitle": "View your achievements and stats"
7
- }
8
- },
9
- "gamification": {
10
- "title": "Your Progress",
11
- "level": {
12
- "title": "Level {{level}}"
13
- },
14
- "stats": {
15
- "title": "Statistics",
16
- "totalPoints": "Total Points",
17
- "tasksCompleted": "Tasks Completed",
18
- "achievementsUnlocked": "Achievements Unlocked"
19
- },
20
- "achievements": {
21
- "title": "Achievements",
22
- "empty": "No achievements yet. Keep going!",
23
- "first_task": {
24
- "title": "First Steps",
25
- "description": "Complete your first task"
26
- },
27
- "five_tasks": {
28
- "title": "Getting Started",
29
- "description": "Complete 5 tasks"
30
- },
31
- "ten_tasks": {
32
- "title": "On a Roll",
33
- "description": "Complete 10 tasks"
34
- },
35
- "fifty_tasks": {
36
- "title": "Dedicated",
37
- "description": "Complete 50 tasks"
38
- },
39
- "hundred_tasks": {
40
- "title": "Century Club",
41
- "description": "Complete 100 tasks"
42
- },
43
- "three_day_streak": {
44
- "title": "Consistent",
45
- "description": "Maintain a 3-day streak"
46
- },
47
- "week_streak": {
48
- "title": "Week Warrior",
49
- "description": "Maintain a 7-day streak"
50
- },
51
- "month_streak": {
52
- "title": "Monthly Master",
53
- "description": "Maintain a 30-day streak"
54
- },
55
- "first_login": {
56
- "title": "Welcome!",
57
- "description": "Join the community"
58
- },
59
- "power_user": {
60
- "title": "Power User",
61
- "description": "Unlock all features"
62
- }
63
- },
64
- "streak": {
65
- "title": "Daily Streak",
66
- "current": "Current Streak",
67
- "best": "Best Streak",
68
- "days": "days"
69
- }
70
- }
71
- }
@@ -1,28 +0,0 @@
1
- /**
2
- * Gamification Settings Integration Types
3
- * Wrapper types for integrating gamification into settings
4
- */
5
-
6
- import type { GamificationConfig } from "./index";
7
- import type { GamificationScreenProps } from "../components/GamificationScreen/types";
8
-
9
- /**
10
- * Configuration for gamification in settings
11
- */
12
- export interface GamificationSettingsConfig {
13
- enabled: boolean;
14
- config: GamificationConfig;
15
- screenProps: Omit<GamificationScreenProps, "levelProps" | "stats" | "achievements">;
16
- onNavigate?: () => void;
17
- }
18
-
19
- /**
20
- * Configuration for gamification menu item
21
- */
22
- export interface GamificationMenuConfig {
23
- enabled: boolean;
24
- title: string;
25
- subtitle?: string;
26
- icon?: string;
27
- onPress?: () => void;
28
- }