@convep_mobilogy/react-native-qms-plugin 0.9.0 → 0.9.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/QmsPlugin.podspec CHANGED
@@ -6,7 +6,12 @@ Pod::Spec.new do |s|
6
6
  s.name = "QmsPlugin"
7
7
  s.version = package["version"]
8
8
  s.summary = package["description"]
9
- s.homepage = package["homepage"]
9
+ homepage = package["homepage"]
10
+ if homepage.nil? || homepage.empty?
11
+ repo_url = package.dig("repository", "url")
12
+ homepage = repo_url ? repo_url.sub(/\Agit\+/, "") : "https://example.com"
13
+ end
14
+ s.homepage = homepage
10
15
  s.license = package["license"]
11
16
  s.authors = package["author"]
12
17
  s.platforms = { :ios => "12.4" }
@@ -75,7 +75,7 @@ dependencies {
75
75
  implementation "com.facebook.react:react-android"
76
76
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
77
77
  implementation 'com.facebook.react:react-native:+'
78
- implementation "com.convep.qms:qms-plugin:1.9.5"
78
+ implementation "com.convep.qms:qms-plugin:1.9.15"
79
79
  implementation 'androidx.appcompat:appcompat:1.6.1'
80
80
 
81
81
  implementation 'com.squareup.okhttp3:logging-interceptor:4.12.0'
@@ -6,43 +6,75 @@
6
6
  @interface QmsDashboardView : UIView
7
7
  @property (nonatomic, strong) UIViewController *dashboardVC;
8
8
  @property (nonatomic, assign) BOOL didSetupVC;
9
- // New props
9
+
10
10
  @property (nonatomic, copy) NSString *ClientID;
11
11
  @property (nonatomic, copy) NSString *ClientCode;
12
12
  @property (nonatomic, copy) NSString *user_token;
13
+
14
+ @property (nonatomic, copy) RCTDirectEventBlock onClose;
13
15
  @end
14
16
 
15
17
  @implementation QmsDashboardView
16
18
 
17
19
  - (instancetype)initWithFrame:(CGRect)frame {
18
20
  if (self = [super initWithFrame:frame]) {
19
- _dashboardVC = [QmsPluginUI makeViewController];
21
+ _dashboardVC = [QmsPluginUI makeViewController];
20
22
  _didSetupVC = NO;
21
23
  _dashboardVC.view.backgroundColor = [UIColor whiteColor];
24
+
25
+ // Listen for native dashboard close notification
26
+ [[NSNotificationCenter defaultCenter] addObserver:self
27
+ selector:@selector(handleDashboardClose:)
28
+ name:@"QmsDashboardDidCloseNotification"
29
+ object:nil];
22
30
  }
23
31
  return self;
24
32
  }
25
33
 
26
34
  - (void)didMoveToWindow {
27
- [super didMoveToWindow];
28
- if (self.window && !_didSetupVC) {
29
- UIViewController *parentVC = [UIApplication sharedApplication].keyWindow.rootViewController;
30
- if (parentVC) {
31
- [parentVC addChildViewController:_dashboardVC];
32
- _dashboardVC.view.frame = parentVC.view.bounds;
33
- _dashboardVC.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
34
- [parentVC.view addSubview:_dashboardVC.view];
35
- [_dashboardVC didMoveToParentViewController:parentVC];
36
- _didSetupVC = YES;
37
-
38
- // Forward props once the VC is added
39
- [self forwardPropsToVC];
35
+ [super didMoveToWindow];
36
+ if (self.window && !_didSetupVC) {
37
+ UIViewController *parentVC = [UIApplication sharedApplication].keyWindow.rootViewController;
38
+ if (parentVC) {
39
+
40
+ // 1️⃣ create VC with props
41
+ _dashboardVC = [QmsPluginUI makeViewController];
42
+
43
+ [parentVC addChildViewController:_dashboardVC];
44
+ _dashboardVC.view.frame = parentVC.view.bounds;
45
+ _dashboardVC.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
46
+ [parentVC.view addSubview:_dashboardVC.view];
47
+ [_dashboardVC didMoveToParentViewController:parentVC];
48
+ _didSetupVC = YES;
49
+
50
+ // 2️⃣ forward props again if needed
51
+ [self forwardPropsToVC];
52
+ }
40
53
  }
41
- }
42
54
  }
43
55
 
44
- #pragma mark - Prop Setters
56
+ - (void)handleDashboardClose:(NSNotification *)note {
57
+ // 1️⃣ Notify JS
58
+ if (self.onClose) {
59
+ self.onClose(@{});
60
+ }
61
+
62
+ // 2️⃣ Clean up the native view controller
63
+ [self cleanupDashboard];
64
+ }
45
65
 
66
+ - (void)cleanupDashboard {
67
+ if (!_dashboardVC) return;
68
+
69
+ [_dashboardVC willMoveToParentViewController:nil];
70
+ [_dashboardVC.view removeFromSuperview];
71
+ [_dashboardVC removeFromParentViewController];
72
+
73
+ _dashboardVC = nil;
74
+ _didSetupVC = NO;
75
+ }
76
+
77
+ #pragma mark - Prop Setters
46
78
  - (void)setClientID:(NSString *)ClientID {
47
79
  _ClientID = [ClientID copy];
48
80
  [self forwardProp:@"ClientID" value:_ClientID];
@@ -59,7 +91,6 @@
59
91
  }
60
92
 
61
93
  #pragma mark - Forward Props via KVC
62
-
63
94
  - (void)forwardProp:(NSString *)key value:(NSString *)value {
64
95
  if (_dashboardVC && [_dashboardVC respondsToSelector:NSSelectorFromString(key)]) {
65
96
  @try {
@@ -76,6 +107,11 @@
76
107
  [self forwardProp:@"user_token" value:_user_token];
77
108
  }
78
109
 
110
+ - (void)removeFromSuperview {
111
+ [self cleanupDashboard];
112
+ [super removeFromSuperview];
113
+ }
114
+
79
115
  @end
80
116
 
81
117
  @interface QmsDashboardViewManager : RCTViewManager
@@ -95,3 +131,48 @@ RCT_EXPORT_VIEW_PROPERTY(ClientCode, NSString)
95
131
  RCT_EXPORT_VIEW_PROPERTY(user_token, NSString)
96
132
 
97
133
  @end
134
+
135
+ #import <React/RCTEventEmitter.h>
136
+ #import <React/RCTBridgeModule.h>
137
+
138
+ @interface QmsDashboardEmitter : RCTEventEmitter <RCTBridgeModule>
139
+ @end
140
+
141
+ @implementation QmsDashboardEmitter
142
+
143
+ RCT_EXPORT_MODULE();
144
+
145
+ + (id)allocWithZone:(NSZone *)zone {
146
+ static QmsDashboardEmitter *sharedInstance = nil;
147
+ static dispatch_once_t onceToken;
148
+ dispatch_once(&onceToken, ^{
149
+ sharedInstance = [super allocWithZone:zone];
150
+ });
151
+ return sharedInstance;
152
+ }
153
+
154
+ - (instancetype)init {
155
+ if (self = [super init]) {
156
+ // Listen for the framework notification
157
+ [[NSNotificationCenter defaultCenter] addObserver:self
158
+ selector:@selector(handleDashboardClose:)
159
+ name:@"QmsDashboardDidCloseNotification"
160
+ object:nil];
161
+ }
162
+ return self;
163
+ }
164
+
165
+ - (NSArray<NSString *> *)supportedEvents {
166
+ return @[@"onClose"];
167
+ }
168
+
169
+ - (void)handleDashboardClose:(NSNotification *)note {
170
+ // Send event to JS
171
+ [self sendEventWithName:@"onClose" body:note.userInfo];
172
+ }
173
+
174
+ - (void)dealloc {
175
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
176
+ }
177
+
178
+ @end
@@ -6,7 +6,7 @@
6
6
  <dict>
7
7
  <key>Assets.car</key>
8
8
  <data>
9
- 4/wVNoFd+WcEg7nmH9Hm5v1nm7s=
9
+ tiDJHgS+Mbu43+C6GiuoJR1rE/s=
10
10
  </data>
11
11
  <key>Headers/QmsPlugin.h</key>
12
12
  <data>
@@ -31,7 +31,7 @@
31
31
  <dict>
32
32
  <key>hash2</key>
33
33
  <data>
34
- zhv68b8E95A9988/pvXA0JKzn5/KsdixWe45ATxfW3g=
34
+ NzmSax3a+FRy3d2BvvftoEyaWVf17BzGCiO9/CkeCM8=
35
35
  </data>
36
36
  </dict>
37
37
  <key>Headers/QmsPlugin.h</key>
@@ -6,7 +6,7 @@
6
6
  <dict>
7
7
  <key>Assets.car</key>
8
8
  <data>
9
- 4/wVNoFd+WcEg7nmH9Hm5v1nm7s=
9
+ tiDJHgS+Mbu43+C6GiuoJR1rE/s=
10
10
  </data>
11
11
  <key>Headers/QmsPlugin.h</key>
12
12
  <data>
@@ -31,7 +31,7 @@
31
31
  <dict>
32
32
  <key>hash2</key>
33
33
  <data>
34
- zhv68b8E95A9988/pvXA0JKzn5/KsdixWe45ATxfW3g=
34
+ NzmSax3a+FRy3d2BvvftoEyaWVf17BzGCiO9/CkeCM8=
35
35
  </data>
36
36
  </dict>
37
37
  <key>Headers/QmsPlugin.h</key>
@@ -1,12 +1,13 @@
1
1
  "use strict";
2
2
 
3
- import React from 'react';
4
- import { requireNativeComponent } from 'react-native';
3
+ import React, { useEffect } from 'react';
4
+ import { NativeEventEmitter, NativeModules, requireNativeComponent } from 'react-native';
5
5
  import { jsx as _jsx } from "react/jsx-runtime";
6
6
  // Make sure your iOS native view manager is exported as "QmsDashboardView"
7
7
  const NativeQmsDashboardView = requireNativeComponent('QmsDashboardView');
8
8
  export const QmsDashboardView = props => {
9
9
  const {
10
+ onClose,
10
11
  clientID,
11
12
  clientCode,
12
13
  ClientID,
@@ -20,6 +21,14 @@ export const QmsDashboardView = props => {
20
21
  const resolvedClientID = clientID ?? ClientID ?? '';
21
22
  const resolvedClientCode = clientCode ?? ClientCode ?? '';
22
23
  const resolvedToken = user_token ?? token ?? userToken ?? '';
24
+ useEffect(() => {
25
+ if (!onClose) return;
26
+ const nativeEmitterModule = NativeModules.QmsDashboardEmitter;
27
+ if (!nativeEmitterModule) return;
28
+ const emitter = new NativeEventEmitter(nativeEmitterModule);
29
+ const subscription = emitter.addListener('onClose', onClose);
30
+ return () => subscription.remove();
31
+ }, [onClose]);
23
32
  return /*#__PURE__*/_jsx(NativeQmsDashboardView, {
24
33
  ...rest,
25
34
  ClientID: resolvedClientID,
@@ -1 +1 @@
1
- {"version":3,"names":["React","requireNativeComponent","jsx","_jsx","NativeQmsDashboardView","QmsDashboardView","props","clientID","clientCode","ClientID","ClientCode","user_token","userToken","token","rest","resolvedClientID","resolvedClientCode","resolvedToken"],"sourceRoot":"../../src","sources":["QmsDashboardView.ios.tsx"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,sBAAsB,QAAQ,cAAc;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAGtD;AACA,MAAMC,sBAAsB,GAC1BH,sBAAsB,CAAwB,kBAAkB,CAAC;AAEnE,OAAO,MAAMI,gBAAiD,GAAIC,KAAK,IAAK;EAC1E,MAAM;IACJC,QAAQ;IACRC,UAAU;IACVC,QAAQ;IACRC,UAAU;IACVC,UAAU;IACVC,SAAS;IACTC,KAAK;IACL;IACA,GAAGC;EACL,CAAC,GAAGR,KAAK;EAET,MAAMS,gBAAgB,GAAGR,QAAQ,IAAIE,QAAQ,IAAI,EAAE;EACnD,MAAMO,kBAAkB,GAAGR,UAAU,IAAIE,UAAU,IAAI,EAAE;EACzD,MAAMO,aAAa,GAAGN,UAAU,IAAIE,KAAK,IAAID,SAAS,IAAI,EAAE;EAE5D,oBACET,IAAA,CAACC,sBAAsB;IAAA,GACjBU,IAAI;IACRL,QAAQ,EAAEM,gBAAiB;IAC3BL,UAAU,EAAEM,kBAAmB;IAC/BL,UAAU,EAAEM;EAAc,CAC3B,CAAC;AAEN,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["React","useEffect","NativeEventEmitter","NativeModules","requireNativeComponent","jsx","_jsx","NativeQmsDashboardView","QmsDashboardView","props","onClose","clientID","clientCode","ClientID","ClientCode","user_token","userToken","token","rest","resolvedClientID","resolvedClientCode","resolvedToken","nativeEmitterModule","QmsDashboardEmitter","emitter","subscription","addListener","remove"],"sourceRoot":"../../src","sources":["QmsDashboardView.ios.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,SAAS,QAAQ,OAAO;AACxC,SACEC,kBAAkB,EAClBC,aAAa,EACbC,sBAAsB,QACjB,cAAc;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAGtB;AACA,MAAMC,sBAAsB,GAC1BH,sBAAsB,CAAwB,kBAAkB,CAAC;AAEnE,OAAO,MAAMI,gBAAiD,GAAIC,KAAK,IAAK;EAC1E,MAAM;IACJC,OAAO;IACPC,QAAQ;IACRC,UAAU;IACVC,QAAQ;IACRC,UAAU;IACVC,UAAU;IACVC,SAAS;IACTC,KAAK;IACL;IACA,GAAGC;EACL,CAAC,GAAGT,KAAK;EAET,MAAMU,gBAAgB,GAAGR,QAAQ,IAAIE,QAAQ,IAAI,EAAE;EACnD,MAAMO,kBAAkB,GAAGR,UAAU,IAAIE,UAAU,IAAI,EAAE;EACzD,MAAMO,aAAa,GAAGN,UAAU,IAAIE,KAAK,IAAID,SAAS,IAAI,EAAE;EAE5Df,SAAS,CAAC,MAAM;IACd,IAAI,CAACS,OAAO,EAAE;IACd,MAAMY,mBAAmB,GAAGnB,aAAa,CAACoB,mBAAmB;IAC7D,IAAI,CAACD,mBAAmB,EAAE;IAC1B,MAAME,OAAO,GAAG,IAAItB,kBAAkB,CAACoB,mBAAmB,CAAC;IAC3D,MAAMG,YAAY,GAAGD,OAAO,CAACE,WAAW,CAAC,SAAS,EAAEhB,OAAO,CAAC;IAC5D,OAAO,MAAMe,YAAY,CAACE,MAAM,CAAC,CAAC;EACpC,CAAC,EAAE,CAACjB,OAAO,CAAC,CAAC;EAEb,oBACEJ,IAAA,CAACC,sBAAsB;IAAA,GACjBW,IAAI;IACRL,QAAQ,EAAEM,gBAAiB;IAC3BL,UAAU,EAAEM,kBAAmB;IAC/BL,UAAU,EAAEM;EAAc,CAC3B,CAAC;AAEN,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"QmsDashboardView.ios.d.ts","sourceRoot":"","sources":["../../../src/QmsDashboardView.ios.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAMtE,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CAyB5D,CAAC"}
1
+ {"version":3,"file":"QmsDashboardView.ios.d.ts","sourceRoot":"","sources":["../../../src/QmsDashboardView.ios.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAMzC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAMtE,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CAmC5D,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@convep_mobilogy/react-native-qms-plugin",
3
- "version": "0.9.0",
3
+ "version": "0.9.2",
4
4
  "description": "To handle defect managment",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
@@ -1,5 +1,9 @@
1
- import React from 'react';
2
- import { requireNativeComponent } from 'react-native';
1
+ import React, { useEffect } from 'react';
2
+ import {
3
+ NativeEventEmitter,
4
+ NativeModules,
5
+ requireNativeComponent,
6
+ } from 'react-native';
3
7
  import type { QmsDashboardViewProps } from './QmsDashboardView.types';
4
8
 
5
9
  // Make sure your iOS native view manager is exported as "QmsDashboardView"
@@ -8,6 +12,7 @@ const NativeQmsDashboardView =
8
12
 
9
13
  export const QmsDashboardView: React.FC<QmsDashboardViewProps> = (props) => {
10
14
  const {
15
+ onClose,
11
16
  clientID,
12
17
  clientCode,
13
18
  ClientID,
@@ -23,6 +28,15 @@ export const QmsDashboardView: React.FC<QmsDashboardViewProps> = (props) => {
23
28
  const resolvedClientCode = clientCode ?? ClientCode ?? '';
24
29
  const resolvedToken = user_token ?? token ?? userToken ?? '';
25
30
 
31
+ useEffect(() => {
32
+ if (!onClose) return;
33
+ const nativeEmitterModule = NativeModules.QmsDashboardEmitter;
34
+ if (!nativeEmitterModule) return;
35
+ const emitter = new NativeEventEmitter(nativeEmitterModule);
36
+ const subscription = emitter.addListener('onClose', onClose);
37
+ return () => subscription.remove();
38
+ }, [onClose]);
39
+
26
40
  return (
27
41
  <NativeQmsDashboardView
28
42
  {...rest}