@lodev09/react-native-true-sheet 3.0.0-beta.6 → 3.0.0-beta.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.
- package/README.md +1 -0
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetContainerView.kt +51 -99
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetContainerViewManager.kt +0 -7
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetContentView.kt +10 -18
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetFooterView.kt +76 -20
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetHeaderView.kt +38 -0
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetHeaderViewManager.kt +21 -0
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetPackage.kt +1 -0
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetView.kt +106 -136
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewController.kt +305 -419
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewManager.kt +9 -4
- package/android/src/main/java/com/lodev09/truesheet/core/RNScreensFragmentObserver.kt +116 -0
- package/android/src/main/java/com/lodev09/truesheet/utils/ScreenUtils.kt +33 -5
- package/android/src/main/jni/TrueSheetSpec.h +1 -1
- package/common/cpp/react/renderer/components/TrueSheetSpec/{TrueSheetContainerViewComponentDescriptor.h → TrueSheetViewComponentDescriptor.h} +5 -5
- package/common/cpp/react/renderer/components/TrueSheetSpec/{TrueSheetContainerViewShadowNode.cpp → TrueSheetViewShadowNode.cpp} +4 -4
- package/common/cpp/react/renderer/components/TrueSheetSpec/{TrueSheetContainerViewShadowNode.h → TrueSheetViewShadowNode.h} +8 -8
- package/common/cpp/react/renderer/components/TrueSheetSpec/{TrueSheetContainerViewState.cpp → TrueSheetViewState.cpp} +2 -2
- package/common/cpp/react/renderer/components/TrueSheetSpec/{TrueSheetContainerViewState.h → TrueSheetViewState.h} +6 -6
- package/ios/TrueSheetContainerView.h +20 -2
- package/ios/TrueSheetContainerView.mm +62 -62
- package/ios/TrueSheetContentView.h +4 -2
- package/ios/TrueSheetContentView.mm +29 -72
- package/ios/TrueSheetFooterView.mm +2 -2
- package/ios/TrueSheetHeaderView.h +29 -0
- package/ios/TrueSheetHeaderView.mm +60 -0
- package/ios/TrueSheetView.mm +195 -214
- package/ios/TrueSheetViewController.h +2 -2
- package/ios/TrueSheetViewController.mm +126 -231
- package/ios/utils/LayoutUtil.h +2 -1
- package/ios/utils/LayoutUtil.mm +14 -1
- package/lib/module/TrueSheet.js +9 -2
- package/lib/module/TrueSheet.js.map +1 -1
- package/lib/module/fabric/TrueSheetContainerViewNativeComponent.ts +1 -3
- package/lib/module/fabric/TrueSheetHeaderViewNativeComponent.ts +8 -0
- package/lib/module/fabric/TrueSheetViewNativeComponent.ts +3 -1
- package/lib/typescript/src/TrueSheet.d.ts.map +1 -1
- package/lib/typescript/src/TrueSheet.types.d.ts +9 -9
- package/lib/typescript/src/TrueSheet.types.d.ts.map +1 -1
- package/lib/typescript/src/fabric/TrueSheetContainerViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/fabric/TrueSheetHeaderViewNativeComponent.d.ts +6 -0
- package/lib/typescript/src/fabric/TrueSheetHeaderViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/fabric/TrueSheetViewNativeComponent.d.ts.map +1 -1
- package/package.json +6 -3
- package/react-native.config.js +1 -1
- package/src/TrueSheet.tsx +9 -0
- package/src/TrueSheet.types.ts +10 -11
- package/src/fabric/TrueSheetContainerViewNativeComponent.ts +1 -3
- package/src/fabric/TrueSheetHeaderViewNativeComponent.ts +8 -0
- package/src/fabric/TrueSheetViewNativeComponent.ts +3 -1
|
@@ -53,98 +53,55 @@ using namespace facebook::react;
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
- (void)
|
|
56
|
+
- (void)unpinScrollViewFromParentView:(UIView *)parentView {
|
|
57
57
|
// Unpin previous scroll view if exists
|
|
58
58
|
if (_pinnedScrollView) {
|
|
59
|
-
[LayoutUtil unpinView:_pinnedScrollView];
|
|
59
|
+
[LayoutUtil unpinView:_pinnedScrollView fromParentView:parentView];
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
- (void)setupScrollViewPinning:(BOOL)pinned {
|
|
63
|
+
- (void)setupScrollViewPinning:(BOOL)pinned withHeaderView:(UIView *)headerView {
|
|
64
|
+
// Pin to container view (parent of content view)
|
|
65
|
+
UIView *containerView = self.superview;
|
|
66
|
+
|
|
64
67
|
if (!pinned) {
|
|
65
|
-
[self
|
|
68
|
+
[self unpinScrollViewFromParentView:containerView];
|
|
69
|
+
_pinnedScrollView = nil;
|
|
66
70
|
return;
|
|
67
71
|
}
|
|
68
72
|
|
|
69
73
|
// Auto-detect and pin scroll views for proper sheet scrolling behavior
|
|
70
|
-
// Pinning ensures ScrollView fills the
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
[self
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
} else {
|
|
87
|
-
// No top sibling, pin to all edges of container (original behavior)
|
|
88
|
-
[LayoutUtil pinView:scrollView toParentView:containerView edges:UIRectEdgeAll];
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
_pinnedScrollView = scrollView;
|
|
74
|
+
// Pinning ensures ScrollView fills the available area and scrolls correctly with the sheet
|
|
75
|
+
RCTScrollViewComponentView *scrollView = [self findScrollView];
|
|
76
|
+
|
|
77
|
+
if (scrollView && containerView) {
|
|
78
|
+
// Always unpin first to remove old constraints
|
|
79
|
+
[self unpinScrollViewFromParentView:containerView];
|
|
80
|
+
|
|
81
|
+
if (headerView) {
|
|
82
|
+
// Pin ScrollView below the header view
|
|
83
|
+
[LayoutUtil pinView:scrollView
|
|
84
|
+
toParentView:containerView
|
|
85
|
+
withTopView:headerView
|
|
86
|
+
edges:UIRectEdgeLeft | UIRectEdgeRight | UIRectEdgeBottom];
|
|
87
|
+
} else {
|
|
88
|
+
// No header, pin to all edges of container
|
|
89
|
+
[LayoutUtil pinView:scrollView toParentView:containerView edges:UIRectEdgeAll];
|
|
92
90
|
}
|
|
91
|
+
|
|
92
|
+
_pinnedScrollView = scrollView;
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
- (RCTScrollViewComponentView *)findScrollView {
|
|
97
|
-
return [self findScrollView:nil];
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
- (RCTScrollViewComponentView *)findScrollView:(UIView **)outTopSibling {
|
|
101
|
-
if (self.subviews.count == 0) {
|
|
102
|
-
return nil;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
RCTScrollViewComponentView *scrollView = nil;
|
|
106
|
-
UIView *topSibling = nil;
|
|
107
|
-
|
|
108
97
|
// Check first-level children for scroll views (ScrollView or FlatList)
|
|
109
98
|
for (UIView *subview in self.subviews) {
|
|
110
99
|
if ([subview isKindOfClass:RCTScrollViewComponentView.class]) {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
// Find the view positioned directly above this ScrollView by frame position
|
|
114
|
-
if (self.subviews.count > 1) {
|
|
115
|
-
CGFloat scrollViewTop = CGRectGetMinY(scrollView.frame);
|
|
116
|
-
CGFloat closestDistance = CGFLOAT_MAX;
|
|
117
|
-
|
|
118
|
-
for (UIView *sibling in self.subviews) {
|
|
119
|
-
// Skip the ScrollView itself
|
|
120
|
-
if (sibling == scrollView) {
|
|
121
|
-
continue;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
CGFloat siblingBottom = CGRectGetMaxY(sibling.frame);
|
|
125
|
-
|
|
126
|
-
// Check if this sibling is positioned above the ScrollView
|
|
127
|
-
if (siblingBottom <= scrollViewTop) {
|
|
128
|
-
CGFloat distance = scrollViewTop - siblingBottom;
|
|
129
|
-
|
|
130
|
-
// Find the closest view above (smallest distance)
|
|
131
|
-
if (distance < closestDistance) {
|
|
132
|
-
closestDistance = distance;
|
|
133
|
-
topSibling = sibling;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
break; // Found ScrollView, no need to continue
|
|
100
|
+
return (RCTScrollViewComponentView *)subview;
|
|
140
101
|
}
|
|
141
102
|
}
|
|
142
103
|
|
|
143
|
-
|
|
144
|
-
*outTopSibling = topSibling;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
return scrollView;
|
|
104
|
+
return nil;
|
|
148
105
|
}
|
|
149
106
|
|
|
150
107
|
- (void)prepareForRecycle {
|
|
@@ -152,7 +109,7 @@ using namespace facebook::react;
|
|
|
152
109
|
|
|
153
110
|
// Remove scroll view constraints
|
|
154
111
|
if (_pinnedScrollView) {
|
|
155
|
-
[LayoutUtil unpinView:_pinnedScrollView];
|
|
112
|
+
[LayoutUtil unpinView:_pinnedScrollView fromParentView:self.superview];
|
|
156
113
|
_pinnedScrollView = nil;
|
|
157
114
|
}
|
|
158
115
|
}
|
|
@@ -48,7 +48,7 @@ using namespace facebook::react;
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
// Remove existing constraints before applying new ones
|
|
51
|
-
[LayoutUtil unpinView:self];
|
|
51
|
+
[LayoutUtil unpinView:self fromParentView:parentView];
|
|
52
52
|
|
|
53
53
|
// Pin footer to bottom and sides of container with specific height
|
|
54
54
|
[LayoutUtil pinView:self
|
|
@@ -90,7 +90,7 @@ using namespace facebook::react;
|
|
|
90
90
|
[super prepareForRecycle];
|
|
91
91
|
|
|
92
92
|
// Remove footer constraints
|
|
93
|
-
[LayoutUtil unpinView:self];
|
|
93
|
+
[LayoutUtil unpinView:self fromParentView:self.superview];
|
|
94
94
|
|
|
95
95
|
_lastHeight = 0;
|
|
96
96
|
_didInitialLayout = NO;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Created by Jovanni Lo (@lodev09)
|
|
3
|
+
// Copyright (c) 2024-present. All rights reserved.
|
|
4
|
+
//
|
|
5
|
+
// This source code is licensed under the MIT license found in the
|
|
6
|
+
// LICENSE file in the root directory of this source tree.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
10
|
+
|
|
11
|
+
#import <React/RCTViewComponentView.h>
|
|
12
|
+
#import <UIKit/UIKit.h>
|
|
13
|
+
|
|
14
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
15
|
+
|
|
16
|
+
@protocol TrueSheetHeaderViewDelegate <NSObject>
|
|
17
|
+
@optional
|
|
18
|
+
- (void)headerViewDidChangeSize:(CGSize)size;
|
|
19
|
+
@end
|
|
20
|
+
|
|
21
|
+
@interface TrueSheetHeaderView : RCTViewComponentView
|
|
22
|
+
|
|
23
|
+
@property (nonatomic, weak, nullable) id<TrueSheetHeaderViewDelegate> delegate;
|
|
24
|
+
|
|
25
|
+
@end
|
|
26
|
+
|
|
27
|
+
NS_ASSUME_NONNULL_END
|
|
28
|
+
|
|
29
|
+
#endif
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Created by Jovanni Lo (@lodev09)
|
|
3
|
+
// Copyright (c) 2024-present. All rights reserved.
|
|
4
|
+
//
|
|
5
|
+
// This source code is licensed under the MIT license found in the
|
|
6
|
+
// LICENSE file in the root directory of this source tree.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
10
|
+
|
|
11
|
+
#import "TrueSheetHeaderView.h"
|
|
12
|
+
#import <react/renderer/components/TrueSheetSpec/ComponentDescriptors.h>
|
|
13
|
+
#import <react/renderer/components/TrueSheetSpec/EventEmitters.h>
|
|
14
|
+
#import <react/renderer/components/TrueSheetSpec/Props.h>
|
|
15
|
+
#import <react/renderer/components/TrueSheetSpec/RCTComponentViewHelpers.h>
|
|
16
|
+
#import "utils/LayoutUtil.h"
|
|
17
|
+
|
|
18
|
+
using namespace facebook::react;
|
|
19
|
+
|
|
20
|
+
@implementation TrueSheetHeaderView {
|
|
21
|
+
CGSize _lastSize;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
+ (ComponentDescriptorProvider)componentDescriptorProvider {
|
|
25
|
+
return concreteComponentDescriptorProvider<TrueSheetHeaderViewComponentDescriptor>();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
- (instancetype)initWithFrame:(CGRect)frame {
|
|
29
|
+
if (self = [super initWithFrame:frame]) {
|
|
30
|
+
static const auto defaultProps = std::make_shared<const TrueSheetHeaderViewProps>();
|
|
31
|
+
_props = defaultProps;
|
|
32
|
+
|
|
33
|
+
_lastSize = CGSizeZero;
|
|
34
|
+
}
|
|
35
|
+
return self;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
- (void)updateLayoutMetrics:(const facebook::react::LayoutMetrics &)layoutMetrics
|
|
39
|
+
oldLayoutMetrics:(const facebook::react::LayoutMetrics &)oldLayoutMetrics {
|
|
40
|
+
[super updateLayoutMetrics:layoutMetrics oldLayoutMetrics:oldLayoutMetrics];
|
|
41
|
+
|
|
42
|
+
CGSize newSize = CGSizeMake(layoutMetrics.frame.size.width, layoutMetrics.frame.size.height);
|
|
43
|
+
|
|
44
|
+
// Notify delegate when header size changes
|
|
45
|
+
if (!CGSizeEqualToSize(newSize, _lastSize)) {
|
|
46
|
+
_lastSize = newSize;
|
|
47
|
+
if ([self.delegate respondsToSelector:@selector(headerViewDidChangeSize:)]) {
|
|
48
|
+
[self.delegate headerViewDidChangeSize:newSize];
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
- (void)prepareForRecycle {
|
|
54
|
+
[super prepareForRecycle];
|
|
55
|
+
_lastSize = CGSizeZero;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
@end
|
|
59
|
+
|
|
60
|
+
#endif
|