react-native-sheet2 6.1.18 → 7.12.4
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/README.md +754 -80
- package/{Sheet.podspec → Sheet2.podspec} +2 -2
- package/android/build.gradle +2 -25
- package/android/check.jks +0 -0
- package/android/src/main/AndroidManifest.xml +1 -2
- package/android/src/main/cpp/react/renderer/components/SheetViewSpec/SheetViewComponentDescriptor.h +12 -0
- package/android/src/main/cpp/react/renderer/components/SheetViewSpec/SheetViewShadowNode.cpp +17 -0
- package/android/src/main/cpp/react/renderer/components/SheetViewSpec/SheetViewShadowNode.h +36 -0
- package/android/src/main/cpp/react/renderer/components/SheetViewSpec/SheetViewState.h +52 -0
- package/android/src/main/java/com/behavior/BottomSheetBehavior.java +84 -16
- package/android/src/main/java/com/sheet2/AppFittedSheet.kt +431 -0
- package/android/src/main/java/com/{sheet → sheet2}/BaseRNView.kt +38 -31
- package/android/src/main/java/com/sheet2/CenteredSheetDialog.kt +272 -0
- package/android/src/main/java/com/{sheet → sheet2}/CustomBottomSheetDialog.java +32 -4
- package/android/src/main/java/com/{sheet → sheet2}/DialogRootViewGroup.kt +54 -12
- package/android/src/main/java/com/sheet2/FragmentModalBottomSheet.kt +161 -0
- package/android/src/main/java/com/sheet2/InlineFooterPresenter.kt +74 -0
- package/android/src/main/java/com/sheet2/InlineSheetPresenter.kt +249 -0
- package/android/src/main/java/com/sheet2/PassThroughLayouts.kt +17 -0
- package/android/src/main/java/com/{sheet → sheet2}/SafeAreaUtils.kt +4 -5
- package/android/src/main/java/com/sheet2/Sheet2Package.kt +44 -0
- package/android/src/main/java/com/sheet2/Sheet2View.kt +5 -0
- package/android/src/main/java/com/sheet2/Sheet2ViewManager.kt +163 -0
- package/android/src/main/java/com/{sheet → sheet2}/SheetDismissEvent.kt +1 -1
- package/android/src/main/java/com/{sheet → sheet2}/SheetModule.kt +14 -3
- package/android/src/main/java/com/{sheet → sheet2}/SheetPackage.kt +2 -3
- package/android/src/main/java/com/sheet2/SheetTreeLog.kt +78 -0
- package/android/src/main/java/com/{sheet → sheet2}/utils.kt +1 -2
- package/android/src/main/jni/CMakeLists.txt +72 -0
- package/android/src/main/jni/SheetViewSpec.h +40 -0
- package/ios/FittedSheets/SheetOptions.swift +5 -0
- package/ios/FittedSheets/SheetTransition.swift +83 -4
- package/ios/FittedSheets/SheetViewController.swift +222 -24
- package/ios/HostFittedSheet.swift +440 -51
- package/ios/SheetModule.h +5 -4
- package/ios/SheetModule.mm +11 -1
- package/ios/SheetTreeLog.swift +52 -0
- package/ios/SheetView.mm +118 -31
- package/ios/SheetViewComponentDescriptor.h +24 -0
- package/ios/SheetViewShadowNode.cpp +17 -0
- package/ios/SheetViewShadowNode.h +37 -0
- package/ios/SheetViewState.h +54 -0
- package/package.json +44 -74
- package/react-native.config.js +6 -4
- package/src/FittedSheet.tsx +131 -71
- package/src/GlobalSheetView.tsx +209 -0
- package/src/NativeSheet.ts +4 -0
- package/src/PublicSheetView.tsx +2 -1
- package/src/SheetTreeLog.ts +39 -0
- package/src/SheetViewNativeComponent.ts +25 -4
- package/src/index.tsx +34 -4
- package/src/logger.ts +16 -0
- package/android/generated/java/com/facebook/react/viewmanagers/SheetViewManagerDelegate.java +0 -67
- package/android/generated/java/com/facebook/react/viewmanagers/SheetViewManagerInterface.java +0 -27
- package/android/generated/java/com/sheet/NativeSheetSpec.java +0 -78
- package/android/generated/jni/CMakeLists.txt +0 -36
- package/android/generated/jni/RNSheetViewSpec-generated.cpp +0 -50
- package/android/generated/jni/RNSheetViewSpec.h +0 -31
- package/android/generated/jni/react/renderer/components/RNSheetViewSpec/ComponentDescriptors.cpp +0 -22
- package/android/generated/jni/react/renderer/components/RNSheetViewSpec/ComponentDescriptors.h +0 -24
- package/android/generated/jni/react/renderer/components/RNSheetViewSpec/EventEmitters.cpp +0 -24
- package/android/generated/jni/react/renderer/components/RNSheetViewSpec/EventEmitters.h +0 -25
- package/android/generated/jni/react/renderer/components/RNSheetViewSpec/Props.cpp +0 -33
- package/android/generated/jni/react/renderer/components/RNSheetViewSpec/Props.h +0 -36
- package/android/generated/jni/react/renderer/components/RNSheetViewSpec/RNSheetViewSpecJSI-generated.cpp +0 -46
- package/android/generated/jni/react/renderer/components/RNSheetViewSpec/RNSheetViewSpecJSI.h +0 -98
- package/android/generated/jni/react/renderer/components/RNSheetViewSpec/ShadowNodes.cpp +0 -17
- package/android/generated/jni/react/renderer/components/RNSheetViewSpec/ShadowNodes.h +0 -32
- package/android/generated/jni/react/renderer/components/RNSheetViewSpec/States.cpp +0 -16
- package/android/generated/jni/react/renderer/components/RNSheetViewSpec/States.h +0 -29
- package/android/src/main/AndroidManifestNew.xml +0 -2
- package/android/src/main/java/com/sheet/AppFittedSheet.kt +0 -214
- package/android/src/main/java/com/sheet/FragmentModalBottomSheet.kt +0 -67
- package/android/src/main/java/com/sheet/SheetView.kt +0 -5
- package/android/src/main/java/com/sheet/SheetViewManager.kt +0 -106
- package/ios/generated/RNSheetViewSpec/ComponentDescriptors.cpp +0 -22
- package/ios/generated/RNSheetViewSpec/ComponentDescriptors.h +0 -24
- package/ios/generated/RNSheetViewSpec/EventEmitters.cpp +0 -24
- package/ios/generated/RNSheetViewSpec/EventEmitters.h +0 -25
- package/ios/generated/RNSheetViewSpec/Props.cpp +0 -33
- package/ios/generated/RNSheetViewSpec/Props.h +0 -36
- package/ios/generated/RNSheetViewSpec/RCTComponentViewHelpers.h +0 -44
- package/ios/generated/RNSheetViewSpec/RNSheetViewSpec-generated.mm +0 -60
- package/ios/generated/RNSheetViewSpec/RNSheetViewSpec.h +0 -100
- package/ios/generated/RNSheetViewSpec/ShadowNodes.cpp +0 -17
- package/ios/generated/RNSheetViewSpec/ShadowNodes.h +0 -32
- package/ios/generated/RNSheetViewSpec/States.cpp +0 -16
- package/ios/generated/RNSheetViewSpec/States.h +0 -29
- package/ios/generated/RNSheetViewSpecJSI-generated.cpp +0 -46
- package/ios/generated/RNSheetViewSpecJSI.h +0 -98
- package/lib/module/FittedSheet.js +0 -153
- package/lib/module/FittedSheet.js.map +0 -1
- package/lib/module/NativeSheet.ts +0 -17
- package/lib/module/PublicSheetView.js +0 -48
- package/lib/module/PublicSheetView.js.map +0 -1
- package/lib/module/SheetViewNativeComponent.ts +0 -31
- package/lib/module/index.js +0 -13
- package/lib/module/index.js.map +0 -1
- package/lib/module/package.json +0 -1
- package/lib/typescript/package.json +0 -1
- package/lib/typescript/src/FittedSheet.d.ts +0 -51
- package/lib/typescript/src/FittedSheet.d.ts.map +0 -1
- package/lib/typescript/src/NativeSheet.d.ts +0 -16
- package/lib/typescript/src/NativeSheet.d.ts.map +0 -1
- package/lib/typescript/src/PublicSheetView.d.ts +0 -12
- package/lib/typescript/src/PublicSheetView.d.ts.map +0 -1
- package/lib/typescript/src/SheetViewNativeComponent.d.ts +0 -22
- package/lib/typescript/src/SheetViewNativeComponent.d.ts.map +0 -1
- package/lib/typescript/src/index.d.ts +0 -8
- package/lib/typescript/src/index.d.ts.map +0 -1
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import UIKit
|
|
3
|
+
import os
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
Every place where this library moves a view React Native believes it owns —
|
|
7
|
+
the iOS half of the Android `SheetTreeLog`.
|
|
8
|
+
|
|
9
|
+
On iOS the crashes do carry our symbols (`HostFittedSheet.setFittedSheetParams`,
|
|
10
|
+
`dismissSheet` inside `RCTMountingManager.performTransaction`), so what is
|
|
11
|
+
missing there is not the name but the state: which subview was mounted, which
|
|
12
|
+
one was taken away, and whether the sheet was already being destroyed. That is
|
|
13
|
+
what these entries carry.
|
|
14
|
+
|
|
15
|
+
The trail lives in memory and in the unified log under the `com.sheet2`
|
|
16
|
+
subsystem; `getTreeLog()` on the Sheet module hands the last entries to JS.
|
|
17
|
+
*/
|
|
18
|
+
@objc public class SheetTreeLog: NSObject {
|
|
19
|
+
private static let capacity = 32
|
|
20
|
+
private static let lock = NSLock()
|
|
21
|
+
private static var entries: [String] = []
|
|
22
|
+
@objc public static var logsEnabled = false
|
|
23
|
+
private static let osLog = OSLog(subsystem: "com.sheet2", category: "tree")
|
|
24
|
+
|
|
25
|
+
@objc public static func log(_ op: String, details: String) {
|
|
26
|
+
let entry = "\(op) \(details)"
|
|
27
|
+
|
|
28
|
+
lock.lock()
|
|
29
|
+
entries.append(entry)
|
|
30
|
+
if entries.count > capacity {
|
|
31
|
+
entries.removeFirst(entries.count - capacity)
|
|
32
|
+
}
|
|
33
|
+
lock.unlock()
|
|
34
|
+
|
|
35
|
+
if logsEnabled {
|
|
36
|
+
os_log("%{public}@", log: osLog, type: .debug, entry)
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@objc public static func snapshot() -> [String] {
|
|
41
|
+
lock.lock()
|
|
42
|
+
defer { lock.unlock() }
|
|
43
|
+
return entries
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/// A view named the way a crash report names it: the React tag when the view
|
|
47
|
+
/// carries one, and the address, which is what an EXC_BAD_ACCESS points at.
|
|
48
|
+
@objc public static func name(_ view: UIView?) -> String {
|
|
49
|
+
guard let view else { return "-" }
|
|
50
|
+
return "tag=\(view.tag)/\(Unmanaged.passUnretained(view).toOpaque())"
|
|
51
|
+
}
|
|
52
|
+
}
|
package/ios/SheetView.mm
CHANGED
|
@@ -1,21 +1,26 @@
|
|
|
1
1
|
#import "SheetView.h"
|
|
2
|
+
#import "SheetViewComponentDescriptor.h"
|
|
3
|
+
#import "SheetViewShadowNode.h"
|
|
4
|
+
#import "SheetViewState.h"
|
|
5
|
+
#import <react/renderer/components/SheetViewSpec/EventEmitters.h>
|
|
6
|
+
#import <react/renderer/components/SheetViewSpec/Props.h>
|
|
7
|
+
#import <react/renderer/components/SheetViewSpec/RCTComponentViewHelpers.h>
|
|
2
8
|
|
|
3
|
-
#import <Sheet/ComponentDescriptors.h>
|
|
4
|
-
#import <Sheet/EventEmitters.h>
|
|
5
|
-
#import <Sheet/Props.h>
|
|
6
|
-
#import <Sheet/RCTComponentViewHelpers.h>
|
|
7
9
|
#import <React/RCTConversions.h>
|
|
8
10
|
|
|
9
11
|
#import "RCTFabricComponentsPlugins.h"
|
|
10
12
|
|
|
11
|
-
#if __has_include("
|
|
12
|
-
#import "
|
|
13
|
+
#if __has_include("Sheet2-Swift.h")
|
|
14
|
+
#import "Sheet2-Swift.h"
|
|
13
15
|
#else
|
|
14
|
-
#import <
|
|
16
|
+
#import <Sheet2/Sheet2-Swift.h>
|
|
15
17
|
#endif
|
|
16
18
|
|
|
17
19
|
using namespace facebook::react;
|
|
18
20
|
|
|
21
|
+
// `SheetViewComponentName` is defined in `SheetViewShadowNode.cpp` (mirror
|
|
22
|
+
// of the Android-side symbol).
|
|
23
|
+
|
|
19
24
|
@interface SheetView () <RCTSheetViewViewProtocol>
|
|
20
25
|
|
|
21
26
|
@end
|
|
@@ -23,6 +28,12 @@ using namespace facebook::react;
|
|
|
23
28
|
@implementation SheetView {
|
|
24
29
|
HostFittedSheet * _view2;
|
|
25
30
|
UIView * _view;
|
|
31
|
+
// Typed state handle — cast from the base `State::Shared` we receive in
|
|
32
|
+
// `updateState:oldState:`. Having it typed lets us call
|
|
33
|
+
// `updateState(lambda)` with `SheetViewState` to push the visual
|
|
34
|
+
// content-origin delta when the sheet is re-parented for inline
|
|
35
|
+
// presentation.
|
|
36
|
+
SheetViewShadowNode::ConcreteState::Shared _sheetState;
|
|
26
37
|
}
|
|
27
38
|
|
|
28
39
|
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
|
@@ -42,20 +53,10 @@ using namespace facebook::react;
|
|
|
42
53
|
if (self = [super initWithFrame:frame]) {
|
|
43
54
|
static const auto defaultProps = std::make_shared<const SheetViewProps>();
|
|
44
55
|
_props = defaultProps;
|
|
45
|
-
|
|
46
56
|
_view = [[UIView alloc] init];
|
|
47
57
|
_view2 = [[HostFittedSheet alloc] init];
|
|
48
58
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
__weak SheetView *weakSelf = self;
|
|
52
|
-
_view2.onSheetDismiss = ^{
|
|
53
|
-
NSLog(@"😀 ---- onSheetDismiss");
|
|
54
|
-
auto eventEmitter = [weakSelf modalEventEmitter];
|
|
55
|
-
if (eventEmitter) {
|
|
56
|
-
eventEmitter->onSheetDismiss({});
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
+
[self _bindStateUpdater];
|
|
59
60
|
|
|
60
61
|
self.contentView = _view2;
|
|
61
62
|
}
|
|
@@ -63,29 +64,80 @@ using namespace facebook::react;
|
|
|
63
64
|
return self;
|
|
64
65
|
}
|
|
65
66
|
|
|
67
|
+
// The sheet content is rendered in another view hierarchy; this placeholder must never take touches.
|
|
68
|
+
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
|
|
69
|
+
{
|
|
70
|
+
UIView *view = [super hitTest:point withEvent:event];
|
|
71
|
+
return view == self || view == _view2 ? nil : view;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
- (void)_bindStateUpdater
|
|
75
|
+
{
|
|
76
|
+
__weak SheetView *weakSelf = self;
|
|
77
|
+
_view2.stateUpdater = ^(float x, float y) {
|
|
78
|
+
__strong SheetView *strongSelf = weakSelf;
|
|
79
|
+
if (!strongSelf) return;
|
|
80
|
+
[strongSelf pushContentOriginOffsetX:x y:y];
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
- (void)updateState:(const facebook::react::State::Shared &)state
|
|
85
|
+
oldState:(const facebook::react::State::Shared &)oldState
|
|
86
|
+
{
|
|
87
|
+
_sheetState = std::static_pointer_cast<const SheetViewShadowNode::ConcreteState>(state);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
- (void)pushContentOriginOffsetX:(float)x y:(float)y
|
|
91
|
+
{
|
|
92
|
+
if (!_sheetState) return;
|
|
93
|
+
_sheetState->updateState(
|
|
94
|
+
[x, y](const SheetViewShadowNode::ConcreteState::Data &oldData)
|
|
95
|
+
-> SheetViewShadowNode::ConcreteState::SharedData {
|
|
96
|
+
if (std::abs(oldData.contentOriginOffset.x - x) < 0.01 &&
|
|
97
|
+
std::abs(oldData.contentOriginOffset.y - y) < 0.01) {
|
|
98
|
+
return nullptr;
|
|
99
|
+
}
|
|
100
|
+
auto newData = oldData;
|
|
101
|
+
newData.contentOriginOffset = {x, y};
|
|
102
|
+
return std::make_shared<const SheetViewShadowNode::ConcreteState::Data>(newData);
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
66
106
|
- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
|
|
67
107
|
{
|
|
68
|
-
NSLog(@"😀 updateProps");
|
|
69
108
|
const auto &oldViewProps = *std::static_pointer_cast<SheetViewProps const>(_props);
|
|
70
109
|
const auto &newViewProps = *std::static_pointer_cast<SheetViewProps const>(props);
|
|
71
110
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
111
|
+
[_view2 setUniqueId:[[NSString alloc]initWithUTF8String:newViewProps.uniqueId.c_str()]];
|
|
112
|
+
|
|
113
|
+
// Apply all props unconditionally — after prepareForRecycle the new
|
|
114
|
+
// HostFittedSheet instance has default state, but the props diff against
|
|
115
|
+
// the preserved _props may be a no-op, leaving the recycled instance in
|
|
116
|
+
// defaults (e.g. useInlinePresentation=false, windowLevel=.alert).
|
|
117
|
+
[_view2 setFittedSheetParams:@{
|
|
118
|
+
@"maxWidth": @(newViewProps.maxWidth),
|
|
119
|
+
@"dismissable": @(newViewProps.dismissable),
|
|
120
|
+
@"topLeftRightCornerRadius": @(newViewProps.topLeftRightCornerRadius),
|
|
121
|
+
@"dismissOnOverlayTap": @(newViewProps.dismissOnOverlayTap),
|
|
122
|
+
@"overlayOpacity": @(newViewProps.overlayOpacity),
|
|
123
|
+
@"collapsedHeight": @(newViewProps.collapsedHeight)
|
|
124
|
+
}];
|
|
79
125
|
|
|
80
126
|
auto color = RCTUIColorFromSharedColor(newViewProps.sheetBackgroundColor);
|
|
81
127
|
[_view2 setSheetBackgroundColor:color];
|
|
82
128
|
|
|
129
|
+
[_view2 setWindowLevel:[[NSString alloc]initWithUTF8String:newViewProps.windowLevel.c_str()]];
|
|
130
|
+
|
|
131
|
+
[_view2 setUseInlinePresentation:newViewProps.useInlinePresentation];
|
|
132
|
+
|
|
133
|
+
[_view2 setPresentationStyle:[[NSString alloc] initWithUTF8String:newViewProps.presentationStyle.c_str()]];
|
|
134
|
+
[_view2 setCenterAnimation:[[NSString alloc] initWithUTF8String:newViewProps.centerAnimation.c_str()]];
|
|
135
|
+
|
|
83
136
|
if (oldViewProps.passScrollViewReactTag != newViewProps.passScrollViewReactTag) {
|
|
84
137
|
[_view2 setPassScrollViewReactTag];
|
|
85
138
|
}
|
|
86
139
|
|
|
87
140
|
|
|
88
|
-
NSLog(@"----- %f", newViewProps.calculatedHeight);
|
|
89
141
|
[_view2 setCalculatedHeight:newViewProps.calculatedHeight];
|
|
90
142
|
|
|
91
143
|
|
|
@@ -93,19 +145,55 @@ using namespace facebook::react;
|
|
|
93
145
|
}
|
|
94
146
|
|
|
95
147
|
- (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index {
|
|
96
|
-
|
|
148
|
+
[SheetTreeLog log:@"host.mountChild"
|
|
149
|
+
details:[NSString stringWithFormat:@"child=%@ index=%ld host=%@",
|
|
150
|
+
[SheetTreeLog name:childComponentView], (long)index,
|
|
151
|
+
[SheetTreeLog name:_view2]]];
|
|
97
152
|
[_view2 insertReactSubview:childComponentView atIndex:index];
|
|
153
|
+
|
|
154
|
+
__weak SheetView *weakSelf = self;
|
|
155
|
+
_view2.onSheetDismiss = ^{
|
|
156
|
+
__strong SheetView *strongSelf = weakSelf;
|
|
157
|
+
if (!strongSelf) return; // object already destroyed, exiting
|
|
158
|
+
|
|
159
|
+
auto eventEmitter = [strongSelf modalEventEmitter];
|
|
160
|
+
if (eventEmitter) {
|
|
161
|
+
eventEmitter->onSheetDismiss({});
|
|
162
|
+
}
|
|
163
|
+
};
|
|
98
164
|
}
|
|
99
165
|
|
|
100
166
|
- (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index {
|
|
101
|
-
|
|
167
|
+
[SheetTreeLog log:@"host.unmountChild"
|
|
168
|
+
details:[NSString stringWithFormat:@"child=%@ index=%ld host=%@",
|
|
169
|
+
[SheetTreeLog name:childComponentView], (long)index,
|
|
170
|
+
[SheetTreeLog name:_view2]]];
|
|
102
171
|
[_view2 removeReactSubview:childComponentView];
|
|
103
172
|
}
|
|
104
173
|
|
|
105
174
|
- (void)prepareForRecycle {
|
|
106
|
-
|
|
175
|
+
// The HostFittedSheet is thrown away and rebuilt here, so anything the
|
|
176
|
+
// mounting layer still holds from before this point is stale.
|
|
177
|
+
[SheetTreeLog log:@"host.prepareForRecycle"
|
|
178
|
+
details:[NSString stringWithFormat:@"host=%@", [SheetTreeLog name:_view2]]];
|
|
179
|
+
[_view2 destroy];
|
|
180
|
+
_view2.onSheetDismiss = nil;
|
|
181
|
+
|
|
182
|
+
// Remove old HostFittedSheet from hierarchy
|
|
183
|
+
[_view2 removeFromSuperview];
|
|
184
|
+
|
|
185
|
+
// Create new HostFittedSheet instance for next use
|
|
186
|
+
_view2 = [[HostFittedSheet alloc] init];
|
|
187
|
+
[self _bindStateUpdater];
|
|
188
|
+
self.contentView = _view2;
|
|
189
|
+
|
|
107
190
|
[super prepareForRecycle];
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
- (void)dealloc {
|
|
108
194
|
[_view2 destroy];
|
|
195
|
+
_view2.onSheetDismiss = nil;
|
|
196
|
+
_view2 = nil;
|
|
109
197
|
}
|
|
110
198
|
|
|
111
199
|
- (void)finalizeUpdates:(RNComponentViewUpdateMask)updateMask {
|
|
@@ -125,5 +213,4 @@ Class<RCTComponentViewProtocol> SheetViewCls(void) {
|
|
|
125
213
|
return SheetView.class;
|
|
126
214
|
}
|
|
127
215
|
|
|
128
|
-
|
|
129
216
|
@end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include "SheetViewShadowNode.h"
|
|
4
|
+
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* iOS-side declarations for the `SheetView` Fabric component.
|
|
8
|
+
*
|
|
9
|
+
* We set `interfaceOnly: true` on the JS spec (see
|
|
10
|
+
* `src/SheetViewNativeComponent.ts`) so codegen stops auto-emitting default
|
|
11
|
+
* `SheetViewShadowNode` / `SheetViewComponentDescriptor` typedefs — the
|
|
12
|
+
* library provides its own subclass (`SheetViewShadowNode`) that overrides
|
|
13
|
+
* `getContentOriginOffset` to keep Pressability region checks in sync with
|
|
14
|
+
* the real on-screen position after child-VC containment for inline
|
|
15
|
+
* presentation. `SheetView.mm`'s `componentDescriptorProvider` picks up this
|
|
16
|
+
* `SheetViewComponentDescriptor` below.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
namespace facebook::react {
|
|
20
|
+
|
|
21
|
+
using SheetViewComponentDescriptor =
|
|
22
|
+
ConcreteComponentDescriptor<SheetViewShadowNode>;
|
|
23
|
+
|
|
24
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#include "SheetViewShadowNode.h"
|
|
2
|
+
|
|
3
|
+
namespace facebook::react {
|
|
4
|
+
|
|
5
|
+
extern const char SheetViewComponentName[] = "SheetView";
|
|
6
|
+
|
|
7
|
+
Point SheetViewShadowNode::getContentOriginOffset(
|
|
8
|
+
bool includeTransform) const {
|
|
9
|
+
auto const& stateData = getStateData();
|
|
10
|
+
auto offset = stateData.contentOriginOffset;
|
|
11
|
+
auto transform =
|
|
12
|
+
includeTransform ? getTransform() : Transform::Identity();
|
|
13
|
+
auto result = transform * Vector{offset.x, offset.y, 0.0f, 1.0f};
|
|
14
|
+
return {result.x, result.y};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <jsi/jsi.h>
|
|
4
|
+
#include <react/renderer/components/SheetViewSpec/EventEmitters.h>
|
|
5
|
+
#include <react/renderer/components/SheetViewSpec/Props.h>
|
|
6
|
+
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
|
|
7
|
+
|
|
8
|
+
#include "SheetViewState.h"
|
|
9
|
+
|
|
10
|
+
namespace facebook::react {
|
|
11
|
+
|
|
12
|
+
JSI_EXPORT extern const char SheetViewComponentName[];
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Custom `ShadowNode` for <SheetView>. The override on
|
|
16
|
+
* `getContentOriginOffset` lets the Swift side (`HostFittedSheet`) push a
|
|
17
|
+
* visual X/Y delta via state updates after child-VC containment for inline
|
|
18
|
+
* presentation. The offset is consumed by
|
|
19
|
+
* `LayoutableShadowNode::computeRelativeLayoutMetrics` (line 180 in
|
|
20
|
+
* `LayoutableShadowNode.cpp`), so that `measure()` / `measureInWindow()`
|
|
21
|
+
* called from JS on descendant refs returns coordinates relative to the
|
|
22
|
+
* sheet's actual on-screen position — which keeps Pressability's responder
|
|
23
|
+
* region check in sync with real touch coordinates.
|
|
24
|
+
*/
|
|
25
|
+
class JSI_EXPORT SheetViewShadowNode final
|
|
26
|
+
: public ConcreteViewShadowNode<
|
|
27
|
+
SheetViewComponentName,
|
|
28
|
+
SheetViewProps,
|
|
29
|
+
SheetViewEventEmitter,
|
|
30
|
+
SheetViewState> {
|
|
31
|
+
public:
|
|
32
|
+
using ConcreteViewShadowNode::ConcreteViewShadowNode;
|
|
33
|
+
|
|
34
|
+
Point getContentOriginOffset(bool includeTransform) const override;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <react/renderer/core/Props.h>
|
|
4
|
+
#include <react/renderer/graphics/Float.h>
|
|
5
|
+
#include <react/renderer/graphics/Point.h>
|
|
6
|
+
|
|
7
|
+
#ifdef RN_SERIALIZABLE_STATE
|
|
8
|
+
#include <react/renderer/mapbuffer/MapBuffer.h>
|
|
9
|
+
#include <react/renderer/mapbuffer/MapBufferBuilder.h>
|
|
10
|
+
#endif
|
|
11
|
+
|
|
12
|
+
namespace facebook::react {
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* State for the `SheetView` Fabric component.
|
|
16
|
+
*
|
|
17
|
+
* `contentOriginOffset` is the visual delta between the Yoga-computed
|
|
18
|
+
* position of the sheet content and its actual on-screen position after the
|
|
19
|
+
* iOS host view has been re-parented via child-VC containment for inline
|
|
20
|
+
* presentation. It is pushed from the Swift side (`HostFittedSheet`) on
|
|
21
|
+
* containment-settle, and consumed by
|
|
22
|
+
* `SheetViewShadowNode::getContentOriginOffset()` so that descendants'
|
|
23
|
+
* `measure()` and Pressability region checks report the real screen
|
|
24
|
+
* position.
|
|
25
|
+
*/
|
|
26
|
+
class SheetViewState {
|
|
27
|
+
public:
|
|
28
|
+
SheetViewState() = default;
|
|
29
|
+
SheetViewState(SheetViewState const& previousState, Point contentOriginOffset)
|
|
30
|
+
: contentOriginOffset(contentOriginOffset) {}
|
|
31
|
+
|
|
32
|
+
#ifdef RN_SERIALIZABLE_STATE
|
|
33
|
+
SheetViewState(SheetViewState const& previousState, folly::dynamic data) {
|
|
34
|
+
auto x = data["contentOriginOffsetX"];
|
|
35
|
+
auto y = data["contentOriginOffsetY"];
|
|
36
|
+
contentOriginOffset = {
|
|
37
|
+
x.isNumber() ? (Float)x.asDouble() : 0,
|
|
38
|
+
y.isNumber() ? (Float)y.asDouble() : 0};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
folly::dynamic getDynamic() const {
|
|
42
|
+
return folly::dynamic::object("contentOriginOffsetX", (double)contentOriginOffset.x)(
|
|
43
|
+
"contentOriginOffsetY", (double)contentOriginOffset.y);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
MapBuffer getMapBuffer() const {
|
|
47
|
+
return MapBufferBuilder::EMPTY();
|
|
48
|
+
}
|
|
49
|
+
#endif
|
|
50
|
+
|
|
51
|
+
Point contentOriginOffset{0, 0};
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
} // namespace facebook::react
|
package/package.json
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-sheet2",
|
|
3
|
-
"
|
|
3
|
+
"workspaces": [
|
|
4
|
+
"example"
|
|
5
|
+
],
|
|
6
|
+
"version": "7.12.4",
|
|
4
7
|
"description": "Native implementation of Bottom sheet",
|
|
5
8
|
"main": "src/index.tsx",
|
|
6
9
|
"module": "src/index",
|
|
@@ -26,13 +29,18 @@
|
|
|
26
29
|
"!**/.*"
|
|
27
30
|
],
|
|
28
31
|
"scripts": {
|
|
29
|
-
"example": "
|
|
32
|
+
"example": "npm --prefix example",
|
|
30
33
|
"test": "jest",
|
|
34
|
+
"test:e2e:ios": "detox test --configuration ios.sim.debug",
|
|
35
|
+
"test:e2e:android": "detox test --configuration android.emu.debug",
|
|
36
|
+
"test:e2e:build:ios": "detox build --configuration ios.sim.debug",
|
|
37
|
+
"test:e2e:build:android": "detox build --configuration android.emu.debug",
|
|
31
38
|
"typecheck": "tsc",
|
|
32
39
|
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
33
40
|
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
|
|
34
|
-
"
|
|
35
|
-
"release": "release-it"
|
|
41
|
+
"build": "bob build",
|
|
42
|
+
"release": "release-it --only-version",
|
|
43
|
+
"gen": "react-native codegen --platform ios && react-native codegen --platform android"
|
|
36
44
|
},
|
|
37
45
|
"keywords": [
|
|
38
46
|
"react-native",
|
|
@@ -52,72 +60,39 @@
|
|
|
52
60
|
"publishConfig": {
|
|
53
61
|
"registry": "https://registry.npmjs.org/"
|
|
54
62
|
},
|
|
63
|
+
"dependencies": {},
|
|
55
64
|
"devDependencies": {
|
|
56
|
-
"@
|
|
57
|
-
"@eslint/
|
|
58
|
-
"@eslint/
|
|
59
|
-
"@
|
|
60
|
-
"@react-native-
|
|
61
|
-
"@react-native/eslint-config": "^0.
|
|
62
|
-
"@
|
|
63
|
-
"@
|
|
64
|
-
"@types/
|
|
65
|
-
"
|
|
66
|
-
"del-cli": "^
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"eslint
|
|
65
|
+
"@eslint/compat": "^1.3.2",
|
|
66
|
+
"@eslint/eslintrc": "^3.3.1",
|
|
67
|
+
"@eslint/js": "^9.35.0",
|
|
68
|
+
"@react-native-community/cli": "20.0.1",
|
|
69
|
+
"@react-native/babel-preset": "0.81.1",
|
|
70
|
+
"@react-native/eslint-config": "^0.81.1",
|
|
71
|
+
"@testing-library/jest-native": "^5.4.3",
|
|
72
|
+
"@testing-library/react-native": "^13.3.3",
|
|
73
|
+
"@types/jest": "^29.5.14",
|
|
74
|
+
"@types/react": "^19.1.0",
|
|
75
|
+
"del-cli": "^6.0.0",
|
|
76
|
+
"detox": "^20.45.1",
|
|
77
|
+
"detox-cli": "^20.0.0",
|
|
78
|
+
"eslint": "^9.35.0",
|
|
79
|
+
"eslint-config-prettier": "^10.1.8",
|
|
80
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
70
81
|
"jest": "^29.7.0",
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"react
|
|
74
|
-
"react-native
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
"@gorhom/portal": "^1.0.14"
|
|
82
|
+
"jest-circus": "^30.2.0",
|
|
83
|
+
"prettier": "^3.6.2",
|
|
84
|
+
"react": "19.1.0",
|
|
85
|
+
"react-native": "0.81.1",
|
|
86
|
+
"react-native-builder-bob": "^0.40.13",
|
|
87
|
+
"react-test-renderer": "19.1.0",
|
|
88
|
+
"release-it": "^19.0.4",
|
|
89
|
+
"turbo": "^2.5.6",
|
|
90
|
+
"typescript": "^5.9.2"
|
|
81
91
|
},
|
|
82
92
|
"peerDependencies": {
|
|
83
93
|
"react": "*",
|
|
84
94
|
"react-native": "*"
|
|
85
95
|
},
|
|
86
|
-
"workspaces": [
|
|
87
|
-
"example"
|
|
88
|
-
],
|
|
89
|
-
"packageManager": "yarn@3.6.1",
|
|
90
|
-
"jest": {
|
|
91
|
-
"preset": "react-native",
|
|
92
|
-
"modulePathIgnorePatterns": [
|
|
93
|
-
"<rootDir>/example/node_modules",
|
|
94
|
-
"<rootDir>/lib/"
|
|
95
|
-
]
|
|
96
|
-
},
|
|
97
|
-
"commitlint": {
|
|
98
|
-
"extends": [
|
|
99
|
-
"@commitlint/config-conventional"
|
|
100
|
-
]
|
|
101
|
-
},
|
|
102
|
-
"release-it": {
|
|
103
|
-
"git": {
|
|
104
|
-
"commitMessage": "chore: release ${version}",
|
|
105
|
-
"tagName": "v${version}"
|
|
106
|
-
},
|
|
107
|
-
"npm": {
|
|
108
|
-
"publish": true
|
|
109
|
-
},
|
|
110
|
-
"github": {
|
|
111
|
-
"release": true
|
|
112
|
-
},
|
|
113
|
-
"plugins": {
|
|
114
|
-
"@release-it/conventional-changelog": {
|
|
115
|
-
"preset": {
|
|
116
|
-
"name": "angular"
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
},
|
|
121
96
|
"prettier": {
|
|
122
97
|
"quoteProps": "consistent",
|
|
123
98
|
"singleQuote": true,
|
|
@@ -129,7 +104,6 @@
|
|
|
129
104
|
"source": "src",
|
|
130
105
|
"output": "lib",
|
|
131
106
|
"targets": [
|
|
132
|
-
"codegen",
|
|
133
107
|
[
|
|
134
108
|
"module",
|
|
135
109
|
{
|
|
@@ -145,26 +119,22 @@
|
|
|
145
119
|
]
|
|
146
120
|
},
|
|
147
121
|
"codegenConfig": {
|
|
148
|
-
"name": "
|
|
122
|
+
"name": "SheetViewSpec",
|
|
149
123
|
"type": "all",
|
|
150
124
|
"jsSrcsDir": "src",
|
|
151
|
-
"outputDir": {
|
|
152
|
-
"ios": "ios/generated",
|
|
153
|
-
"android": "android/generated"
|
|
154
|
-
},
|
|
155
125
|
"android": {
|
|
156
|
-
"javaPackageName": "com.
|
|
126
|
+
"javaPackageName": "com.sheet2"
|
|
157
127
|
},
|
|
158
128
|
"ios": {
|
|
159
129
|
"componentProvider": {
|
|
160
130
|
"SheetView": "SheetView"
|
|
161
131
|
}
|
|
162
|
-
}
|
|
163
|
-
"includesGeneratedCode": true
|
|
132
|
+
}
|
|
164
133
|
},
|
|
165
134
|
"create-react-native-library": {
|
|
166
135
|
"languages": "kotlin-objc",
|
|
167
136
|
"type": "fabric-view",
|
|
168
|
-
"version": "0.
|
|
169
|
-
}
|
|
137
|
+
"version": "0.54.3"
|
|
138
|
+
},
|
|
139
|
+
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
|
|
170
140
|
}
|
package/react-native.config.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @type {import('@react-native-community/cli-types').UserDependencyConfig}
|
|
3
|
-
*/
|
|
4
1
|
module.exports = {
|
|
5
2
|
dependency: {
|
|
6
3
|
platforms: {
|
|
7
4
|
android: {
|
|
8
|
-
|
|
5
|
+
// Declare our Fabric ComponentDescriptor so `autolinking.cpp` registers
|
|
6
|
+
// it. Paired with the custom `android/src/main/jni/CMakeLists.txt`,
|
|
7
|
+
// which shadows the codegen include path so our subclass (with the
|
|
8
|
+
// `getContentOriginOffset` override) is picked up.
|
|
9
|
+
componentDescriptors: ['SheetViewComponentDescriptor'],
|
|
10
|
+
cmakeListsPath: '../android/src/main/jni/CMakeLists.txt',
|
|
9
11
|
},
|
|
10
12
|
},
|
|
11
13
|
},
|