|
1 |
| -import { IOSHelper, Page, Trace, Utils, View, fromObject, Screen } from '@nativescript/core'; |
| 1 | +import { Application, IOSHelper, Page, Screen, Trace, Utils, View, fromObject } from '@nativescript/core'; |
| 2 | +import { iOSNativeHelper } from '@nativescript/core/utils'; |
| 3 | +import { iosIgnoreSafeAreaProperty } from '@nativescript/core/ui/core/view/view-common'; |
2 | 4 | import { applyMixins } from '@nativescript-community/ui-material-core';
|
3 | 5 | import { BottomSheetOptions } from './bottomsheet';
|
4 | 6 | import { ViewWithBottomSheetBase } from './bottomsheet-common';
|
@@ -113,28 +115,41 @@ function layoutView(controller: IUILayoutViewController, owner: View): void {
|
113 | 115 |
|
114 | 116 | const adjustedPosition = startPos;
|
115 | 117 |
|
116 |
| - const topDelta = safeAreaPosition.top - fullscreenPosition.top; |
117 |
| - // move content upwards, because safearea is handled in this view and the child view |
118 |
| - adjustedPosition.top -= topDelta; |
119 |
| - console.log("safeAreaPosition.top, fullscreenPosition.top", safeAreaPosition.top, fullscreenPosition.top); |
120 |
| - console.log("topDelta", topDelta); |
| 118 | + const orientation = UIDevice.currentDevice.orientation; |
| 119 | + const isLandscape = Application.orientation() === 'landscape'; |
121 | 120 |
|
122 |
| - const bottomDelta = fullscreenPosition.bottom - safeAreaPosition.bottom; |
123 |
| - // extend background behind bottom bar on landscape |
124 |
| - adjustedPosition.bottom += Math.max(bottomDelta - topDelta, 0); |
125 |
| - console.log("Math.max(bottomDelta - topDelta, 0)", Math.max(bottomDelta - topDelta, 0)); |
126 |
| - console.log("safeAreaPosition.bottom, fullscreenPosition.bottom", safeAreaPosition.bottom, fullscreenPosition.bottom); |
127 |
| - console.log("bottom delta", bottomDelta); |
128 |
| - |
129 |
| - adjustedPosition.right = adjustedPosition.right - adjustedPosition.left; |
130 |
| - adjustedPosition.left = 0; |
| 121 | + // there are still some issues in landscape Right but they seem to come from N |
131 | 122 |
|
| 123 | + owner.iosIgnoreSafeArea = !isLandscape; |
132 | 124 | if (controller.ignoreTopSafeArea) {
|
133 |
| - effectiveHeight -= topDelta; |
134 |
| - adjustedPosition.top -= topDelta; |
| 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 | + } |
| 137 | + const delta = safeAreaPosition[key] - fullscreenPosition[key]; |
| 138 | + effectiveHeight -= delta; |
| 139 | + adjustedPosition[oppositeKey] -= delta; |
| 140 | + adjustedPosition[key] -= delta; |
135 | 141 | }
|
136 | 142 | if (controller.ignoreBottomSafeArea) {
|
137 |
| - effectiveHeight -= bottomDelta; |
| 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 | + } |
| 151 | + const delta = fullscreenPosition[key] - safeAreaPosition[key]; |
| 152 | + effectiveHeight -= delta; |
138 | 153 | }
|
139 | 154 | owner.nativeViewProtected.frame = CGRectMake(
|
140 | 155 | Utils.layout.toDeviceIndependentPixels(adjustedPosition.left),
|
|
0 commit comments