plotline-engage 4.0.3 → 4.0.5
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/android/build.gradle +1 -1
- package/android/src/main/java/com/reactnativeplotline/PlotlineViewManager.java +33 -0
- package/android/src/main/java/com/reactnativeplotline/PlotlineWrapperView.java +61 -0
- package/android/src/main/java/com/reactnativeplotline/RNPlotlinePackage.java +1 -1
- package/index.d.ts +9 -1
- package/index.js +12 -2
- package/package.json +1 -1
package/android/build.gradle
CHANGED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
package com.reactnativeplotline;
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.uimanager.ThemedReactContext;
|
|
4
|
+
import com.facebook.react.uimanager.ViewGroupManager;
|
|
5
|
+
import com.facebook.react.uimanager.annotations.ReactProp;
|
|
6
|
+
|
|
7
|
+
import so.plotline.insights.PlotlineWidget;
|
|
8
|
+
|
|
9
|
+
public class PlotlineViewManager extends ViewGroupManager<PlotlineWrapperView> {
|
|
10
|
+
public static final String REACT_CLASS = "PlotlineView";
|
|
11
|
+
private String testId;
|
|
12
|
+
|
|
13
|
+
@Override
|
|
14
|
+
public String getName() {
|
|
15
|
+
return REACT_CLASS;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@ReactProp(name = "testID")
|
|
19
|
+
public void setTestId(PlotlineWrapperView view, String testID) {
|
|
20
|
+
PlotlineWidget widget = (PlotlineWidget) view.getContentView();
|
|
21
|
+
widget.setElementId(testID);
|
|
22
|
+
widget.setTag(testID);
|
|
23
|
+
this.testId = testID;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@Override
|
|
27
|
+
protected PlotlineWrapperView createViewInstance(ThemedReactContext reactContext) {
|
|
28
|
+
PlotlineWrapperView wrapperView = new PlotlineWrapperView(reactContext);
|
|
29
|
+
PlotlineWidget plotlineWidget = new PlotlineWidget(reactContext, testId);
|
|
30
|
+
wrapperView.setContentView(plotlineWidget);
|
|
31
|
+
return wrapperView;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
package com.reactnativeplotline;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import android.view.View;
|
|
5
|
+
import android.widget.FrameLayout;
|
|
6
|
+
|
|
7
|
+
import com.facebook.react.uimanager.ThemedReactContext;
|
|
8
|
+
import com.facebook.react.uimanager.UIManagerModule;
|
|
9
|
+
|
|
10
|
+
public class PlotlineWrapperView extends FrameLayout {
|
|
11
|
+
private View contentView;
|
|
12
|
+
|
|
13
|
+
public PlotlineWrapperView(Context context) {
|
|
14
|
+
super(context);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@Override
|
|
18
|
+
public void requestLayout() {
|
|
19
|
+
super.requestLayout();
|
|
20
|
+
post(measureAndLayout);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
private final Runnable measureAndLayout = () -> {
|
|
24
|
+
measure(
|
|
25
|
+
MeasureSpec.makeMeasureSpec(getWidth(), MeasureSpec.EXACTLY),
|
|
26
|
+
MeasureSpec.makeMeasureSpec(getHeight(), MeasureSpec.EXACTLY));
|
|
27
|
+
layout(getLeft(), getTop(), getRight(), getBottom());
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
@Override
|
|
31
|
+
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
|
32
|
+
int maxWidth = 0;
|
|
33
|
+
int maxHeight = 0;
|
|
34
|
+
|
|
35
|
+
for (int i = 0; i < getChildCount(); i++) {
|
|
36
|
+
View child = getChildAt(i);
|
|
37
|
+
if (child.getVisibility() != GONE) {
|
|
38
|
+
child.measure(widthMeasureSpec, MeasureSpec.UNSPECIFIED);
|
|
39
|
+
|
|
40
|
+
maxWidth = Math.max(maxWidth, child.getMeasuredWidth());
|
|
41
|
+
maxHeight = Math.max(maxHeight, child.getMeasuredHeight());
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
int finalWidth = Math.max(maxWidth, getSuggestedMinimumWidth());
|
|
46
|
+
int finalHeight = Math.max(maxHeight, getSuggestedMinimumHeight());
|
|
47
|
+
|
|
48
|
+
setMeasuredDimension(finalWidth, finalHeight);
|
|
49
|
+
((ThemedReactContext) getContext()).runOnNativeModulesQueueThread(() -> ((ThemedReactContext) getContext()).getNativeModule(UIManagerModule.class).updateNodeSize(getId(), finalWidth, finalHeight));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
public void setContentView(View view) {
|
|
53
|
+
contentView = view;
|
|
54
|
+
addView(contentView);
|
|
55
|
+
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
public View getContentView() {
|
|
59
|
+
return contentView;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -24,6 +24,6 @@ public class RNPlotlinePackage implements ReactPackage {
|
|
|
24
24
|
|
|
25
25
|
@Override
|
|
26
26
|
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
|
|
27
|
-
return
|
|
27
|
+
return Arrays.<ViewManager>asList(new PlotlineViewManager());
|
|
28
28
|
}
|
|
29
29
|
}
|
package/index.d.ts
CHANGED
|
@@ -21,6 +21,14 @@ declare class ScrollView extends React.Component<ScrollViewProps> {
|
|
|
21
21
|
|
|
22
22
|
declare class FlatList<T> extends React.Component<FlatListProps<T>> {
|
|
23
23
|
}
|
|
24
|
+
|
|
25
|
+
interface PlotlineWidgetProps extends ViewProps {
|
|
26
|
+
testID?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
declare class PlotlineWidget extends React.Component<PlotlineWidgetProps> {
|
|
30
|
+
}
|
|
31
|
+
|
|
24
32
|
declare const Plotline: plotline;
|
|
25
|
-
export { ScrollView, FlatList };
|
|
33
|
+
export { ScrollView, FlatList, PlotlineWidget };
|
|
26
34
|
export default Plotline;
|
package/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { NativeModules, DeviceEventEmitter, Platform, NativeEventEmitter } from 'react-native';
|
|
2
|
+
import { NativeModules, DeviceEventEmitter, Platform, NativeEventEmitter, requireNativeComponent } from 'react-native';
|
|
3
3
|
import { ScrollView as RNScrollView, FlatList as RNFlatList} from 'react-native';
|
|
4
4
|
import React from 'react';
|
|
5
5
|
const { RNPlotline } = NativeModules;
|
|
@@ -149,5 +149,15 @@ const FlatList = (props) => {
|
|
|
149
149
|
);
|
|
150
150
|
};
|
|
151
151
|
|
|
152
|
+
const PlotlineView = requireNativeComponent('PlotlineView');
|
|
153
|
+
|
|
154
|
+
const PlotlineWidget = ({testID}) => {
|
|
155
|
+
if (Platform.OS === 'android') {
|
|
156
|
+
return <PlotlineView testID={testID} />;
|
|
157
|
+
} else {
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
|
|
152
162
|
export default Plotline;
|
|
153
|
-
export {ScrollView, FlatList};
|
|
163
|
+
export {ScrollView, FlatList, PlotlineWidget};
|