@sency/react-native-smkit-ui 0.1.0 → 0.1.1-snapshot-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/README.md CHANGED
@@ -1,31 +1,201 @@
1
- # react-native-smkit-ui
1
+ # [react-native-smkit-ui demo](https://github.com/sency-ai/smkit-sdk)
2
2
 
3
- smkit-ui-library
3
+ 1. [ Installation ](#inst)
4
+ 2. [ Setup ](#setup)
5
+ 3. [ Configure ](#conf)
6
+ 4. [ Start ](#start)
7
+ 5. [ Data ](#data)
4
8
 
5
- ## Installation
9
+ <a name="inst"></a>
10
+ ## 1. Installation
11
+ 1. run `npm install @sency/react-native-smkit-ui`
6
12
 
7
- ```sh
8
- npm install smkit-ui-library
13
+ 2. Update *Podfile* in `iOS` folder:
9
14
  ```
15
+ [1] add the source to the top of your Podfile.
16
+ source 'https://bitbucket.org/sency-ios/sency_ios_sdk.git'
17
+ source 'https://github.com/CocoaPods/Specs.git'
10
18
 
11
- ## Usage
19
+ [2] add use_frameworks! commend to your target
20
+ target 'YOUR_TARGET' do
21
+ use_frameworks!
22
+ ```
23
+
24
+ 3. Run `NO_FLIPPER=1 pod install` to install the necessary pods.
25
+
26
+ ## 2. Setup <a name="setup"></a>
27
+
28
+ ### iOS
29
+ Add camera permission request to `Info.plist`
30
+ ```Xml
31
+ <key>NSCameraUsageDescription</key>
32
+ <string>Camera access is needed</string>
33
+ ```
34
+
35
+ ### Android
36
+ In order to integrate SMKitUI you need to import the smkitui dependency
37
+ Add on project level build.gradle:
38
+ ```groovy
39
+ allprojects {
40
+ maven {
41
+ url "https://artifacts.sency.ai/artifactory/release/"
42
+ }
43
+ }
44
+ ```
45
+
46
+ #### FBJNI
47
+
48
+ Both React Native and SencyMotion use **fbjni**. For example, the versions for SMKitUI that are used for
49
+ development are:
50
+
51
+ React Native (<= 0.64) uses fbjni **0.0.2**
52
+ SMKitUI uses fbjni **0.2.2**.
53
+ Therefore we need to exclude fbjbi on app level build.gradle:
54
+ ```groovy
55
+ dependencies {
56
+ ...
57
+ implementation('com.sency.smkitui:smkitui:$latest_version'){
58
+ exclude group: 'com.facebook.fbjni', module: 'fbjni-java-only'
59
+ }
60
+ ...
61
+ }
62
+ ```
63
+
64
+ ## 3. Configure <a name="conf"></a>
12
65
 
13
66
  ```js
14
- import { multiply } from 'smkit-ui-library';
67
+ [1] First import configure
68
+ import { configure } from '@sency/react-native-smkit-ui-dev/src/index.tsx';
69
+
70
+ [2] then call the configure function with your auth key
71
+ try{
72
+ var res = await configure("YOUR_AUTH_KEY");
73
+ }catch (e) {
74
+ console.error(e);
75
+ }
76
+ ```
77
+
78
+ To reduce wait time we recommend to call `configure` on app launch.
15
79
 
16
- // ...
80
+ **⚠️ smkit_ui_library will not work if you don't first call configure.**
17
81
 
18
- const result = await multiply(3, 7);
82
+ ## 4. Start <a name="start"></a>
83
+
84
+ 1. Import the sdk
85
+ ```js
86
+ import { startAssessment, startCustomWorkout, AssessmentTypes } from '@sency/react-native-smkit-ui-dev/src/index.tsx';
87
+ import SMKitUI from '@sency/react-native-smkit-ui-dev/src/SMKitUIView.tsx';
88
+ import * as SMWorkoutLibrary from '@sency/react-native-smkit-ui-dev/src/SMWorkout.tsx';
19
89
  ```
20
90
 
21
- ## Contributing
91
+ 2. Add `SMKitUI` view:
92
+ ```js
93
+ return (
94
+ <View style={styles.centeredView}>
95
+ <SMKitUI/>
96
+ </View>
97
+ );
98
+ ```
22
99
 
23
- See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
100
+ #### [Start Assessment](https://github.com/sency-ai/smkit-sdk/blob/main/AI-Fitness-Assessment.md)
101
+ **startAssessment** starts one of Sency's blueprint assessments.
102
+ ```js
103
+ async function startFitnessAssessment(){
104
+ try{
105
+ var result = await startAssessment(AssessmentTypes.Fitness);
106
+ console.log(result.summary);
107
+ console.log(result.didFinish);
108
+ }catch(e) {
109
+ console.error(e);
110
+ }
111
+ }
112
+ ```
113
+ > Check out [this info page](https://github.com/sency-ai/smkit-sdk/blob/main/AI-Fitness-Assessment.md) if you want to learn more about **Sency's AI Fitness Assessment**
114
+
115
+ ### Start Custom Workout
116
+ **startWorkout** starts a custom workout.
117
+ ```js
118
+ async function startSMKitUICustomWorkout(){
119
+ try{
120
+ // list of exercies
121
+ var exercises = [
122
+ new SMWorkoutLibrary.SMExercise(
123
+ name: "First Exercise", // => name:string | null
124
+ 35, // => totalSeconds: number | null
125
+ 5, // => introSeconds: number | null
126
+ null, // => videoInstruction: string | null (url for a video)
127
+ null, // => exerciseIntro: string | null (url for a sound)
128
+ [SMWorkoutLibrary.UIElement.RepsCounter, SMWorkoutLibrary.UIElement.Timer], // => uiElements: UIElement[] | null
129
+ "HighKnees", // => detector: string
130
+ true, // => repBased: boolean | null
131
+ null, // => exerciseClosure: string | null (url for a sound)
132
+ 13, // => targetReps: number | null
133
+ 20, // => targetTime: number | null
134
+ 0.3 // => scoreFactor: number | null
135
+ ),
136
+ new SMWorkoutLibrary.SMExercise(
137
+ "Second Exercise", // => name:string | null
138
+ 25, // => totalSeconds: number | null
139
+ 5, // => introSeconds: number | null
140
+ null, // => videoInstruction: string | null (url for a video)
141
+ null, // => exerciseIntro: string | null (url for a sound)
142
+ [SMWorkoutLibrary.UIElement.GaugeOfMotion, SMWorkoutLibrary.UIElement.Timer], // => uiElements: UIElement[] | null
143
+ "SquatRegularOverheadStatic", // => detector: string
144
+ false, // => repBased: boolean | null
145
+ null, // => exerciseClosure: string | null (url for a sound)
146
+ null, // => targetReps: number | null
147
+ 20, // => targetTime: number | null
148
+ 0.3 // => scoreFactor: number | null
149
+ ),
150
+ ];
24
151
 
25
- ## License
152
+ var workout = new SMWorkoutLibrary.SMWorkout(
153
+ "50", // => id: string | null
154
+ "demo workout",// => name: string | null
155
+ null, // => workoutIntro: string | null (url for a sound)
156
+ null, // => soundtrack: string | null (url for a sound)
157
+ exercises, // => exercises: SMExercise[]
158
+ null, // => getInFrame: string | null (url for a sound)
159
+ null, // => bodycalFinished: string | null (url for a sound)
160
+ null // => workoutClosure: string | null (url for a sound)
161
+ );
162
+ var result = await startCustomWorkout(workout);
163
+ console.log(result.summary);
164
+ console.log(result.didFinish);
165
+ }catch(e){
166
+ console.error(e);
167
+ }
168
+ }
169
+ ```
26
170
 
27
- MIT
171
+ ### Start Program
172
+ **startWorkoutProgram** starts a workout program according to your WorkoutConfig.
173
+ ```js
174
+ async function startSMKitUIProgram(){
175
+ try{
176
+ //WorkoutConfig
177
+ var config = new SMWorkoutLibrary.WorkoutConfig(
178
+ 3, // => week: number
179
+ SMWorkoutLibrary.BodyZone.FullBody, // => bodyZone: BodyZone
180
+ SMWorkoutLibrary.WorkoutDifficulty.HighDifficulty, // => difficultyLevel: WorkoutDifficulty
181
+ SMWorkoutLibrary.WorkoutDuration.Short, // => workoutDuration: WorkoutDuration
182
+ "YOUR_PROGRAM_ID" // => programID: string
183
+ );
184
+ var result = await startWorkoutProgram(config);
185
+ console.log(result.summary);
186
+ console.log(result.didFinish);
187
+ }catch(e){
188
+ console.error(e);
189
+ }
190
+ }
191
+ }
192
+ ```
28
193
 
29
- ---
194
+ ## Available Data Types <a name="data"></a>
195
+ #### `AssessmentTypes`
196
+ | Name |
197
+ |---------------------|
198
+ | Fitness |
199
+ | Custom |
30
200
 
31
- Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
201
+ Having issues? [Contact us](mailto:support@sency.ai) and let us know what the problem is.
@@ -92,7 +92,7 @@ dependencies {
92
92
  implementation "com.facebook.react:react-native:+"
93
93
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
94
94
 
95
- implementation "com.sency.smkit:0.1.0"
95
+ compileOnly("com.sency.smkitui:smkitui:${SMKitUI_Version}")
96
96
 
97
97
  // Moshi JSON library
98
98
  def moshi = "1.15.0"
@@ -8,6 +8,7 @@ import com.facebook.react.bridge.ReactMethod
8
8
  import com.sency.smbase.core.listener.ConfigurationResult
9
9
  import com.sency.smkitui.SMKitUI
10
10
  import com.sency.smkitui.listener.SMKitUIWorkoutListener
11
+ import com.sency.smkitui.model.ExerciseData
11
12
  import com.sency.smkitui.model.WorkoutSummaryData
12
13
  import com.smkituilibrary.mapper.toSMWorkout
13
14
  import com.smkituilibrary.mapper.toWorkoutConfig
@@ -25,7 +26,7 @@ class SmkitUiLibraryModule(reactContext: ReactApplicationContext) :
25
26
  private var resultPromise: Promise? = null
26
27
  private val moshi: Moshi by lazy { moshi() }
27
28
 
28
- override fun getName(): String = "SmkitUiLibrary"
29
+ override fun getName(): String = "SMKitUIManager"
29
30
 
30
31
  override fun handleWorkoutErrors(error: Error) {
31
32
  resultPromise?.reject("Workout Exercise Error", error)
@@ -39,6 +40,10 @@ class SmkitUiLibraryModule(reactContext: ReactApplicationContext) :
39
40
  sendResult(summary, didFinish = false)
40
41
  }
41
42
 
43
+ override fun exerciseDidFinish(data: ExerciseData) {
44
+ println(data)
45
+ }
46
+
42
47
  @ReactMethod
43
48
  fun configure(key: String, promise: Promise) {
44
49
  smKitUI = SMKitUI.Configuration(reactApplicationContext)
@@ -84,7 +89,7 @@ class SmkitUiLibraryModule(reactContext: ReactApplicationContext) :
84
89
  val adapter = moshi.adapter(SMKitWorkoutConfig::class.java)
85
90
  val smKitWorkoutConfig = adapter.fromJson(jsonArguments) ?: return
86
91
 
87
- smKitUI?.startWorkoutFromProgram(
92
+ smKitUI?.startWorkoutProgram(
88
93
  workoutConfig = smKitWorkoutConfig.toWorkoutConfig(),
89
94
  listener = this,
90
95
  )
@@ -1,5 +1,6 @@
1
1
  import Foundation
2
2
  import SMKitUI
3
+ import SMBase
3
4
 
4
5
  @objc(SMKitUIManager)
5
6
  class SMKitUIManager: RCTViewManager {
@@ -113,7 +114,7 @@ extension SMKitUIManager:SMKitUIWorkoutDelegate{
113
114
  }
114
115
  do{
115
116
  let result:[String:Any] = [
116
- "summary": try data.json(),
117
+ "summary": try data.toStringJson(),
117
118
  "didFinish": didFinish
118
119
  ]
119
120
  onWorkoutDidFinish(result)
@@ -1,3 +1,4 @@
1
- import * as React from 'react';
2
- export default function App(): React.JSX.Element;
1
+ import React from 'react';
2
+ declare const App: () => React.JSX.Element;
3
+ export default App;
3
4
  //# sourceMappingURL=App.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../../../example/src/App.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,MAAM,CAAC,OAAO,UAAU,GAAG,sBAM1B"}
1
+ {"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../../../example/src/App.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAKxC,QAAA,MAAM,GAAG,yBAoIR,CAAA;AA4BD,eAAe,GAAG,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sency/react-native-smkit-ui",
3
- "version": "0.1.0",
3
+ "version": "0.1.1-snapshot-2",
4
4
  "description": "react-native-smkit-ui",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",
@@ -44,7 +44,7 @@
44
44
  "url": "git+https://sency-motion-sdk.document360.io.git"
45
45
  },
46
46
  "author": "Sency <Ofer.g@sency.ai> (https://github.com/sency-ai/smkit-ui-react-native-demo)",
47
- "license": "Other",
47
+ "license": "SEE LICENSE IN LICENCE",
48
48
  "bugs": {
49
49
  "url": "contact@sency.ai"
50
50
  },
@@ -15,7 +15,7 @@ Pod::Spec.new do |s|
15
15
  s.source = { :git => "https://sency-motion-sdk.document360.io.git", :tag => "#{s.version}" }
16
16
 
17
17
  s.source_files = "ios/**/*.{h,m,mm,swift}"
18
- s.dependency "SMKitUI" ,'0.1.4'
18
+ s.dependency "SMKitUI" ,'0.1.5'
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.