@sency/react-native-smkit-ui 0.1.3 → 0.1.4

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/LICENSE CHANGED
@@ -1,5 +1,5 @@
1
1
  Sency
2
- Terms of Use
2
+ Terms of Use.
3
3
 
4
4
  Last updated: [Sep 11th 2022]
5
5
 
@@ -93,7 +93,7 @@ dependencies {
93
93
  implementation "com.facebook.react:react-native:+"
94
94
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
95
95
 
96
- compileOnly("com.sency.smkitui:smkitui:0.1.2") {
96
+ compileOnly("com.sency.smkitui:smkitui:0.1.4") {
97
97
  exclude group: 'com.facebook.fbjni', module: 'fbjni-java-only'
98
98
  }
99
99
 
@@ -1,13 +1,12 @@
1
1
  package com.smkituilibrary.mapper
2
2
 
3
- import android.net.Uri
4
- import com.sency.smkitui.model.BodyZone
5
- import com.sency.smkitui.model.DifficultyLevel
6
3
  import com.sency.smkitui.model.SMExercise
7
- import com.sency.smkitui.model.SMLanguage
8
4
  import com.sency.smkitui.model.SMWorkout
9
- import com.sency.smkitui.model.WorkoutConfig
10
- import com.sency.smkitui.model.WorkoutDuration
5
+ import com.sency.smkitui.model.workoutConfig.BodyZone
6
+ import com.sency.smkitui.model.workoutConfig.DifficultyLevel
7
+ import com.sency.smkitui.model.workoutConfig.SMLanguage
8
+ import com.sency.smkitui.model.workoutConfig.WorkoutConfig
9
+ import com.sency.smkitui.model.workoutConfig.WorkoutDuration
11
10
  import com.smkituilibrary.model.SMKitExercise
12
11
  import com.smkituilibrary.model.SMKitWorkout
13
12
  import com.smkituilibrary.model.SMKitWorkoutConfig
@@ -15,9 +14,9 @@ import com.smkituilibrary.model.SMKitWorkoutConfig
15
14
  internal fun SMKitWorkoutConfig.toWorkoutConfig(): WorkoutConfig = WorkoutConfig(
16
15
  programId = programID,
17
16
  week = week,
18
- bodyZone = BodyZone.valueOf(bodyZone, BodyZone.FullBody),
19
- difficultyLevel = DifficultyLevel.valueOf(difficultyLevel, DifficultyLevel.HighDifficulty),
20
- workoutDuration = WorkoutDuration.valueOf(workoutDuration, WorkoutDuration.Long),
17
+ bodyZone = BodyZone.valueOf(bodyZone),
18
+ difficultyLevel = DifficultyLevel.valueOf(difficultyLevel),
19
+ workoutDuration = WorkoutDuration.valueOf(workoutDuration),
21
20
  language = SMLanguage.English,
22
21
  )
23
22
 
@@ -4,13 +4,19 @@ import SMBase
4
4
 
5
5
  @objc(SMKitUIManager)
6
6
  class SMKitUIManager: RCTViewManager {
7
-
8
- let smkitUIViewController = SMKitUIViewController()
7
+
9
8
  var onWorkoutDidFinish:RCTPromiseResolveBlock?
10
9
  var onWorkoutFailed:RCTPromiseRejectBlock?
11
10
 
12
- override func view() -> UIView! {
13
- return smkitUIViewController.view as? SMKitUIView
11
+ var smkitUIViewController:UIViewController?{
12
+ let keyWindow = UIApplication.shared.windows.filter {$0.isKeyWindow}.first
13
+ if var topController = keyWindow?.rootViewController {
14
+ while let presentedViewController = topController.presentedViewController {
15
+ topController = presentedViewController
16
+ }
17
+ return topController
18
+ }
19
+ return nil
14
20
  }
15
21
 
16
22
  @objc(configure:onSuccess:onFailure:)
@@ -24,13 +30,17 @@ class SMKitUIManager: RCTViewManager {
24
30
 
25
31
  @objc(startAssessment:showSummary:onWorkoutDidFinish:onWorkoutFailed:)
26
32
  func startAssessment(type:NSString, showSummary:Bool, onWorkoutDidFinish: @escaping RCTPromiseResolveBlock, onWorkoutFailed:@escaping RCTPromiseRejectBlock){
33
+ guard let smkitUIViewController = smkitUIViewController else {
34
+ onWorkoutFailed("StartAssessment Failed", "Failed to present view", nil)
35
+ return
36
+ }
27
37
 
28
38
  self.onWorkoutDidFinish = onWorkoutDidFinish
29
39
  self.onWorkoutFailed = onWorkoutFailed
30
40
  DispatchQueue.main.async {
31
41
  do{
32
42
  if let type = AssessmentTypes(rawValue: "\(type)"){
33
- try SMKitUIModel.startAssessmet(viewController: self.smkitUIViewController, type: type, showSummary: showSummary, delegate: self){error in
43
+ try SMKitUIModel.startAssessmet(viewController: smkitUIViewController, type: type, showSummary: showSummary, delegate: self){error in
34
44
  onWorkoutFailed("StartAssessment Failed", error.localizedDescription, error)
35
45
  }
36
46
  }else{
@@ -44,12 +54,16 @@ class SMKitUIManager: RCTViewManager {
44
54
 
45
55
  @objc(startCustomWorkout:onWorkoutDidFinish:onWorkoutFailed:)
46
56
  func startCustomWorkout(json:[String:Any], onWorkoutDidFinish: @escaping RCTPromiseResolveBlock, onWorkoutFailed:@escaping RCTPromiseRejectBlock){
57
+ guard let smkitUIViewController = smkitUIViewController else {
58
+ onWorkoutFailed("StartCustomWorkout Failed", "Failed to present view", nil)
59
+ return
60
+ }
47
61
  self.onWorkoutDidFinish = onWorkoutDidFinish
48
62
  self.onWorkoutFailed = onWorkoutFailed
49
63
  DispatchQueue.main.async {
50
64
  do{
51
65
  let workout = try SMWorkout(FromJson: json)
52
- try SMKitUIModel.startWorkout(viewController: self.smkitUIViewController, workout: workout, delegate: self)
66
+ try SMKitUIModel.startWorkout(viewController: smkitUIViewController, workout: workout, delegate: self)
53
67
  }catch{
54
68
  onWorkoutFailed("StartCustomWorkout Failed", error.localizedDescription, error)
55
69
  }
@@ -61,6 +75,11 @@ class SMKitUIManager: RCTViewManager {
61
75
  self.onWorkoutDidFinish = onWorkoutDidFinish
62
76
  self.onWorkoutFailed = onWorkoutFailed
63
77
 
78
+ guard let smkitUIViewController = smkitUIViewController else {
79
+ onWorkoutFailed("StartWorkoutProgram Failed", "Failed to present view", nil)
80
+ return
81
+ }
82
+
64
83
  guard let week = json["week"] as? Int,
65
84
  let zone = json["bodyZone"] as? String,
66
85
  let difficultyLevelRaw = json["difficultyLevel"] as? String,
@@ -82,7 +101,7 @@ class SMKitUIManager: RCTViewManager {
82
101
  programID: programID
83
102
  )
84
103
 
85
- SMKitUIModel.startWorkoutFromProgram(viewController: self.smkitUIViewController, workoutConfig: config, delegate: self) { error in
104
+ SMKitUIModel.startWorkoutFromProgram(viewController: smkitUIViewController, workoutConfig: config, delegate: self) { error in
86
105
  onWorkoutFailed("StartWorkoutProgram Failed", error.localizedDescription, error)
87
106
  }
88
107
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sency/react-native-smkit-ui",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "react-native-smkit-ui",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",
@@ -12,10 +12,10 @@ Pod::Spec.new do |s|
12
12
  s.authors = package["author"]
13
13
 
14
14
  s.platforms = { :ios => min_ios_version_supported }
15
- s.source = { :git => "https://sency-motion-sdk.document360.io.git", :tag => "#{s.version}" }
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" ,'0.1.6'
18
+ s.dependency "SMKitUI" ,'0.1.9'
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.
@@ -1,20 +0,0 @@
1
- //
2
- // SMKitUIViewContoller.swift
3
- // smkit-ui-library
4
- //
5
- // Created by netanel-yerushalmi on 31/03/2024.
6
- //
7
-
8
- import UIKit
9
-
10
- class SMKitUIViewController: UIViewController {
11
- let sdkView = SMKitUIView()
12
-
13
- override func loadView() {
14
- view = sdkView
15
- }
16
- }
17
-
18
- class SMKitUIView:UIView{
19
-
20
- }
@@ -1,5 +0,0 @@
1
- "use strict";
2
-
3
- var _reactNative = require("react-native");
4
- module.exports = (0, _reactNative.requireNativeComponent)('SMKitUI');
5
- //# sourceMappingURL=SMKitUIView.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_reactNative","require","module","exports","requireNativeComponent"],"sourceRoot":"../../src","sources":["SMKitUIView.tsx"],"mappings":";;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEAC,MAAM,CAACC,OAAO,GAAG,IAAAC,mCAAsB,EAAC,SAAS,CAAC","ignoreList":[]}
@@ -1,3 +0,0 @@
1
- import { requireNativeComponent } from 'react-native';
2
- module.exports = requireNativeComponent('SMKitUI');
3
- //# sourceMappingURL=SMKitUIView.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["requireNativeComponent","module","exports"],"sourceRoot":"../../src","sources":["SMKitUIView.tsx"],"mappings":"AAAA,SAASA,sBAAsB,QAAO,cAAc;AAEpDC,MAAM,CAACC,OAAO,GAAGF,sBAAsB,CAAC,SAAS,CAAC","ignoreList":[]}
@@ -1,4 +0,0 @@
1
- import React from 'react';
2
- declare const App: () => React.JSX.Element;
3
- export default App;
4
- //# sourceMappingURL=App.d.ts.map
@@ -1 +0,0 @@
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"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=SMKitUIView.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SMKitUIView.d.ts","sourceRoot":"","sources":["../../../src/SMKitUIView.tsx"],"names":[],"mappings":""}
@@ -1,3 +0,0 @@
1
- import { requireNativeComponent} from 'react-native';
2
-
3
- module.exports = requireNativeComponent('SMKitUI');