@@ -51,23 +51,16 @@ class MDCBottomSheetControllerDelegateImpl extends NSObject {
51
51
bottomSheetControllerDidDismissBottomSheet ( controller : MDCBottomSheetController ) {
52
52
// called when clicked on background
53
53
const owner = this . _owner . get ( ) ;
54
- if ( owner ) {
55
- owner . _onDismissBottomSheetCallback && owner . _onDismissBottomSheetCallback ( ) ;
56
- if ( owner && owner . isLoaded ) {
57
- owner . callUnloaded ( ) ;
58
- }
59
- }
54
+ owner && owner . _unloadBottomSheet ( ) ;
55
+
60
56
}
61
57
bottomSheetControllerStateChangedState ( controller : MDCBottomSheetController , state : MDCSheetState ) {
62
58
// called when swiped
63
59
const owner = this . _owner . get ( ) ;
64
60
if ( state === MDCSheetState . Closed ) {
65
61
if ( owner ) {
66
- owner . _onDismissBottomSheetCallback && owner . _onDismissBottomSheetCallback ( ) ;
67
62
owner . _onChangeStateBottomSheetCallback && owner . _onChangeStateBottomSheetCallback ( StateBottomSheet . CLOSED ) ;
68
- if ( owner && owner . isLoaded ) {
69
- owner . callUnloaded ( ) ;
70
- }
63
+ owner && owner . _unloadBottomSheet ( ) ;
71
64
}
72
65
} else {
73
66
if ( owner && owner . _onChangeStateBottomSheetCallback ) {
@@ -186,12 +179,14 @@ function layoutView(controller: IMDLayoutViewController, owner: View): void {
186
179
// adjustedPosition[oppositeKey] += Utils.layout.toDevicePixels(delta);
187
180
// adjustedPosition[key] += Utils.layout.toDevicePixels(delta);
188
181
}
189
- owner . nativeViewProtected . frame = CGRectMake (
190
- Utils . layout . toDeviceIndependentPixels ( adjustedPosition . left ) ,
191
- Utils . layout . toDeviceIndependentPixels ( adjustedPosition . top ) ,
192
- Utils . layout . toDeviceIndependentPixels ( adjustedPosition . right ) ,
193
- Utils . layout . toDeviceIndependentPixels ( adjustedPosition . bottom )
194
- ) ;
182
+ if ( owner . nativeViewProtected ) {
183
+ owner . nativeViewProtected . frame = CGRectMake (
184
+ Utils . layout . toDeviceIndependentPixels ( adjustedPosition . left ) ,
185
+ Utils . layout . toDeviceIndependentPixels ( adjustedPosition . top ) ,
186
+ Utils . layout . toDeviceIndependentPixels ( adjustedPosition . right ) ,
187
+ Utils . layout . toDeviceIndependentPixels ( adjustedPosition . bottom )
188
+ ) ;
189
+ }
195
190
}
196
191
controller . preferredContentSize = CGSizeMake ( Utils . layout . toDeviceIndependentPixels ( effectiveWidth ) , Utils . layout . toDeviceIndependentPixels ( effectiveHeight ) ) ;
197
192
@@ -449,6 +444,16 @@ export class ViewWithBottomSheet extends ViewWithBottomSheetBase {
449
444
const animated = this . viewController . nsAnimated ;
450
445
parentController . dismissViewControllerAnimatedCompletion ( animated , whenClosedCallback ) ;
451
446
}
447
+
448
+ _unloadBottomSheet ( ) {
449
+ if ( this . isLoaded ) {
450
+ this . callUnloaded ( ) ;
451
+ }
452
+ // it is very important to clear the viewController as N does not do it
453
+ // and the destroy of the view from svelte could trigger a layout pass on the viewController
454
+ this . viewController = null ;
455
+ this . _onDismissBottomSheetCallback && this . _onDismissBottomSheetCallback ( ) ;
456
+ }
452
457
}
453
458
454
459
let mixinInstalled = false ;
0 commit comments