@sdcx/bottom-sheet 1.0.7 → 1.0.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.
@@ -1,10 +1,15 @@
1
1
  package com.reactnative.bottomsheet;
2
2
 
3
3
  import android.content.Context;
4
+ import android.graphics.PixelFormat;
5
+ import android.graphics.drawable.Drawable;
6
+
7
+ import androidx.annotation.NonNull;
4
8
 
5
9
  import com.facebook.react.bridge.Arguments;
6
10
  import com.facebook.react.bridge.WritableMap;
7
11
  import com.facebook.react.uimanager.PixelUtil;
12
+ import com.facebook.react.uimanager.PointerEvents;
8
13
  import com.facebook.react.uimanager.StateWrapper;
9
14
  import com.facebook.react.views.view.ReactViewGroup;
10
15
 
@@ -14,7 +19,6 @@ import com.facebook.react.views.view.ReactViewGroup;
14
19
  */
15
20
  public class BottomSheetContentView extends ReactViewGroup {
16
21
 
17
- @SuppressWarnings("NullableProblems")
18
22
  private StateWrapper stateWrapper;
19
23
 
20
24
  public BottomSheetContentView(Context context) {
@@ -36,4 +40,14 @@ public class BottomSheetContentView extends ReactViewGroup {
36
40
  stateWrapper.updateState(map);
37
41
  }
38
42
  }
43
+
44
+ @NonNull
45
+ @Override
46
+ public PointerEvents getPointerEvents() {
47
+ Drawable bg = getBackground();
48
+ if (bg == null || bg.getOpacity() != PixelFormat.OPAQUE) {
49
+ return PointerEvents.BOX_NONE;
50
+ }
51
+ return PointerEvents.AUTO;
52
+ }
39
53
  }
@@ -1,5 +1,8 @@
1
1
  #import "RNBottomSheetContentView.h"
2
2
 
3
+ #import <CoreGraphics/CoreGraphics.h>
4
+ #import <UIKit/UIKit.h>
5
+
3
6
  #import <react/renderer/components/bottomsheet/BottomSheetContentViewComponentDescriptor.h>
4
7
  #import <react/renderer/components/bottomsheet/BottomSheetContentViewShadowNode.h>
5
8
  #import <react/renderer/components/bottomsheet/EventEmitters.h>
@@ -44,4 +47,20 @@ using namespace facebook::react;
44
47
  });
45
48
  }
46
49
 
50
+ - (BOOL)_isBackgroundTransparent {
51
+ if (self.backgroundColor == nil) {
52
+ return YES;
53
+ }
54
+ return CGColorGetAlpha(self.backgroundColor.CGColor) < 1.0;
55
+ }
56
+
57
+ - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
58
+ UIView *hit = [super hitTest:point withEvent:event];
59
+ // 背景透明时相当于 BOX_NONE:只有子视图接收触摸,自身不接收
60
+ if ([self _isBackgroundTransparent] && hit == self) {
61
+ return nil;
62
+ }
63
+ return hit;
64
+ }
65
+
47
66
  @end
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sdcx/bottom-sheet",
3
3
  "description": "A react-native BottomSheet component.",
4
- "version": "1.0.7",
4
+ "version": "1.0.8",
5
5
  "main": "./dist/index",
6
6
  "module": "./dist/index",
7
7
  "types": "./dist/index.d.ts",