From 0552a3a722469312044fd2e9c40be630d04312ec Mon Sep 17 00:00:00 2001 From: Eduardo Speroni Date: Wed, 2 Nov 2022 16:22:42 -0300 Subject: [PATCH] fix(ios): ensure view layout when using large titles (#10044) Co-authored-by: Nathan Walker --- packages/core/ui/page/index.ios.ts | 33 +++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/packages/core/ui/page/index.ios.ts b/packages/core/ui/page/index.ios.ts index fcc20fb74..f164f8101 100644 --- a/packages/core/ui/page/index.ios.ts +++ b/packages/core/ui/page/index.ios.ts @@ -74,6 +74,24 @@ class UIViewControllerImpl extends UIViewController { public isBackstackSkipped: boolean; public isBackstackCleared: boolean; + private _isRunningLayout = 0; + private get isRunningLayout() { + return this._isRunningLayout === 0; + } + private startRunningLayout() { + this._isRunningLayout++; + } + private finishRunningLayout() { + this._isRunningLayout--; + } + private runLayout(cb: () => void) { + try { + this.startRunningLayout(); + cb(); + } finally { + this.finishRunningLayout(); + } + } public static initWithOwner(owner: WeakRef): UIViewControllerImpl { const controller = UIViewControllerImpl.new(); @@ -254,7 +272,19 @@ class UIViewControllerImpl extends UIViewController { } } + public viewSafeAreaInsetsDidChange(): void { + super.viewSafeAreaInsetsDidChange(); + if (this.isRunningLayout) { + return; + } + const owner = this._owner.get(); + if (owner) { + this.runLayout(() => IOSHelper.layoutView(this, owner)); + } + } + public viewDidLayoutSubviews(): void { + this.startRunningLayout(); super.viewDidLayoutSubviews(); const owner = this._owner.get(); if (owner) { @@ -306,6 +336,7 @@ class UIViewControllerImpl extends UIViewController { IOSHelper.layoutView(this, owner); } + this.finishRunningLayout(); } // Mind implementation for other controllerss @@ -407,7 +438,7 @@ export class Page extends PageBase { updateWithWillAppear(animated: boolean) { // this method is important because it allows plugins to react to modal page close // for example allowing updating status bar background color - if (this.hasActionBar) { + if (this.hasActionBar) { this.actionBar.update(); } this.updateStatusBar();