@sency/react-native-smkit-ui 2.0.1 → 2.0.3
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/README.md +368 -525
- 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/README.md
CHANGED
|
@@ -1,113 +1,138 @@
|
|
|
1
|
-
#
|
|
1
|
+
# React Native SMKit UI Library
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
2. [ Setup ](#setup)
|
|
5
|
-
3. [ API ](#api)
|
|
6
|
-
4. [ Data ](#data)
|
|
3
|
+
AI-powered fitness assessments, custom workouts, and workout programs with real-time motion detection for React Native apps.
|
|
7
4
|
|
|
8
|
-
|
|
5
|
+
## Table of Contents
|
|
9
6
|
|
|
10
|
-
|
|
7
|
+
1. [Features](#features)
|
|
8
|
+
2. [Requirements](#requirements)
|
|
9
|
+
3. [Installation](#installation)
|
|
10
|
+
4. [Platform Setup](#platform-setup)
|
|
11
|
+
5. [Getting Started](#getting-started)
|
|
12
|
+
6. [Core Features](#core-features)
|
|
13
|
+
7. [API Reference](#api-reference)
|
|
14
|
+
8. [Examples](#examples)
|
|
15
|
+
9. [Troubleshooting](#troubleshooting)
|
|
16
|
+
10. [Support](#support)
|
|
11
17
|
|
|
12
|
-
|
|
18
|
+
---
|
|
13
19
|
|
|
14
|
-
##
|
|
20
|
+
## Features
|
|
15
21
|
|
|
16
|
-
|
|
22
|
+
- **Fitness Assessments** - AI-driven fitness evaluations tailored to user fitness levels
|
|
23
|
+
- **Workout Programs** - Multi-week customizable workout plans with progression tracking
|
|
24
|
+
- **Motion Detection** - Real-time motion capture and analysis with pose detection
|
|
25
|
+
- **Multiple Assessment Types** - Fitness, Body360, Strength, Cardio, and custom assessments
|
|
26
|
+
- **Cross-Platform** - Native support for iOS and Android
|
|
27
|
+
- **Configurable Workouts** - Customize by body zone, difficulty, and duration
|
|
17
28
|
|
|
18
|
-
|
|
29
|
+
---
|
|
19
30
|
|
|
20
|
-
|
|
21
|
-
[1] add the source to the top of your Podfile.
|
|
22
|
-
source 'https://bitbucket.org/sencyai/ios_sdks_release.git'
|
|
23
|
-
source 'https://github.com/CocoaPods/Specs.git'
|
|
31
|
+
## Requirements
|
|
24
32
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
33
|
+
### General
|
|
34
|
+
- **Node.js** 18+
|
|
35
|
+
- **npm** or **yarn**
|
|
28
36
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
__apply_Xcode_12_5_M1_post_install_workaround(installer)
|
|
43
|
-
end
|
|
44
|
-
end
|
|
37
|
+
### iOS
|
|
38
|
+
- **iOS 13+**
|
|
39
|
+
- **Xcode 14+**
|
|
40
|
+
- **CocoaPods**
|
|
41
|
+
|
|
42
|
+
### Android
|
|
43
|
+
- **Android API 26+**
|
|
44
|
+
- **Android Studio** with SDK tools
|
|
45
|
+
- **JDK 11+**
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Installation
|
|
45
50
|
|
|
51
|
+
Install the package via npm:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
npm install @sency/react-native-smkit-ui
|
|
46
55
|
```
|
|
47
56
|
|
|
48
|
-
|
|
49
|
-
3. Add camera permission request to `Info.plist`
|
|
57
|
+
Or with yarn:
|
|
50
58
|
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
|
|
59
|
+
```bash
|
|
60
|
+
yarn add @sency/react-native-smkit-ui
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Then install native dependencies:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
cd ios && pod install && cd ..
|
|
54
67
|
```
|
|
55
68
|
|
|
56
69
|
---
|
|
57
70
|
|
|
58
|
-
##
|
|
71
|
+
## Platform Setup
|
|
72
|
+
|
|
73
|
+
### iOS Setup
|
|
59
74
|
|
|
60
|
-
1.
|
|
61
|
-
If you're unable to use use_frameworks you should add the following code to your Podfile:
|
|
75
|
+
1. Add the required CocoaPods sources to your `ios/Podfile`:
|
|
62
76
|
|
|
63
77
|
```ruby
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
end
|
|
75
|
-
end
|
|
78
|
+
source 'https://bitbucket.org/sencyai/ios_sdks_release.git'
|
|
79
|
+
source 'https://github.com/CocoaPods/Specs.git'
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
2. Add `use_frameworks!` to your target:
|
|
83
|
+
|
|
84
|
+
```ruby
|
|
85
|
+
target 'YourApp' do
|
|
86
|
+
use_frameworks!
|
|
87
|
+
# ... other pods
|
|
76
88
|
end
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
3. Add the post-install hook at the end of your Podfile:
|
|
77
92
|
|
|
78
|
-
|
|
93
|
+
```ruby
|
|
79
94
|
post_install do |installer|
|
|
80
|
-
react_native_post_install(
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
95
|
+
react_native_post_install(
|
|
96
|
+
installer,
|
|
97
|
+
:mac_catalyst_enabled => false
|
|
98
|
+
)
|
|
99
|
+
installer.pods_project.targets.each do |target|
|
|
100
|
+
target.build_configurations.each do |config|
|
|
101
|
+
config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
|
|
102
|
+
config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64'
|
|
88
103
|
end
|
|
89
104
|
end
|
|
105
|
+
__apply_Xcode_12_5_M1_post_install_workaround(installer)
|
|
90
106
|
end
|
|
91
107
|
```
|
|
92
108
|
|
|
93
|
-
|
|
109
|
+
4. Install pods:
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
cd ios
|
|
113
|
+
NO_FLIPPER=1 pod install
|
|
114
|
+
cd ..
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
5. Add camera permission to `Info.plist`:
|
|
94
118
|
|
|
95
|
-
|
|
119
|
+
```xml
|
|
120
|
+
<key>NSCameraUsageDescription</key>
|
|
121
|
+
<string>Camera access is needed for fitness assessments and motion detection</string>
|
|
122
|
+
```
|
|
96
123
|
|
|
97
|
-
|
|
98
|
-
Add on project level `build.gradle`:
|
|
124
|
+
### Android Setup
|
|
99
125
|
|
|
100
|
-
|
|
126
|
+
1. Update your project-level `build.gradle`:
|
|
127
|
+
|
|
128
|
+
```gradle
|
|
101
129
|
buildscript {
|
|
102
130
|
ext {
|
|
103
131
|
minSdkVersion = 26
|
|
132
|
+
// ... other settings
|
|
104
133
|
}
|
|
105
134
|
}
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
Add on project level build.gradle:
|
|
109
135
|
|
|
110
|
-
```groovy
|
|
111
136
|
allprojects {
|
|
112
137
|
maven {
|
|
113
138
|
url "https://artifacts.sency.ai/artifactory/release/"
|
|
@@ -115,558 +140,376 @@ allprojects {
|
|
|
115
140
|
}
|
|
116
141
|
```
|
|
117
142
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
### 1. Configure <a name="conf"></a>
|
|
143
|
+
2. Ensure your app's `build.gradle` targets Android API 26+:
|
|
121
144
|
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}catch (e) {
|
|
130
|
-
console.error(e);
|
|
145
|
+
```gradle
|
|
146
|
+
android {
|
|
147
|
+
compileSdkVersion 35
|
|
148
|
+
defaultConfig {
|
|
149
|
+
minSdkVersion 26
|
|
150
|
+
targetSdkVersion 35
|
|
151
|
+
}
|
|
131
152
|
}
|
|
132
153
|
```
|
|
133
154
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
**⚠️ smkit_ui_library will not work if you don't first call configure.**
|
|
137
|
-
|
|
138
|
-
## 2. Start <a name="start"></a>
|
|
139
|
-
|
|
140
|
-
#### [Start Assessment](#data)
|
|
141
|
-
|
|
142
|
-
- [Start Assessment](https://github.com/sency-ai/smkit-ui-react-native-demo/blob/main/Assessment.md)
|
|
143
|
-
|
|
144
|
-
- [Start Workout](https://github.com/sency-ai/smkit-ui-react-native-demo/blob/main/Workout.md)
|
|
145
|
-
|
|
146
|
-
- [Build Your Own Assessment](https://github.com/sency-ai/smkit-ui-react-native-demo/blob/main/CustomizedAssessment.md)
|
|
147
|
-
|
|
148
|
-
##Data <a name="data"></a>
|
|
149
|
-
|
|
150
|
-
### AssessmentTypes
|
|
151
|
-
|
|
152
|
-
| Name (enum) | Description | More info |
|
|
153
|
-
| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------- |
|
|
154
|
-
| Fitness | For individuals of any activity level who seek to enhance their physical abilities, strength, and endurance through a tailored plan. | [Link](https://github.com/sency-ai/smkit-sdk/blob/main/Assessments/AI-Fitness-Assessment.md) |
|
|
155
|
-
| Body360 | Designed for individuals of any age and activity level, this assessment determines the need for a preventative plan or medical support. | [Link](https://github.com/sency-ai/smkit-sdk/blob/main/Assessments/360-Body-Assessment.md) |
|
|
156
|
-
| Strength | For individuals of any activity level who seek to assess their strength capabilities (core and endurance) \* This assessment will be available soon. Contact us for more info. | [Link](https://github.com/sency-ai/smkit-sdk/blob/main/Assessments/Strength.md) |
|
|
157
|
-
| Cardio | For individuals of any activity level who seek to assess their cardiovascular capabilities \* This assessment will be available soon. Contact us for more info. | [Link](https://github.com/sency-ai/smkit-sdk/blob/main/Assessments/Cardio.md) |
|
|
158
|
-
| Custom | If Sency created a tailored assessment for you, you probably know it, and you should use this enum. | |
|
|
159
|
-
|
|
160
|
-
Having issues? [Contact us](mailto:support@sency.ai) and let us know what the problem is.
|
|
161
|
-
|
|
162
|
-
# React Native SMKit UI Library
|
|
163
|
-
|
|
164
|
-
This is a React Native plugin that implements the SMKit UI native library for both iOS and Android platforms. The library provides fitness assessments, custom workouts, and workout programs with motion detection capabilities.
|
|
165
|
-
|
|
166
|
-
## Prerequisites
|
|
167
|
-
|
|
168
|
-
Before running the example app, ensure you have the following installed:
|
|
169
|
-
|
|
170
|
-
### General Requirements
|
|
171
|
-
- **Node.js** (version 18 or higher)
|
|
172
|
-
- **Yarn** package manager
|
|
173
|
-
- **React Native CLI**
|
|
174
|
-
|
|
175
|
-
### iOS Development
|
|
176
|
-
- **Xcode** (latest version)
|
|
177
|
-
- **CocoaPods**
|
|
178
|
-
- **iOS Simulator** or physical iOS device
|
|
155
|
+
---
|
|
179
156
|
|
|
180
|
-
|
|
181
|
-
- **Android Studio** with Android SDK
|
|
182
|
-
- **Java Development Kit (JDK)** 11 or higher
|
|
183
|
-
- **Android Virtual Device (AVD)** or physical Android device
|
|
157
|
+
## Getting Started
|
|
184
158
|
|
|
185
|
-
|
|
159
|
+
### 1. Initialize the Library
|
|
186
160
|
|
|
187
|
-
|
|
161
|
+
Call `configure()` as early as possible in your app (e.g., on app launch):
|
|
188
162
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
npm install -g yarn
|
|
192
|
-
```
|
|
163
|
+
```typescript
|
|
164
|
+
import { configure } from '@sency/react-native-smkit-ui';
|
|
193
165
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
166
|
+
try {
|
|
167
|
+
await configure('YOUR_API_KEY');
|
|
168
|
+
} catch (error) {
|
|
169
|
+
console.error('Failed to configure SMKit UI:', error);
|
|
170
|
+
}
|
|
197
171
|
```
|
|
198
172
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
```bash
|
|
202
|
-
# Navigate to the project root
|
|
203
|
-
cd /path/to/react-native-smkit-ui
|
|
204
|
-
|
|
205
|
-
# Install root dependencies
|
|
206
|
-
yarn install
|
|
207
|
-
|
|
208
|
-
# Build the library
|
|
209
|
-
yarn build
|
|
210
|
-
```
|
|
173
|
+
> **⚠️ Important:** The library will not function until `configure()` is called successfully.
|
|
211
174
|
|
|
212
|
-
###
|
|
175
|
+
### 2. Request Camera Permissions
|
|
213
176
|
|
|
214
|
-
|
|
215
|
-
# Create the library package
|
|
216
|
-
npm pack
|
|
177
|
+
Ensure your app has camera permissions granted before starting assessments or workouts:
|
|
217
178
|
|
|
218
|
-
|
|
219
|
-
|
|
179
|
+
```typescript
|
|
180
|
+
import { request, PERMISSIONS, RESULTS } from 'react-native-permissions';
|
|
220
181
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
182
|
+
const cameraPermission = await request(
|
|
183
|
+
Platform.OS === 'ios'
|
|
184
|
+
? PERMISSIONS.IOS.CAMERA
|
|
185
|
+
: PERMISSIONS.ANDROID.CAMERA
|
|
186
|
+
);
|
|
224
187
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
{
|
|
228
|
-
"dependencies": {
|
|
229
|
-
"@sency/react-native-smkit-ui": "file:../sency-react-native-smkit-ui-1.3.2.tgz",
|
|
230
|
-
// ... other dependencies
|
|
231
|
-
}
|
|
188
|
+
if (cameraPermission === RESULTS.GRANTED) {
|
|
189
|
+
// Ready to start assessments/workouts
|
|
232
190
|
}
|
|
233
191
|
```
|
|
234
192
|
|
|
235
|
-
|
|
236
|
-
# Install example dependencies
|
|
237
|
-
yarn install
|
|
238
|
-
```
|
|
193
|
+
---
|
|
239
194
|
|
|
240
|
-
##
|
|
195
|
+
## Core Features
|
|
241
196
|
|
|
242
|
-
###
|
|
243
|
-
```bash
|
|
244
|
-
cd example/ios
|
|
245
|
-
pod install
|
|
246
|
-
cd ..
|
|
247
|
-
```
|
|
197
|
+
### Assessment Types
|
|
248
198
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
199
|
+
| Type | Purpose | Use Case |
|
|
200
|
+
|------|---------|----------|
|
|
201
|
+
| **Fitness** | Comprehensive fitness evaluation | General fitness assessment for all levels |
|
|
202
|
+
| **Body360** | Full-body movement and posture analysis | Preventative health screening |
|
|
203
|
+
| **Strength** | Core and endurance strength testing | Evaluate strength capabilities |
|
|
204
|
+
| **Cardio** | Cardiovascular capacity assessment | Assess aerobic fitness |
|
|
205
|
+
| **Custom** | Custom assessment (provided by Sency) | Specialized evaluations |
|
|
253
206
|
|
|
254
|
-
###
|
|
255
|
-
In a new terminal:
|
|
256
|
-
```bash
|
|
257
|
-
cd example
|
|
258
|
-
yarn ios
|
|
259
|
-
```
|
|
207
|
+
### Workout Configuration
|
|
260
208
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
209
|
+
Customize workouts with:
|
|
210
|
+
- **Body Zones**: Full Body, Upper Body, Lower Body, Core
|
|
211
|
+
- **Difficulty**: Low, Medium, High
|
|
212
|
+
- **Duration**: Short, Medium, Long
|
|
213
|
+
- **Week Number**: For multi-week programs
|
|
265
214
|
|
|
266
|
-
|
|
215
|
+
---
|
|
267
216
|
|
|
268
|
-
|
|
217
|
+
## API Reference
|
|
269
218
|
|
|
270
|
-
|
|
271
|
-
- Android Studio installed with Android SDK
|
|
272
|
-
- Android Virtual Device (AVD) created and running, OR
|
|
273
|
-
- Physical Android device connected with USB debugging enabled
|
|
219
|
+
### Core Methods
|
|
274
220
|
|
|
275
|
-
|
|
276
|
-
```bash
|
|
277
|
-
npx react-native doctor
|
|
278
|
-
```
|
|
221
|
+
#### `configure(apiKey: string): Promise<void>`
|
|
279
222
|
|
|
280
|
-
|
|
223
|
+
Initialize the SMKit UI library with your API key.
|
|
281
224
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
org.gradle.jvmargs=-Xmx4096m -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
|
|
285
|
-
org.gradle.parallel=true
|
|
286
|
-
android.useAndroidX=true
|
|
287
|
-
android.enableJetifier=true
|
|
288
|
-
hermesEnabled=true
|
|
289
|
-
```
|
|
225
|
+
```typescript
|
|
226
|
+
import { configure } from '@sency/react-native-smkit-ui';
|
|
290
227
|
|
|
291
|
-
|
|
292
|
-
```bash
|
|
293
|
-
cd example
|
|
294
|
-
yarn start
|
|
228
|
+
await configure('YOUR_API_KEY');
|
|
295
229
|
```
|
|
296
230
|
|
|
297
|
-
|
|
298
|
-
In a new terminal:
|
|
299
|
-
```bash
|
|
300
|
-
cd example
|
|
301
|
-
yarn android
|
|
302
|
-
```
|
|
303
|
-
|
|
304
|
-
## Troubleshooting
|
|
305
|
-
|
|
306
|
-
### Metro Port Already in Use
|
|
307
|
-
If you get "EADDRINUSE: address already in use :::8081":
|
|
308
|
-
```bash
|
|
309
|
-
# Kill existing Metro process
|
|
310
|
-
lsof -ti:8081 | xargs kill -9
|
|
231
|
+
---
|
|
311
232
|
|
|
312
|
-
|
|
313
|
-
yarn start --reset-cache
|
|
314
|
-
```
|
|
233
|
+
#### `startAssessment(type: AssessmentType, options?: AssessmentOptions): Promise<AssessmentResult>`
|
|
315
234
|
|
|
316
|
-
|
|
235
|
+
Start a fitness assessment.
|
|
317
236
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
```bash
|
|
321
|
-
# Clean build cache
|
|
322
|
-
cd example/android
|
|
323
|
-
./gradlew clean
|
|
324
|
-
cd ..
|
|
325
|
-
|
|
326
|
-
# Clear Gradle cache
|
|
327
|
-
rm -rf ~/.gradle/caches/
|
|
237
|
+
```typescript
|
|
238
|
+
import { startAssessment, AssessmentType } from '@sency/react-native-smkit-ui';
|
|
328
239
|
|
|
329
|
-
|
|
330
|
-
|
|
240
|
+
const result = await startAssessment(AssessmentType.Fitness, {
|
|
241
|
+
showSummary: true,
|
|
242
|
+
customId: 'user-123'
|
|
243
|
+
});
|
|
331
244
|
```
|
|
332
245
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
yarn install
|
|
339
|
-
|
|
340
|
-
# Reset Metro cache
|
|
341
|
-
yarn start --reset-cache
|
|
342
|
-
```
|
|
246
|
+
**Parameters:**
|
|
247
|
+
- `type` - The assessment type (Fitness, Body360, Strength, Cardio, Custom)
|
|
248
|
+
- `options` - Optional configuration object
|
|
249
|
+
- `showSummary` - Display summary after completion (default: true)
|
|
250
|
+
- `customId` - Custom identifier for the assessment
|
|
343
251
|
|
|
344
|
-
|
|
252
|
+
---
|
|
345
253
|
|
|
346
|
-
####
|
|
347
|
-
```bash
|
|
348
|
-
cd example/ios
|
|
349
|
-
rm -rf Pods
|
|
350
|
-
rm Podfile.lock
|
|
351
|
-
pod cache clean --all
|
|
352
|
-
pod install
|
|
353
|
-
cd ..
|
|
354
|
-
```
|
|
254
|
+
#### `startWorkoutProgram(config: WorkoutConfig): Promise<WorkoutResult>`
|
|
355
255
|
|
|
356
|
-
|
|
357
|
-
- Open `example/ios/SmkitUiLibraryExample.xcworkspace` in Xcode
|
|
358
|
-
- Clean Build Folder (⌘ + Shift + K)
|
|
359
|
-
- Build the project (⌘ + B)
|
|
360
|
-
|
|
361
|
-
## Example App Features
|
|
362
|
-
|
|
363
|
-
The example app demonstrates the following SMKit UI library features:
|
|
364
|
-
|
|
365
|
-
### Fitness Assessments
|
|
366
|
-
- **Basic Assessment**: Standard fitness evaluation
|
|
367
|
-
- **Body360 Assessment**: Comprehensive body analysis
|
|
368
|
-
- **Custom Assessments**: Configurable assessment types
|
|
369
|
-
|
|
370
|
-
### Workouts
|
|
371
|
-
- **Custom Workouts**: Create personalized exercise routines
|
|
372
|
-
- **Workout Programs**: Multi-week fitness programs
|
|
373
|
-
- **Exercise Types**: Squats, push-ups, lunges, planks, and more
|
|
374
|
-
|
|
375
|
-
### Configuration Options
|
|
376
|
-
- Body zones (Full Body, Upper Body, Lower Body, Core)
|
|
377
|
-
- Difficulty levels (Low, Medium, High)
|
|
378
|
-
- Duration settings (Short, Medium, Long)
|
|
379
|
-
- Motion detection capabilities
|
|
380
|
-
|
|
381
|
-
## Development Workflow
|
|
382
|
-
|
|
383
|
-
### Making Changes to the Library
|
|
384
|
-
|
|
385
|
-
1. Make your changes in the `src/` directory
|
|
386
|
-
2. Build the library:
|
|
387
|
-
```bash
|
|
388
|
-
yarn build
|
|
389
|
-
```
|
|
390
|
-
3. Create new package:
|
|
391
|
-
```bash
|
|
392
|
-
npm pack
|
|
393
|
-
```
|
|
394
|
-
4. Update example app dependency and reinstall:
|
|
395
|
-
```bash
|
|
396
|
-
cd example
|
|
397
|
-
yarn install
|
|
398
|
-
```
|
|
399
|
-
5. Test your changes:
|
|
400
|
-
```bash
|
|
401
|
-
yarn ios # or yarn android
|
|
402
|
-
```
|
|
403
|
-
|
|
404
|
-
### Testing on Physical Devices
|
|
405
|
-
|
|
406
|
-
#### iOS
|
|
407
|
-
- Connect your iOS device
|
|
408
|
-
- Ensure it's registered in your Apple Developer account
|
|
409
|
-
- Run: `yarn ios --device`
|
|
410
|
-
|
|
411
|
-
#### Android
|
|
412
|
-
- Enable Developer Options and USB Debugging on your device
|
|
413
|
-
- Connect via USB
|
|
414
|
-
- Verify connection: `adb devices`
|
|
415
|
-
- Run: `yarn android`
|
|
416
|
-
|
|
417
|
-
## API Usage
|
|
418
|
-
|
|
419
|
-
The example app in `example/src/App.tsx` shows how to use the main library functions:
|
|
256
|
+
Start a workout program with customization options.
|
|
420
257
|
|
|
421
258
|
```typescript
|
|
422
|
-
import {
|
|
423
|
-
|
|
424
|
-
// Configure the library
|
|
425
|
-
await configure(apiKey, userId);
|
|
426
|
-
|
|
427
|
-
// Start an assessment
|
|
428
|
-
await startAssessment(assessmentType, showSummary, customId);
|
|
429
|
-
|
|
430
|
-
// Start a workout program
|
|
431
|
-
const config = new WorkoutConfig(week, bodyZone, difficulty, duration, programId);
|
|
432
|
-
await startWorkoutProgram(config);
|
|
433
|
-
```
|
|
434
|
-
|
|
435
|
-
## Updating Native Dependencies
|
|
259
|
+
import { startWorkoutProgram, WorkoutConfig, BodyZone, Difficulty, Duration } from '@sency/react-native-smkit-ui';
|
|
436
260
|
|
|
437
|
-
|
|
261
|
+
const config = new WorkoutConfig(
|
|
262
|
+
week: 1,
|
|
263
|
+
bodyZone: BodyZone.FullBody,
|
|
264
|
+
difficulty: Difficulty.Medium,
|
|
265
|
+
duration: Duration.Medium,
|
|
266
|
+
programId: 'program-123'
|
|
267
|
+
);
|
|
438
268
|
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
Update the version in the plugin's `android/build.gradle`:
|
|
442
|
-
```gradle
|
|
443
|
-
dependencies {
|
|
444
|
-
implementation 'com.sency.smkitui:smkitui:1.3.7' // Updated version
|
|
445
|
-
// ...other dependencies
|
|
446
|
-
}
|
|
269
|
+
const result = await startWorkoutProgram(config);
|
|
447
270
|
```
|
|
448
271
|
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
```bash
|
|
452
|
-
# From plugin root directory
|
|
453
|
-
npm pack
|
|
454
|
-
```
|
|
455
|
-
|
|
456
|
-
### 3. Update Example App
|
|
457
|
-
|
|
458
|
-
```bash
|
|
459
|
-
cd example
|
|
460
|
-
|
|
461
|
-
# Clean and reinstall dependencies
|
|
462
|
-
rm -rf node_modules
|
|
463
|
-
yarn install
|
|
272
|
+
---
|
|
464
273
|
|
|
465
|
-
|
|
466
|
-
cd android
|
|
467
|
-
./gradlew clean --refresh-dependencies
|
|
468
|
-
cd ..
|
|
274
|
+
#### `startCustomAssessment(config: CustomAssessmentConfig): Promise<AssessmentResult>`
|
|
469
275
|
|
|
470
|
-
|
|
471
|
-
yarn start --reset-cache &
|
|
472
|
-
yarn android
|
|
473
|
-
```
|
|
276
|
+
Start a custom assessment (assessment configured by Sency for your specific needs).
|
|
474
277
|
|
|
475
|
-
|
|
278
|
+
```typescript
|
|
279
|
+
import { startCustomAssessment } from '@sency/react-native-smkit-ui';
|
|
476
280
|
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
281
|
+
const result = await startCustomAssessment({
|
|
282
|
+
customId: 'assessment-123',
|
|
283
|
+
showSummary: true
|
|
284
|
+
});
|
|
481
285
|
```
|
|
482
286
|
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
If you get "Could not read script" errors:
|
|
486
|
-
|
|
487
|
-
#### For react-native-config Issues:
|
|
488
|
-
```bash
|
|
489
|
-
cd example
|
|
287
|
+
---
|
|
490
288
|
|
|
491
|
-
|
|
492
|
-
yarn remove react-native-config
|
|
493
|
-
yarn add react-native-config
|
|
289
|
+
## Examples
|
|
494
290
|
|
|
495
|
-
|
|
496
|
-
# // apply from: "../../node_modules/react-native-config/android/dotenv.gradle"
|
|
291
|
+
### Complete Setup Example
|
|
497
292
|
|
|
498
|
-
|
|
293
|
+
```typescript
|
|
294
|
+
import React, { useEffect, useState } from 'react';
|
|
295
|
+
import { View, TouchableOpacity, Text } from 'react-native';
|
|
296
|
+
import {
|
|
297
|
+
configure,
|
|
298
|
+
startAssessment,
|
|
299
|
+
startWorkoutProgram,
|
|
300
|
+
AssessmentType,
|
|
301
|
+
BodyZone,
|
|
302
|
+
Difficulty,
|
|
303
|
+
Duration,
|
|
304
|
+
WorkoutConfig
|
|
305
|
+
} from '@sency/react-native-smkit-ui';
|
|
306
|
+
|
|
307
|
+
export default function FitnessApp() {
|
|
308
|
+
const [isConfigured, setIsConfigured] = useState(false);
|
|
309
|
+
|
|
310
|
+
useEffect(() => {
|
|
311
|
+
initializeApp();
|
|
312
|
+
}, []);
|
|
313
|
+
|
|
314
|
+
const initializeApp = async () => {
|
|
315
|
+
try {
|
|
316
|
+
await configure('YOUR_API_KEY');
|
|
317
|
+
setIsConfigured(true);
|
|
318
|
+
} catch (error) {
|
|
319
|
+
console.error('Configuration failed:', error);
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
const handleFitnessAssessment = async () => {
|
|
324
|
+
try {
|
|
325
|
+
const result = await startAssessment(AssessmentType.Fitness, {
|
|
326
|
+
showSummary: true
|
|
327
|
+
});
|
|
328
|
+
console.log('Assessment completed:', result);
|
|
329
|
+
} catch (error) {
|
|
330
|
+
console.error('Assessment failed:', error);
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
|
|
334
|
+
const handleWorkout = async () => {
|
|
335
|
+
try {
|
|
336
|
+
const config = new WorkoutConfig(
|
|
337
|
+
1,
|
|
338
|
+
BodyZone.FullBody,
|
|
339
|
+
Difficulty.Medium,
|
|
340
|
+
Duration.Medium
|
|
341
|
+
);
|
|
342
|
+
const result = await startWorkoutProgram(config);
|
|
343
|
+
console.log('Workout completed:', result);
|
|
344
|
+
} catch (error) {
|
|
345
|
+
console.error('Workout failed:', error);
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
return (
|
|
350
|
+
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
|
|
351
|
+
<TouchableOpacity
|
|
352
|
+
onPress={handleFitnessAssessment}
|
|
353
|
+
disabled={!isConfigured}
|
|
354
|
+
>
|
|
355
|
+
<Text>Start Fitness Assessment</Text>
|
|
356
|
+
</TouchableOpacity>
|
|
357
|
+
|
|
358
|
+
<TouchableOpacity
|
|
359
|
+
onPress={handleWorkout}
|
|
360
|
+
disabled={!isConfigured}
|
|
361
|
+
>
|
|
362
|
+
<Text>Start Workout</Text>
|
|
363
|
+
</TouchableOpacity>
|
|
364
|
+
</View>
|
|
365
|
+
);
|
|
366
|
+
}
|
|
499
367
|
```
|
|
500
368
|
|
|
501
|
-
|
|
502
|
-
```bash
|
|
503
|
-
# Clean gradle caches
|
|
504
|
-
rm -rf ~/.gradle/caches/modules-2/files-2.1/com.sency.smkitui/
|
|
369
|
+
### Body360 Assessment Example
|
|
505
370
|
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
371
|
+
```typescript
|
|
372
|
+
const startBody360Assessment = async () => {
|
|
373
|
+
try {
|
|
374
|
+
const result = await startAssessment(AssessmentType.Body360, {
|
|
375
|
+
showSummary: true,
|
|
376
|
+
customId: `user-${Date.now()}`
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
if (result.success) {
|
|
380
|
+
console.log('Body360 assessment completed');
|
|
381
|
+
console.log('Results:', result.data);
|
|
382
|
+
}
|
|
383
|
+
} catch (error) {
|
|
384
|
+
console.error('Body360 assessment error:', error);
|
|
385
|
+
}
|
|
386
|
+
};
|
|
513
387
|
```
|
|
514
388
|
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
The example app supports Android 15 (API level 35) with the following configuration:
|
|
389
|
+
### Customized Workout Example
|
|
518
390
|
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
}
|
|
391
|
+
```typescript
|
|
392
|
+
const startCustomizedWorkout = async () => {
|
|
393
|
+
try {
|
|
394
|
+
const config = new WorkoutConfig(
|
|
395
|
+
week: 2,
|
|
396
|
+
bodyZone: BodyZone.UpperBody,
|
|
397
|
+
difficulty: Difficulty.High,
|
|
398
|
+
duration: Duration.Long
|
|
399
|
+
);
|
|
400
|
+
|
|
401
|
+
const result = await startWorkoutProgram(config);
|
|
402
|
+
console.log('Workout program completed:', result);
|
|
403
|
+
} catch (error) {
|
|
404
|
+
console.error('Workout error:', error);
|
|
405
|
+
}
|
|
406
|
+
};
|
|
535
407
|
```
|
|
536
408
|
|
|
537
|
-
|
|
538
|
-
1. Create an Android 15 emulator in Android Studio
|
|
539
|
-
2. Ensure camera permissions are granted
|
|
540
|
-
3. Monitor for privacy-related warnings in logcat
|
|
409
|
+
---
|
|
541
410
|
|
|
542
|
-
##
|
|
411
|
+
## Troubleshooting
|
|
543
412
|
|
|
544
|
-
|
|
413
|
+
### "Configuration Failed" Error
|
|
545
414
|
|
|
546
|
-
|
|
547
|
-
1. Copy `.env.example` to `.env` in the `example` directory
|
|
548
|
-
2. Add your API key: `SMKIT_API_KEY=your_actual_key`
|
|
549
|
-
3. The `.env` file is automatically ignored by git
|
|
415
|
+
**Problem:** `configure()` throws an error or returns false.
|
|
550
416
|
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
417
|
+
**Solutions:**
|
|
418
|
+
- Verify your API key is correct
|
|
419
|
+
- Check your internet connection
|
|
420
|
+
- Ensure the SMKit backend service is available
|
|
421
|
+
- Call `configure()` before using any other library functions
|
|
554
422
|
|
|
555
|
-
|
|
556
|
-
await configure(apiKey);
|
|
557
|
-
```
|
|
423
|
+
### Camera Permissions Not Granted
|
|
558
424
|
|
|
559
|
-
|
|
560
|
-
If you get "Missing API Key" errors:
|
|
561
|
-
1. Verify `.env` file exists in `example/` directory
|
|
562
|
-
2. Check `SMKIT_API_KEY` is set correctly
|
|
563
|
-
3. Clean and rebuild: `yarn start --reset-cache`
|
|
564
|
-
4. For testing, you can temporarily use a hardcoded key
|
|
425
|
+
**Problem:** Assessment or workout fails with camera permission error.
|
|
565
426
|
|
|
566
|
-
|
|
427
|
+
**Solutions:**
|
|
428
|
+
- Request camera permissions before starting assessments
|
|
429
|
+
- Check that permissions are granted in device settings
|
|
430
|
+
- On iOS, verify `NSCameraUsageDescription` is in `Info.plist`
|
|
431
|
+
- On Android, ensure runtime permissions are requested
|
|
567
432
|
|
|
568
|
-
###
|
|
433
|
+
### iOS Pod Installation Issues
|
|
569
434
|
|
|
570
|
-
|
|
435
|
+
**Problem:** `pod install` fails or shows version conflicts.
|
|
571
436
|
|
|
437
|
+
**Solutions:**
|
|
572
438
|
```bash
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
439
|
+
cd ios
|
|
440
|
+
rm -rf Pods
|
|
441
|
+
rm Podfile.lock
|
|
442
|
+
pod cache clean --all
|
|
443
|
+
pod install
|
|
444
|
+
cd ..
|
|
578
445
|
```
|
|
579
446
|
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
The publish script (`scripts/publish.sh`) provides:
|
|
583
|
-
|
|
584
|
-
- ✅ **Git Status Check** - Warns about uncommitted changes
|
|
585
|
-
- ✅ **Version Management** - Interactive version selection (patch/minor/major/custom)
|
|
586
|
-
- ✅ **Build Verification** - Cleans and builds with Bob
|
|
587
|
-
- ✅ **Testing Support** - Creates test package for example app validation
|
|
588
|
-
- ✅ **NPM Authentication** - Checks login status and prompts if needed
|
|
589
|
-
- ✅ **Dry Run** - Shows package contents before publishing
|
|
590
|
-
- ✅ **Safety Confirmations** - Multiple confirmation steps
|
|
591
|
-
- ✅ **Automated Publishing** - Publishes to NPM with proper access
|
|
592
|
-
- ✅ **Changelog Reminder** - Prompts to update CHANGELOG.md with release notes
|
|
593
|
-
- ✅ **Git Tagging** - Creates and pushes release tags automatically
|
|
594
|
-
- ✅ **Verification** - Confirms package availability on NPM
|
|
447
|
+
### Android Build Failures
|
|
595
448
|
|
|
596
|
-
|
|
449
|
+
**Problem:** Gradle build fails with native dependency errors.
|
|
597
450
|
|
|
451
|
+
**Solutions:**
|
|
598
452
|
```bash
|
|
599
|
-
#
|
|
600
|
-
|
|
453
|
+
# Clean Gradle caches
|
|
454
|
+
rm -rf ~/.gradle/caches/
|
|
601
455
|
|
|
602
|
-
#
|
|
603
|
-
|
|
456
|
+
# Clean project
|
|
457
|
+
cd android
|
|
458
|
+
./gradlew clean
|
|
459
|
+
cd ..
|
|
604
460
|
|
|
605
|
-
#
|
|
606
|
-
npm
|
|
461
|
+
# Rebuild
|
|
462
|
+
npm install
|
|
463
|
+
yarn android
|
|
607
464
|
```
|
|
608
465
|
|
|
609
|
-
|
|
466
|
+
### Motion Detection Not Working
|
|
610
467
|
|
|
611
|
-
|
|
468
|
+
**Problem:** Assessment starts but motion detection fails.
|
|
612
469
|
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
npm run clean
|
|
619
|
-
npx bob build
|
|
470
|
+
**Solutions:**
|
|
471
|
+
- Ensure adequate lighting in the environment
|
|
472
|
+
- Position user fully in camera frame
|
|
473
|
+
- Verify camera lens is clean
|
|
474
|
+
- Check that device camera is not in use by another app
|
|
620
475
|
|
|
621
|
-
|
|
622
|
-
npm pack
|
|
623
|
-
# Update example/package.json to use the .tgz file
|
|
624
|
-
# Test the example app
|
|
476
|
+
### Library Not Initializing
|
|
625
477
|
|
|
626
|
-
|
|
627
|
-
npm login
|
|
628
|
-
npm publish --access public
|
|
478
|
+
**Problem:** Features don't work even after calling `configure()`.
|
|
629
479
|
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
480
|
+
**Solutions:**
|
|
481
|
+
- Verify `configure()` was called and completed successfully
|
|
482
|
+
- Check for error messages in console logs
|
|
483
|
+
- Ensure you're not calling library methods before `configure()` completes
|
|
484
|
+
- Test with a fresh app start
|
|
634
485
|
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
Before publishing, ensure:
|
|
638
|
-
|
|
639
|
-
- ✅ Native dependencies are updated (e.g., `smkitui:1.3.7`)
|
|
640
|
-
- ✅ Version numbers are consistent across all files
|
|
641
|
-
- ✅ CHANGELOG.md is updated with release notes
|
|
642
|
-
- ✅ Library builds successfully with `npx bob build`
|
|
643
|
-
- ✅ Example app works with the new build
|
|
644
|
-
- ✅ All changes are committed to git
|
|
645
|
-
- ✅ You have NPM publish permissions for `@sency/react-native-smkit-ui`
|
|
486
|
+
---
|
|
646
487
|
|
|
647
|
-
##
|
|
488
|
+
## Additional Resources
|
|
648
489
|
|
|
649
|
-
- **[API
|
|
490
|
+
- **[API Documentation](API.md)** - Complete API reference with detailed parameters
|
|
650
491
|
- **[Changelog](CHANGELOG.md)** - Version history and release notes
|
|
651
|
-
- **[Example App](example/)** - Working
|
|
492
|
+
- **[Example App](example/)** - Working demonstration app with source code
|
|
652
493
|
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
Visit our [NPM page](https://www.npmjs.com/package/@sency/react-native-smkit-ui) for:
|
|
656
|
-
- Latest version information
|
|
657
|
-
- Download statistics
|
|
658
|
-
- Dependency information
|
|
659
|
-
- Version history
|
|
494
|
+
---
|
|
660
495
|
|
|
661
496
|
## Support
|
|
662
497
|
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
498
|
+
Need help?
|
|
499
|
+
|
|
500
|
+
- **Documentation**: See [API.md](API.md) for detailed API documentation
|
|
501
|
+
- **Issues**: Check our [GitHub Issues](https://github.com/sency-ai/smkit-sdk/issues)
|
|
502
|
+
- **Email**: [support@sency.ai](mailto:support@sency.ai)
|
|
503
|
+
|
|
504
|
+
---
|
|
669
505
|
|
|
670
506
|
## License
|
|
671
507
|
|
|
672
508
|
MIT
|
|
509
|
+
|
|
510
|
+
---
|
|
511
|
+
|
|
512
|
+
## Repository
|
|
513
|
+
|
|
514
|
+
- **GitHub**: [sency-ai/smkit-sdk](https://github.com/sency-ai/smkit-sdk)
|
|
515
|
+
- **NPM Package**: [@sency/react-native-smkit-ui](https://www.npmjs.com/package/@sency/react-native-smkit-ui)
|