@sdcx/bottom-sheet 0.14.0 → 0.15.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.
|
@@ -22,10 +22,13 @@
|
|
|
22
22
|
@property(nonatomic, strong) CADisplayLink *displayLink;
|
|
23
23
|
@property(nonatomic, strong) RCTEventDispatcher *eventDispatcher;
|
|
24
24
|
|
|
25
|
+
@property(nonatomic, assign) RNBottomSheetState finalState;
|
|
26
|
+
|
|
25
27
|
@end
|
|
26
28
|
|
|
27
29
|
@implementation RNBottomSheet {
|
|
28
30
|
__weak RCTRootContentView *_rootView;
|
|
31
|
+
BOOL _isInitialRender;
|
|
29
32
|
}
|
|
30
33
|
|
|
31
34
|
- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher {
|
|
@@ -33,7 +36,9 @@
|
|
|
33
36
|
_panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)];
|
|
34
37
|
_panGestureRecognizer.delegate = self;
|
|
35
38
|
_state = RNBottomSheetStateCollapsed;
|
|
39
|
+
_finalState = RNBottomSheetStateCollapsed;
|
|
36
40
|
_eventDispatcher = eventDispatcher;
|
|
41
|
+
_isInitialRender = YES;
|
|
37
42
|
}
|
|
38
43
|
return self;
|
|
39
44
|
}
|
|
@@ -162,6 +167,14 @@
|
|
|
162
167
|
}
|
|
163
168
|
[self dispatchOnSlide:self.contentView.frame.origin.y];
|
|
164
169
|
}
|
|
170
|
+
|
|
171
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
172
|
+
if (self.finalState == RNBottomSheetStateExpanded && self->_isInitialRender) {
|
|
173
|
+
[self settleToState:self.finalState withFling:YES];
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
self->_isInitialRender = NO;
|
|
177
|
+
});
|
|
165
178
|
}
|
|
166
179
|
|
|
167
180
|
- (void)calculateOffset {
|
|
@@ -171,7 +184,7 @@
|
|
|
171
184
|
}
|
|
172
185
|
|
|
173
186
|
- (void)handlePan:(UIPanGestureRecognizer *)pan {
|
|
174
|
-
if (!self.draggable) {
|
|
187
|
+
if (!self.draggable || self.state == RNBottomSheetStateSettling) {
|
|
175
188
|
return;
|
|
176
189
|
}
|
|
177
190
|
|
|
@@ -292,20 +305,17 @@
|
|
|
292
305
|
}
|
|
293
306
|
|
|
294
307
|
- (void)setState:(RNBottomSheetState)state {
|
|
295
|
-
if (
|
|
296
|
-
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
if (self.state == RNBottomSheetStateSettling) {
|
|
300
|
-
[self.layer removeAllAnimations];
|
|
308
|
+
if (_isInitialRender) {
|
|
309
|
+
self.finalState = state;
|
|
301
310
|
return;
|
|
302
311
|
}
|
|
303
312
|
|
|
304
|
-
if (
|
|
305
|
-
[self setStateInternal:state];
|
|
313
|
+
if (self.finalState == state) {
|
|
306
314
|
return;
|
|
307
315
|
}
|
|
308
316
|
|
|
317
|
+
self.finalState = state;
|
|
318
|
+
|
|
309
319
|
[self settleToState:state withFling:YES];
|
|
310
320
|
}
|
|
311
321
|
|