plotline-engage 4.8.6 → 4.8.8

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.
@@ -45,6 +45,6 @@ repositories {
45
45
 
46
46
  dependencies {
47
47
  implementation 'com.facebook.react:react-native:+'
48
- implementation 'so.plotline:plotline-android-sdk:4.4.1'
48
+ implementation 'so.plotline:plotline-android-sdk:4.4.7'
49
49
  }
50
50
 
@@ -5,6 +5,9 @@ import com.facebook.react.uimanager.ViewGroupManager;
5
5
  import com.facebook.react.uimanager.annotations.ReactProp;
6
6
 
7
7
  import so.plotline.insights.PlotlineWidget;
8
+ import androidx.annotation.Nullable;
9
+ import com.facebook.react.common.MapBuilder;
10
+ import java.util.Map;
8
11
 
9
12
  public class PlotlineViewManager extends ViewGroupManager<PlotlineWrapperView> {
10
13
  public static final String REACT_CLASS = "PlotlineView";
@@ -27,4 +30,18 @@ public class PlotlineViewManager extends ViewGroupManager<PlotlineWrapperView> {
27
30
  wrapperView.setContentView(plotlineWidget);
28
31
  return wrapperView;
29
32
  }
33
+
34
+ @Override
35
+ @Nullable
36
+ public Map<String, Object> getExportedCustomBubblingEventTypeConstants() {
37
+ return MapBuilder.<String, Object>builder()
38
+ .put(
39
+ "topSizeChange",
40
+ MapBuilder.of(
41
+ "phasedRegistrationNames",
42
+ MapBuilder.of("bubbled", "onSizeChange")
43
+ )
44
+ )
45
+ .build();
46
+ }
30
47
  }
@@ -3,9 +3,22 @@ package com.reactnativeplotline;
3
3
  import android.content.Context;
4
4
  import android.view.View;
5
5
  import android.widget.FrameLayout;
6
-
6
+ import com.facebook.react.bridge.Arguments;
7
+ import com.facebook.react.bridge.ReactContext;
8
+ import com.facebook.react.bridge.WritableMap;
9
+ import com.facebook.react.uimanager.PixelUtil;
7
10
  import com.facebook.react.uimanager.ThemedReactContext;
11
+ import com.facebook.react.uimanager.UIManagerHelper;
8
12
  import com.facebook.react.uimanager.UIManagerModule;
13
+ import com.facebook.react.uimanager.events.Event;
14
+ import com.facebook.react.uimanager.events.EventDispatcher;
15
+ import com.facebook.react.uimanager.events.RCTEventEmitter;
16
+ import com.reactnativeplotline.BuildConfig;
17
+ import androidx.annotation.Nullable;
18
+ import com.facebook.react.common.MapBuilder;
19
+ import java.util.Map;
20
+ import com.facebook.react.fabric.FabricUIManager;
21
+
9
22
 
10
23
  public class PlotlineWrapperView extends FrameLayout {
11
24
  private View contentView;
@@ -46,8 +59,34 @@ public class PlotlineWrapperView extends FrameLayout {
46
59
  int finalHeight = Math.max(maxHeight, getSuggestedMinimumHeight());
47
60
 
48
61
  setMeasuredDimension(finalWidth, finalHeight);
49
- ((ThemedReactContext) getContext()).runOnNativeModulesQueueThread(() -> ((ThemedReactContext) getContext()).getNativeModule(UIManagerModule.class).updateNodeSize(getId(), finalWidth, finalHeight));
62
+ try {
63
+ ThemedReactContext themedReactContext = (ThemedReactContext) getContext();
64
+ if (themedReactContext.hasActiveReactInstance()) {
65
+ if (UIManagerHelper.getUIManager(themedReactContext, getId()) instanceof FabricUIManager) {
66
+
67
+ WritableMap eventData = Arguments.createMap();
68
+ eventData.putDouble("width", PixelUtil.toDIPFromPixel(finalWidth));
69
+ eventData.putDouble("height", PixelUtil.toDIPFromPixel(finalHeight));
70
+
71
+ EventDispatcher eventDispatcher = UIManagerHelper.getEventDispatcherForReactTag(themedReactContext, getId());
72
+ if (eventDispatcher != null) {
73
+ eventDispatcher.dispatchEvent(new SizeChangedEvent(UIManagerHelper.getSurfaceId(getContext()), getId(), eventData));
74
+ }
75
+ } else {
76
+ // LEGACY ARCHITECTURE PATH
77
+ themedReactContext.runOnNativeModulesQueueThread(() -> {
78
+ UIManagerModule uiManagerModule = themedReactContext.getNativeModule(UIManagerModule.class);
79
+ if (uiManagerModule != null) {
80
+ uiManagerModule.updateNodeSize(getId(), finalWidth, finalHeight);
81
+ }
82
+ });
83
+ }
84
+ }
85
+ } catch (Exception e) {
86
+ e.printStackTrace();
87
+ }
50
88
  }
89
+
51
90
 
52
91
  public void setContentView(View view) {
53
92
  contentView = view;
@@ -58,4 +97,24 @@ public class PlotlineWrapperView extends FrameLayout {
58
97
  public View getContentView() {
59
98
  return contentView;
60
99
  }
100
+ }
101
+ class SizeChangedEvent extends Event<SizeChangedEvent> {
102
+
103
+ public static final String EVENT_NAME = "topSizeChange";
104
+ private final WritableMap mPayload;
105
+
106
+ public SizeChangedEvent(int surfaceId, int viewId, WritableMap payload) {
107
+ super(surfaceId, viewId);
108
+ mPayload = payload;
109
+ }
110
+
111
+ @Override
112
+ public String getEventName() {
113
+ return EVENT_NAME;
114
+ }
115
+
116
+ @Override
117
+ protected WritableMap getEventData() {
118
+ return mPayload;
119
+ }
61
120
  }
package/index.js CHANGED
@@ -215,7 +215,7 @@ const plotlineEvents = new NativeEventEmitter(PlotlineWidgetEventEmitter);
215
215
  const PlotlineView = requireNativeComponent('PlotlineView');
216
216
 
217
217
  const PlotlineWidget = ({ testID }) => {
218
- const [size, setSize] = useState({ width: 0, height: 0 });
218
+ const [size, setSize] = useState({ width: '100%', height: 0 });
219
219
  const [layout, setLayout] = useState(null);
220
220
 
221
221
  useEffect(() => {
@@ -237,9 +237,21 @@ const PlotlineWidget = ({ testID }) => {
237
237
  };
238
238
  }, []);
239
239
 
240
- if (Platform.OS === 'android') {
241
- return <PlotlineView testID={testID} />;
242
- } else if (Platform.OS === 'ios') {
240
+ const onSizeChange = (event) => {
241
+ const { width, height } = event.nativeEvent;
242
+
243
+ if (width > 0 && height > 0) {
244
+ setSize({ width, height });
245
+ }
246
+ };
247
+
248
+ if (Platform.OS === 'android') {
249
+ return <PlotlineView
250
+ testID={testID}
251
+ onSizeChange={onSizeChange}
252
+ style={{ width: size.width, height: size.height }}
253
+ />
254
+ } else if (Platform.OS === 'ios') {
243
255
  return (
244
256
  <View
245
257
  onLayout={(e) =>{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plotline-engage",
3
- "version": "4.8.6",
3
+ "version": "4.8.8",
4
4
  "description": "React Native plugin for Plotline",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"