plotline-engage 5.7.4 → 5.7.6

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.
@@ -49,6 +49,6 @@ rootProject.allprojects {
49
49
 
50
50
  dependencies {
51
51
  implementation 'com.facebook.react:react-native:+'
52
- implementation 'com.gitlab.plotline:plotline-android-sdk:5.3.0'
52
+ implementation 'com.gitlab.plotline:plotline-android-sdk:5.3.1'
53
53
  }
54
54
 
@@ -61,24 +61,18 @@ public class PlotlineWrapperView extends FrameLayout {
61
61
  try {
62
62
  ThemedReactContext themedReactContext = (ThemedReactContext) getContext();
63
63
  if (themedReactContext.hasActiveReactInstance()) {
64
- if (UIManagerHelper.getUIManager(themedReactContext, getId()) instanceof FabricUIManager) {
65
-
66
- WritableMap eventData = Arguments.createMap();
67
- eventData.putDouble("width", PixelUtil.toDIPFromPixel(finalWidth));
68
- eventData.putDouble("height", PixelUtil.toDIPFromPixel(finalHeight));
64
+ WritableMap eventData = Arguments.createMap();
65
+ eventData.putDouble("width", PixelUtil.toDIPFromPixel(finalWidth));
66
+ eventData.putDouble("height", PixelUtil.toDIPFromPixel(finalHeight));
69
67
 
68
+ if (UIManagerHelper.getUIManager(themedReactContext, getId()) instanceof FabricUIManager) {
70
69
  EventDispatcher eventDispatcher = UIManagerHelper.getEventDispatcherForReactTag(themedReactContext, getId());
71
70
  if (eventDispatcher != null) {
72
71
  eventDispatcher.dispatchEvent(new SizeChangedEvent(UIManagerHelper.getSurfaceId(getContext()), getId(), eventData));
73
72
  }
74
73
  } else {
75
- // LEGACY ARCHITECTURE PATH
76
- themedReactContext.runOnNativeModulesQueueThread(() -> {
77
- UIManagerModule uiManagerModule = themedReactContext.getNativeModule(UIManagerModule.class);
78
- if (uiManagerModule != null) {
79
- uiManagerModule.updateNodeSize(getId(), finalWidth, finalHeight);
80
- }
81
- });
74
+ // LEGACY ARCHITECTURE PATH: same event as Fabric; updateNodeSize pinned the width in points, so the view never followed later parent resizes.
75
+ themedReactContext.getJSModule(RCTEventEmitter.class).receiveEvent(getId(), SizeChangedEvent.EVENT_NAME, eventData);
82
76
  }
83
77
  }
84
78
  } catch (Exception e) {
package/index.js CHANGED
@@ -245,7 +245,8 @@ const PlotlineWidget = ({ testID }) => {
245
245
  const { width, height } = event.nativeEvent;
246
246
 
247
247
  if (width > 0) {
248
- setSize({ width, height });
248
+ // Android: keep the width at 100% so the view follows later parent resizes; the native width only echoes the parent width at measure time.
249
+ setSize({ width: '100%', height });
249
250
  }
250
251
  };
251
252
 
@@ -9,6 +9,27 @@
9
9
  #import "PlotlineWidgetEventEmitter.h"
10
10
  #import <Plotline/Plotline.h>
11
11
 
12
+ // Each native widget needs its own listener because size callbacks have no sender.
13
+ @interface PlotlineWidgetSizeListener : NSObject <PlotlineWidgetListener>
14
+ @property (nonatomic, weak) PlotlineViewContent *owner;
15
+ @property (nonatomic) NSUInteger generation;
16
+ @end
17
+
18
+ @interface PlotlineViewContent ()
19
+ @property (nonatomic, strong) PlotlineWidgetSizeListener *widgetListener;
20
+ @property (nonatomic) NSUInteger widgetGeneration;
21
+ @end
22
+
23
+ @implementation PlotlineWidgetSizeListener
24
+ - (void)onWidgetReadyWithWidth:(CGFloat)width height:(CGFloat)height {
25
+ PlotlineViewContent *owner = self.owner;
26
+ if (!owner || owner.widgetListener != self || owner.widgetGeneration != self.generation) {
27
+ return;
28
+ }
29
+ [owner onWidgetReadyWithWidth:width height:height];
30
+ }
31
+ @end
32
+
12
33
  @implementation PlotlineViewContent
13
34
 
14
35
  - (instancetype)initWithFrame:(CGRect)frame {
@@ -22,12 +43,30 @@
22
43
  - (void)setParentWidth:(NSString *)parentWidth {
23
44
  if (![_parentWidth isEqualToString:parentWidth]) {
24
45
  _parentWidth = parentWidth;
46
+ NSUInteger generation = ++self.widgetGeneration;
47
+ // Invalidate immediately, including callbacks before the queued replacement runs.
48
+ self.widgetListener.owner = nil;
25
49
  dispatch_async(dispatch_get_main_queue(), ^{
50
+ if (generation != self.widgetGeneration) {
51
+ return;
52
+ }
26
53
  [self.plotlineView removeFromSuperview];
54
+ self.plotlineView = nil;
55
+ self.widgetListener = nil;
27
56
  if (parentWidth.integerValue != 0) {
28
- self.plotlineView = [[PlotlineWidget alloc] initWithClientElementId:self.testID frame:CGRectMake(0, 0, parentWidth.integerValue, 0) plotlineWidgetListener:self];
57
+ PlotlineWidgetSizeListener *listener = [PlotlineWidgetSizeListener new];
58
+ listener.owner = self;
59
+ listener.generation = generation;
60
+ self.widgetListener = listener;
61
+ self.plotlineView = [[PlotlineWidget alloc] initWithClientElementId:self.testID frame:CGRectMake(0, 0, parentWidth.integerValue, 0) plotlineWidgetListener:listener];
29
62
  self.plotlineView.translatesAutoresizingMaskIntoConstraints = NO;
30
63
  [self addSubview:self.plotlineView];
64
+ // Pin the width: with no constraints the host layout pass resizes the widget to this view's stale JS size (0 after an empty callback).
65
+ [NSLayoutConstraint activateConstraints:@[
66
+ [self.plotlineView.leadingAnchor constraintEqualToAnchor:self.leadingAnchor],
67
+ [self.plotlineView.topAnchor constraintEqualToAnchor:self.topAnchor],
68
+ [self.plotlineView.widthAnchor constraintEqualToConstant:parentWidth.integerValue],
69
+ ]];
31
70
  }
32
71
  });
33
72
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plotline-engage",
3
- "version": "5.7.4",
3
+ "version": "5.7.6",
4
4
  "description": "React Native plugin for Plotline",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"