@sency/react-native-smkit-ui 0.2.0 → 0.2.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/android/build.gradle +1 -1
- package/android/src/main/java/com/smkituilibrary/SmkitUiLibraryModule.kt +22 -3
- package/android/src/main/java/com/smkituilibrary/mapper/SMMapper.kt +3 -1
- package/android/src/main/java/com/smkituilibrary/model/SMUserData.kt +17 -0
- package/ios/SMKitUIManager.mm +2 -2
- package/ios/SMKitUIManager.swift +63 -7
- package/lib/commonjs/SMWorkout.js +143 -1
- package/lib/commonjs/SMWorkout.js.map +1 -1
- package/lib/commonjs/index.js +44 -4
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/SMWorkout.js +147 -0
- package/lib/module/SMWorkout.js.map +1 -1
- package/lib/module/index.js +44 -4
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/example/src/App.d.ts +4 -0
- package/lib/typescript/example/src/App.d.ts.map +1 -0
- package/lib/typescript/src/SMWorkout.d.ts +117 -0
- package/lib/typescript/src/SMWorkout.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +37 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/react-native-smkit-ui.podspec +1 -1
- package/src/SMWorkout.tsx +163 -0
- package/src/index.tsx +63 -6
package/src/SMWorkout.tsx
CHANGED
|
@@ -1,39 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enum representing assessment types.
|
|
3
|
+
* @enum {string}
|
|
4
|
+
*/
|
|
1
5
|
export enum AssessmentTypes {
|
|
2
6
|
Fitness = 'fitness',
|
|
3
7
|
Custom = 'custom',
|
|
4
8
|
Body360 = 'body360',
|
|
5
9
|
}
|
|
6
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Enum representing UI elements that can be displayed during workouts.
|
|
13
|
+
* @enum {string}
|
|
14
|
+
*/
|
|
7
15
|
export enum UIElement {
|
|
8
16
|
RepsCounter = 'repsCounter',
|
|
9
17
|
Timer = 'timer',
|
|
10
18
|
GaugeOfMotion = 'gaugeOfMotion',
|
|
11
19
|
}
|
|
12
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Enum representing body zones targeted in workouts.
|
|
23
|
+
* @enum {string}
|
|
24
|
+
*/
|
|
13
25
|
export enum BodyZone {
|
|
14
26
|
UpperBody = 'UpperBody',
|
|
15
27
|
LowerBody = 'LowerBody',
|
|
16
28
|
FullBody = 'FullBody',
|
|
17
29
|
}
|
|
18
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Enum representing workout difficulty levels.
|
|
33
|
+
* @enum {string}
|
|
34
|
+
*/
|
|
19
35
|
export enum WorkoutDifficulty {
|
|
20
36
|
LowDifficulty = 'LowDifficulty',
|
|
21
37
|
MidDifficulty = 'MidDifficulty',
|
|
22
38
|
HighDifficulty = 'HighDifficulty',
|
|
23
39
|
}
|
|
24
40
|
|
|
41
|
+
/**
|
|
42
|
+
* Enum representing workout durations.
|
|
43
|
+
* @enum {string}
|
|
44
|
+
*/
|
|
25
45
|
export enum WorkoutDuration {
|
|
26
46
|
Short = 'Short',
|
|
27
47
|
Long = 'Long',
|
|
28
48
|
}
|
|
29
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Enum representing different types of scoring methods.
|
|
52
|
+
* @enum {string}
|
|
53
|
+
*/
|
|
30
54
|
export enum ScoringType {
|
|
31
55
|
Rom = 'rom',
|
|
32
56
|
Time = 'time',
|
|
33
57
|
Reps = 'reps',
|
|
34
58
|
}
|
|
35
59
|
|
|
60
|
+
/**
|
|
61
|
+
* Enum representing gender options for user data.
|
|
62
|
+
* @enum {string}
|
|
63
|
+
*/
|
|
64
|
+
export enum Gender {
|
|
65
|
+
Female = 'Female',
|
|
66
|
+
Male = 'Male',
|
|
67
|
+
Other = 'Rather not say',
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Class representing a workout.
|
|
72
|
+
*/
|
|
36
73
|
export class SMWorkout {
|
|
74
|
+
/**
|
|
75
|
+
* @param {string | null} id - Unique identifier for the workout.
|
|
76
|
+
* @param {string | null} name - Name of the workout.
|
|
77
|
+
* @param {string | null} workoutIntro - URL for workout intro sound.
|
|
78
|
+
* @param {string | null} soundtrack - URL for soundtrack.
|
|
79
|
+
* @param {SMExercise[]} exercises - List of exercises included in the workout.
|
|
80
|
+
* @param {string | null} getInFrame - URL for body cal get in frame sound.
|
|
81
|
+
* @param {string | null} bodycalFinished - URL for body cal finished sound.
|
|
82
|
+
* @param {string | null} workoutClosure - URL for workout closure sound.
|
|
83
|
+
*/
|
|
37
84
|
id: string | null;
|
|
38
85
|
name: string | null;
|
|
39
86
|
workoutIntro: string | null;
|
|
@@ -77,7 +124,20 @@ export class SMWorkout {
|
|
|
77
124
|
}
|
|
78
125
|
}
|
|
79
126
|
|
|
127
|
+
/**
|
|
128
|
+
* Class representing an exercise in a workout.
|
|
129
|
+
*/
|
|
80
130
|
export class SMExercise {
|
|
131
|
+
/**
|
|
132
|
+
* @param {string | null} prettyName - Name of the exercise.
|
|
133
|
+
* @param {number | null} totalSeconds - Duration of the exercise in seconds.
|
|
134
|
+
* @param {string | null} videoInstruction - Video instruction URL.
|
|
135
|
+
* @param {string | null} exerciseIntro - URL for exercise intro sound.
|
|
136
|
+
* @param {UIElement[] | null} uiElements - List of UI elements for this exercise.
|
|
137
|
+
* @param {string} detector - Name of the detector for tracking exercise movement.
|
|
138
|
+
* @param {string | null} exerciseClosure - URL for exercise closer sound.
|
|
139
|
+
* @param {SMScoringParams | null} scoringParams - Parameters for exercise scoring.
|
|
140
|
+
*/
|
|
81
141
|
detector: string;
|
|
82
142
|
uiElements: UIElement[] | null;
|
|
83
143
|
videoInstruction: string | null;
|
|
@@ -108,7 +168,75 @@ export class SMExercise {
|
|
|
108
168
|
}
|
|
109
169
|
}
|
|
110
170
|
|
|
171
|
+
/**
|
|
172
|
+
* Class representing an exercise in an assessment.
|
|
173
|
+
*/
|
|
174
|
+
export class SMAssessmentExercise extends SMExercise {
|
|
175
|
+
/**
|
|
176
|
+
* @param {string | null} prettyName - Name of the exercise.
|
|
177
|
+
* @param {number | null} totalSeconds - Duration of the exercise in seconds.
|
|
178
|
+
* @param {string | null} videoInstruction - Video instruction URL.
|
|
179
|
+
* @param {string | null} exerciseIntro - URL for exercise intro sound.
|
|
180
|
+
* @param {UIElement[] | null} uiElements - List of UI elements for this exercise.
|
|
181
|
+
* @param {string} detector - Name of the detector for tracking exercise movement.
|
|
182
|
+
* @param {string | null} exerciseClosure - URL for exercise closer sound.
|
|
183
|
+
* @param {SMScoringParams | null} scoringParams - Parameters for exercise scoring.
|
|
184
|
+
* @param {string | null} summaryTitle - Title for the exercise summary.
|
|
185
|
+
* @param {string | null} summarySubTitle - Subtitle for the exercise summary.
|
|
186
|
+
* @param {string | null} summaryMainMetricTitle - Main metric title in the summary.
|
|
187
|
+
* @param {string | null} summaryMainMetricSubTitle - Main metric subtitle in the summary.
|
|
188
|
+
*/
|
|
189
|
+
summaryTitle: string | null;
|
|
190
|
+
summarySubTitle: string | null;
|
|
191
|
+
summaryMainMetricTitle: string | null;
|
|
192
|
+
summaryMainMetricSubTitle: string | null;
|
|
193
|
+
|
|
194
|
+
constructor(
|
|
195
|
+
prettyName: string | null,
|
|
196
|
+
totalSeconds: number | null,
|
|
197
|
+
videoInstruction: string | null,
|
|
198
|
+
exerciseIntro: string | null,
|
|
199
|
+
uiElements: UIElement[] | null,
|
|
200
|
+
detector: string,
|
|
201
|
+
exerciseClosure: string | null,
|
|
202
|
+
scoringParams: SMScoringParams | null,
|
|
203
|
+
summaryTitle: string | null,
|
|
204
|
+
summarySubTitle: string | null,
|
|
205
|
+
summaryMainMetricTitle: string | null,
|
|
206
|
+
summaryMainMetricSubTitle: string | null
|
|
207
|
+
) {
|
|
208
|
+
// Call the constructor of the parent class (SMExercise)
|
|
209
|
+
super(
|
|
210
|
+
prettyName,
|
|
211
|
+
totalSeconds,
|
|
212
|
+
videoInstruction,
|
|
213
|
+
exerciseIntro,
|
|
214
|
+
uiElements,
|
|
215
|
+
detector,
|
|
216
|
+
exerciseClosure,
|
|
217
|
+
scoringParams
|
|
218
|
+
);
|
|
219
|
+
|
|
220
|
+
// Set additional properties specific to SMAssessmentExercise
|
|
221
|
+
this.summaryTitle = summaryTitle || null;
|
|
222
|
+
this.summarySubTitle = summarySubTitle || null;
|
|
223
|
+
this.summaryMainMetricTitle = summaryMainMetricTitle || null;
|
|
224
|
+
this.summaryMainMetricSubTitle = summaryMainMetricSubTitle || null;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Class representing scoring parameters for an exercise.
|
|
230
|
+
*/
|
|
111
231
|
export class SMScoringParams {
|
|
232
|
+
/**
|
|
233
|
+
* @param {ScoringType | null} type - Type of scoring (e.g., ROM, time, reps).
|
|
234
|
+
* @param {number | null} scoreFactor - Factor to adjust the score.
|
|
235
|
+
* @param {number | null} targetTime - Target time for time-based scoring.
|
|
236
|
+
* @param {number | null} targetReps - Target reps for rep-based scoring.
|
|
237
|
+
* @param {string | null} targetRom - Range of motion target for ROM-based scoring.
|
|
238
|
+
* @param {string[] | null} passCriteria - List of criteria required to pass.
|
|
239
|
+
*/
|
|
112
240
|
type: ScoringType | null;
|
|
113
241
|
scoreFactor: number | null;
|
|
114
242
|
targetTime: number | null;
|
|
@@ -133,7 +261,18 @@ export class SMScoringParams {
|
|
|
133
261
|
}
|
|
134
262
|
}
|
|
135
263
|
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Class representing the configuration for a workout program.
|
|
267
|
+
*/
|
|
136
268
|
export class WorkoutConfig {
|
|
269
|
+
/**
|
|
270
|
+
* @param {number} week - Week number in the program.
|
|
271
|
+
* @param {BodyZone} bodyZone - Targeted body zone for the workout.
|
|
272
|
+
* @param {WorkoutDifficulty} difficultyLevel - Difficulty level of the workout.
|
|
273
|
+
* @param {WorkoutDuration} workoutDuration - Duration of the workout.
|
|
274
|
+
* @param {string} programID - Unique identifier for the workout program.
|
|
275
|
+
*/
|
|
137
276
|
week: number;
|
|
138
277
|
bodyZone: BodyZone;
|
|
139
278
|
difficultyLevel: WorkoutDifficulty;
|
|
@@ -164,3 +303,27 @@ export class WorkoutConfig {
|
|
|
164
303
|
});
|
|
165
304
|
}
|
|
166
305
|
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Class representing user data.
|
|
309
|
+
*/
|
|
310
|
+
export class UserData {
|
|
311
|
+
/**
|
|
312
|
+
* @param {Gender} gender - User's gender.
|
|
313
|
+
* @param {number} age - User's age.
|
|
314
|
+
*/
|
|
315
|
+
gender: Gender;
|
|
316
|
+
age: number;
|
|
317
|
+
|
|
318
|
+
constructor(gender: Gender, age: number) {
|
|
319
|
+
this.gender = gender;
|
|
320
|
+
this.age = age;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
toJson(): string {
|
|
324
|
+
return JSON.stringify({
|
|
325
|
+
gender: this.gender,
|
|
326
|
+
age: this.age,
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
}
|
package/src/index.tsx
CHANGED
|
@@ -18,26 +18,83 @@ const SMKitUIManager = NativeModules.SMKitUIManager
|
|
|
18
18
|
}
|
|
19
19
|
);
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* This function will configure the sdk
|
|
23
|
+
* @param {string} key - your auth key
|
|
24
|
+
*/
|
|
21
25
|
export function configure(key: string): Promise<string> {
|
|
22
26
|
return SMKitUIManager.configure(key);
|
|
23
27
|
}
|
|
24
28
|
|
|
29
|
+
/**
|
|
30
|
+
* start an assessment session.
|
|
31
|
+
*
|
|
32
|
+
* @param {SMWorkoutLibrary.AssessmentTypes} type - The type of assessment to start.
|
|
33
|
+
* @param {boolean} [showSummary=true] - Determines if the summary should be shown after assessment completion.
|
|
34
|
+
* @param {SMWorkoutLibrary.UserData | null} userData - User data for the assessment session, or `null` if no user data is provided.
|
|
35
|
+
* @param {boolean} [forceShowUserDataScreen=false] - Forces the display of the user data screen even if user data is provided.
|
|
36
|
+
* @param {string} customAssessmentID - A unique identifier for a custom assessment session.
|
|
37
|
+
* @returns {Promise<{ summary: string; didFinish: boolean }>} - A promise that resolves with an object containing the summary and a flag indicating whether the assessment finished.
|
|
38
|
+
*/
|
|
25
39
|
export function startAssessment(
|
|
26
40
|
type: SMWorkoutLibrary.AssessmentTypes,
|
|
27
|
-
showSummary: boolean,
|
|
41
|
+
showSummary: boolean = true,
|
|
42
|
+
userData: SMWorkoutLibrary.UserData | null,
|
|
43
|
+
forceShowUserDataScreen: boolean = false,
|
|
28
44
|
customAssessmentID: string
|
|
29
45
|
): Promise<{ summary: string; didFinish: boolean }> {
|
|
30
|
-
return SMKitUIManager.startAssessment(
|
|
46
|
+
return SMKitUIManager.startAssessment(
|
|
47
|
+
type,
|
|
48
|
+
showSummary,
|
|
49
|
+
userData?.toJson(),
|
|
50
|
+
forceShowUserDataScreen,
|
|
51
|
+
customAssessmentID
|
|
52
|
+
);
|
|
31
53
|
}
|
|
32
54
|
|
|
33
|
-
|
|
55
|
+
/**
|
|
56
|
+
* Starts a custom workout session.
|
|
57
|
+
*
|
|
58
|
+
* @param {SMWorkoutLibrary.SMWorkout} workout - The custom workout configuration.
|
|
59
|
+
* @returns {Promise<{ summary: string; didFinish: boolean }>} - A promise that resolves with an object containing the summary and a flag indicating if the workout session finished.
|
|
60
|
+
*/
|
|
61
|
+
export function startCustomWorkout(
|
|
62
|
+
workout: SMWorkoutLibrary.SMWorkout
|
|
63
|
+
): Promise<{ summary: string; didFinish: boolean }> {
|
|
34
64
|
return SMKitUIManager.startCustomWorkout(workout.toJson());
|
|
35
65
|
}
|
|
36
66
|
|
|
37
|
-
|
|
38
|
-
|
|
67
|
+
/**
|
|
68
|
+
* Initiates a custom assessment session.
|
|
69
|
+
*
|
|
70
|
+
* @param {SMWorkoutLibrary.SMWorkout} assessment - The assessment configuration for the session.
|
|
71
|
+
* @param {SMWorkoutLibrary.UserData | null} userData - User data for the assessment, or `null` if no user data is provided.
|
|
72
|
+
* @param {boolean} [forceShowUserDataScreen=false] - Forces the display of the user data screen even if user data is provided.
|
|
73
|
+
* @param {boolean} [showSummary=true] - Determines if the summary should be shown after assessment completion.
|
|
74
|
+
* @returns {Promise<{ summary: string; didFinish: boolean }>} - A promise that resolves with an object containing the summary and a flag indicating if the assessment finished.
|
|
75
|
+
*/
|
|
76
|
+
export function startCustomAssessment(
|
|
77
|
+
assessment: SMWorkoutLibrary.SMWorkout,
|
|
78
|
+
userData: SMWorkoutLibrary.UserData | null,
|
|
79
|
+
forceShowUserDataScreen: boolean = false,
|
|
80
|
+
showSummary: boolean = true
|
|
81
|
+
): Promise<{ summary: string; didFinish: boolean }> {
|
|
82
|
+
return SMKitUIManager.startCustomAssessment(
|
|
83
|
+
assessment.toJson(),
|
|
84
|
+
userData?.toJson(),
|
|
85
|
+
forceShowUserDataScreen,
|
|
86
|
+
showSummary
|
|
87
|
+
);
|
|
39
88
|
}
|
|
40
89
|
|
|
41
|
-
|
|
90
|
+
/**
|
|
91
|
+
* Starts a workout program using the provided workout configuration.
|
|
92
|
+
*
|
|
93
|
+
* @param {SMWorkoutLibrary.WorkoutConfig} workoutConfig - The configuration for the workout program.
|
|
94
|
+
* @returns {Promise<{ summary: string; didFinish: boolean }>} - A promise that resolves with an object containing the summary and a flag indicating if the workout program finished.
|
|
95
|
+
*/
|
|
96
|
+
export function startWorkoutProgram(
|
|
97
|
+
workoutConfig: SMWorkoutLibrary.WorkoutConfig
|
|
98
|
+
): Promise<{ summary: string; didFinish: boolean }> {
|
|
42
99
|
return SMKitUIManager.startWorkoutProgram(workoutConfig.toJson());
|
|
43
100
|
}
|