@sency/react-native-smkit-ui 2.0.1 → 2.0.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 +2 -2
- package/android/gradle.properties +1 -1
- package/android/src/main/java/com/smkituilibrary/SmkitUiLibraryModule.kt +47 -14
- package/ios/SMKitUIManager.mm +5 -6
- package/ios/SMKitUIManager.swift +74 -34
- package/ios/SmkitUiLibrary-Bridging-Header.h +1 -1
- package/lib/commonjs/index.js +28 -12
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +28 -12
- package/lib/module/index.js.map +1 -1
- package/package.json +2 -2
- package/react-native-smkit-ui.podspec +1 -1
- package/src/index.tsx +46 -18
package/android/build.gradle
CHANGED
|
@@ -8,7 +8,7 @@ buildscript {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
dependencies {
|
|
11
|
-
classpath "com.android.tools.build:gradle:8.
|
|
11
|
+
classpath "com.android.tools.build:gradle:8.6.1"
|
|
12
12
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
13
13
|
}
|
|
14
14
|
}
|
|
@@ -95,7 +95,7 @@ dependencies {
|
|
|
95
95
|
implementation "com.facebook.react:react-android"
|
|
96
96
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
97
97
|
|
|
98
|
-
implementation("com.sency.smkitui:smkitui:1.
|
|
98
|
+
implementation("com.sency.smkitui:smkitui:1.4.2") {
|
|
99
99
|
exclude group: 'com.facebook.fbjni', module: 'fbjni-java-only'
|
|
100
100
|
// // Don't exclude native libraries
|
|
101
101
|
// exclude group: 'com.facebook.react', module: 'react-native'
|
|
@@ -186,8 +186,10 @@ class SmkitUiLibraryModule(reactContext: ReactApplicationContext) :
|
|
|
186
186
|
userData: String?,
|
|
187
187
|
forceShowUserDataScreen: Boolean,
|
|
188
188
|
customAssessmentId: String,
|
|
189
|
-
|
|
189
|
+
modifications: String?,
|
|
190
|
+
promise: Promise
|
|
190
191
|
) {
|
|
192
|
+
Log.d(TAG, "startAssessment called - type: $type, showSummary: $showSummary, userData: $userData, forceShowUserDataScreen: $forceShowUserDataScreen, customAssessmentId: $customAssessmentId, modifications: $modifications")
|
|
191
193
|
this.resultPromise = promise
|
|
192
194
|
compactJson = false
|
|
193
195
|
try {
|
|
@@ -203,24 +205,32 @@ class SmkitUiLibraryModule(reactContext: ReactApplicationContext) :
|
|
|
203
205
|
listener = listener,
|
|
204
206
|
assessmentType = assessmentType,
|
|
205
207
|
userData = user,
|
|
206
|
-
showSummary = showSummary
|
|
208
|
+
showSummary = showSummary,
|
|
209
|
+
modifications = modifications
|
|
207
210
|
)
|
|
208
211
|
} catch (e: Exception) {
|
|
209
|
-
|
|
212
|
+
Log.e(TAG, "Exception in startAssessment", e)
|
|
213
|
+
promise.reject("Starting Assessment Failed", e.message ?: e.toString(), e)
|
|
210
214
|
}
|
|
211
215
|
}
|
|
212
216
|
|
|
213
217
|
@ReactMethod
|
|
214
|
-
fun startCustomWorkout(jsonArguments: String, promise: Promise) {
|
|
218
|
+
fun startCustomWorkout(jsonArguments: String, modifications: String?, promise: Promise) {
|
|
215
219
|
compactJson = false
|
|
216
220
|
|
|
217
221
|
try {
|
|
222
|
+
Log.d(TAG, "startCustomWorkout called with modifications: $modifications")
|
|
218
223
|
resultPromise = promise
|
|
219
|
-
serializeWorkout(jsonArguments)
|
|
220
|
-
|
|
224
|
+
val workout = serializeWorkout(jsonArguments)
|
|
225
|
+
if (workout == null) {
|
|
226
|
+
Log.e(TAG, "Failed to serialize workout from JSON")
|
|
227
|
+
promise.reject("Starting Custom Workout Failed", "Failed to parse workout JSON")
|
|
228
|
+
return
|
|
221
229
|
}
|
|
230
|
+
smKitUI?.startCustomizedWorkout(workout = workout, listener = listener, modifications = modifications)
|
|
222
231
|
} catch (e: Exception) {
|
|
223
|
-
|
|
232
|
+
Log.e(TAG, "Exception in startCustomWorkout", e)
|
|
233
|
+
promise.reject("Starting Custom Workout Failed", e.message ?: e.toString(), e)
|
|
224
234
|
}
|
|
225
235
|
}
|
|
226
236
|
|
|
@@ -230,16 +240,32 @@ class SmkitUiLibraryModule(reactContext: ReactApplicationContext) :
|
|
|
230
240
|
userDataJson: String?,
|
|
231
241
|
forceShowUserDataScreen: Boolean,
|
|
232
242
|
showSummary: Boolean,
|
|
243
|
+
modifications: String?,
|
|
233
244
|
promise: Promise
|
|
234
245
|
) {
|
|
235
246
|
compactJson = true
|
|
236
247
|
try {
|
|
248
|
+
Log.d(TAG, "startCustomAssessment called with modifications: $modifications")
|
|
237
249
|
resultPromise = promise
|
|
238
|
-
serializeWorkout(assessmentJson)
|
|
239
|
-
|
|
250
|
+
val workout = serializeWorkout(assessmentJson)
|
|
251
|
+
if (workout == null) {
|
|
252
|
+
Log.e(TAG, "Failed to serialize workout from JSON")
|
|
253
|
+
promise.reject("Starting Custom Assessment Failed", "Failed to parse workout JSON")
|
|
254
|
+
return
|
|
255
|
+
}
|
|
256
|
+
Log.d(TAG, "Starting customized assessment with workout: ${workout.name}")
|
|
257
|
+
smKitUI?.startCustomizedAssessment(
|
|
258
|
+
workout = workout,
|
|
259
|
+
showSummary = showSummary,
|
|
260
|
+
listener = listener,
|
|
261
|
+
modifications = modifications
|
|
262
|
+
) ?: run {
|
|
263
|
+
Log.e(TAG, "SMKitUI is null, cannot start assessment")
|
|
264
|
+
promise.reject("Starting Custom Assessment Failed", "SMKitUI not configured")
|
|
240
265
|
}
|
|
241
266
|
} catch (e: Exception) {
|
|
242
|
-
|
|
267
|
+
Log.e(TAG, "Exception in startCustomAssessment", e)
|
|
268
|
+
promise.reject("Starting Custom Assessment Failed", e.message ?: e.toString(), e)
|
|
243
269
|
}
|
|
244
270
|
}
|
|
245
271
|
|
|
@@ -251,20 +277,27 @@ class SmkitUiLibraryModule(reactContext: ReactApplicationContext) :
|
|
|
251
277
|
|
|
252
278
|
|
|
253
279
|
@ReactMethod
|
|
254
|
-
fun startWorkoutProgram(jsonArguments: String, promise: Promise) {
|
|
280
|
+
fun startWorkoutProgram(jsonArguments: String, modifications: String?, promise: Promise) {
|
|
255
281
|
compactJson = true
|
|
256
282
|
try {
|
|
257
|
-
Log.d(TAG, "startWorkoutProgram: $jsonArguments")
|
|
283
|
+
Log.d(TAG, "startWorkoutProgram: $jsonArguments, modifications: $modifications")
|
|
258
284
|
val adapter = moshi.adapter(SMKitWorkoutConfig::class.java)
|
|
259
|
-
val smKitWorkoutConfig = adapter.fromJson(jsonArguments)
|
|
285
|
+
val smKitWorkoutConfig = adapter.fromJson(jsonArguments)
|
|
286
|
+
if (smKitWorkoutConfig == null) {
|
|
287
|
+
Log.e(TAG, "Failed to parse workout config JSON")
|
|
288
|
+
promise.reject("Starting workout from program Failed", "Failed to parse workout config JSON")
|
|
289
|
+
return
|
|
290
|
+
}
|
|
260
291
|
|
|
261
292
|
resultPromise = promise
|
|
262
293
|
smKitUI?.startWorkoutProgram(
|
|
263
294
|
workoutConfig = smKitWorkoutConfig.toWorkoutConfig(),
|
|
264
295
|
listener = listener,
|
|
296
|
+
modifications = modifications
|
|
265
297
|
)
|
|
266
298
|
} catch (e: Exception) {
|
|
267
|
-
|
|
299
|
+
Log.e(TAG, "Exception in startWorkoutProgram", e)
|
|
300
|
+
promise.reject("Starting workout from program Failed", e.message ?: e.toString(), e)
|
|
268
301
|
}
|
|
269
302
|
}
|
|
270
303
|
|
package/ios/SMKitUIManager.mm
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
#import <React/RCTBridgeModule.h>
|
|
2
|
-
#import "React/RCTViewManager.h"
|
|
3
2
|
|
|
4
|
-
@interface RCT_EXTERN_MODULE(SMKitUIManager,
|
|
3
|
+
@interface RCT_EXTERN_MODULE(SMKitUIManager, NSObject)
|
|
5
4
|
RCT_EXTERN_METHOD(configure:(NSString*)key onSuccess:(RCTPromiseResolveBlock)onSuccess onFailure:(RCTPromiseRejectBlock)onFailure)
|
|
6
|
-
RCT_EXTERN_METHOD(startAssessment:(NSString*)type showSummary:(BOOL)showSummary userData:(NSString*)userData forceShowUserDataScreen:(BOOL)forceShowUserDataScreen customAssessmentID:(NSString*)customAssessmentID onWorkoutDidFinish:(RCTPromiseResolveBlock)onWorkoutDidFinish onWorkoutFailed:(RCTPromiseRejectBlock)onWorkoutFailed)
|
|
7
|
-
RCT_EXTERN_METHOD(startCustomWorkout:(NSString*)rawJson onWorkoutDidFinish:(RCTPromiseResolveBlock)onWorkoutDidFinish onWorkoutFailed:(RCTPromiseRejectBlock)onWorkoutFailed)
|
|
8
|
-
RCT_EXTERN_METHOD(startCustomAssessment:(NSString*)rawJson userData:(NSString*)userData forceShowUserDataScreen:(BOOL)forceShowUserDataScreen showSummary:(BOOL)showSummary onWorkoutDidFinish:(RCTPromiseResolveBlock)onWorkoutDidFinish onWorkoutFailed:(RCTPromiseRejectBlock)onWorkoutFailed)
|
|
9
|
-
RCT_EXTERN_METHOD(startWorkoutProgram:(NSString*)dic onWorkoutDidFinish:(RCTPromiseResolveBlock)onWorkoutDidFinish onWorkoutFailed:(RCTPromiseRejectBlock)onWorkoutFailed)
|
|
5
|
+
RCT_EXTERN_METHOD(startAssessment:(NSString*)type showSummary:(BOOL)showSummary userData:(NSString* _Nullable)userData forceShowUserDataScreen:(BOOL)forceShowUserDataScreen customAssessmentID:(NSString* _Nullable)customAssessmentID modifications:(NSString* _Nullable)modifications onWorkoutDidFinish:(RCTPromiseResolveBlock)onWorkoutDidFinish onWorkoutFailed:(RCTPromiseRejectBlock)onWorkoutFailed)
|
|
6
|
+
RCT_EXTERN_METHOD(startCustomWorkout:(NSString*)rawJson modifications:(NSString* _Nullable)modifications onWorkoutDidFinish:(RCTPromiseResolveBlock)onWorkoutDidFinish onWorkoutFailed:(RCTPromiseRejectBlock)onWorkoutFailed)
|
|
7
|
+
RCT_EXTERN_METHOD(startCustomAssessment:(NSString*)rawJson userData:(NSString* _Nullable)userData forceShowUserDataScreen:(BOOL)forceShowUserDataScreen showSummary:(BOOL)showSummary modifications:(NSString* _Nullable)modifications onWorkoutDidFinish:(RCTPromiseResolveBlock)onWorkoutDidFinish onWorkoutFailed:(RCTPromiseRejectBlock)onWorkoutFailed)
|
|
8
|
+
RCT_EXTERN_METHOD(startWorkoutProgram:(NSString*)dic modifications:(NSString* _Nullable)modifications onWorkoutDidFinish:(RCTPromiseResolveBlock)onWorkoutDidFinish onWorkoutFailed:(RCTPromiseRejectBlock)onWorkoutFailed)
|
|
10
9
|
|
|
11
10
|
RCT_EXTERN_METHOD(setSessionLanguage:(NSString*)language)
|
|
12
11
|
RCT_EXTERN_METHOD(setEndExercisePreferences:(NSString*)preferencesString)
|
package/ios/SMKitUIManager.swift
CHANGED
|
@@ -3,7 +3,16 @@ import SMKitUI
|
|
|
3
3
|
import SMBase
|
|
4
4
|
|
|
5
5
|
@objc(SMKitUIManager)
|
|
6
|
-
|
|
6
|
+
@objcMembers
|
|
7
|
+
class SMKitUIManager: NSObject, RCTBridgeModule {
|
|
8
|
+
|
|
9
|
+
// Disable TurboModules for this module to use legacy bridge
|
|
10
|
+
@objc
|
|
11
|
+
static func requiresMainQueueSetup() -> Bool {
|
|
12
|
+
return true
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
static func moduleName() -> String! { "SMKitUIManager" }
|
|
7
16
|
|
|
8
17
|
var onWorkoutDidFinish:RCTPromiseResolveBlock?
|
|
9
18
|
var onWorkoutFailed:RCTPromiseRejectBlock?
|
|
@@ -40,27 +49,45 @@ class SMKitUIManager: RCTViewManager {
|
|
|
40
49
|
|
|
41
50
|
@objc(configure:onSuccess:onFailure:)
|
|
42
51
|
func configure(key:NSString, onSuccess: @escaping RCTPromiseResolveBlock,onFailure:@escaping RCTPromiseRejectBlock) -> Void {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
52
|
+
// Ensure configure is called on main thread
|
|
53
|
+
if Thread.isMainThread {
|
|
54
|
+
var isConfigDone = false
|
|
55
|
+
var didFail = false
|
|
56
|
+
SMKitUIModel.configure(authKey: "\(key)") {
|
|
57
|
+
if !isConfigDone{
|
|
58
|
+
isConfigDone = true
|
|
59
|
+
onSuccess("")
|
|
60
|
+
}
|
|
61
|
+
} onFailure: { err in
|
|
62
|
+
if !didFail{
|
|
63
|
+
didFail = true
|
|
64
|
+
onFailure("Configure Failed", err?.localizedDescription ?? "", err)
|
|
65
|
+
}
|
|
49
66
|
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
67
|
+
} else {
|
|
68
|
+
DispatchQueue.main.async {
|
|
69
|
+
var isConfigDone = false
|
|
70
|
+
var didFail = false
|
|
71
|
+
SMKitUIModel.configure(authKey: "\(key)") {
|
|
72
|
+
if !isConfigDone{
|
|
73
|
+
isConfigDone = true
|
|
74
|
+
onSuccess("")
|
|
75
|
+
}
|
|
76
|
+
} onFailure: { err in
|
|
77
|
+
if !didFail{
|
|
78
|
+
didFail = true
|
|
79
|
+
onFailure("Configure Failed", err?.localizedDescription ?? "", err)
|
|
80
|
+
}
|
|
81
|
+
}
|
|
54
82
|
}
|
|
55
83
|
}
|
|
56
84
|
}
|
|
57
85
|
|
|
58
|
-
@objc(startAssessment:showSummary:userData:forceShowUserDataScreen:customAssessmentID:onWorkoutDidFinish:onWorkoutFailed:)
|
|
59
|
-
func startAssessment(type:NSString, showSummary:Bool, userData:NSString?, forceShowUserDataScreen:Bool, customAssessmentID:
|
|
86
|
+
@objc(startAssessment:showSummary:userData:forceShowUserDataScreen:customAssessmentID:modifications:onWorkoutDidFinish:onWorkoutFailed:)
|
|
87
|
+
func startAssessment(type:NSString, showSummary:Bool, userData:NSString?, forceShowUserDataScreen:Bool, customAssessmentID:NSString?, modifications:NSString?, onWorkoutDidFinish: @escaping RCTPromiseResolveBlock, onWorkoutFailed:@escaping RCTPromiseRejectBlock){
|
|
60
88
|
DispatchQueue.main.async {[weak self] in
|
|
61
|
-
|
|
62
89
|
guard let self = self,
|
|
63
|
-
let smkitUIViewController = smkitUIViewController else {
|
|
90
|
+
let smkitUIViewController = self.smkitUIViewController else {
|
|
64
91
|
onWorkoutFailed("StartAssessment Failed", "Failed to present view", nil)
|
|
65
92
|
return
|
|
66
93
|
}
|
|
@@ -70,17 +97,23 @@ class SMKitUIManager: RCTViewManager {
|
|
|
70
97
|
|
|
71
98
|
do{
|
|
72
99
|
let userData = try self.getUserData(rawJson: userData)
|
|
100
|
+
// Get modifications from React Native arguments (same pattern as Flutter bridge)
|
|
101
|
+
let modificationsDict = try self.getModifications(rawJson: modifications)
|
|
102
|
+
let finalModifications = (modificationsDict?.isEmpty == false) ? modificationsDict : nil
|
|
73
103
|
if let type = AssessmentTypes(rawValue: "\(type)"){
|
|
74
104
|
try SMKitUIModel.startAssessmet(
|
|
75
105
|
viewController: smkitUIViewController,
|
|
76
106
|
type: type,
|
|
77
|
-
customAssessmentID:customAssessmentID ==
|
|
107
|
+
customAssessmentID:(customAssessmentID?.length ?? 0) == 0 ? nil : (customAssessmentID as String?),
|
|
78
108
|
userData: userData,
|
|
79
109
|
forceShowUserDataScreen: forceShowUserDataScreen,
|
|
80
110
|
showSummary: showSummary,
|
|
81
|
-
delegate: self
|
|
111
|
+
delegate: self,
|
|
112
|
+
onFailure: {error in
|
|
82
113
|
onWorkoutFailed("StartAssessment Failed", error.localizedDescription, error)
|
|
83
|
-
}
|
|
114
|
+
},
|
|
115
|
+
modifications: finalModifications
|
|
116
|
+
)
|
|
84
117
|
}else{
|
|
85
118
|
onWorkoutFailed("StartAssessment Failed", "Invalid type", nil)
|
|
86
119
|
}
|
|
@@ -90,8 +123,8 @@ class SMKitUIManager: RCTViewManager {
|
|
|
90
123
|
}
|
|
91
124
|
}
|
|
92
125
|
|
|
93
|
-
@objc(startCustomWorkout:onWorkoutDidFinish:onWorkoutFailed:)
|
|
94
|
-
func startCustomWorkout(rawJson:String, onWorkoutDidFinish: @escaping RCTPromiseResolveBlock, onWorkoutFailed:@escaping RCTPromiseRejectBlock){
|
|
126
|
+
@objc(startCustomWorkout:modifications:onWorkoutDidFinish:onWorkoutFailed:)
|
|
127
|
+
func startCustomWorkout(rawJson:String, modifications:NSString?, onWorkoutDidFinish: @escaping RCTPromiseResolveBlock, onWorkoutFailed:@escaping RCTPromiseRejectBlock){
|
|
95
128
|
DispatchQueue.main.async {[weak self] in
|
|
96
129
|
|
|
97
130
|
guard let self = self,
|
|
@@ -104,15 +137,18 @@ class SMKitUIManager: RCTViewManager {
|
|
|
104
137
|
do{
|
|
105
138
|
let json = try stringJsonToDic(stringJSON: rawJson)
|
|
106
139
|
let workout = try SMWorkout(FromJson: json)
|
|
107
|
-
|
|
140
|
+
// Get modifications from React Native arguments (same pattern as Flutter bridge)
|
|
141
|
+
let modificationsDict = try self.getModifications(rawJson: modifications)
|
|
142
|
+
let finalModifications = (modificationsDict?.isEmpty == false) ? modificationsDict : nil
|
|
143
|
+
try SMKitUIModel.startWorkout(viewController: smkitUIViewController, workout: workout, delegate: self, modifications: finalModifications)
|
|
108
144
|
}catch{
|
|
109
145
|
onWorkoutFailed("StartCustomWorkout Failed", error.localizedDescription, error)
|
|
110
146
|
}
|
|
111
147
|
}
|
|
112
148
|
}
|
|
113
149
|
|
|
114
|
-
@objc(startCustomAssessment:userData:forceShowUserDataScreen:showSummary:onWorkoutDidFinish:onWorkoutFailed:)
|
|
115
|
-
func startCustomAssessment(rawJson:String, userData:NSString?, forceShowUserDataScreen:Bool, showSummary:Bool, onWorkoutDidFinish: @escaping RCTPromiseResolveBlock, onWorkoutFailed:@escaping RCTPromiseRejectBlock){
|
|
150
|
+
@objc(startCustomAssessment:userData:forceShowUserDataScreen:showSummary:modifications:onWorkoutDidFinish:onWorkoutFailed:)
|
|
151
|
+
func startCustomAssessment(rawJson:String, userData:NSString?, forceShowUserDataScreen:Bool, showSummary:Bool, modifications:NSString?, onWorkoutDidFinish: @escaping RCTPromiseResolveBlock, onWorkoutFailed:@escaping RCTPromiseRejectBlock){
|
|
116
152
|
DispatchQueue.main.async { [weak self] in
|
|
117
153
|
guard let self = self,
|
|
118
154
|
let smkitUIViewController = smkitUIViewController else {
|
|
@@ -126,17 +162,20 @@ class SMKitUIManager: RCTViewManager {
|
|
|
126
162
|
let userData = try self.getUserData(rawJson: userData)
|
|
127
163
|
let json = try stringJsonToDic(stringJSON: rawJson)
|
|
128
164
|
let assessment = try SMWorkoutAssessment.initFromJSON(json)
|
|
129
|
-
|
|
165
|
+
// Get modifications from React Native arguments (same pattern as Flutter bridge)
|
|
166
|
+
let modificationsDict = try self.getModifications(rawJson: modifications)
|
|
167
|
+
let finalModifications = (modificationsDict?.isEmpty == false) ? modificationsDict : nil
|
|
168
|
+
try SMKitUIModel.startCustomAssessment(viewController: smkitUIViewController, assessment: assessment, userData:userData, forceShowUserDataScreen: forceShowUserDataScreen, showSummary: showSummary, delegate: self, onFailure: { error in
|
|
130
169
|
onWorkoutFailed("startCustomAssessment Failed", error.localizedDescription, error)
|
|
131
|
-
}
|
|
170
|
+
}, modifications: finalModifications)
|
|
132
171
|
}catch{
|
|
133
172
|
onWorkoutFailed("startCustomAssessment Failed", error.localizedDescription, error)
|
|
134
173
|
}
|
|
135
174
|
}
|
|
136
175
|
}
|
|
137
176
|
|
|
138
|
-
@objc(startWorkoutProgram:onWorkoutDidFinish:onWorkoutFailed:)
|
|
139
|
-
func startWorkoutProgram(rawJson:String, onWorkoutDidFinish: @escaping RCTPromiseResolveBlock, onWorkoutFailed:@escaping RCTPromiseRejectBlock){
|
|
177
|
+
@objc(startWorkoutProgram:modifications:onWorkoutDidFinish:onWorkoutFailed:)
|
|
178
|
+
func startWorkoutProgram(rawJson:String, modifications:NSString?, onWorkoutDidFinish: @escaping RCTPromiseResolveBlock, onWorkoutFailed:@escaping RCTPromiseRejectBlock){
|
|
140
179
|
self.onWorkoutDidFinish = onWorkoutDidFinish
|
|
141
180
|
self.onWorkoutFailed = onWorkoutFailed
|
|
142
181
|
|
|
@@ -172,9 +211,10 @@ class SMKitUIManager: RCTViewManager {
|
|
|
172
211
|
programID: programID
|
|
173
212
|
)
|
|
174
213
|
|
|
175
|
-
|
|
214
|
+
// Note: startWorkoutFromProgram doesn't support modifications parameter in SDK 1.4.3
|
|
215
|
+
SMKitUIModel.startWorkoutFromProgram(viewController: smkitUIViewController, workoutConfig: config, delegate: self, onFailure: { error in
|
|
176
216
|
onWorkoutFailed("StartWorkoutProgram Failed", error.localizedDescription, error)
|
|
177
|
-
}
|
|
217
|
+
})
|
|
178
218
|
}
|
|
179
219
|
}
|
|
180
220
|
|
|
@@ -203,11 +243,6 @@ class SMKitUIManager: RCTViewManager {
|
|
|
203
243
|
return json
|
|
204
244
|
}
|
|
205
245
|
|
|
206
|
-
|
|
207
|
-
override class func requiresMainQueueSetup() -> Bool {
|
|
208
|
-
true
|
|
209
|
-
}
|
|
210
|
-
|
|
211
246
|
func getUserData(rawJson:NSString?) throws -> UserData?{
|
|
212
247
|
guard let rawJson = rawJson as? String else { return nil }
|
|
213
248
|
let json = try stringJsonToDic(stringJSON: rawJson)
|
|
@@ -217,6 +252,11 @@ class SMKitUIManager: RCTViewManager {
|
|
|
217
252
|
)
|
|
218
253
|
}
|
|
219
254
|
|
|
255
|
+
func getModifications(rawJson:NSString?) throws -> [String: Any]?{
|
|
256
|
+
guard let rawJson = rawJson as? String, !rawJson.isEmpty else { return nil }
|
|
257
|
+
return try stringJsonToDic(stringJSON: rawJson)
|
|
258
|
+
}
|
|
259
|
+
|
|
220
260
|
func getBirthdayDate(from age: Int) -> Date? {
|
|
221
261
|
// Create a date components instance to subtract years
|
|
222
262
|
var dateComponents = DateComponents()
|
package/lib/commonjs/index.js
CHANGED
|
@@ -36,24 +36,35 @@ function configure(key) {
|
|
|
36
36
|
* start an assessment session.
|
|
37
37
|
*
|
|
38
38
|
* @param {SMWorkoutLibrary.AssessmentTypes} type - The type of assessment to start.
|
|
39
|
-
* @param {boolean}
|
|
39
|
+
* @param {boolean} showSummary - Determines if the summary should be shown after assessment completion.
|
|
40
40
|
* @param {SMWorkoutLibrary.UserData | null} userData - User data for the assessment session, or `null` if no user data is provided.
|
|
41
|
-
* @param {boolean}
|
|
41
|
+
* @param {boolean} forceShowUserDataScreen - Forces the display of the user data screen even if user data is provided.
|
|
42
42
|
* @param {string} customAssessmentID - A unique identifier for a custom assessment session.
|
|
43
|
+
* @param {string | null} modifications - Optional JSON string with exercise feedback parameter modifications.
|
|
43
44
|
* @returns {Promise<{ summary: string; didFinish: boolean }>} - A promise that resolves with an object containing the summary and a flag indicating whether the assessment finished.
|
|
44
45
|
*/
|
|
45
|
-
function startAssessment(type, showSummary
|
|
46
|
-
|
|
46
|
+
function startAssessment(type, showSummary, userData, forceShowUserDataScreen, customAssessmentID, modifications) {
|
|
47
|
+
const userDataJson = userData !== null && userData !== undefined ? userData.toJson() : null;
|
|
48
|
+
// Ensure modifications is explicitly null (not undefined) for React Native bridge
|
|
49
|
+
// Convert empty string to null, but ensure we always pass a value (even if null)
|
|
50
|
+
const modificationsJson = modifications !== null && modifications !== undefined && modifications !== '' ? modifications : null;
|
|
51
|
+
|
|
52
|
+
// Call native method - React Native legacy bridge automatically handles promise conversion
|
|
53
|
+
// IMPORTANT: Always pass all 6 arguments, even if null
|
|
54
|
+
// React Native bridge counts arguments, so we must pass modifications even when null
|
|
55
|
+
return SMKitUIManager.startAssessment(String(type), showSummary, userDataJson ?? null, forceShowUserDataScreen, customAssessmentID || '', modificationsJson ?? null);
|
|
47
56
|
}
|
|
48
57
|
|
|
49
58
|
/**
|
|
50
59
|
* Starts a custom workout session.
|
|
51
60
|
*
|
|
52
61
|
* @param {SMWorkoutLibrary.SMWorkout} workout - The custom workout configuration.
|
|
62
|
+
* @param {string | null} modifications - Optional JSON string with exercise feedback parameter modifications.
|
|
53
63
|
* @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.
|
|
54
64
|
*/
|
|
55
|
-
function startCustomWorkout(workout) {
|
|
56
|
-
|
|
65
|
+
function startCustomWorkout(workout, modifications) {
|
|
66
|
+
const modificationsJson = modifications !== null && modifications !== undefined && modifications !== '' ? modifications : null;
|
|
67
|
+
return SMKitUIManager.startCustomWorkout(workout.toJson(), modificationsJson);
|
|
57
68
|
}
|
|
58
69
|
|
|
59
70
|
/**
|
|
@@ -61,22 +72,27 @@ function startCustomWorkout(workout) {
|
|
|
61
72
|
*
|
|
62
73
|
* @param {SMWorkoutLibrary.SMWorkout} assessment - The assessment configuration for the session.
|
|
63
74
|
* @param {SMWorkoutLibrary.UserData | null} userData - User data for the assessment, or `null` if no user data is provided.
|
|
64
|
-
* @param {boolean}
|
|
65
|
-
* @param {boolean}
|
|
75
|
+
* @param {boolean} forceShowUserDataScreen - Forces the display of the user data screen even if user data is provided.
|
|
76
|
+
* @param {boolean} showSummary - Determines if the summary should be shown after assessment completion.
|
|
77
|
+
* @param {string | null} modifications - Optional JSON string with exercise feedback parameter modifications.
|
|
66
78
|
* @returns {Promise<{ summary: string; didFinish: boolean }>} - A promise that resolves with an object containing the summary and a flag indicating if the assessment finished.
|
|
67
79
|
*/
|
|
68
|
-
function startCustomAssessment(assessment, userData, forceShowUserDataScreen
|
|
69
|
-
|
|
80
|
+
function startCustomAssessment(assessment, userData, forceShowUserDataScreen, showSummary, modifications) {
|
|
81
|
+
const userDataJson = userData !== null && userData !== undefined ? userData.toJson() : null;
|
|
82
|
+
const modificationsJson = modifications !== null && modifications !== undefined && modifications !== '' ? modifications : null;
|
|
83
|
+
return SMKitUIManager.startCustomAssessment(assessment.toJson(), userDataJson, forceShowUserDataScreen, showSummary, modificationsJson);
|
|
70
84
|
}
|
|
71
85
|
|
|
72
86
|
/**
|
|
73
87
|
* Starts a workout program using the provided workout configuration.
|
|
74
88
|
*
|
|
75
89
|
* @param {SMWorkoutLibrary.WorkoutConfig} workoutConfig - The configuration for the workout program.
|
|
90
|
+
* @param {string | null} modifications - Optional JSON string with exercise feedback parameter modifications.
|
|
76
91
|
* @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.
|
|
77
92
|
*/
|
|
78
|
-
function startWorkoutProgram(workoutConfig) {
|
|
79
|
-
|
|
93
|
+
function startWorkoutProgram(workoutConfig, modifications) {
|
|
94
|
+
const modificationsJson = modifications !== null && modifications !== undefined && modifications !== '' ? modifications : null;
|
|
95
|
+
return SMKitUIManager.startWorkoutProgram(workoutConfig.toJson(), modificationsJson);
|
|
80
96
|
}
|
|
81
97
|
|
|
82
98
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","LINKING_ERROR","Platform","select","ios","default","SMKitUIManager","NativeModules","Proxy","get","Error","configure","key","startAssessment","type","showSummary","userData","forceShowUserDataScreen","customAssessmentID","toJson","startCustomWorkout","workout","startCustomAssessment","assessment","startWorkoutProgram","workoutConfig","setSessionLanguage","language","setEndExercisePreferences","endExercisePreferences","setCounterPreferences","counterPreferences"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAGA,MAAMC,aAAa,GACjB,gFAAgF,GAChFC,qBAAQ,CAACC,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;;AAEjC;AACA,MAAMC,cAAc,GAAGC,0BAAa,CAAC,gBAAgB,CAAC,GAClDA,0BAAa,CAAC,gBAAgB,CAAC,GAC/B,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACT,aAAa,CAAC;EAChC;AACF,CACF,CAAC;;AAEL;AACA;AACA;AACA;AACO,SAASU,SAASA,CAACC,GAAW,EAAmB;EACtD,OAAON,cAAc,CAACK,SAAS,CAACC,GAAG,CAAC;AACtC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,eAAeA,CAC7BC,IAAsC,EACtCC,WAAoB,
|
|
1
|
+
{"version":3,"names":["_reactNative","require","LINKING_ERROR","Platform","select","ios","default","SMKitUIManager","NativeModules","Proxy","get","Error","configure","key","startAssessment","type","showSummary","userData","forceShowUserDataScreen","customAssessmentID","modifications","userDataJson","undefined","toJson","modificationsJson","String","startCustomWorkout","workout","startCustomAssessment","assessment","startWorkoutProgram","workoutConfig","setSessionLanguage","language","setEndExercisePreferences","endExercisePreferences","setCounterPreferences","counterPreferences"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAGA,MAAMC,aAAa,GACjB,gFAAgF,GAChFC,qBAAQ,CAACC,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;;AAEjC;AACA,MAAMC,cAAc,GAAGC,0BAAa,CAAC,gBAAgB,CAAC,GAClDA,0BAAa,CAAC,gBAAgB,CAAC,GAC/B,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACT,aAAa,CAAC;EAChC;AACF,CACF,CAAC;;AAEL;AACA;AACA;AACA;AACO,SAASU,SAASA,CAACC,GAAW,EAAmB;EACtD,OAAON,cAAc,CAACK,SAAS,CAACC,GAAG,CAAC;AACtC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,eAAeA,CAC7BC,IAAsC,EACtCC,WAAoB,EACpBC,QAA0C,EAC1CC,uBAAgC,EAChCC,kBAA0B,EAC1BC,aAA4B,EACsB;EAClD,MAAMC,YAAY,GAAGJ,QAAQ,KAAK,IAAI,IAAIA,QAAQ,KAAKK,SAAS,GAAGL,QAAQ,CAACM,MAAM,CAAC,CAAC,GAAG,IAAI;EAC3F;EACA;EACA,MAAMC,iBAAiB,GAAGJ,aAAa,KAAK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EAClD,MAAMI,iBAAiB,GAAGJ,aAAa,KAAK,IAAI,IAAIA,aAAa,KAAKE,SAAS,IAAIF,aAAa,KAAK,EAAE,GAAGA,aAAa,GAAG,IAAI;EAC9H,OAAOb,cAAc,CAACuB,mBAAmB,CACvCC,aAAa,CAACR,MAAM,CAAC,CAAC,EACtBC,iBACF,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACO,SAASQ,kBAAkBA,CAACC,QAAmC,EAAE;EACtE1B,cAAc,CAACyB,kBAAkB,CAACC,QAAQ,CAAC;AAC7C;;AAEA;AACA;AACA;AACA;AACO,SAASC,yBAAyBA,CACvCC,sBAA+D,EAC/D;EACA5B,cAAc,CAAC2B,yBAAyB,CAACC,sBAAsB,CAAC;AAClE;;AAEA;AACA;AACA;AACA;AACO,SAASC,qBAAqBA,CACnCC,kBAAuD,EACvD;EACA9B,cAAc,CAAC6B,qBAAqB,CAACC,kBAAkB,CAAC;AAC1D","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
|
@@ -23,24 +23,35 @@ export function configure(key) {
|
|
|
23
23
|
* start an assessment session.
|
|
24
24
|
*
|
|
25
25
|
* @param {SMWorkoutLibrary.AssessmentTypes} type - The type of assessment to start.
|
|
26
|
-
* @param {boolean}
|
|
26
|
+
* @param {boolean} showSummary - Determines if the summary should be shown after assessment completion.
|
|
27
27
|
* @param {SMWorkoutLibrary.UserData | null} userData - User data for the assessment session, or `null` if no user data is provided.
|
|
28
|
-
* @param {boolean}
|
|
28
|
+
* @param {boolean} forceShowUserDataScreen - Forces the display of the user data screen even if user data is provided.
|
|
29
29
|
* @param {string} customAssessmentID - A unique identifier for a custom assessment session.
|
|
30
|
+
* @param {string | null} modifications - Optional JSON string with exercise feedback parameter modifications.
|
|
30
31
|
* @returns {Promise<{ summary: string; didFinish: boolean }>} - A promise that resolves with an object containing the summary and a flag indicating whether the assessment finished.
|
|
31
32
|
*/
|
|
32
|
-
export function startAssessment(type, showSummary
|
|
33
|
-
|
|
33
|
+
export function startAssessment(type, showSummary, userData, forceShowUserDataScreen, customAssessmentID, modifications) {
|
|
34
|
+
const userDataJson = userData !== null && userData !== undefined ? userData.toJson() : null;
|
|
35
|
+
// Ensure modifications is explicitly null (not undefined) for React Native bridge
|
|
36
|
+
// Convert empty string to null, but ensure we always pass a value (even if null)
|
|
37
|
+
const modificationsJson = modifications !== null && modifications !== undefined && modifications !== '' ? modifications : null;
|
|
38
|
+
|
|
39
|
+
// Call native method - React Native legacy bridge automatically handles promise conversion
|
|
40
|
+
// IMPORTANT: Always pass all 6 arguments, even if null
|
|
41
|
+
// React Native bridge counts arguments, so we must pass modifications even when null
|
|
42
|
+
return SMKitUIManager.startAssessment(String(type), showSummary, userDataJson ?? null, forceShowUserDataScreen, customAssessmentID || '', modificationsJson ?? null);
|
|
34
43
|
}
|
|
35
44
|
|
|
36
45
|
/**
|
|
37
46
|
* Starts a custom workout session.
|
|
38
47
|
*
|
|
39
48
|
* @param {SMWorkoutLibrary.SMWorkout} workout - The custom workout configuration.
|
|
49
|
+
* @param {string | null} modifications - Optional JSON string with exercise feedback parameter modifications.
|
|
40
50
|
* @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.
|
|
41
51
|
*/
|
|
42
|
-
export function startCustomWorkout(workout) {
|
|
43
|
-
|
|
52
|
+
export function startCustomWorkout(workout, modifications) {
|
|
53
|
+
const modificationsJson = modifications !== null && modifications !== undefined && modifications !== '' ? modifications : null;
|
|
54
|
+
return SMKitUIManager.startCustomWorkout(workout.toJson(), modificationsJson);
|
|
44
55
|
}
|
|
45
56
|
|
|
46
57
|
/**
|
|
@@ -48,22 +59,27 @@ export function startCustomWorkout(workout) {
|
|
|
48
59
|
*
|
|
49
60
|
* @param {SMWorkoutLibrary.SMWorkout} assessment - The assessment configuration for the session.
|
|
50
61
|
* @param {SMWorkoutLibrary.UserData | null} userData - User data for the assessment, or `null` if no user data is provided.
|
|
51
|
-
* @param {boolean}
|
|
52
|
-
* @param {boolean}
|
|
62
|
+
* @param {boolean} forceShowUserDataScreen - Forces the display of the user data screen even if user data is provided.
|
|
63
|
+
* @param {boolean} showSummary - Determines if the summary should be shown after assessment completion.
|
|
64
|
+
* @param {string | null} modifications - Optional JSON string with exercise feedback parameter modifications.
|
|
53
65
|
* @returns {Promise<{ summary: string; didFinish: boolean }>} - A promise that resolves with an object containing the summary and a flag indicating if the assessment finished.
|
|
54
66
|
*/
|
|
55
|
-
export function startCustomAssessment(assessment, userData, forceShowUserDataScreen
|
|
56
|
-
|
|
67
|
+
export function startCustomAssessment(assessment, userData, forceShowUserDataScreen, showSummary, modifications) {
|
|
68
|
+
const userDataJson = userData !== null && userData !== undefined ? userData.toJson() : null;
|
|
69
|
+
const modificationsJson = modifications !== null && modifications !== undefined && modifications !== '' ? modifications : null;
|
|
70
|
+
return SMKitUIManager.startCustomAssessment(assessment.toJson(), userDataJson, forceShowUserDataScreen, showSummary, modificationsJson);
|
|
57
71
|
}
|
|
58
72
|
|
|
59
73
|
/**
|
|
60
74
|
* Starts a workout program using the provided workout configuration.
|
|
61
75
|
*
|
|
62
76
|
* @param {SMWorkoutLibrary.WorkoutConfig} workoutConfig - The configuration for the workout program.
|
|
77
|
+
* @param {string | null} modifications - Optional JSON string with exercise feedback parameter modifications.
|
|
63
78
|
* @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.
|
|
64
79
|
*/
|
|
65
|
-
export function startWorkoutProgram(workoutConfig) {
|
|
66
|
-
|
|
80
|
+
export function startWorkoutProgram(workoutConfig, modifications) {
|
|
81
|
+
const modificationsJson = modifications !== null && modifications !== undefined && modifications !== '' ? modifications : null;
|
|
82
|
+
return SMKitUIManager.startWorkoutProgram(workoutConfig.toJson(), modificationsJson);
|
|
67
83
|
}
|
|
68
84
|
|
|
69
85
|
/**
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeModules","Platform","LINKING_ERROR","select","ios","default","SMKitUIManager","Proxy","get","Error","configure","key","startAssessment","type","showSummary","userData","forceShowUserDataScreen","customAssessmentID","toJson","startCustomWorkout","workout","startCustomAssessment","assessment","startWorkoutProgram","workoutConfig","setSessionLanguage","language","setEndExercisePreferences","endExercisePreferences","setCounterPreferences","counterPreferences"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA,SAASA,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AAGtD,MAAMC,aAAa,GACjB,gFAAgF,GAChFD,QAAQ,CAACE,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;;AAEjC;AACA,MAAMC,cAAc,GAAGN,aAAa,CAAC,gBAAgB,CAAC,GAClDA,aAAa,CAAC,gBAAgB,CAAC,GAC/B,IAAIO,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACP,aAAa,CAAC;EAChC;AACF,CACF,CAAC;;AAEL;AACA;AACA;AACA;AACA,OAAO,SAASQ,SAASA,CAACC,GAAW,EAAmB;EACtD,OAAOL,cAAc,CAACI,SAAS,CAACC,GAAG,CAAC;AACtC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,eAAeA,CAC7BC,IAAsC,EACtCC,WAAoB,
|
|
1
|
+
{"version":3,"names":["NativeModules","Platform","LINKING_ERROR","select","ios","default","SMKitUIManager","Proxy","get","Error","configure","key","startAssessment","type","showSummary","userData","forceShowUserDataScreen","customAssessmentID","modifications","userDataJson","undefined","toJson","modificationsJson","String","startCustomWorkout","workout","startCustomAssessment","assessment","startWorkoutProgram","workoutConfig","setSessionLanguage","language","setEndExercisePreferences","endExercisePreferences","setCounterPreferences","counterPreferences"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA,SAASA,aAAa,EAAEC,Q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QAAQ,CAAC;AAC7C;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASC,yBAAyBA,CACvCC,sBAA+D,EAC/D;EACA3B,cAAc,CAAC0B,yBAAyB,CAACC,sBAAsB,CAAC;AAClE;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASC,qBAAqBA,CACnCC,kBAAuD,EACvD;EACA7B,cAAc,CAAC4B,qBAAqB,CAACC,kBAAkB,CAAC;AAC1D","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sency/react-native-smkit-ui",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "React Native library for SMKit UI - Advanced fitness assessments and workout programs with AI-powered motion detection and real-time performance tracking",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"@types/react": "^18.3.0",
|
|
68
68
|
"react": "^18.3.1",
|
|
69
|
-
"react-native": "^0.76.
|
|
69
|
+
"react-native": "^0.76.9",
|
|
70
70
|
"react-native-builder-bob": "^0.20.0",
|
|
71
71
|
"typescript": "^5.6.3"
|
|
72
72
|
},
|
|
@@ -15,7 +15,7 @@ Pod::Spec.new do |s|
|
|
|
15
15
|
s.source = { :git => "https://github.com/sency-ai/smkit-ui-react-native-demo.git", :tag => "#{s.version}" }
|
|
16
16
|
|
|
17
17
|
s.source_files = "ios/**/*.{h,m,mm,swift}"
|
|
18
|
-
s.dependency "SMKitUI" ,'
|
|
18
|
+
s.dependency "SMKitUI" ,'1.4.4'
|
|
19
19
|
|
|
20
20
|
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
|
|
21
21
|
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
|
package/src/index.tsx
CHANGED
|
@@ -31,25 +31,36 @@ export function configure(key: string): Promise<string> {
|
|
|
31
31
|
* start an assessment session.
|
|
32
32
|
*
|
|
33
33
|
* @param {SMWorkoutLibrary.AssessmentTypes} type - The type of assessment to start.
|
|
34
|
-
* @param {boolean}
|
|
34
|
+
* @param {boolean} showSummary - Determines if the summary should be shown after assessment completion.
|
|
35
35
|
* @param {SMWorkoutLibrary.UserData | null} userData - User data for the assessment session, or `null` if no user data is provided.
|
|
36
|
-
* @param {boolean}
|
|
36
|
+
* @param {boolean} forceShowUserDataScreen - Forces the display of the user data screen even if user data is provided.
|
|
37
37
|
* @param {string} customAssessmentID - A unique identifier for a custom assessment session.
|
|
38
|
+
* @param {string | null} modifications - Optional JSON string with exercise feedback parameter modifications.
|
|
38
39
|
* @returns {Promise<{ summary: string; didFinish: boolean }>} - A promise that resolves with an object containing the summary and a flag indicating whether the assessment finished.
|
|
39
40
|
*/
|
|
40
41
|
export function startAssessment(
|
|
41
42
|
type: SMWorkoutLibrary.AssessmentTypes,
|
|
42
|
-
showSummary: boolean
|
|
43
|
+
showSummary: boolean,
|
|
43
44
|
userData: SMWorkoutLibrary.UserData | null,
|
|
44
|
-
forceShowUserDataScreen: boolean
|
|
45
|
-
customAssessmentID: string
|
|
45
|
+
forceShowUserDataScreen: boolean,
|
|
46
|
+
customAssessmentID: string,
|
|
47
|
+
modifications: string | null
|
|
46
48
|
): Promise<{ summary: string; didFinish: boolean }> {
|
|
49
|
+
const userDataJson = userData !== null && userData !== undefined ? userData.toJson() : null;
|
|
50
|
+
// Ensure modifications is explicitly null (not undefined) for React Native bridge
|
|
51
|
+
// Convert empty string to null, but ensure we always pass a value (even if null)
|
|
52
|
+
const modificationsJson = modifications !== null && modifications !== undefined && modifications !== '' ? modifications : null;
|
|
53
|
+
|
|
54
|
+
// Call native method - React Native legacy bridge automatically handles promise conversion
|
|
55
|
+
// IMPORTANT: Always pass all 6 arguments, even if null
|
|
56
|
+
// React Native bridge counts arguments, so we must pass modifications even when null
|
|
47
57
|
return SMKitUIManager.startAssessment(
|
|
48
|
-
type,
|
|
58
|
+
String(type),
|
|
49
59
|
showSummary,
|
|
50
|
-
|
|
60
|
+
userDataJson ?? null,
|
|
51
61
|
forceShowUserDataScreen,
|
|
52
|
-
customAssessmentID
|
|
62
|
+
customAssessmentID || '',
|
|
63
|
+
modificationsJson ?? null
|
|
53
64
|
);
|
|
54
65
|
}
|
|
55
66
|
|
|
@@ -57,12 +68,18 @@ export function startAssessment(
|
|
|
57
68
|
* Starts a custom workout session.
|
|
58
69
|
*
|
|
59
70
|
* @param {SMWorkoutLibrary.SMWorkout} workout - The custom workout configuration.
|
|
71
|
+
* @param {string | null} modifications - Optional JSON string with exercise feedback parameter modifications.
|
|
60
72
|
* @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.
|
|
61
73
|
*/
|
|
62
74
|
export function startCustomWorkout(
|
|
63
|
-
workout: SMWorkoutLibrary.SMWorkout
|
|
75
|
+
workout: SMWorkoutLibrary.SMWorkout,
|
|
76
|
+
modifications: string | null
|
|
64
77
|
): Promise<{ summary: string; didFinish: boolean }> {
|
|
65
|
-
|
|
78
|
+
const modificationsJson = modifications !== null && modifications !== undefined && modifications !== '' ? modifications : null;
|
|
79
|
+
return SMKitUIManager.startCustomWorkout(
|
|
80
|
+
workout.toJson(),
|
|
81
|
+
modificationsJson
|
|
82
|
+
);
|
|
66
83
|
}
|
|
67
84
|
|
|
68
85
|
/**
|
|
@@ -70,21 +87,26 @@ export function startCustomWorkout(
|
|
|
70
87
|
*
|
|
71
88
|
* @param {SMWorkoutLibrary.SMWorkout} assessment - The assessment configuration for the session.
|
|
72
89
|
* @param {SMWorkoutLibrary.UserData | null} userData - User data for the assessment, or `null` if no user data is provided.
|
|
73
|
-
* @param {boolean}
|
|
74
|
-
* @param {boolean}
|
|
90
|
+
* @param {boolean} forceShowUserDataScreen - Forces the display of the user data screen even if user data is provided.
|
|
91
|
+
* @param {boolean} showSummary - Determines if the summary should be shown after assessment completion.
|
|
92
|
+
* @param {string | null} modifications - Optional JSON string with exercise feedback parameter modifications.
|
|
75
93
|
* @returns {Promise<{ summary: string; didFinish: boolean }>} - A promise that resolves with an object containing the summary and a flag indicating if the assessment finished.
|
|
76
94
|
*/
|
|
77
95
|
export function startCustomAssessment(
|
|
78
96
|
assessment: SMWorkoutLibrary.SMWorkout,
|
|
79
97
|
userData: SMWorkoutLibrary.UserData | null,
|
|
80
|
-
forceShowUserDataScreen: boolean
|
|
81
|
-
showSummary: boolean
|
|
98
|
+
forceShowUserDataScreen: boolean,
|
|
99
|
+
showSummary: boolean,
|
|
100
|
+
modifications: string | null
|
|
82
101
|
): Promise<{ summary: string; didFinish: boolean }> {
|
|
102
|
+
const userDataJson = userData !== null && userData !== undefined ? userData.toJson() : null;
|
|
103
|
+
const modificationsJson = modifications !== null && modifications !== undefined && modifications !== '' ? modifications : null;
|
|
83
104
|
return SMKitUIManager.startCustomAssessment(
|
|
84
105
|
assessment.toJson(),
|
|
85
|
-
|
|
106
|
+
userDataJson,
|
|
86
107
|
forceShowUserDataScreen,
|
|
87
|
-
showSummary
|
|
108
|
+
showSummary,
|
|
109
|
+
modificationsJson
|
|
88
110
|
);
|
|
89
111
|
}
|
|
90
112
|
|
|
@@ -92,12 +114,18 @@ export function startCustomAssessment(
|
|
|
92
114
|
* Starts a workout program using the provided workout configuration.
|
|
93
115
|
*
|
|
94
116
|
* @param {SMWorkoutLibrary.WorkoutConfig} workoutConfig - The configuration for the workout program.
|
|
117
|
+
* @param {string | null} modifications - Optional JSON string with exercise feedback parameter modifications.
|
|
95
118
|
* @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.
|
|
96
119
|
*/
|
|
97
120
|
export function startWorkoutProgram(
|
|
98
|
-
workoutConfig: SMWorkoutLibrary.WorkoutConfig
|
|
121
|
+
workoutConfig: SMWorkoutLibrary.WorkoutConfig,
|
|
122
|
+
modifications: string | null
|
|
99
123
|
): Promise<{ summary: string; didFinish: boolean }> {
|
|
100
|
-
|
|
124
|
+
const modificationsJson = modifications !== null && modifications !== undefined && modifications !== '' ? modifications : null;
|
|
125
|
+
return SMKitUIManager.startWorkoutProgram(
|
|
126
|
+
workoutConfig.toJson(),
|
|
127
|
+
modificationsJson
|
|
128
|
+
);
|
|
101
129
|
}
|
|
102
130
|
|
|
103
131
|
/**
|