@umituz/react-native-gamification 1.4.1 β†’ 1.4.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.
Files changed (3) hide show
  1. package/package.json +2 -2
  2. package/LICENSE +0 -29
  3. package/README.md +0 -283
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-gamification",
3
- "version": "1.4.1",
3
+ "version": "1.4.2",
4
4
  "description": "Generic gamification system for React Native apps - achievements, points, levels, streaks with customizable UI components",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -51,4 +51,4 @@
51
51
  "README.md",
52
52
  "LICENSE"
53
53
  ]
54
- }
54
+ }
package/LICENSE DELETED
@@ -1,29 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2024 Ümit UZ
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
-
package/README.md DELETED
@@ -1,283 +0,0 @@
1
- # @umituz/react-native-gamification
2
-
3
- Comprehensive gamification system for React Native apps with achievements, points, levels, streaks, leaderboards, rewards, and progress tracking.
4
-
5
- ## Features
6
-
7
- - πŸ† **Achievements** - Track and unlock user achievements
8
- - πŸ’° **Points System** - Award and manage user points
9
- - πŸ“ˆ **Levels** - Experience-based leveling system
10
- - πŸ”₯ **Streaks** - Track consecutive activities
11
- - πŸ… **Leaderboards** - Competitive rankings
12
- - 🎁 **Rewards** - Unlockable rewards system
13
- - πŸ“Š **Progress Tracking** - Monitor user progress across metrics
14
-
15
- ## Installation
16
-
17
- ```bash
18
- npm install @umituz/react-native-gamification
19
- ```
20
-
21
- ## Peer Dependencies
22
-
23
- - `react` >= 18.2.0
24
- - `react-native` >= 0.74.0
25
- - `@umituz/react-native-storage` (latest)
26
- - `zustand` >= 4.0.0
27
-
28
- ## Quick Start
29
-
30
- ```typescript
31
- import { useGamification, useGamificationInitializer } from '@umituz/react-native-gamification';
32
-
33
- function App() {
34
- const userId = 'user-123';
35
- useGamificationInitializer(userId);
36
-
37
- const {
38
- achievements,
39
- pointBalance,
40
- level,
41
- addPoints,
42
- addExperience
43
- } = useGamification();
44
-
45
- // Add points when user completes an action
46
- const handleActionComplete = async () => {
47
- await addPoints(10, 'action_completed', 'action-id', 'actions', 'Completed action');
48
- };
49
-
50
- return (
51
- // Your app UI
52
- );
53
- }
54
- ```
55
-
56
- ## Usage
57
-
58
- ### Initialization
59
-
60
- ```typescript
61
- import { useGamification, useGamificationInitializer } from '@umituz/react-native-gamification';
62
-
63
- function MyComponent() {
64
- const userId = 'user-123';
65
-
66
- // Initialize gamification system
67
- useGamificationInitializer(userId);
68
-
69
- const gamification = useGamification();
70
-
71
- // Check if initialized
72
- if (!gamification.isInitialized) {
73
- return <Loading />;
74
- }
75
-
76
- return <YourContent />;
77
- }
78
- ```
79
-
80
- ### Achievements
81
-
82
- ```typescript
83
- import { useAchievements } from '@umituz/react-native-gamification';
84
-
85
- function AchievementsScreen() {
86
- const {
87
- achievements,
88
- unlockAchievement,
89
- updateAchievementProgress
90
- } = useAchievements();
91
-
92
- // Update progress
93
- await updateAchievementProgress('achievement-id', 50);
94
-
95
- // Unlock achievement
96
- await unlockAchievement('achievement-id');
97
-
98
- return (
99
- <View>
100
- {achievements.map(achievement => (
101
- <AchievementCard key={achievement.id} achievement={achievement} />
102
- ))}
103
- </View>
104
- );
105
- }
106
- ```
107
-
108
- ### Points
109
-
110
- ```typescript
111
- import { usePoints } from '@umituz/react-native-gamification';
112
-
113
- function PointsDisplay() {
114
- const {
115
- pointBalance,
116
- addPoints,
117
- deductPoints
118
- } = usePoints();
119
-
120
- // Add points
121
- await addPoints(100, 'purchase', 'purchase-id', 'purchases', 'Made a purchase');
122
-
123
- // Deduct points
124
- await deductPoints(50, 'reward_claim', 'reward-id', 'Claimed reward');
125
-
126
- return (
127
- <Text>Total Points: {pointBalance?.total || 0}</Text>
128
- );
129
- }
130
- ```
131
-
132
- ### Levels
133
-
134
- ```typescript
135
- import { useLevel } from '@umituz/react-native-gamification';
136
-
137
- function LevelDisplay() {
138
- const {
139
- level,
140
- addExperience
141
- } = useLevel();
142
-
143
- // Add experience
144
- await addExperience(50, 'action_completed');
145
-
146
- return (
147
- <View>
148
- <Text>Level: {level?.currentLevel || 1}</Text>
149
- <Text>XP: {level?.currentExperience || 0} / {level?.experienceToNextLevel || 100}</Text>
150
- <ProgressBar progress={level?.levelProgress || 0} />
151
- </View>
152
- );
153
- }
154
- ```
155
-
156
- ### Streaks
157
-
158
- ```typescript
159
- import { useStreaks } from '@umituz/react-native-gamification';
160
-
161
- function StreakDisplay() {
162
- const {
163
- streaks,
164
- updateStreakActivity
165
- } = useStreaks();
166
-
167
- // Update streak
168
- await updateStreakActivity('daily_login', new Date().toISOString());
169
-
170
- const loginStreak = streaks.find(s => s.type === 'daily_login');
171
-
172
- return (
173
- <Text>Login Streak: {loginStreak?.currentStreak || 0} days</Text>
174
- );
175
- }
176
- ```
177
-
178
- ### Rewards
179
-
180
- ```typescript
181
- import { useRewards } from '@umituz/react-native-gamification';
182
-
183
- function RewardsScreen() {
184
- const {
185
- rewards,
186
- claimReward,
187
- getAvailableRewards
188
- } = useRewards();
189
-
190
- const availableRewards = getAvailableRewards();
191
-
192
- const handleClaim = async (rewardId: string) => {
193
- const claim = await claimReward(rewardId);
194
- if (claim) {
195
- console.log('Reward claimed!');
196
- }
197
- };
198
-
199
- return (
200
- <View>
201
- {availableRewards.map(reward => (
202
- <RewardCard
203
- key={reward.id}
204
- reward={reward}
205
- onClaim={() => handleClaim(reward.id)}
206
- />
207
- ))}
208
- </View>
209
- );
210
- }
211
- ```
212
-
213
- ### Progress Tracking
214
-
215
- ```typescript
216
- import { useProgress } from '@umituz/react-native-gamification';
217
-
218
- function ProgressTracker() {
219
- const {
220
- progress,
221
- updateProgress
222
- } = useProgress();
223
-
224
- // Update progress
225
- await updateProgress({
226
- userId: 'user-123',
227
- metric: 'goals_completed',
228
- increment: 1,
229
- category: 'goals',
230
- period: 'all-time'
231
- });
232
-
233
- const goalsProgress = progress.find(p => p.metric === 'goals_completed');
234
-
235
- return (
236
- <View>
237
- <Text>Goals Completed: {goalsProgress?.currentValue || 0}</Text>
238
- <ProgressBar progress={goalsProgress?.progress || 0} />
239
- </View>
240
- );
241
- }
242
- ```
243
-
244
- ## Custom Repository
245
-
246
- You can provide a custom repository implementation for app-specific storage:
247
-
248
- ```typescript
249
- import { useGamificationRepository } from '@umituz/react-native-gamification';
250
- import { MyCustomRepository } from './MyCustomRepository';
251
-
252
- function App() {
253
- const customRepository = new MyCustomRepository();
254
-
255
- useGamificationRepository(customRepository);
256
-
257
- // Rest of your app
258
- }
259
- ```
260
-
261
- ## Architecture
262
-
263
- This package follows Domain-Driven Design (DDD) principles:
264
-
265
- - **Domain Layer** - Entities and repository interfaces
266
- - **Infrastructure Layer** - Repository implementations and stores
267
- - **Presentation Layer** - React hooks for easy integration
268
-
269
- ## License
270
-
271
- MIT
272
-
273
- ## Author
274
-
275
- Ümit UZ <umit@umituz.com>
276
-
277
-
278
-
279
-
280
-
281
-
282
-
283
-