@swmansion/react-native-bottom-sheet 0.8.0-next.2 → 0.8.0-next.3

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,13 +1,22 @@
1
1
  #pragma once
2
2
 
3
- #include <react/renderer/components/ReactNativeBottomSheetSpec/ShadowNodes.h>
3
+ #include "ShadowNodes.h"
4
4
  #include <react/renderer/core/ConcreteComponentDescriptor.h>
5
5
 
6
6
  namespace facebook::react {
7
7
 
8
8
  class BottomSheetViewComponentDescriptor final
9
9
  : public ConcreteComponentDescriptor<BottomSheetViewShadowNode> {
10
+ public:
10
11
  using ConcreteComponentDescriptor::ConcreteComponentDescriptor;
12
+
13
+ State::Shared createInitialState(
14
+ const Props::Shared& /*props*/,
15
+ const ShadowNodeFamily::Shared& family) const override {
16
+ return std::make_shared<BottomSheetViewShadowNode::ConcreteState>(
17
+ std::make_shared<const BottomSheetViewState>(),
18
+ family);
19
+ }
11
20
  };
12
21
 
13
22
  } // namespace facebook::react
@@ -1,10 +1,10 @@
1
1
  #import "BottomSheetComponentView.h"
2
2
  #import "BottomSheetContentView.h"
3
+ #import "../common/cpp/react/renderer/components/ReactNativeBottomSheetSpec/BottomSheetStateHelper.h"
4
+ #import "../common/cpp/react/renderer/components/ReactNativeBottomSheetSpec/ComponentDescriptors.h"
3
5
 
4
6
  #import <React/RCTConversions.h>
5
7
  #import <React/RCTFabricComponentsPlugins.h>
6
- #import <react/renderer/components/ReactNativeBottomSheetSpec/BottomSheetStateHelper.h>
7
- #import <react/renderer/components/ReactNativeBottomSheetSpec/ComponentDescriptors.h>
8
8
  #import <react/renderer/components/ReactNativeBottomSheetSpec/EventEmitters.h>
9
9
  #import <react/renderer/components/ReactNativeBottomSheetSpec/Props.h>
10
10
  #import <react/renderer/components/ReactNativeBottomSheetSpec/RCTComponentViewHelpers.h>
@@ -107,7 +107,7 @@ using namespace facebook::react;
107
107
  emitter->onPositionChange({.position = static_cast<double>(position)});
108
108
  }
109
109
 
110
- float contentOffsetY = static_cast<float>(self.bounds.size.height - position);
110
+ float contentOffsetY = static_cast<float>(view.currentContentOffsetY);
111
111
  if (contentOffsetY == _lastContentOffsetY) {
112
112
  return;
113
113
  }
@@ -19,6 +19,7 @@ NS_ASSUME_NONNULL_BEGIN
19
19
  - (void)setDetents:(NSArray<NSDictionary *> *)raw;
20
20
  - (void)setDetentIndex:(NSInteger)newIndex;
21
21
  - (void)setScrimColor:(UIColor *_Nullable)color;
22
+ - (CGFloat)currentContentOffsetY;
22
23
  - (void)mountChildComponentView:(UIView *)childView atIndex:(NSInteger)index;
23
24
  - (void)unmountChildComponentView:(UIView *)childView;
24
25
  - (void)resetSheetState;
@@ -65,6 +65,11 @@
65
65
  _impl.scrimColor = color;
66
66
  }
67
67
 
68
+ - (CGFloat)currentContentOffsetY
69
+ {
70
+ return _impl.currentContentOffsetY;
71
+ }
72
+
68
73
  - (void)mountChildComponentView:(UIView *)childView atIndex:(NSInteger)index
69
74
  {
70
75
  [_impl mountChildComponentView:childView atIndex:index];
@@ -237,6 +237,13 @@ public final class RNSBottomSheetHostingView: UIView {
237
237
  return maxHeight - ty
238
238
  }
239
239
 
240
+ public var currentContentOffsetY: CGFloat {
241
+ let maxHeight = detentSpecs.last?.height ?? bounds.height
242
+ let containerTop = bounds.height - maxHeight
243
+ let ty = sheetContainer.layer.presentation()?.affineTransform().ty ?? sheetContainer.transform.ty
244
+ return containerTop + ty
245
+ }
246
+
240
247
  private var isScrimVisible: Bool {
241
248
  modal && currentSheetHeight > 0.5
242
249
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swmansion/react-native-bottom-sheet",
3
- "version": "0.8.0-next.2",
3
+ "version": "0.8.0-next.3",
4
4
  "description": "Provides bottom-sheet components for React Native.",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",