@@ -36,14 +36,14 @@ export const scrollViewProperty = new Property<PersistentBottomSheet, string>({
36
36
name : 'scrollViewId' ,
37
37
defaultValue : undefined ,
38
38
valueChanged : ( target , oldValue , newValue ) => {
39
- target . _onScrollViewIdChanged ( oldValue , newValue ) ;
39
+ ( target as any ) . _onScrollViewIdChanged ( oldValue , newValue ) ;
40
40
} ,
41
41
} ) ;
42
42
export const bottomSheetProperty = new Property < PersistentBottomSheet , View > ( {
43
43
name : 'bottomSheet' ,
44
44
defaultValue : undefined ,
45
45
valueChanged : ( target , oldValue , newValue ) => {
46
- target . _onBottomSheetChanged ( oldValue , newValue ) ;
46
+ ( target as any ) . _onBottomSheetChanged ( oldValue , newValue ) ;
47
47
} ,
48
48
} ) ;
49
49
export const gestureEnabledProperty = new Property < PersistentBottomSheet , boolean > ( {
@@ -75,7 +75,30 @@ export class PersistentBottomSheet extends GridLayout {
75
75
// isPanning = false;
76
76
backdropColor = null ;
77
77
78
- _steps : number [ ] = [ 70 ] ;
78
+ panGestureHandler : PanGestureHandler ;
79
+
80
+ private stepIndex = 0 ;
81
+
82
+ private _steps : number [ ] = [ 70 ] ;
83
+ private isAnimating = false ;
84
+ private prevDeltaY = 0 ;
85
+ private viewHeight = 0 ;
86
+ private bottomViewHeight = 0 ;
87
+
88
+ private lastScrollY : number ;
89
+ private lastTouchY : number ;
90
+ private scrollViewTouched = false ;
91
+ private _translationY = - 1 ;
92
+ private gestureEnabled = true ;
93
+ private _scrollView : ScrollView ;
94
+ private _isScrollEnabled = true ;
95
+ private scrollViewAtTop : boolean = true ;
96
+
97
+ constructor ( ) {
98
+ super ( ) ;
99
+ this . isPassThroughParentEnabled = true ;
100
+ this . on ( 'layoutChanged' , this . onLayoutChange , this ) ;
101
+ }
79
102
80
103
get steps ( ) {
81
104
const result = this . _steps || ( this . bottomSheet && ( this . bottomSheet as any ) . steps ) ;
@@ -84,22 +107,10 @@ export class PersistentBottomSheet extends GridLayout {
84
107
set steps ( value : number [ ] ) {
85
108
this . _steps = value ;
86
109
}
87
- stepIndex = 0 ;
88
-
89
- isAnimating = false ;
90
- prevDeltaY = 0 ;
91
- viewHeight = 0 ;
92
- bottomViewHeight = 0 ;
93
- panGestureHandler : PanGestureHandler ;
94
-
95
- lastScrollY : number ;
96
- lastTouchY : number ;
97
- scrollViewTouched = false ;
98
110
99
111
// nativeGestureHandler: PanGestureHandler;
100
- gestureEnabled = true ;
101
112
translationFunction ?: ( height : number , delta : number , progress : number ) => { bottomSheet ?: AnimationDefinition ; backDrop ?: AnimationDefinition } ;
102
- initGestures ( ) {
113
+ protected initGestures ( ) {
103
114
const manager = Manager . getInstance ( ) ;
104
115
const gestureHandler = manager . createGestureHandler ( HandlerType . PAN , PAN_GESTURE_TAG , {
105
116
shouldStartGesture : this . shouldStartGesture . bind ( this ) ,
@@ -116,7 +127,7 @@ export class PersistentBottomSheet extends GridLayout {
116
127
gestureHandler . attachToView ( this ) ;
117
128
this . panGestureHandler = gestureHandler as any ;
118
129
}
119
- shouldStartGesture ( data ) {
130
+ protected shouldStartGesture ( data ) {
120
131
const safeAreatop = Utils . layout . toDeviceIndependentPixels ( this . getSafeAreaInsets ( ) . top ) ;
121
132
const y = data . y - safeAreatop ;
122
133
// console.log('shouldStartGesture ', safeAreatop, data, y, this.viewHeight - (this.translationMaxOffset - this.translationY), this.translationY, this.translationMaxOffset, this.viewHeight);
@@ -147,12 +158,6 @@ export class PersistentBottomSheet extends GridLayout {
147
158
// // this.nativeGestureHandler.attachToView(newValue);
148
159
// }
149
160
// }
150
- constructor ( ) {
151
- super ( ) ;
152
- this . isPassThroughParentEnabled = true ;
153
- this . on ( 'layoutChanged' , this . onLayoutChange , this ) ;
154
- }
155
- _translationY = - 1 ;
156
161
get translationY ( ) {
157
162
return this . _translationY ;
158
163
}
@@ -216,7 +221,7 @@ export class PersistentBottomSheet extends GridLayout {
216
221
this . addBackdropView ( index ) ;
217
222
}
218
223
}
219
- addBackdropView ( index : number ) {
224
+ protected addBackdropView ( index : number ) {
220
225
// console.log('addBackdropView', index);
221
226
this . backDrop = new GridLayout ( ) ;
222
227
this . backDrop . backgroundColor = this . backdropColor ;
@@ -225,7 +230,6 @@ export class PersistentBottomSheet extends GridLayout {
225
230
this . insertChild ( this . backDrop , index ) ;
226
231
}
227
232
228
- _scrollView : ScrollView ;
229
233
230
234
get scrollView ( ) {
231
235
return this . _scrollView ;
@@ -248,7 +252,7 @@ export class PersistentBottomSheet extends GridLayout {
248
252
value . on ( 'touch' , this . onTouch , this ) ;
249
253
}
250
254
}
251
- public _onScrollViewIdChanged ( oldValue : string , newValue : string ) {
255
+ private _onScrollViewIdChanged ( oldValue : string , newValue : string ) {
252
256
if ( newValue && this . bottomSheet ) {
253
257
if ( this . bottomSheet . isLoaded ) {
254
258
const view : ScrollView = this . bottomSheet . getViewById ( newValue ) ;
@@ -264,7 +268,7 @@ export class PersistentBottomSheet extends GridLayout {
264
268
}
265
269
}
266
270
267
- public _onBottomSheetChanged ( oldValue : View , newValue : View ) {
271
+ private _onBottomSheetChanged ( oldValue : View , newValue : View ) {
268
272
if ( oldValue ) {
269
273
this . removeChild ( oldValue ) ;
270
274
}
@@ -306,7 +310,7 @@ export class PersistentBottomSheet extends GridLayout {
306
310
} ,
307
311
} ;
308
312
}
309
- onLayoutChange ( event : EventData ) {
313
+ private onLayoutChange ( event : EventData ) {
310
314
const contentView = event . object as GridLayout ;
311
315
const height = Math . round ( Utils . layout . toDeviceIndependentPixels ( contentView . getMeasuredHeight ( ) ) ) ;
312
316
this . viewHeight = height ;
@@ -320,7 +324,7 @@ export class PersistentBottomSheet extends GridLayout {
320
324
this . applyTrData ( data ) ;
321
325
}
322
326
}
323
- onBottomLayoutChange ( event : EventData ) {
327
+ private onBottomLayoutChange ( event : EventData ) {
324
328
const contentView = event . object as GridLayout ;
325
329
const height = Math . round ( Utils . layout . toDeviceIndependentPixels ( contentView . getMeasuredHeight ( ) ) ) ;
326
330
this . bottomViewHeight = height ;
@@ -334,21 +338,20 @@ export class PersistentBottomSheet extends GridLayout {
334
338
this . applyTrData ( data ) ;
335
339
}
336
340
}
337
- get scrollViewVerticalOffset ( ) {
341
+ private get scrollViewVerticalOffset ( ) {
338
342
if ( global . isAndroid ) {
339
343
return ( this . scrollView . nativeViewProtected as androidx . core . view . ScrollingView ) . computeVerticalScrollOffset ( ) / Utils . layout . getDisplayDensity ( ) ;
340
344
} else {
341
345
return ( this . scrollView . nativeViewProtected as UIScrollView ) . contentOffset . y ;
342
346
}
343
347
}
344
- set scrollViewOffset ( value : number ) {
348
+ private set scrollViewVerticalOffset ( value : number ) {
345
349
if ( global . isAndroid ) {
346
350
( this . scrollView . nativeViewProtected as androidx . recyclerview . widget . RecyclerView ) . scrollTo ( 0 , 0 ) ;
347
351
} else {
348
352
( this . scrollView . nativeViewProtected as UIScrollView ) . contentOffset = CGPointMake ( this . scrollView . nativeViewProtected . contentOffset . x , 0 ) ;
349
353
}
350
354
}
351
- _isScrollEnabled = true ;
352
355
get isScrollEnabled ( ) {
353
356
return this . _isScrollEnabled ;
354
357
}
@@ -360,7 +363,7 @@ export class PersistentBottomSheet extends GridLayout {
360
363
}
361
364
}
362
365
}
363
- onTouch ( event : TouchGestureEventData ) {
366
+ private onTouch ( event : TouchGestureEventData ) {
364
367
let touchY ;
365
368
// if (this.animationTimer) {
366
369
// clearTimeout(this.animationTimer);
@@ -413,8 +416,7 @@ export class PersistentBottomSheet extends GridLayout {
413
416
}
414
417
this . lastTouchY = touchY ;
415
418
}
416
- scrollViewAtTop : boolean = true ;
417
- onScroll ( event : ScrollEventData & { scrollOffset ?: number } ) {
419
+ private onScroll ( event : ScrollEventData & { scrollOffset ?: number } ) {
418
420
const scrollY = event . scrollOffset || event . scrollY || 0 ;
419
421
if ( scrollY <= 0 ) {
420
422
this . scrollViewAtTop = true ;
@@ -429,7 +431,7 @@ export class PersistentBottomSheet extends GridLayout {
429
431
}
430
432
this . lastScrollY = scrollY ;
431
433
}
432
- onGestureState ( args : GestureStateEventData ) {
434
+ private onGestureState ( args : GestureStateEventData ) {
433
435
const { state, prevState, extraData, view } = args . data ;
434
436
if ( prevState === GestureState . ACTIVE ) {
435
437
const { velocityY, translationY } = extraData ;
@@ -441,7 +443,7 @@ export class PersistentBottomSheet extends GridLayout {
441
443
}
442
444
}
443
445
444
- computeAndAnimateEndGestureAnimation ( totalDelta : number ) {
446
+ private computeAndAnimateEndGestureAnimation ( totalDelta : number ) {
445
447
const viewHeight = this . bottomViewHeight ;
446
448
const steps = this . steps ;
447
449
let stepIndex = 0 ;
@@ -461,7 +463,7 @@ export class PersistentBottomSheet extends GridLayout {
461
463
stepIndexProperty . nativeValueChange ( this , stepIndex ) ;
462
464
this . animateToPosition ( viewHeight - destSnapPoint , Math . min ( distance * 2 , OPEN_DURATION ) ) ;
463
465
}
464
- onGestureTouch ( args : GestureTouchEventData ) {
466
+ private onGestureTouch ( args : GestureTouchEventData ) {
465
467
const data = args . data ;
466
468
if ( data . state !== GestureState . ACTIVE ) {
467
469
return ;
@@ -480,7 +482,7 @@ export class PersistentBottomSheet extends GridLayout {
480
482
this . prevDeltaY = deltaY ;
481
483
}
482
484
483
- applyTrData ( trData : { [ k : string ] : any } ) {
485
+ private applyTrData ( trData : { [ k : string ] : any } ) {
484
486
Object . keys ( trData ) . forEach ( ( k ) => {
485
487
const { target, ...others } = trData [ k ] ;
486
488
if ( target ) {
@@ -492,11 +494,11 @@ export class PersistentBottomSheet extends GridLayout {
492
494
} ) ;
493
495
}
494
496
495
- constrainY ( y ) {
497
+ private constrainY ( y ) {
496
498
return Math . max ( Math . min ( y , this . bottomViewHeight ) , this . bottomViewHeight - this . translationMaxOffset ) ;
497
499
}
498
500
499
- async animateToPosition ( position , duration = OPEN_DURATION ) {
501
+ private async animateToPosition ( position , duration = OPEN_DURATION ) {
500
502
if ( this . _scrollView && global . isAndroid ) {
501
503
// on android we get unwanted scroll effect while "swipping the view"
502
504
// cancel the views touches before animation to prevent that
0 commit comments