Merge pull request #839 from NativeScript/hhristov/page-background

Page background now spans under ActionBar
This commit is contained in:
Hristo Hristov
2015-09-29 11:00:55 +03:00
5 changed files with 43 additions and 17 deletions

View File

@@ -1,6 +1,7 @@
{
"version": "1.5.0-beta",
"compilerOptions": {
"moduleResolution": "classic",
"target": "es5",
"module": "commonjs",
"declaration": false,

View File

@@ -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;
}

1
ui/frame/frame.d.ts vendored
View File

@@ -88,6 +88,7 @@ declare module "ui/frame" {
ios: iOSFrame;
//@private
navigationBarHeight: number;
_processNavigationQueue(page: pages.Page);
_updateActionBar(page?: pages.Page);
//@endprivate

View File

@@ -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;
}

View File

@@ -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;