From 03090b78428cd271b950900fbe81f31e68836646 Mon Sep 17 00:00:00 2001 From: hshristov Date: Tue, 29 Sep 2015 09:48:15 +0300 Subject: [PATCH] Page background now spans on the whole height but content is still under NavBar --- tsconfig.json | 1 + ui/frame/frame-common.ts | 2 +- ui/frame/frame.d.ts | 1 + ui/frame/frame.ios.ts | 14 +++++++------- ui/page/page.ios.ts | 42 +++++++++++++++++++++++++++++++--------- 5 files changed, 43 insertions(+), 17 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index a2c650e20..03d1ff2e0 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,7 @@ { "version": "1.5.0-beta", "compilerOptions": { + "moduleResolution": "classic", "target": "es5", "module": "commonjs", "declaration": false, diff --git a/ui/frame/frame-common.ts b/ui/frame/frame-common.ts index 57851256b..f411097d3 100644 --- a/ui/frame/frame-common.ts +++ b/ui/frame/frame-common.ts @@ -341,7 +341,7 @@ export class Frame extends view.CustomLayoutView implements definition.Frame { return "Frame<" + this._domId + ">"; } - protected get navigationBarHeight(): number { + public get navigationBarHeight(): number { return 0; } diff --git a/ui/frame/frame.d.ts b/ui/frame/frame.d.ts index 3468ff24a..9b42f4450 100644 --- a/ui/frame/frame.d.ts +++ b/ui/frame/frame.d.ts @@ -88,6 +88,7 @@ declare module "ui/frame" { ios: iOSFrame; //@private + navigationBarHeight: number; _processNavigationQueue(page: pages.Page); _updateActionBar(page?: pages.Page); //@endprivate diff --git a/ui/frame/frame.ios.ts b/ui/frame/frame.ios.ts index d887af61e..eca7b9e8c 100644 --- a/ui/frame/frame.ios.ts +++ b/ui/frame/frame.ios.ts @@ -192,9 +192,9 @@ export class Frame extends frameCommon.Frame { var height = utils.layout.getMeasureSpecSize(heightMeasureSpec); var heightMode = utils.layout.getMeasureSpecMode(heightMeasureSpec); - var result = view.View.measureChild(this, this.currentPage, widthMeasureSpec, utils.layout.makeMeasureSpec(height - this.navigationBarHeight, heightMode)); - if (this._navigateToEntry) { - view.View.measureChild(this, this._navigateToEntry.resolvedPage, widthMeasureSpec, utils.layout.makeMeasureSpec(height - this.navigationBarHeight, heightMode)); + var result = view.View.measureChild(this, this.currentPage, widthMeasureSpec, heightMeasureSpec); + if (this._navigateToEntry && this.currentPage) { + view.View.measureChild(this, this._navigateToEntry.resolvedPage, widthMeasureSpec, heightMeasureSpec); } var widthAndState = view.View.resolveSizeAndState(result.measuredWidth, width, widthMode, 0); @@ -204,13 +204,13 @@ export class Frame extends frameCommon.Frame { } public onLayout(left: number, top: number, right: number, bottom: number): void { - view.View.layoutChild(this, this.currentPage, 0, this.navigationBarHeight, right - left, bottom - top); - if (this._navigateToEntry) { - view.View.layoutChild(this, this._navigateToEntry.resolvedPage, 0, this.navigationBarHeight, right - left, bottom - top); + view.View.layoutChild(this, this.currentPage, 0, 0, right - left, bottom - top); + if (this._navigateToEntry && this.currentPage) { + view.View.layoutChild(this, this._navigateToEntry.resolvedPage, 0, 0, right - left, bottom - top); } } - protected get navigationBarHeight(): number { + public get navigationBarHeight(): number { var navigationBar = this._ios.controller.navigationBar; return (navigationBar && !this._ios.controller.navigationBarHidden) ? navigationBar.frame.size.height : 0; } diff --git a/ui/page/page.ios.ts b/ui/page/page.ios.ts index 8cc170a0d..4f06b755d 100644 --- a/ui/page/page.ios.ts +++ b/ui/page/page.ios.ts @@ -1,8 +1,9 @@ import pageCommon = require("ui/page/page-common"); import definition = require("ui/page"); -import viewModule = require("ui/core/view"); +import {View} from "ui/core/view"; import trace = require("trace"); import uiUtils = require("ui/utils"); +import utils = require("utils/utils"); global.moduleMerge(pageCommon, exports); @@ -76,7 +77,7 @@ export class Page extends pageCommon.Page { } } - public _onContentChanged(oldView: viewModule.View, newView: viewModule.View) { + public _onContentChanged(oldView: View, newView: View) { super._onContentChanged(oldView, newView); this._removeNativeView(oldView); this._addNativeView(newView); @@ -96,7 +97,7 @@ export class Page extends pageCommon.Page { } } - private _addNativeView(view: viewModule.View) { + private _addNativeView(view: View) { if (view) { trace.write("Native: Adding " + view + " to " + this, trace.categories.ViewHierarchy); if (view.ios instanceof UIView) { @@ -108,7 +109,7 @@ export class Page extends pageCommon.Page { } } - private _removeNativeView(view: viewModule.View) { + private _removeNativeView(view: View) { if (view) { trace.write("Native: Removing " + view + " from " + this, trace.categories.ViewHierarchy); if (view.ios instanceof UIView) { @@ -169,16 +170,39 @@ export class Page extends pageCommon.Page { } public onMeasure(widthMeasureSpec: number, heightMeasureSpec: number) { - viewModule.View.measureChild(this, this.actionBar, widthMeasureSpec, heightMeasureSpec); - super.onMeasure(widthMeasureSpec, heightMeasureSpec); + + var width = utils.layout.getMeasureSpecSize(widthMeasureSpec); + var widthMode = utils.layout.getMeasureSpecMode(widthMeasureSpec); + + let height = utils.layout.getMeasureSpecSize(heightMeasureSpec); + let heightMode = utils.layout.getMeasureSpecMode(heightMeasureSpec); + + let navigationBarHeight = this.frame ? this.frame.navigationBarHeight : 0; + let heightSpec = utils.layout.makeMeasureSpec(height - navigationBarHeight, heightMode); + + // Measure ActionBar with the full height. + let actionBarSize = View.measureChild(this, this.actionBar, widthMeasureSpec, heightMeasureSpec); + + // Measure content with height - navigationBarHeight. Here we could use actionBarSize.measuredHeight probably. + let result = View.measureChild(this, this.content, widthMeasureSpec, heightSpec); + + let measureWidth = Math.max(actionBarSize.measuredWidth, result.measuredWidth, this.minWidth); + let measureHeight = Math.max(result.measuredHeight + actionBarSize.measuredHeight, this.minHeight); + + let widthAndState = View.resolveSizeAndState(measureWidth, width, widthMode, 0); + let heightAndState = View.resolveSizeAndState(measureHeight, height, heightMode, 0); + + this.setMeasuredDimension(widthAndState, heightAndState); } public onLayout(left: number, top: number, right: number, bottom: number) { - viewModule.View.layoutChild(this, this.actionBar, 0, 0, right - left, bottom - top); - super.onLayout(left, top, right, bottom); + View.layoutChild(this, this.actionBar, 0, 0, right - left, bottom - top); + + let navigationBarHeight = this.frame ? this.frame.navigationBarHeight : 0; + View.layoutChild(this, this.content, 0, navigationBarHeight, right - left, bottom - top); } - public _addViewToNativeVisualTree(view: viewModule.View): boolean { + public _addViewToNativeVisualTree(view: View): boolean { // ActionBar is added to the native visual tree by default if (view === this.actionBar) { return true;