@lodev09/react-native-true-sheet 4.0.0-beta.2 → 4.0.0-beta.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/android/src/main/java/com/lodev09/truesheet/TrueSheetContainerView.kt +28 -4
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetContentView.kt +206 -149
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetContentViewManager.kt +5 -0
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetFooterView.kt +6 -17
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetView.kt +73 -13
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewController.kt +101 -18
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewManager.kt +25 -1
- package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetCoordinatorLayout.kt +3 -3
- package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetDetentCalculator.kt +14 -24
- package/android/src/main/java/com/lodev09/truesheet/utils/ViewUtils.kt +0 -7
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetContentViewShadowNode.cpp +50 -4
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetContentViewShadowNode.h +7 -0
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetContentViewState.cpp +2 -1
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetContentViewState.h +11 -3
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetFooterViewShadowNode.cpp +7 -0
- package/ios/TrueSheetContainerView.h +18 -5
- package/ios/TrueSheetContainerView.mm +10 -6
- package/ios/TrueSheetContentView.h +31 -10
- package/ios/TrueSheetContentView.mm +137 -162
- package/ios/TrueSheetFooterView.h +6 -0
- package/ios/TrueSheetFooterView.mm +48 -2
- package/ios/TrueSheetView.mm +95 -21
- package/ios/TrueSheetViewController.h +9 -0
- package/ios/TrueSheetViewController.mm +108 -25
- package/ios/utils/UIView+ScrollEdgeInteraction.h +1 -0
- package/ios/utils/UIView+ScrollEdgeInteraction.mm +24 -2
- package/lib/module/TrueSheet.js +77 -11
- package/lib/module/TrueSheet.js.map +1 -1
- package/lib/module/TrueSheet.web.js +26 -24
- package/lib/module/TrueSheet.web.js.map +1 -1
- package/lib/module/fabric/TrueSheetContentViewNativeComponent.ts +1 -1
- package/lib/module/fabric/TrueSheetViewNativeComponent.ts +4 -0
- package/lib/typescript/src/TrueSheet.d.ts +4 -0
- package/lib/typescript/src/TrueSheet.d.ts.map +1 -1
- package/lib/typescript/src/TrueSheet.types.d.ts +50 -1
- package/lib/typescript/src/TrueSheet.types.d.ts.map +1 -1
- package/lib/typescript/src/TrueSheet.web.d.ts.map +1 -1
- package/lib/typescript/src/fabric/TrueSheetViewNativeComponent.d.ts +3 -0
- package/lib/typescript/src/fabric/TrueSheetViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/navigation/types.d.ts +1 -1
- package/lib/typescript/src/navigation/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/TrueSheet.tsx +78 -9
- package/src/TrueSheet.types.ts +53 -1
- package/src/TrueSheet.web.tsx +37 -23
- package/src/fabric/TrueSheetContentViewNativeComponent.ts +1 -1
- package/src/fabric/TrueSheetViewNativeComponent.ts +4 -0
- package/src/navigation/types.ts +1 -0
|
@@ -4,7 +4,8 @@ namespace facebook::react {
|
|
|
4
4
|
|
|
5
5
|
#ifdef ANDROID
|
|
6
6
|
folly::dynamic TrueSheetContentViewState::getDynamic() const {
|
|
7
|
-
return folly::dynamic::object("scrollableBounded", scrollableBounded)
|
|
7
|
+
return folly::dynamic::object("scrollableBounded", scrollableBounded)(
|
|
8
|
+
"naturalHeight", naturalHeight);
|
|
8
9
|
}
|
|
9
10
|
#endif
|
|
10
11
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
|
+
#include <react/renderer/graphics/Float.h>
|
|
4
|
+
|
|
3
5
|
#ifdef ANDROID
|
|
4
6
|
#include <folly/dynamic.h>
|
|
5
7
|
#include <react/renderer/mapbuffer/MapBuffer.h>
|
|
@@ -10,8 +12,10 @@ namespace facebook::react {
|
|
|
10
12
|
|
|
11
13
|
/*
|
|
12
14
|
* State for <TrueSheetContentView> component.
|
|
13
|
-
*
|
|
14
|
-
* content to the container via flexShrink
|
|
15
|
+
* `scrollableBounded` is set from native when a ScrollView is detected so the
|
|
16
|
+
* shadow node bounds the content to the container via flexShrink.
|
|
17
|
+
* `naturalHeight` is measured by the shadow node during layout — the height
|
|
18
|
+
* the content wants when unbounded (see TrueSheetContentViewShadowNode).
|
|
15
19
|
*/
|
|
16
20
|
class TrueSheetContentViewState final {
|
|
17
21
|
public:
|
|
@@ -21,10 +25,14 @@ class TrueSheetContentViewState final {
|
|
|
21
25
|
TrueSheetContentViewState(
|
|
22
26
|
TrueSheetContentViewState const &previousState,
|
|
23
27
|
folly::dynamic data)
|
|
24
|
-
: scrollableBounded(
|
|
28
|
+
: scrollableBounded(
|
|
29
|
+
data.getDefault("scrollableBounded", previousState.scrollableBounded)
|
|
30
|
+
.getBool()),
|
|
31
|
+
naturalHeight(previousState.naturalHeight) {}
|
|
25
32
|
#endif
|
|
26
33
|
|
|
27
34
|
bool scrollableBounded{false};
|
|
35
|
+
Float naturalHeight{0};
|
|
28
36
|
|
|
29
37
|
#ifdef ANDROID
|
|
30
38
|
folly::dynamic getDynamic() const;
|
package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetFooterViewShadowNode.cpp
CHANGED
|
@@ -25,6 +25,13 @@ void TrueSheetFooterViewShadowNode::adjustLayoutWithState() {
|
|
|
25
25
|
float bottomInset = stateData.bottomInset;
|
|
26
26
|
if (!stateData.initialized && props.autoBottomInset) {
|
|
27
27
|
bottomInset = TrueSheetInsets::bottomSafeArea();
|
|
28
|
+
if (bottomInset != stateData.bottomInset) {
|
|
29
|
+
// Record the seeded value so the mounted view reads exactly the inset
|
|
30
|
+
// baked into this layout — the global may change before mount.
|
|
31
|
+
auto seededData = stateData;
|
|
32
|
+
seededData.bottomInset = bottomInset;
|
|
33
|
+
setStateData(std::move(seededData));
|
|
34
|
+
}
|
|
28
35
|
}
|
|
29
36
|
|
|
30
37
|
// A footer pinned to the sheet's bottom edge owns the bottom safe-area
|
|
@@ -16,7 +16,9 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
16
16
|
|
|
17
17
|
@interface ScrollableOptions : NSObject
|
|
18
18
|
|
|
19
|
+
@property (nonatomic, assign) BOOL contentInsetAdjustment;
|
|
19
20
|
@property (nonatomic, assign) CGFloat keyboardScrollOffset;
|
|
21
|
+
@property (nonatomic, assign) CGFloat keyboardOffset;
|
|
20
22
|
@property (nonatomic, assign) BOOL scrollingExpandsSheet;
|
|
21
23
|
@property (nonatomic, assign) facebook::react::TrueSheetViewTopScrollEdgeEffect topScrollEdgeEffect;
|
|
22
24
|
@property (nonatomic, assign) facebook::react::TrueSheetViewBottomScrollEdgeEffect bottomScrollEdgeEffect;
|
|
@@ -46,17 +48,23 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
46
48
|
@property (nonatomic, weak, nullable) id<TrueSheetContainerViewDelegate> delegate;
|
|
47
49
|
|
|
48
50
|
/**
|
|
49
|
-
*
|
|
51
|
+
* Options for scrollable behavior
|
|
50
52
|
*/
|
|
51
|
-
@property (nonatomic,
|
|
53
|
+
@property (nonatomic, strong, nullable) ScrollableOptions *scrollableOptions;
|
|
52
54
|
|
|
53
55
|
/**
|
|
54
|
-
*
|
|
56
|
+
* React tag of the user-provided scrollable within the content (see the `scrollableRef` prop)
|
|
55
57
|
*/
|
|
56
|
-
@property (nonatomic,
|
|
58
|
+
@property (nonatomic, assign) NSInteger scrollableHandle;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Whether the resolved scrollable's `contentInsetAdjustmentBehavior` is set to
|
|
62
|
+
* `automatic` — already gated by the sheet's `insetAdjustment`
|
|
63
|
+
*/
|
|
64
|
+
@property (nonatomic, assign) BOOL contentInsetAdjustment;
|
|
57
65
|
|
|
58
66
|
/**
|
|
59
|
-
* Whether the sheet has an `auto` detent — bounds the
|
|
67
|
+
* Whether the sheet has an `auto` detent — bounds the detected scrollable's
|
|
60
68
|
* viewport to the container so the sheet height can derive from its content size
|
|
61
69
|
*/
|
|
62
70
|
@property (nonatomic, assign) BOOL hasAutoDetent;
|
|
@@ -82,6 +90,11 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
82
90
|
*/
|
|
83
91
|
- (CGFloat)footerHeight;
|
|
84
92
|
|
|
93
|
+
/**
|
|
94
|
+
* Returns the bottom inset currently baked into the footer's height
|
|
95
|
+
*/
|
|
96
|
+
- (CGFloat)footerAppliedBottomInset;
|
|
97
|
+
|
|
85
98
|
/**
|
|
86
99
|
* Returns the current height of the peek view within the content
|
|
87
100
|
*/
|
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
#import "TrueSheetViewController.h"
|
|
18
18
|
#import "core/TrueSheetKeyboardObserver.h"
|
|
19
19
|
#import "utils/UIView+ScrollEdgeInteraction.h"
|
|
20
|
-
#import "utils/WindowUtil.h"
|
|
21
20
|
|
|
22
21
|
#import <react/renderer/components/TrueSheetSpec/ComponentDescriptors.h>
|
|
23
22
|
#import <react/renderer/components/TrueSheetSpec/EventEmitters.h>
|
|
@@ -33,7 +32,9 @@ using namespace facebook::react;
|
|
|
33
32
|
|
|
34
33
|
- (instancetype)init {
|
|
35
34
|
if (self = [super init]) {
|
|
35
|
+
_contentInsetAdjustment = YES;
|
|
36
36
|
_keyboardScrollOffset = 0;
|
|
37
|
+
_keyboardOffset = 0;
|
|
37
38
|
_scrollingExpandsSheet = YES;
|
|
38
39
|
_topScrollEdgeEffect = TrueSheetViewTopScrollEdgeEffect::Hidden;
|
|
39
40
|
_bottomScrollEdgeEffect = TrueSheetViewBottomScrollEdgeEffect::Hidden;
|
|
@@ -118,6 +119,10 @@ using namespace facebook::react;
|
|
|
118
119
|
return _footerView ? _footerView.frame.size.height : 0;
|
|
119
120
|
}
|
|
120
121
|
|
|
122
|
+
- (CGFloat)footerAppliedBottomInset {
|
|
123
|
+
return _footerView ? _footerView.appliedBottomInset : 0;
|
|
124
|
+
}
|
|
125
|
+
|
|
121
126
|
// Distance from the top of the content view to the bottom of the peek view.
|
|
122
127
|
// Includes the peek view's offset within the content (padding, views above it)
|
|
123
128
|
// so the peek detent reveals everything down to the peek content's bottom edge.
|
|
@@ -145,16 +150,15 @@ using namespace facebook::react;
|
|
|
145
150
|
- (void)setScrollableOptions:(ScrollableOptions *)scrollableOptions {
|
|
146
151
|
_scrollableOptions = scrollableOptions;
|
|
147
152
|
_contentView.keyboardScrollOffset = scrollableOptions ? scrollableOptions.keyboardScrollOffset : 0;
|
|
153
|
+
_contentView.keyboardOffset = scrollableOptions ? scrollableOptions.keyboardOffset : 0;
|
|
148
154
|
}
|
|
149
155
|
|
|
150
156
|
- (void)setupScrollable {
|
|
151
157
|
if (_contentView) {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
bottomInset = [WindowUtil keyWindow].safeAreaInsets.bottom;
|
|
155
|
-
}
|
|
158
|
+
_contentView.scrollableHandle = _scrollableHandle;
|
|
159
|
+
_contentView.contentInsetAdjustment = _contentInsetAdjustment;
|
|
156
160
|
_contentView.hasAutoDetent = _hasAutoDetent;
|
|
157
|
-
[_contentView
|
|
161
|
+
[_contentView setupScrollable];
|
|
158
162
|
[_contentView applyScrollEdgeEffects:_scrollableOptions];
|
|
159
163
|
if (@available(iOS 26.0, *)) {
|
|
160
164
|
[self setupEdgeInteractions];
|
|
@@ -32,38 +32,59 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
32
32
|
|
|
33
33
|
@property (nonatomic, weak, nullable) id<TrueSheetContentViewDelegate> delegate;
|
|
34
34
|
@property (nonatomic, assign) CGFloat keyboardScrollOffset;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Adjustment added to the keyboard bottom inset applied to the detected
|
|
38
|
+
* scrollable — negative values reduce the inset (e.g. to cancel out safe-area
|
|
39
|
+
* padding already baked into the content's paddingBottom).
|
|
40
|
+
*/
|
|
41
|
+
@property (nonatomic, assign) CGFloat keyboardOffset;
|
|
42
|
+
|
|
35
43
|
@property (nonatomic, weak, nullable) TrueSheetKeyboardObserver *keyboardObserver;
|
|
36
44
|
|
|
37
45
|
/**
|
|
38
|
-
* Sibling footer view —
|
|
39
|
-
*
|
|
46
|
+
* Sibling footer view — a relative footer shields part of the keyboard's
|
|
47
|
+
* overlap from the inset; an absolute footer extends the caret reveal target.
|
|
40
48
|
*/
|
|
41
49
|
@property (nonatomic, weak, nullable) TrueSheetFooterView *footerView;
|
|
42
50
|
|
|
43
51
|
/**
|
|
44
52
|
* Whether the sheet has an `auto` detent. Deriving the sheet height from the
|
|
45
|
-
* scroll content is circular with natural layout, so the
|
|
53
|
+
* scroll content is circular with natural layout, so the detected ScrollView's
|
|
46
54
|
* viewport is force-bounded to the container only in this case.
|
|
47
55
|
*/
|
|
48
56
|
@property (nonatomic, assign) BOOL hasAutoDetent;
|
|
49
57
|
|
|
50
58
|
/**
|
|
51
|
-
* Content height
|
|
52
|
-
*
|
|
53
|
-
* Falls back to the frame height
|
|
59
|
+
* Content height measured unconstrained by the shadow node — the height the
|
|
60
|
+
* content wants regardless of container bounds (see
|
|
61
|
+
* TrueSheetContentViewShadowNode). Falls back to the frame height before the
|
|
62
|
+
* first state update.
|
|
54
63
|
*/
|
|
55
64
|
@property (nonatomic, readonly) CGFloat naturalHeight;
|
|
56
65
|
|
|
66
|
+
/**
|
|
67
|
+
* React tag of the user-provided scrollable (see the `scrollableRef` prop).
|
|
68
|
+
* Setting a new handle clears the currently resolved ScrollView.
|
|
69
|
+
*/
|
|
70
|
+
@property (nonatomic, assign) NSInteger scrollableHandle;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Sets the resolved ScrollView's `contentInsetAdjustmentBehavior` to
|
|
74
|
+
* `automatic` while plugged so UIKit applies the bottom safe-area inset to
|
|
75
|
+
* the scroll content. The previous behavior is restored on clear.
|
|
76
|
+
*/
|
|
77
|
+
@property (nonatomic, assign) BOOL contentInsetAdjustment;
|
|
78
|
+
|
|
57
79
|
- (RCTScrollViewComponentView *_Nullable)findScrollView;
|
|
58
80
|
|
|
59
81
|
/**
|
|
60
|
-
*
|
|
61
|
-
* @param bottomInset Bottom content inset for the scroll view
|
|
82
|
+
* Resolve the ScrollView from `scrollableHandle`, wiring keyboard handling
|
|
62
83
|
*/
|
|
63
|
-
- (void)
|
|
84
|
+
- (void)setupScrollable;
|
|
64
85
|
|
|
65
86
|
/**
|
|
66
|
-
* Apply scroll edge effects to the
|
|
87
|
+
* Apply scroll edge effects to the detected scroll view (iOS 26+)
|
|
67
88
|
*/
|
|
68
89
|
- (void)applyScrollEdgeEffects:(nullable ScrollableOptions *)options;
|
|
69
90
|
|