@lodev09/react-native-true-sheet 3.0.0-beta.8 → 3.0.0
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 +13 -6
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetContainerView.kt +29 -33
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetModule.kt +3 -1
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetView.kt +48 -43
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewController.kt +387 -88
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewManager.kt +22 -4
- package/android/src/main/java/com/lodev09/truesheet/core/RNScreensFragmentObserver.kt +0 -5
- package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetDialogObserver.kt +67 -0
- package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetGrabberView.kt +44 -0
- package/android/src/main/java/com/lodev09/truesheet/events/TrueSheetDragEvents.kt +71 -0
- package/android/src/main/java/com/lodev09/truesheet/events/TrueSheetFocusEvents.kt +65 -0
- package/android/src/main/java/com/lodev09/truesheet/events/TrueSheetLifecycleEvents.kt +94 -0
- package/android/src/main/java/com/lodev09/truesheet/events/TrueSheetStateEvents.kt +56 -0
- package/android/src/main/java/com/lodev09/truesheet/utils/ScreenUtils.kt +37 -33
- package/android/src/main/res/anim/true_sheet_slide_in.xml +13 -0
- package/android/src/main/res/anim/true_sheet_slide_out.xml +13 -0
- package/android/src/main/res/values/styles.xml +13 -1
- package/ios/TrueSheetContainerView.mm +4 -0
- package/ios/TrueSheetContentView.h +2 -1
- package/ios/TrueSheetContentView.mm +91 -11
- package/ios/TrueSheetView.mm +65 -41
- package/ios/TrueSheetViewController.h +21 -10
- package/ios/TrueSheetViewController.mm +330 -165
- package/ios/core/TrueSheetBlurView.h +24 -0
- package/ios/{utils/ConversionUtil.mm → core/TrueSheetBlurView.mm} +65 -3
- package/ios/events/TrueSheetDragEvents.h +39 -0
- package/ios/events/TrueSheetDragEvents.mm +62 -0
- package/ios/events/{OnPositionChangeEvent.h → TrueSheetFocusEvents.h} +8 -5
- package/ios/events/TrueSheetFocusEvents.mm +49 -0
- package/ios/events/TrueSheetLifecycleEvents.h +40 -0
- package/ios/events/TrueSheetLifecycleEvents.mm +71 -0
- package/ios/events/TrueSheetStateEvents.h +35 -0
- package/ios/events/TrueSheetStateEvents.mm +49 -0
- package/ios/utils/GestureUtil.h +7 -0
- package/ios/utils/GestureUtil.mm +12 -0
- package/lib/module/TrueSheet.js +65 -12
- package/lib/module/TrueSheet.js.map +1 -1
- package/lib/module/fabric/TrueSheetViewNativeComponent.ts +15 -5
- package/lib/module/index.js +0 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/reanimated/ReanimatedTrueSheet.js +13 -7
- package/lib/module/reanimated/ReanimatedTrueSheet.js.map +1 -1
- package/lib/module/reanimated/ReanimatedTrueSheetProvider.js +4 -2
- package/lib/module/reanimated/ReanimatedTrueSheetProvider.js.map +1 -1
- 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 +58 -6
- package/lib/typescript/src/TrueSheet.types.d.ts.map +1 -1
- package/lib/typescript/src/fabric/TrueSheetViewNativeComponent.d.ts +14 -5
- package/lib/typescript/src/fabric/TrueSheetViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +0 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/reanimated/ReanimatedTrueSheet.d.ts.map +1 -1
- package/lib/typescript/src/reanimated/ReanimatedTrueSheetProvider.d.ts +8 -2
- package/lib/typescript/src/reanimated/ReanimatedTrueSheetProvider.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/TrueSheet.tsx +80 -10
- package/src/TrueSheet.types.ts +65 -6
- package/src/__mocks__/index.js +0 -5
- package/src/fabric/TrueSheetViewNativeComponent.ts +15 -5
- package/src/index.ts +0 -1
- package/src/reanimated/ReanimatedTrueSheet.tsx +12 -7
- package/src/reanimated/ReanimatedTrueSheetProvider.tsx +11 -3
- package/android/src/main/java/com/lodev09/truesheet/events/DetentChangeEvent.kt +0 -26
- package/android/src/main/java/com/lodev09/truesheet/events/DidDismissEvent.kt +0 -20
- package/android/src/main/java/com/lodev09/truesheet/events/DidPresentEvent.kt +0 -26
- package/android/src/main/java/com/lodev09/truesheet/events/DragBeginEvent.kt +0 -26
- package/android/src/main/java/com/lodev09/truesheet/events/DragChangeEvent.kt +0 -26
- package/android/src/main/java/com/lodev09/truesheet/events/DragEndEvent.kt +0 -26
- package/android/src/main/java/com/lodev09/truesheet/events/MountEvent.kt +0 -20
- package/android/src/main/java/com/lodev09/truesheet/events/PositionChangeEvent.kt +0 -32
- package/android/src/main/java/com/lodev09/truesheet/events/WillDismissEvent.kt +0 -20
- package/android/src/main/java/com/lodev09/truesheet/events/WillPresentEvent.kt +0 -26
- package/ios/events/OnDetentChangeEvent.h +0 -28
- package/ios/events/OnDetentChangeEvent.mm +0 -30
- package/ios/events/OnDidDismissEvent.h +0 -26
- package/ios/events/OnDidDismissEvent.mm +0 -25
- package/ios/events/OnDidPresentEvent.h +0 -28
- package/ios/events/OnDidPresentEvent.mm +0 -30
- package/ios/events/OnDragBeginEvent.h +0 -28
- package/ios/events/OnDragBeginEvent.mm +0 -30
- package/ios/events/OnDragChangeEvent.h +0 -28
- package/ios/events/OnDragChangeEvent.mm +0 -30
- package/ios/events/OnDragEndEvent.h +0 -28
- package/ios/events/OnDragEndEvent.mm +0 -30
- package/ios/events/OnMountEvent.h +0 -26
- package/ios/events/OnMountEvent.mm +0 -25
- package/ios/events/OnPositionChangeEvent.mm +0 -32
- package/ios/events/OnWillDismissEvent.h +0 -26
- package/ios/events/OnWillDismissEvent.mm +0 -25
- package/ios/events/OnWillPresentEvent.h +0 -28
- package/ios/events/OnWillPresentEvent.mm +0 -30
- package/ios/utils/ConversionUtil.h +0 -24
- package/lib/module/TrueSheetGrabber.js +0 -51
- package/lib/module/TrueSheetGrabber.js.map +0 -1
- package/lib/typescript/src/TrueSheetGrabber.d.ts +0 -39
- package/lib/typescript/src/TrueSheetGrabber.d.ts.map +0 -1
- package/src/TrueSheetGrabber.tsx +0 -82
|
@@ -21,6 +21,7 @@ using namespace facebook::react;
|
|
|
21
21
|
|
|
22
22
|
@implementation TrueSheetContentView {
|
|
23
23
|
RCTScrollViewComponentView *_pinnedScrollView;
|
|
24
|
+
UIView *_pinnedTopView;
|
|
24
25
|
CGSize _lastSize;
|
|
25
26
|
}
|
|
26
27
|
|
|
@@ -34,6 +35,7 @@ using namespace facebook::react;
|
|
|
34
35
|
_props = defaultProps;
|
|
35
36
|
|
|
36
37
|
_pinnedScrollView = nil;
|
|
38
|
+
_pinnedTopView = nil;
|
|
37
39
|
_lastSize = CGSizeZero;
|
|
38
40
|
}
|
|
39
41
|
return self;
|
|
@@ -53,6 +55,22 @@ using namespace facebook::react;
|
|
|
53
55
|
}
|
|
54
56
|
}
|
|
55
57
|
|
|
58
|
+
- (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index {
|
|
59
|
+
[super mountChildComponentView:childComponentView index:index];
|
|
60
|
+
|
|
61
|
+
if ([self.delegate respondsToSelector:@selector(contentViewDidChangeChildren)]) {
|
|
62
|
+
[self.delegate contentViewDidChangeChildren];
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
- (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index {
|
|
67
|
+
[super unmountChildComponentView:childComponentView index:index];
|
|
68
|
+
|
|
69
|
+
if ([self.delegate respondsToSelector:@selector(contentViewDidChangeChildren)]) {
|
|
70
|
+
[self.delegate contentViewDidChangeChildren];
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
56
74
|
- (void)unpinScrollViewFromParentView:(UIView *)parentView {
|
|
57
75
|
// Unpin previous scroll view if exists
|
|
58
76
|
if (_pinnedScrollView) {
|
|
@@ -67,43 +85,104 @@ using namespace facebook::react;
|
|
|
67
85
|
if (!pinned) {
|
|
68
86
|
[self unpinScrollViewFromParentView:containerView];
|
|
69
87
|
_pinnedScrollView = nil;
|
|
88
|
+
_pinnedTopView = nil;
|
|
70
89
|
return;
|
|
71
90
|
}
|
|
72
91
|
|
|
73
92
|
// Auto-detect and pin scroll views for proper sheet scrolling behavior
|
|
74
93
|
// Pinning ensures ScrollView fills the available area and scrolls correctly with the sheet
|
|
75
|
-
|
|
94
|
+
UIView *topSibling = nil;
|
|
95
|
+
RCTScrollViewComponentView *scrollView = [self findScrollView:&topSibling];
|
|
96
|
+
|
|
97
|
+
// Use closest top sibling if found, otherwise fall back to header view
|
|
98
|
+
UIView *topView = topSibling ?: headerView;
|
|
76
99
|
|
|
77
|
-
|
|
78
|
-
|
|
100
|
+
// Re-pin when scroll view or top view changes
|
|
101
|
+
BOOL scrollViewChanged = scrollView != _pinnedScrollView;
|
|
102
|
+
BOOL topViewChanged = topView != _pinnedTopView;
|
|
103
|
+
|
|
104
|
+
if (scrollView && containerView && (scrollViewChanged || topViewChanged)) {
|
|
105
|
+
// Unpin first to remove old constraints
|
|
79
106
|
[self unpinScrollViewFromParentView:containerView];
|
|
80
107
|
|
|
81
|
-
if (
|
|
82
|
-
// Pin ScrollView below the
|
|
108
|
+
if (topView) {
|
|
109
|
+
// Pin ScrollView below the top view
|
|
83
110
|
[LayoutUtil pinView:scrollView
|
|
84
111
|
toParentView:containerView
|
|
85
|
-
withTopView:
|
|
112
|
+
withTopView:topView
|
|
86
113
|
edges:UIRectEdgeLeft | UIRectEdgeRight | UIRectEdgeBottom];
|
|
87
114
|
} else {
|
|
88
|
-
// No
|
|
115
|
+
// No top view, pin to all edges of container
|
|
89
116
|
[LayoutUtil pinView:scrollView toParentView:containerView edges:UIRectEdgeAll];
|
|
90
117
|
}
|
|
91
118
|
|
|
92
119
|
_pinnedScrollView = scrollView;
|
|
120
|
+
_pinnedTopView = topView;
|
|
121
|
+
} else if (!scrollView && _pinnedScrollView) {
|
|
122
|
+
// ScrollView was removed, clean up
|
|
123
|
+
[self unpinScrollViewFromParentView:containerView];
|
|
124
|
+
_pinnedScrollView = nil;
|
|
125
|
+
_pinnedTopView = nil;
|
|
93
126
|
}
|
|
94
127
|
}
|
|
95
128
|
|
|
96
|
-
- (RCTScrollViewComponentView *)
|
|
97
|
-
|
|
98
|
-
for (UIView *subview in self.subviews) {
|
|
129
|
+
- (RCTScrollViewComponentView *)findScrollViewInSubviews:(NSArray<UIView *> *)subviews {
|
|
130
|
+
for (UIView *subview in subviews) {
|
|
99
131
|
if ([subview isKindOfClass:RCTScrollViewComponentView.class]) {
|
|
100
132
|
return (RCTScrollViewComponentView *)subview;
|
|
101
133
|
}
|
|
102
134
|
}
|
|
103
|
-
|
|
104
135
|
return nil;
|
|
105
136
|
}
|
|
106
137
|
|
|
138
|
+
- (RCTScrollViewComponentView *)findScrollView:(UIView **)outTopSibling {
|
|
139
|
+
if (self.subviews.count == 0) {
|
|
140
|
+
return nil;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
UIView *topSibling = nil;
|
|
144
|
+
|
|
145
|
+
// Check first-level children for scroll views (ScrollView or FlatList)
|
|
146
|
+
RCTScrollViewComponentView *scrollView = [self findScrollViewInSubviews:self.subviews];
|
|
147
|
+
|
|
148
|
+
// If not found, check second level (grandchildren)
|
|
149
|
+
if (!scrollView) {
|
|
150
|
+
for (UIView *subview in self.subviews) {
|
|
151
|
+
scrollView = [self findScrollViewInSubviews:subview.subviews];
|
|
152
|
+
if (scrollView) {
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Find the view positioned directly above the ScrollView (only for first-level)
|
|
159
|
+
if (scrollView && scrollView.superview == self && self.subviews.count > 1) {
|
|
160
|
+
CGFloat scrollViewTop = CGRectGetMinY(scrollView.frame);
|
|
161
|
+
CGFloat closestDistance = CGFLOAT_MAX;
|
|
162
|
+
|
|
163
|
+
for (UIView *sibling in self.subviews) {
|
|
164
|
+
if (sibling == scrollView) {
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
CGFloat siblingBottom = CGRectGetMaxY(sibling.frame);
|
|
169
|
+
if (siblingBottom <= scrollViewTop) {
|
|
170
|
+
CGFloat distance = scrollViewTop - siblingBottom;
|
|
171
|
+
if (distance < closestDistance) {
|
|
172
|
+
closestDistance = distance;
|
|
173
|
+
topSibling = sibling;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
if (outTopSibling) {
|
|
180
|
+
*outTopSibling = topSibling;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return scrollView;
|
|
184
|
+
}
|
|
185
|
+
|
|
107
186
|
- (void)prepareForRecycle {
|
|
108
187
|
[super prepareForRecycle];
|
|
109
188
|
|
|
@@ -111,6 +190,7 @@ using namespace facebook::react;
|
|
|
111
190
|
if (_pinnedScrollView) {
|
|
112
191
|
[LayoutUtil unpinView:_pinnedScrollView fromParentView:self.superview];
|
|
113
192
|
_pinnedScrollView = nil;
|
|
193
|
+
_pinnedTopView = nil;
|
|
114
194
|
}
|
|
115
195
|
}
|
|
116
196
|
|
package/ios/TrueSheetView.mm
CHANGED
|
@@ -14,16 +14,10 @@
|
|
|
14
14
|
#import "TrueSheetFooterView.h"
|
|
15
15
|
#import "TrueSheetModule.h"
|
|
16
16
|
#import "TrueSheetViewController.h"
|
|
17
|
-
#import "events/
|
|
18
|
-
#import "events/
|
|
19
|
-
#import "events/
|
|
20
|
-
#import "events/
|
|
21
|
-
#import "events/OnDragChangeEvent.h"
|
|
22
|
-
#import "events/OnDragEndEvent.h"
|
|
23
|
-
#import "events/OnMountEvent.h"
|
|
24
|
-
#import "events/OnPositionChangeEvent.h"
|
|
25
|
-
#import "events/OnWillDismissEvent.h"
|
|
26
|
-
#import "events/OnWillPresentEvent.h"
|
|
17
|
+
#import "events/TrueSheetDragEvents.h"
|
|
18
|
+
#import "events/TrueSheetFocusEvents.h"
|
|
19
|
+
#import "events/TrueSheetLifecycleEvents.h"
|
|
20
|
+
#import "events/TrueSheetStateEvents.h"
|
|
27
21
|
#import "utils/LayoutUtil.h"
|
|
28
22
|
#import "utils/WindowUtil.h"
|
|
29
23
|
|
|
@@ -53,7 +47,7 @@ using namespace facebook::react;
|
|
|
53
47
|
TrueSheetViewShadowNode::ConcreteState::Shared _state;
|
|
54
48
|
CGSize _lastStateSize;
|
|
55
49
|
NSInteger _initialDetentIndex;
|
|
56
|
-
BOOL
|
|
50
|
+
BOOL _scrollable;
|
|
57
51
|
BOOL _initialDetentAnimated;
|
|
58
52
|
BOOL _isSheetUpdatePending;
|
|
59
53
|
}
|
|
@@ -73,7 +67,7 @@ using namespace facebook::react;
|
|
|
73
67
|
_lastStateSize = CGSizeZero;
|
|
74
68
|
_initialDetentIndex = -1;
|
|
75
69
|
_initialDetentAnimated = YES;
|
|
76
|
-
|
|
70
|
+
_scrollable = NO;
|
|
77
71
|
_isSheetUpdatePending = NO;
|
|
78
72
|
}
|
|
79
73
|
return self;
|
|
@@ -127,6 +121,12 @@ using namespace facebook::react;
|
|
|
127
121
|
// Blur tint
|
|
128
122
|
_controller.blurTint = !newProps.blurTint.empty() ? RCTNSStringFromString(newProps.blurTint) : nil;
|
|
129
123
|
|
|
124
|
+
// Blur intensity (-1 means use system default)
|
|
125
|
+
_controller.blurIntensity = newProps.blurIntensity >= 0 ? @(newProps.blurIntensity) : nil;
|
|
126
|
+
|
|
127
|
+
// Blur interaction
|
|
128
|
+
_controller.blurInteraction = newProps.blurInteraction;
|
|
129
|
+
|
|
130
130
|
// Corner radius
|
|
131
131
|
_controller.cornerRadius = newProps.cornerRadius < 0 ? nil : @(newProps.cornerRadius);
|
|
132
132
|
|
|
@@ -138,6 +138,7 @@ using namespace facebook::react;
|
|
|
138
138
|
_controller.grabber = newProps.grabber;
|
|
139
139
|
_controller.pageSizing = newProps.pageSizing;
|
|
140
140
|
_controller.modalInPresentation = !newProps.dismissible;
|
|
141
|
+
_controller.draggable = newProps.draggable;
|
|
141
142
|
_controller.dimmed = newProps.dimmed;
|
|
142
143
|
|
|
143
144
|
if (newProps.dimmedDetentIndex >= 0) {
|
|
@@ -146,10 +147,10 @@ using namespace facebook::react;
|
|
|
146
147
|
|
|
147
148
|
_initialDetentIndex = newProps.initialDetentIndex;
|
|
148
149
|
_initialDetentAnimated = newProps.initialDetentAnimated;
|
|
149
|
-
|
|
150
|
+
_scrollable = newProps.scrollable;
|
|
150
151
|
|
|
151
152
|
if (_containerView) {
|
|
152
|
-
_containerView.scrollViewPinningEnabled =
|
|
153
|
+
_containerView.scrollViewPinningEnabled = _scrollable;
|
|
153
154
|
}
|
|
154
155
|
}
|
|
155
156
|
|
|
@@ -193,6 +194,7 @@ using namespace facebook::react;
|
|
|
193
194
|
[self->_controller setupSheetDetents];
|
|
194
195
|
[self->_controller applyActiveDetent];
|
|
195
196
|
}];
|
|
197
|
+
[_controller updateDraggable];
|
|
196
198
|
} else if (_initialDetentIndex >= 0) {
|
|
197
199
|
[self presentAtIndex:_initialDetentIndex animated:_initialDetentAnimated completion:nil];
|
|
198
200
|
}
|
|
@@ -239,10 +241,10 @@ using namespace facebook::react;
|
|
|
239
241
|
_controller.headerHeight = @(headerHeight);
|
|
240
242
|
}
|
|
241
243
|
|
|
242
|
-
_containerView.scrollViewPinningEnabled =
|
|
244
|
+
_containerView.scrollViewPinningEnabled = _scrollable;
|
|
243
245
|
[_containerView setupContentScrollViewPinning];
|
|
244
246
|
|
|
245
|
-
[
|
|
247
|
+
[TrueSheetLifecycleEvents emitMount:_eventEmitter];
|
|
246
248
|
}
|
|
247
249
|
|
|
248
250
|
- (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index {
|
|
@@ -265,9 +267,14 @@ using namespace facebook::react;
|
|
|
265
267
|
- (void)presentAtIndex:(NSInteger)index
|
|
266
268
|
animated:(BOOL)animated
|
|
267
269
|
completion:(nullable TrueSheetCompletionBlock)completion {
|
|
270
|
+
if (_controller.isBeingPresented) {
|
|
271
|
+
RCTLogWarn(@"TrueSheet: sheet is being presented. Wait for it to transition before presenting again.");
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
|
|
268
275
|
if (_controller.isPresented) {
|
|
269
276
|
[_controller.sheetPresentationController animateChanges:^{
|
|
270
|
-
[self->_controller
|
|
277
|
+
[self->_controller resizeToDetentIndex:index];
|
|
271
278
|
}];
|
|
272
279
|
if (completion) {
|
|
273
280
|
completion(YES, nil);
|
|
@@ -300,6 +307,11 @@ using namespace facebook::react;
|
|
|
300
307
|
}
|
|
301
308
|
|
|
302
309
|
- (void)dismissAnimated:(BOOL)animated completion:(nullable TrueSheetCompletionBlock)completion {
|
|
310
|
+
if (_controller.isBeingDismissed) {
|
|
311
|
+
RCTLogWarn(@"TrueSheet: sheet is being dismissed. No need to dismiss it again.");
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
|
|
303
315
|
if (!_controller.isPresented) {
|
|
304
316
|
if (completion) {
|
|
305
317
|
completion(YES, nil);
|
|
@@ -315,14 +327,6 @@ using namespace facebook::react;
|
|
|
315
327
|
}];
|
|
316
328
|
}
|
|
317
329
|
|
|
318
|
-
- (void)resizeToIndex:(NSInteger)index {
|
|
319
|
-
if (_controller.isPresented) {
|
|
320
|
-
[_controller.sheetPresentationController animateChanges:^{
|
|
321
|
-
[self->_controller setupActiveDetentWithIndex:index];
|
|
322
|
-
}];
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
|
|
326
330
|
#pragma mark - TrueSheetContainerViewDelegate
|
|
327
331
|
|
|
328
332
|
/**
|
|
@@ -336,7 +340,6 @@ using namespace facebook::react;
|
|
|
336
340
|
|
|
337
341
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
338
342
|
self->_isSheetUpdatePending = NO;
|
|
339
|
-
self->_controller.layoutTransitioning = YES;
|
|
340
343
|
|
|
341
344
|
[self->_controller.sheetPresentationController animateChanges:^{
|
|
342
345
|
[self->_controller setupSheetDetents];
|
|
@@ -356,27 +359,29 @@ using namespace facebook::react;
|
|
|
356
359
|
|
|
357
360
|
#pragma mark - TrueSheetViewControllerDelegate
|
|
358
361
|
|
|
359
|
-
- (void)
|
|
360
|
-
NSInteger index = [_controller currentDetentIndex];
|
|
362
|
+
- (void)viewControllerWillPresentAtIndex:(NSInteger)index position:(CGFloat)position detent:(CGFloat)detent {
|
|
361
363
|
_controller.activeDetentIndex = index;
|
|
362
|
-
[
|
|
364
|
+
[TrueSheetLifecycleEvents emitWillPresent:_eventEmitter index:index position:position detent:detent];
|
|
363
365
|
}
|
|
364
366
|
|
|
365
|
-
- (void)
|
|
366
|
-
[
|
|
367
|
+
- (void)viewControllerDidPresentAtIndex:(NSInteger)index position:(CGFloat)position detent:(CGFloat)detent {
|
|
368
|
+
[TrueSheetLifecycleEvents emitDidPresent:_eventEmitter index:index position:position detent:detent];
|
|
367
369
|
}
|
|
368
370
|
|
|
369
|
-
- (void)viewControllerDidDrag:(UIGestureRecognizerState)state
|
|
371
|
+
- (void)viewControllerDidDrag:(UIGestureRecognizerState)state
|
|
372
|
+
index:(NSInteger)index
|
|
373
|
+
position:(CGFloat)position
|
|
374
|
+
detent:(CGFloat)detent {
|
|
370
375
|
switch (state) {
|
|
371
376
|
case UIGestureRecognizerStateBegan:
|
|
372
|
-
[
|
|
377
|
+
[TrueSheetDragEvents emitDragBegin:_eventEmitter index:index position:position detent:detent];
|
|
373
378
|
break;
|
|
374
379
|
case UIGestureRecognizerStateChanged:
|
|
375
|
-
[
|
|
380
|
+
[TrueSheetDragEvents emitDragChange:_eventEmitter index:index position:position detent:detent];
|
|
376
381
|
break;
|
|
377
382
|
case UIGestureRecognizerStateEnded:
|
|
378
383
|
case UIGestureRecognizerStateCancelled:
|
|
379
|
-
[
|
|
384
|
+
[TrueSheetDragEvents emitDragEnd:_eventEmitter index:index position:position detent:detent];
|
|
380
385
|
break;
|
|
381
386
|
default:
|
|
382
387
|
break;
|
|
@@ -384,29 +389,48 @@ using namespace facebook::react;
|
|
|
384
389
|
}
|
|
385
390
|
|
|
386
391
|
- (void)viewControllerWillDismiss {
|
|
387
|
-
[
|
|
392
|
+
[TrueSheetLifecycleEvents emitWillDismiss:_eventEmitter];
|
|
388
393
|
}
|
|
389
394
|
|
|
390
395
|
- (void)viewControllerDidDismiss {
|
|
391
396
|
_controller.activeDetentIndex = -1;
|
|
392
|
-
[
|
|
397
|
+
[TrueSheetLifecycleEvents emitDidDismiss:_eventEmitter];
|
|
393
398
|
}
|
|
394
399
|
|
|
395
|
-
- (void)viewControllerDidChangeDetent:(NSInteger)index position:(CGFloat)position {
|
|
400
|
+
- (void)viewControllerDidChangeDetent:(NSInteger)index position:(CGFloat)position detent:(CGFloat)detent {
|
|
396
401
|
if (_controller.activeDetentIndex != index) {
|
|
397
402
|
_controller.activeDetentIndex = index;
|
|
398
403
|
}
|
|
399
|
-
[
|
|
404
|
+
[TrueSheetStateEvents emitDetentChange:_eventEmitter index:index position:position detent:detent];
|
|
400
405
|
}
|
|
401
406
|
|
|
402
|
-
- (void)viewControllerDidChangePosition:(
|
|
403
|
-
|
|
407
|
+
- (void)viewControllerDidChangePosition:(CGFloat)index
|
|
408
|
+
position:(CGFloat)position
|
|
409
|
+
detent:(CGFloat)detent
|
|
410
|
+
realtime:(BOOL)realtime {
|
|
411
|
+
[TrueSheetStateEvents emitPositionChange:_eventEmitter index:index position:position detent:detent realtime:realtime];
|
|
404
412
|
}
|
|
405
413
|
|
|
406
414
|
- (void)viewControllerDidChangeSize:(CGSize)size {
|
|
407
415
|
[self updateStateWithSize:size];
|
|
408
416
|
}
|
|
409
417
|
|
|
418
|
+
- (void)viewControllerWillFocus {
|
|
419
|
+
[TrueSheetFocusEvents emitWillFocus:_eventEmitter];
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
- (void)viewControllerDidFocus {
|
|
423
|
+
[TrueSheetFocusEvents emitDidFocus:_eventEmitter];
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
- (void)viewControllerWillBlur {
|
|
427
|
+
[TrueSheetFocusEvents emitWillBlur:_eventEmitter];
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
- (void)viewControllerDidBlur {
|
|
431
|
+
[TrueSheetFocusEvents emitDidBlur:_eventEmitter];
|
|
432
|
+
}
|
|
433
|
+
|
|
410
434
|
#pragma mark - Private Helpers
|
|
411
435
|
|
|
412
436
|
- (UIViewController *)findPresentingViewController {
|
|
@@ -19,14 +19,24 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
19
19
|
|
|
20
20
|
@protocol TrueSheetViewControllerDelegate <NSObject>
|
|
21
21
|
|
|
22
|
-
- (void)
|
|
23
|
-
- (void)
|
|
22
|
+
- (void)viewControllerWillPresentAtIndex:(NSInteger)index position:(CGFloat)position detent:(CGFloat)detent;
|
|
23
|
+
- (void)viewControllerDidPresentAtIndex:(NSInteger)index position:(CGFloat)position detent:(CGFloat)detent;
|
|
24
24
|
- (void)viewControllerWillDismiss;
|
|
25
25
|
- (void)viewControllerDidDismiss;
|
|
26
|
-
- (void)viewControllerDidChangeDetent:(NSInteger)index position:(CGFloat)position;
|
|
27
|
-
- (void)viewControllerDidDrag:(UIGestureRecognizerState)state
|
|
28
|
-
|
|
26
|
+
- (void)viewControllerDidChangeDetent:(NSInteger)index position:(CGFloat)position detent:(CGFloat)detent;
|
|
27
|
+
- (void)viewControllerDidDrag:(UIGestureRecognizerState)state
|
|
28
|
+
index:(NSInteger)index
|
|
29
|
+
position:(CGFloat)position
|
|
30
|
+
detent:(CGFloat)detent;
|
|
31
|
+
- (void)viewControllerDidChangePosition:(CGFloat)index
|
|
32
|
+
position:(CGFloat)position
|
|
33
|
+
detent:(CGFloat)detent
|
|
34
|
+
realtime:(BOOL)realtime;
|
|
29
35
|
- (void)viewControllerDidChangeSize:(CGSize)size;
|
|
36
|
+
- (void)viewControllerWillFocus;
|
|
37
|
+
- (void)viewControllerDidFocus;
|
|
38
|
+
- (void)viewControllerWillBlur;
|
|
39
|
+
- (void)viewControllerDidBlur;
|
|
30
40
|
|
|
31
41
|
@end
|
|
32
42
|
|
|
@@ -38,28 +48,29 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
38
48
|
>
|
|
39
49
|
|
|
40
50
|
@property (nonatomic, weak, nullable) id<TrueSheetViewControllerDelegate> delegate;
|
|
41
|
-
@property (nonatomic, strong) NSArray *detents;
|
|
51
|
+
@property (nonatomic, strong) NSArray<NSNumber *> *detents;
|
|
42
52
|
@property (nonatomic, strong, nullable) NSNumber *maxHeight;
|
|
43
53
|
@property (nonatomic, strong, nullable) NSNumber *contentHeight;
|
|
44
54
|
@property (nonatomic, strong, nullable) NSNumber *headerHeight;
|
|
45
55
|
@property (nonatomic, strong, nullable) UIColor *backgroundColor;
|
|
46
56
|
@property (nonatomic, strong, nullable) NSNumber *cornerRadius;
|
|
47
57
|
@property (nonatomic, assign) BOOL grabber;
|
|
58
|
+
@property (nonatomic, assign) BOOL draggable;
|
|
48
59
|
@property (nonatomic, assign) BOOL dimmed;
|
|
49
60
|
@property (nonatomic, strong, nullable) NSNumber *dimmedDetentIndex;
|
|
50
61
|
@property (nonatomic, copy, nullable) NSString *blurTint;
|
|
62
|
+
@property (nonatomic, strong, nullable) NSNumber *blurIntensity;
|
|
63
|
+
@property (nonatomic, assign) BOOL blurInteraction;
|
|
51
64
|
@property (nonatomic, assign) BOOL pageSizing;
|
|
52
|
-
@property (nonatomic, assign) BOOL layoutTransitioning;
|
|
53
65
|
@property (nonatomic, assign) BOOL isPresented;
|
|
54
66
|
@property (nonatomic, assign) NSInteger activeDetentIndex;
|
|
55
67
|
|
|
56
68
|
- (void)applyActiveDetent;
|
|
57
69
|
- (void)setupActiveDetentWithIndex:(NSInteger)index;
|
|
70
|
+
- (void)resizeToDetentIndex:(NSInteger)index;
|
|
58
71
|
- (void)setupSheetDetents;
|
|
59
72
|
- (void)setupSheetProps;
|
|
60
|
-
- (
|
|
61
|
-
- (CGFloat)currentPosition;
|
|
62
|
-
- (CGFloat)bottomInset;
|
|
73
|
+
- (void)updateDraggable;
|
|
63
74
|
|
|
64
75
|
@end
|
|
65
76
|
|