@@ -64,10 +64,6 @@ export const gestureEnabledProperty = new Property<PersistentBottomSheet, boolea
64
64
defaultValue : true ,
65
65
valueConverter : booleanConverter
66
66
} ) ;
67
- export const stepsProperty = new Property < PersistentBottomSheet , number [ ] > ( {
68
- name : 'steps' ,
69
- defaultValue : [ 70 ]
70
- } ) ;
71
67
export const stepIndexProperty = new Property < PersistentBottomSheet , number > ( {
72
68
name : 'stepIndex' ,
73
69
defaultValue : 0
@@ -109,6 +105,8 @@ export class PersistentBottomSheet extends AbsoluteLayout {
109
105
110
106
private animation : Animation ;
111
107
108
+ private _allowBottomSheetAdd = false ;
109
+
112
110
constructor ( ) {
113
111
super ( ) ;
114
112
this . isPassThroughParentEnabled = true ;
@@ -121,6 +119,10 @@ export class PersistentBottomSheet extends AbsoluteLayout {
121
119
}
122
120
set steps ( value : number [ ] ) {
123
121
this . _steps = value ;
122
+
123
+ if ( this . _steps ?. length ) {
124
+ this . alignToStepPosition ( ) ;
125
+ }
124
126
}
125
127
126
128
// nativeGestureHandler: PanGestureHandler;
@@ -269,9 +271,8 @@ export class PersistentBottomSheet extends AbsoluteLayout {
269
271
this . scrollView = null ;
270
272
}
271
273
}
272
- allowBottomSheetAdd = false
273
274
addChild ( child ) {
274
- if ( child === this . bottomSheet && ! this . allowBottomSheetAdd ) {
275
+ if ( child === this . bottomSheet && ! this . _allowBottomSheetAdd ) {
275
276
return ;
276
277
}
277
278
super . addChild ( child ) ;
@@ -300,9 +301,9 @@ export class PersistentBottomSheet extends AbsoluteLayout {
300
301
let index ;
301
302
if ( ! newValue . parent ) {
302
303
index = this . getChildrenCount ( ) ;
303
- this . allowBottomSheetAdd = true ;
304
+ this . _allowBottomSheetAdd = true ;
304
305
this . addChild ( newValue ) ;
305
- this . allowBottomSheetAdd = false ;
306
+ this . _allowBottomSheetAdd = false ;
306
307
} else {
307
308
index = this . getChildIndex ( newValue ) ;
308
309
}
@@ -336,6 +337,19 @@ export class PersistentBottomSheet extends AbsoluteLayout {
336
337
}
337
338
} ;
338
339
}
340
+ private alignToStepPosition ( ) {
341
+ if ( ! this . bottomSheet ) {
342
+ return ;
343
+ }
344
+
345
+ const steps = this . steps ;
346
+ const step = steps [ Math . min ( this . stepIndex , steps . length - 1 ) ] ;
347
+ const ty = step ;
348
+
349
+ this . translationY = - ty ;
350
+ const data = this . computeTranslationData ( ) ;
351
+ this . applyTrData ( data ) ;
352
+ }
339
353
private onLayoutChange ( event : EventData ) {
340
354
const contentView = event . object as GridLayout ;
341
355
const height = Math . round ( Utils . layout . toDeviceIndependentPixels ( contentView . getMeasuredHeight ( ) ) ) ;
@@ -346,13 +360,8 @@ export class PersistentBottomSheet extends AbsoluteLayout {
346
360
value : contentView . getMeasuredHeight ( )
347
361
} ;
348
362
}
349
- if ( this . translationY === - 1 && this . bottomSheet ) {
350
- const steps = this . steps ;
351
- const step = steps [ this . stepIndex ] ;
352
- const ty = step ;
353
- this . translationY = - ty ;
354
- const data = this . computeTranslationData ( ) ;
355
- this . applyTrData ( data ) ;
363
+ if ( this . translationY === - 1 ) {
364
+ this . alignToStepPosition ( ) ;
356
365
}
357
366
}
358
367
private get scrollViewVerticalOffset ( ) {
0 commit comments