Fix to always get the same bounds no matter if we are shown modally or not (for iOS).

Remove code that moves actionBar when there is incoming call. We now depend on the autolayout to position us correctly.
_addView, _removeView won't request layout for iOS.
LayoutBase: addChild & remvoeChild will request layout.
ContentView: content change will request layout.
This commit is contained in:
Hristo Hristov
2017-10-27 13:50:20 +03:00
parent 53b92ad83a
commit a35e603d85
5 changed files with 29 additions and 43 deletions

View File

@ -1,4 +1,4 @@
<Page xmlns="http://schemas.nativescript.org/tns.xsd" loaded="pageLoaded" backgroundColor="Red"> <Page xmlns="http://schemas.nativescript.org/tns.xsd" loaded="pageLoaded" backgroundColor="white">
<StackLayout backgroundColor="PaleGreen"> <StackLayout backgroundColor="PaleGreen">
<Button text="Login (pop-up)" tap="onTap" /> <Button text="Login (pop-up)" tap="onTap" />
<Button text="Login (full-screen)" tap="onTap" /> <Button text="Login (full-screen)" tap="onTap" />

View File

@ -22,6 +22,9 @@ export class ContentView extends CustomLayoutView implements ContentViewDefiniti
} }
this._onContentChanged(oldView, value); this._onContentChanged(oldView, value);
if (oldView !== value) {
this.requestLayout();
}
} }
get layoutView(): View { get layoutView(): View {

View File

@ -40,16 +40,6 @@ export class View extends ViewCommon {
*/ */
_nativeBackgroundState: "unset" | "invalid" | "drawn"; _nativeBackgroundState: "unset" | "invalid" | "drawn";
public _addViewCore(view: ViewCommon, atIndex?: number) {
super._addViewCore(view, atIndex);
this.requestLayout();
}
public _removeViewCore(view: ViewCommon) {
super._removeViewCore(view);
this.requestLayout();
}
get isLayoutRequired(): boolean { get isLayoutRequired(): boolean {
return (this._privateFlags & PFLAG_LAYOUT_REQUIRED) === PFLAG_LAYOUT_REQUIRED; return (this._privateFlags & PFLAG_LAYOUT_REQUIRED) === PFLAG_LAYOUT_REQUIRED;
} }
@ -255,7 +245,7 @@ export class View extends ViewCommon {
} }
const background = this.style.backgroundInternal; const background = this.style.backgroundInternal;
const backgroundDependsOnSize = background.image const backgroundDependsOnSize = background.image
|| !background.hasUniformBorder() || !background.hasUniformBorder()
|| background.hasBorderRadius(); || background.hasBorderRadius();
@ -630,9 +620,9 @@ export namespace ios {
if (extendedController.scrollable !== scrollable if (extendedController.scrollable !== scrollable
|| extendedController.navBarHidden !== navBarHidden || extendedController.navBarHidden !== navBarHidden
|| extendedController.hasChildControllers !== hasChildControllers) { || extendedController.hasChildControllers !== hasChildControllers) {
extendedController.scrollable = scrollable; extendedController.scrollable = scrollable;
extendedController.navBarHidden = navBarHidden; extendedController.navBarHidden = navBarHidden;
extendedController.hasChildControllers = hasChildControllers; extendedController.hasChildControllers = hasChildControllers;
constrainView(extendedController, owner); constrainView(extendedController, owner);
} }
} }
@ -643,7 +633,7 @@ export namespace ios {
return; return;
} }
const frame = controller.beingPresented ? owner.nativeView.superview.frame : controller.view.subviews[0].bounds; const frame = controller.view.subviews[0].bounds;
const origin = frame.origin; const origin = frame.origin;
const size = frame.size; const size = frame.size;
const width = layout.toDevicePixels(size.width); const width = layout.toDevicePixels(size.width);

View File

@ -252,28 +252,6 @@ export class Frame extends FrameBase {
public _onNavigatingTo(backstackEntry: BackstackEntry, isBack: boolean) { public _onNavigatingTo(backstackEntry: BackstackEntry, isBack: boolean) {
// //
} }
_handleHigherInCallStatusBarIfNeeded() {
let statusBarHeight = uiUtils.ios.getStatusBarHeight();
if (!this._ios ||
!this._ios.controller ||
!this._ios.controller.navigationBar ||
this._ios.controller.navigationBar.hidden ||
utils.layout.toDevicePixels(this._ios.controller.navigationBar.frame.origin.y) === statusBarHeight) {
return;
}
if (traceEnabled()) {
traceWrite(`Forcing navigationBar.frame.origin.y to ${statusBarHeight} due to a higher in-call status-bar`, traceCategories.Layout);
}
this._ios.controller.navigationBar.removeConstraints((<any>this)._ios.controller.navigationBar.constraints);
this._ios.controller.navigationBar.frame = CGRectMake(
this._ios.controller.navigationBar.frame.origin.x,
utils.layout.toDeviceIndependentPixels(statusBarHeight),
this._ios.controller.navigationBar.frame.size.width,
this._ios.controller.navigationBar.frame.size.height);
}
} }
let transitionDelegates = new Array<TransitionDelegate>(); let transitionDelegates = new Array<TransitionDelegate>();

View File

@ -1,15 +1,23 @@
import { LayoutBaseCommon, clipToBoundsProperty } from "./layout-base-common"; import { LayoutBaseCommon, clipToBoundsProperty, View } from "./layout-base-common";
export * from "./layout-base-common"; export * from "./layout-base-common";
export class LayoutBase extends LayoutBaseCommon { export class LayoutBase extends LayoutBaseCommon {
nativeViewProtected: UIView; nativeViewProtected: UIView;
[clipToBoundsProperty.getDefault](): boolean { public addChild(child: View): void {
return false; super.addChild(child);
this.requestLayout();
} }
[clipToBoundsProperty.setNative](value: boolean) {
this._setNativeClipToBounds(); public insertChild(child: View, atIndex: number): void {
super.insertChild(child, atIndex);
this.requestLayout();
}
public removeChild(child: View): void {
super.removeChild(child);
this.requestLayout();
} }
_setNativeClipToBounds() { _setNativeClipToBounds() {
@ -19,4 +27,11 @@ export class LayoutBase extends LayoutBaseCommon {
super._setNativeClipToBounds(); super._setNativeClipToBounds();
} }
} }
[clipToBoundsProperty.getDefault](): boolean {
return false;
}
[clipToBoundsProperty.setNative](value: boolean) {
this._setNativeClipToBounds();
}
} }