@lodev09/react-native-true-sheet 4.0.0-beta.3 → 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 +50 -7
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewController.kt +101 -18
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewManager.kt +24 -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/ios/TrueSheetContainerView.h +13 -5
- package/ios/TrueSheetContainerView.mm +6 -6
- package/ios/TrueSheetContentView.h +31 -10
- package/ios/TrueSheetContentView.mm +137 -162
- package/ios/TrueSheetFooterView.mm +17 -0
- package/ios/TrueSheetView.mm +13 -4
- package/ios/utils/UIView+ScrollEdgeInteraction.h +1 -0
- package/ios/utils/UIView+ScrollEdgeInteraction.mm +24 -2
- package/lib/module/TrueSheet.js +37 -9
- 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 +2 -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 +34 -8
- 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
|
@@ -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;
|
|
@@ -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;
|
|
@@ -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;
|
|
@@ -149,16 +150,15 @@ using namespace facebook::react;
|
|
|
149
150
|
- (void)setScrollableOptions:(ScrollableOptions *)scrollableOptions {
|
|
150
151
|
_scrollableOptions = scrollableOptions;
|
|
151
152
|
_contentView.keyboardScrollOffset = scrollableOptions ? scrollableOptions.keyboardScrollOffset : 0;
|
|
153
|
+
_contentView.keyboardOffset = scrollableOptions ? scrollableOptions.keyboardOffset : 0;
|
|
152
154
|
}
|
|
153
155
|
|
|
154
156
|
- (void)setupScrollable {
|
|
155
157
|
if (_contentView) {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
bottomInset = [WindowUtil keyWindow].safeAreaInsets.bottom;
|
|
159
|
-
}
|
|
158
|
+
_contentView.scrollableHandle = _scrollableHandle;
|
|
159
|
+
_contentView.contentInsetAdjustment = _contentInsetAdjustment;
|
|
160
160
|
_contentView.hasAutoDetent = _hasAutoDetent;
|
|
161
|
-
[_contentView
|
|
161
|
+
[_contentView setupScrollable];
|
|
162
162
|
[_contentView applyScrollEdgeEffects:_scrollableOptions];
|
|
163
163
|
if (@available(iOS 26.0, *)) {
|
|
164
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
|
|