Skip to content

Commit 6966149

Browse files
committed
fix(bottomsheet): fix landscape mode. Not perfect yet
1 parent bc646d2 commit 6966149

File tree

1 file changed

+31
-23
lines changed

1 file changed

+31
-23
lines changed

src/bottomsheet/bottomsheet.ios.ts

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ function layoutView(controller: IUILayoutViewController, owner: View): void {
8484
const widthSpec = Utils.layout.makeMeasureSpec(safeAreaWidth, Utils.layout.EXACTLY);
8585
const heightSpec = Utils.layout.makeMeasureSpec(safeAreaHeight, Utils.layout.UNSPECIFIED);
8686

87-
owner.iosOverflowSafeArea = true;
88-
8987
// reset _cachedFrame or it will wrongly move the view on subsequent layouts
9088
(owner as any)._cachedFrame = null;
9189
View.measureChild(null, owner, widthSpec, heightSpec);
@@ -120,37 +118,46 @@ function layoutView(controller: IUILayoutViewController, owner: View): void {
120118

121119
// there are still some issues in landscape Right but they seem to come from N
122120

123-
owner.iosIgnoreSafeArea = !isLandscape;
121+
owner.iosIgnoreSafeArea = true;
124122
if (controller.ignoreTopSafeArea) {
125-
let key = 'top';
126-
let oppositeKey = 'bottom';
127-
if (orientation === UIDeviceOrientation.LandscapeLeft) {
128-
key = 'left';
129-
oppositeKey = 'right';
130-
} else if (orientation === UIDeviceOrientation.LandscapeRight) {
131-
key = 'right';
132-
oppositeKey = 'left';
133-
} else if (orientation === UIDeviceOrientation.PortraitUpsideDown) {
134-
key = 'bottom';
135-
oppositeKey = 'top';
136-
}
123+
const key = 'top';
124+
const oppositeKey = 'bottom';
125+
// if (orientation === UIDeviceOrientation.LandscapeLeft) {
126+
// key = 'left';
127+
// oppositeKey = 'right';
128+
// } else if (orientation === UIDeviceOrientation.LandscapeRight) {
129+
// key = 'right';
130+
// oppositeKey = 'left';
131+
// } else if (orientation === UIDeviceOrientation.PortraitUpsideDown) {
132+
// key = 'bottom';
133+
// oppositeKey = 'top';
134+
// }
137135
const delta = safeAreaPosition[key] - fullscreenPosition[key];
138136
effectiveHeight -= delta;
139137
adjustedPosition[oppositeKey] -= delta;
140138
adjustedPosition[key] -= delta;
141139
}
142140
if (controller.ignoreBottomSafeArea) {
143-
let key = 'bottom';
144-
if (orientation === UIDeviceOrientation.LandscapeLeft) {
145-
key = 'right';
146-
} else if (orientation === UIDeviceOrientation.LandscapeRight) {
147-
key = 'left';
148-
} else if (orientation === UIDeviceOrientation.PortraitUpsideDown) {
149-
key = 'top';
150-
}
141+
const key = 'bottom';
142+
// if (orientation === UIDeviceOrientation.LandscapeLeft) {
143+
// key = 'right';
144+
// } else if (orientation === UIDeviceOrientation.LandscapeRight) {
145+
// key = 'left';
146+
// } else if (orientation === UIDeviceOrientation.PortraitUpsideDown) {
147+
// key = 'top';
148+
// }
151149
const delta = fullscreenPosition[key] - safeAreaPosition[key];
152150
effectiveHeight -= delta;
153151
}
152+
if (orientation === UIDeviceOrientation.LandscapeRight || orientation === UIDeviceOrientation.LandscapeLeft) {
153+
const key = 'left';
154+
const oppositeKey = 'right';
155+
const delta = fullscreenPosition[key] - safeAreaPosition[key];
156+
adjustedPosition[oppositeKey] += Utils.layout.toDevicePixels(delta);
157+
// adjustedPosition[key] += (delta);
158+
// adjustedPosition[oppositeKey] += Utils.layout.toDevicePixels(delta);
159+
// adjustedPosition[key] += Utils.layout.toDevicePixels(delta);
160+
}
154161
owner.nativeViewProtected.frame = CGRectMake(
155162
Utils.layout.toDeviceIndependentPixels(adjustedPosition.left),
156163
Utils.layout.toDeviceIndependentPixels(adjustedPosition.top),
@@ -253,6 +260,7 @@ class UILayoutViewController extends UIViewController {
253260
super.viewWillLayoutSubviews();
254261
const owner = this.owner.get();
255262
if (owner) {
263+
owner.iosOverflowSafeArea = true;
256264
IOSHelper.updateConstraints(this, owner);
257265
}
258266
}

0 commit comments

Comments
 (0)