plotline-engage 4.1.0 → 4.1.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.
@@ -39,6 +39,6 @@ repositories {
39
39
 
40
40
  dependencies {
41
41
  implementation 'com.facebook.react:react-native:+'
42
- implementation 'com.gitlab.plotline:plotline-android-sdk:3.1.8'
42
+ implementation 'com.gitlab.plotline:plotline-android-sdk:3.2.8'
43
43
  }
44
44
 
package/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  import { NativeModules, DeviceEventEmitter, Platform, NativeEventEmitter, requireNativeComponent } from 'react-native';
3
- import { ScrollView as RNScrollView, FlatList as RNFlatList} from 'react-native';
4
- import React from 'react';
3
+ import { View, ScrollView as RNScrollView, FlatList as RNFlatList} from 'react-native';
4
+ import React, { useEffect, useState } from 'react';
5
5
  const { RNPlotline } = NativeModules;
6
6
 
7
7
  function convertToStringValues(obj) {
@@ -171,14 +171,48 @@ const FlatList = (props) => {
171
171
  );
172
172
  };
173
173
 
174
+ const { PlotlineWidgetEventEmitter } = NativeModules;
175
+ const plotlineEvents = new NativeEventEmitter(PlotlineWidgetEventEmitter);
174
176
  const PlotlineView = requireNativeComponent('PlotlineView');
175
177
 
176
- const PlotlineWidget = ({testID}) => {
178
+ const PlotlineWidget = ({ testID }) => {
179
+ const [size, setSize] = useState({ width: 0, height: 0 });
180
+ const [layout, setLayout] = useState(null);
181
+
182
+ useEffect(() => {
183
+
184
+ if (Platform.OS === 'android') return;
185
+
186
+ const subscription = plotlineEvents.addListener(
187
+ 'onPlotlineWidgetReady',
188
+ (event) => {
189
+ const { width, height } = event;
190
+ setSize({ width, height });
191
+ }
192
+ );
193
+
194
+ return () => {
195
+ subscription.remove();
196
+ };
197
+ }, []);
198
+
177
199
  if (Platform.OS === 'android') {
178
200
  return <PlotlineView testID={testID} />;
179
- } else {
180
- return null;
201
+ } else if (Platform.OS === 'ios') {
202
+ return (
203
+ <View
204
+ onLayout={(e) =>{
205
+ setLayout(e.nativeEvent.layout);
206
+ }}>
207
+ <PlotlineView
208
+ testID={testID}
209
+ style={{ width: size.width, height: size.height }}
210
+ parentWidth={layout ? layout.width.toString() : "0"}
211
+ />
212
+ </View>
213
+ );
181
214
  }
215
+ return null;
182
216
  };
183
217
 
184
218
  export default Plotline;
@@ -0,0 +1,12 @@
1
+ //
2
+ // PlotlineView.h
3
+ // plotline-engage
4
+ //
5
+ // Created by SHUBH SARASWAT on 11/09/23.
6
+ //
7
+
8
+ #import <React/RCTViewManager.h>
9
+
10
+ @interface PlotlineView : RCTViewManager
11
+ @end
12
+
@@ -0,0 +1,29 @@
1
+ //
2
+ // PlotlineView.m
3
+ // RNPlotline
4
+ //
5
+ // Created by SHUBH SARASWAT on 16/08/23.
6
+ // Copyright © 2023 Facebook. All rights reserved.
7
+ //
8
+
9
+ #import "PlotlineView.h"
10
+ #import "PlotlineViewContent.h"
11
+
12
+ @implementation PlotlineView
13
+
14
+ RCT_EXPORT_MODULE()
15
+
16
+ RCT_EXPORT_VIEW_PROPERTY(parentWidth, NSString)
17
+ RCT_EXPORT_VIEW_PROPERTY(testID, NSString)
18
+
19
+ - (UIView *)view {
20
+ PlotlineViewContent *myView = [[PlotlineViewContent alloc] init];
21
+ myView.eventBridge = self.bridge;
22
+ return myView;
23
+ }
24
+
25
+ + (BOOL)requiresMainQueueSetup {
26
+ return YES;
27
+ }
28
+
29
+ @end
@@ -0,0 +1,19 @@
1
+ //
2
+ // PlotlineViewContent.h
3
+ // plotline-engage
4
+ //
5
+ // Created by SHUBH SARASWAT on 11/09/23.
6
+ //
7
+
8
+ #import <UIKit/UIKit.h>
9
+ #import <React/RCTBridge.h>
10
+ #import <Plotline/Plotline.h>
11
+
12
+ @interface PlotlineViewContent : UIView <PlotlineWidgetListener>
13
+ @property (nonatomic, strong) RCTBridge *eventBridge;
14
+ @property (nonatomic, strong) NSString *parentWidth;
15
+ @property (nonatomic, strong) NSString *testID;
16
+ @property (nonatomic, strong) UIView *plotlineView;
17
+ @end
18
+
19
+
@@ -0,0 +1,46 @@
1
+ //
2
+ // PlotlineViewContent.m
3
+ // plotline-engage
4
+ //
5
+ // Created by SHUBH SARASWAT on 11/09/23.
6
+ //
7
+
8
+ #import "PlotlineViewContent.h"
9
+ #import "PlotlineWidgetEventEmitter.h"
10
+ #import <Plotline/Plotline.h>
11
+
12
+ @implementation PlotlineViewContent
13
+
14
+ - (instancetype)initWithFrame:(CGRect)frame {
15
+ self = [super initWithFrame:frame];
16
+ if (self) {
17
+
18
+ }
19
+ return self;
20
+ }
21
+
22
+ - (void)setParentWidth:(NSString *)parentWidth {
23
+ if (![_parentWidth isEqualToString:parentWidth]) {
24
+ _parentWidth = parentWidth;
25
+ dispatch_async(dispatch_get_main_queue(), ^{
26
+ [self.plotlineView removeFromSuperview];
27
+ if (parentWidth.integerValue != 0) {
28
+ self.plotlineView = [[PlotlineWidget alloc] initWithClientElementId:self.testID frame:CGRectMake(0, 0, parentWidth.integerValue, 0) plotlineWidgetListener:self];
29
+ self.plotlineView.translatesAutoresizingMaskIntoConstraints = NO;
30
+ [self addSubview:self.plotlineView];
31
+ }
32
+ });
33
+ }
34
+ }
35
+
36
+ - (void)setTestID:(NSString *)testID {
37
+ _testID = testID;
38
+
39
+ }
40
+
41
+ - (void)onWidgetReadyWithWidth:(CGFloat)width height:(CGFloat)height {
42
+ PlotlineWidgetEventEmitter *plotlineWidgetEventEmitter = [self.eventBridge moduleForClass:[PlotlineWidgetEventEmitter class]];
43
+ [plotlineWidgetEventEmitter sendSizeEventWithWidth:width height:height];
44
+ }
45
+
46
+ @end
@@ -0,0 +1,15 @@
1
+ //
2
+ // PlotlineWidgetEventEmitter.h
3
+ // plotline-engage
4
+ //
5
+ // Created by SHUBH SARASWAT on 11/09/23.
6
+ //
7
+
8
+ #import <React/RCTEventEmitter.h>
9
+
10
+ @interface PlotlineWidgetEventEmitter : RCTEventEmitter
11
+ @property (nonatomic) BOOL hasListeners;
12
+ - (void)sendSizeEventWithWidth:(CGFloat)width height:(CGFloat)height;
13
+ @end
14
+
15
+
@@ -0,0 +1,37 @@
1
+ //
2
+ // PlotlineView.swift
3
+ // plotline-engage
4
+ //
5
+ // Created by SHUBH SARASWAT on 20/08/23.
6
+ //
7
+
8
+ #import "PlotlineWidgetEventEmitter.h"
9
+
10
+ @implementation PlotlineWidgetEventEmitter
11
+
12
+ RCT_EXPORT_MODULE(PlotlineWidgetEventEmitter)
13
+
14
+ - (NSArray<NSString *> *)supportedEvents {
15
+ return @[@"onPlotlineWidgetReady"];
16
+ }
17
+
18
+ - (void)sendSizeEventWithWidth:(CGFloat)width height:(CGFloat)height {
19
+ if (self.hasListeners) {
20
+ [self sendEventWithName:@"onPlotlineWidgetReady" body:@{@"width": @(width), @"height": @(height)}];
21
+ }
22
+ }
23
+
24
+ - (void)startObserving {
25
+ self.hasListeners = YES;
26
+ }
27
+
28
+ - (void)stopObserving {
29
+ self.hasListeners = NO;
30
+ }
31
+
32
+ + (BOOL)requiresMainQueueSetup {
33
+ return YES;
34
+ }
35
+
36
+ @end
37
+
@@ -8,6 +8,8 @@
8
8
 
9
9
  /* Begin PBXBuildFile section */
10
10
  B3E7B58A1CC2AC0600A0062D /* RNPlotline.m in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* RNPlotline.m */; };
11
+ BCD7E3DF2A92B58900C88E76 /* PlotlineView.m in Sources */ = {isa = PBXBuildFile; fileRef = BCD7E3DE2A92B58900C88E76 /* PlotlineView.m */; };
12
+ BCD7E3E32A92B5D700C88E76 /* PlotlineWidgetEventEmitter.m in Sources */ = {isa = PBXBuildFile; fileRef = BCD7E3E12A92B5D700C88E76 /* PlotlineWidgetEventEmitter.m */; };
11
13
  /* End PBXBuildFile section */
12
14
 
13
15
  /* Begin PBXCopyFilesBuildPhase section */
@@ -26,6 +28,8 @@
26
28
  134814201AA4EA6300B7C361 /* libRNPlotline.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRNPlotline.a; sourceTree = BUILT_PRODUCTS_DIR; };
27
29
  B3E7B5881CC2AC0600A0062D /* RNPlotline.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNPlotline.h; sourceTree = "<group>"; };
28
30
  B3E7B5891CC2AC0600A0062D /* RNPlotline.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNPlotline.m; sourceTree = "<group>"; };
31
+ BCD7E3DE2A92B58900C88E76 /* PlotlineView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PlotlineView.m; sourceTree = "<group>"; };
32
+ BCD7E3E12A92B5D700C88E76 /* PlotlineWidgetEventEmitter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PlotlineWidgetEventEmitter.m; sourceTree = "<group>"; };
29
33
  /* End PBXFileReference section */
30
34
 
31
35
  /* Begin PBXFrameworksBuildPhase section */
@@ -50,6 +54,8 @@
50
54
  58B511D21A9E6C8500147676 = {
51
55
  isa = PBXGroup;
52
56
  children = (
57
+ BCD7E3E12A92B5D700C88E76 /* PlotlineWidgetEventEmitter.m */,
58
+ BCD7E3DE2A92B58900C88E76 /* PlotlineView.m */,
53
59
  B3E7B5881CC2AC0600A0062D /* RNPlotline.h */,
54
60
  B3E7B5891CC2AC0600A0062D /* RNPlotline.m */,
55
61
  134814211AA4EA7D00B7C361 /* Products */,
@@ -87,6 +93,7 @@
87
93
  TargetAttributes = {
88
94
  58B511DA1A9E6C8500147676 = {
89
95
  CreatedOnToolsVersion = 6.1.1;
96
+ LastSwiftMigration = 1500;
90
97
  };
91
98
  };
92
99
  };
@@ -95,6 +102,7 @@
95
102
  developmentRegion = English;
96
103
  hasScannedForEncodings = 0;
97
104
  knownRegions = (
105
+ English,
98
106
  en,
99
107
  );
100
108
  mainGroup = 58B511D21A9E6C8500147676;
@@ -112,7 +120,9 @@
112
120
  isa = PBXSourcesBuildPhase;
113
121
  buildActionMask = 2147483647;
114
122
  files = (
123
+ BCD7E3E32A92B5D700C88E76 /* PlotlineWidgetEventEmitter.m in Sources */,
115
124
  B3E7B58A1CC2AC0600A0062D /* RNPlotline.m in Sources */,
125
+ BCD7E3DF2A92B58900C88E76 /* PlotlineView.m in Sources */,
116
126
  );
117
127
  runOnlyForDeploymentPostprocessing = 0;
118
128
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plotline-engage",
3
- "version": "4.1.0",
3
+ "version": "4.1.2",
4
4
  "description": "React Native plugin for Plotline",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"