Skip to content

Commit b8cdf2f

Browse files
committed
chore: better handling of it all
1 parent 935ab2f commit b8cdf2f

File tree

2 files changed

+36
-21
lines changed

2 files changed

+36
-21
lines changed

src/bottomsheet/bottomsheet-common.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export abstract class ViewWithBottomSheetBase extends View {
4646
eventName: shownInBottomSheetEvent,
4747
object: this,
4848
context: this._bottomSheetContext,
49-
closeCallback: this._closeBottomSheetCallback,
49+
closeCallback: this._closeBottomSheetCallback
5050
};
5151

5252
this.notify(args);
@@ -114,7 +114,7 @@ export abstract class ViewWithBottomSheetBase extends View {
114114
eventName: showingInBottomSheetEvent,
115115
object: this,
116116
context: this._bottomSheetContext,
117-
closeCallback: this._closeBottomSheetCallback,
117+
closeCallback: this._closeBottomSheetCallback
118118
};
119119
this.notify(args);
120120
}
@@ -138,7 +138,7 @@ export abstract class ViewWithBottomSheetBase extends View {
138138
options.view instanceof View
139139
? (options.view as ViewWithBottomSheetBase)
140140
: (Builder.createViewFromEntry({
141-
moduleName: options.view as string,
141+
moduleName: options.view as string
142142
}) as ViewWithBottomSheetBase);
143143
view._showNativeBottomSheet(this, options);
144144
return view;

src/bottomsheet/bottomsheet.ios.ts

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
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';
24
import { applyMixins } from '@nativescript-community/ui-material-core';
35
import { BottomSheetOptions } from './bottomsheet';
46
import { ViewWithBottomSheetBase } from './bottomsheet-common';
@@ -113,28 +115,41 @@ function layoutView(controller: IUILayoutViewController, owner: View): void {
113115

114116
const adjustedPosition = startPos;
115117

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';
121120

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
131122

123+
owner.iosIgnoreSafeArea = !isLandscape;
132124
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;
135141
}
136142
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;
138153
}
139154
owner.nativeViewProtected.frame = CGRectMake(
140155
Utils.layout.toDeviceIndependentPixels(adjustedPosition.left),

0 commit comments

Comments
 (0)