From 57f15abf278d0a5db273b2937899be1f0c7da027 Mon Sep 17 00:00:00 2001 From: vakrilov Date: Wed, 3 Feb 2016 15:38:48 +0200 Subject: [PATCH] Fixed ios proxy view blocks layout requests --- .../proxy-view-container-tests.ts | 26 +++++++++++++++++++ .../proxy-view-container.ts | 17 +++++++----- 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/apps/tests/ui/proxy-view-container/proxy-view-container-tests.ts b/apps/tests/ui/proxy-view-container/proxy-view-container-tests.ts index 1bd9095d4..22b1ab976 100644 --- a/apps/tests/ui/proxy-view-container/proxy-view-container-tests.ts +++ b/apps/tests/ui/proxy-view-container/proxy-view-container-tests.ts @@ -161,6 +161,32 @@ export function test_insert_after_porxy() { helper.buildUIAndRunTest(outer, testAction); } +export function test_proxy_does_not_stop_request_layout_bubble() { + var outer = new StackLayout(); + var proxy = new ProxyViewContainer(); + + outer.addChild(createBtn("1")); + outer.addChild(proxy); + var btn = createBtn("2"); + proxy.addChild(btn); + + function testAction(views: Array) { + assertNativeChildren(outer, ["1", "2"]); + waitUntilElementLayoutIsValid(outer); + TKUnit.assert(outer.isLayoutValid, "outer container isLayoutValid should be true"); + btn.requestLayout(); + TKUnit.assertFalse(outer.isLayoutValid, "outer container isLayoutValid should be invalidated here"); + }; + + helper.buildUIAndRunTest(outer, testAction); +} + +function waitUntilElementLayoutIsValid(view: View, timeoutSec?: number): void { + TKUnit.waitUntilReady(() => { + return view.isLayoutValid; + }, timeoutSec || 1); +} + function createBtn(text: string): Button { var b = new Button(); b.text = text; diff --git a/ui/proxy-view-container/proxy-view-container.ts b/ui/proxy-view-container/proxy-view-container.ts index 4ab99ef19..b7e0f5edd 100644 --- a/ui/proxy-view-container/proxy-view-container.ts +++ b/ui/proxy-view-container/proxy-view-container.ts @@ -18,18 +18,23 @@ import {LayoutBase} from "ui/layouts/layout-base"; // - Android: _onDetached calls _removeViewFromNativeVisualTree recursively when the proxy is removed from its parent. export class ProxyViewContainer extends LayoutBase implements definition.ProxyViewContainer { // No native view for proxy container. - get ios(): any { - return null; + get ios(): any { + return null; } - + get android(): any { return null; } - + get _nativeView(): any { return null; } - + + get isLayoutRequested(): boolean { + // Always return false so all layout requests from children bubble up. + return false; + } + public _createUI() { // } @@ -70,7 +75,7 @@ export class ProxyViewContainer extends LayoutBase implements definition.ProxyVi // Add last; insideIndex = this._getNativeViewsCount(); } - + trace.write("ProxyViewContainer._addViewToNativeVisualTree at: " + atIndex + " base: " + baseIndex + " additional: " + insideIndex, trace.categories.ViewHierarchy); return parent._addViewToNativeVisualTree(child, baseIndex + insideIndex); }