mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Handle the case whr proxy is inside ContentView
This commit is contained in:
@@ -22,7 +22,7 @@ export class Border extends contentView.ContentView implements definition.Border
|
||||
var density = utils.layout.getDisplayDensity();
|
||||
var borderSize = (2 * this.borderWidth) * density;
|
||||
|
||||
var result = viewModule.View.measureChild(this, this.content,
|
||||
var result = viewModule.View.measureChild(this, this.layoutView,
|
||||
utils.layout.makeMeasureSpec(width - borderSize, widthMode),
|
||||
utils.layout.makeMeasureSpec(height - borderSize, heightMode));
|
||||
|
||||
@@ -35,6 +35,6 @@ export class Border extends contentView.ContentView implements definition.Border
|
||||
public onLayout(left: number, top: number, right: number, bottom: number): void {
|
||||
var density = utils.layout.getDisplayDensity();
|
||||
var borderSize = this.borderWidth * density;
|
||||
viewModule.View.layoutChild(this, this.content, borderSize, borderSize, right - left - borderSize, bottom - top - borderSize);
|
||||
viewModule.View.layoutChild(this, this.layoutView, borderSize, borderSize, right - left - borderSize, bottom - top - borderSize);
|
||||
}
|
||||
}
|
||||
2
ui/content-view/content-view.d.ts
vendored
2
ui/content-view/content-view.d.ts
vendored
@@ -24,5 +24,7 @@ declare module "ui/content-view" {
|
||||
//@endprivate
|
||||
|
||||
_addChildFromBuilder(name: string, value: any): void;
|
||||
|
||||
layoutView: view.View;
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,24 @@ export class ContentView extends view.CustomLayoutView implements definition.Con
|
||||
this._onContentChanged(oldView, value);
|
||||
}
|
||||
|
||||
get layoutView(): view.View {
|
||||
var result: view.View;
|
||||
|
||||
if (this._content) {
|
||||
let first = true;
|
||||
this._content._eachLayoutView((child) => {
|
||||
if (first) {
|
||||
first = false;
|
||||
result = child;
|
||||
} else {
|
||||
throw new Error("More than one layout child inside a ContentView");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
get _childrenCount(): number {
|
||||
if (this._content) {
|
||||
return 1;
|
||||
@@ -49,7 +67,7 @@ export class ContentView extends view.CustomLayoutView implements definition.Con
|
||||
|
||||
// This method won't be called in Android because we use the native android layout.
|
||||
public onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void {
|
||||
var result = view.View.measureChild(this, this.content, widthMeasureSpec, heightMeasureSpec);
|
||||
var result = view.View.measureChild(this, this.layoutView, widthMeasureSpec, heightMeasureSpec);
|
||||
|
||||
var width = utils.layout.getMeasureSpecSize(widthMeasureSpec);
|
||||
var widthMode = utils.layout.getMeasureSpecMode(widthMeasureSpec);
|
||||
@@ -69,6 +87,6 @@ export class ContentView extends view.CustomLayoutView implements definition.Con
|
||||
|
||||
// This method won't be called in Android because we use the native android layout.
|
||||
public onLayout(left: number, top: number, right: number, bottom: number): void {
|
||||
view.View.layoutChild(this, this.content, 0, 0, right - left, bottom - top);
|
||||
view.View.layoutChild(this, this.layoutView, 0, 0, right - left, bottom - top);
|
||||
}
|
||||
}
|
||||
@@ -276,7 +276,7 @@ export class Page extends pageCommon.Page {
|
||||
let heightSpec = utils.layout.makeMeasureSpec(height - actionBarHeight - statusBarHeight, heightMode);
|
||||
|
||||
// Measure content with height - navigationBarHeight. Here we could use actionBarSize.measuredHeight probably.
|
||||
let result = View.measureChild(this, this.content, widthMeasureSpec, heightSpec);
|
||||
let result = View.measureChild(this, this.layoutView, widthMeasureSpec, heightSpec);
|
||||
|
||||
let measureWidth = Math.max(actionBarWidth, result.measuredWidth, this.minWidth);
|
||||
let measureHeight = Math.max(result.measuredHeight + actionBarHeight, this.minHeight);
|
||||
@@ -307,7 +307,7 @@ export class Page extends pageCommon.Page {
|
||||
statusBarHeight = 0;
|
||||
}
|
||||
|
||||
View.layoutChild(this, this.content, 0, navigationBarHeight + statusBarHeight, right - left, bottom - top);
|
||||
View.layoutChild(this, this.layoutView, 0, navigationBarHeight + statusBarHeight, right - left, bottom - top);
|
||||
}
|
||||
|
||||
public _addViewToNativeVisualTree(view: View): boolean {
|
||||
|
||||
@@ -109,7 +109,7 @@ export class ScrollView extends common.ScrollView implements definition.ScrollVi
|
||||
var heightMode = utils.layout.getMeasureSpecMode(heightMeasureSpec);
|
||||
|
||||
var density = utils.layout.getDisplayDensity();
|
||||
var child = this.content
|
||||
var child = this.layoutView;
|
||||
if (!child) {
|
||||
this._contentMeasuredWidth = this.minWidth * density;
|
||||
this._contentMeasuredHeight = this.minHeight * density;
|
||||
@@ -140,10 +140,10 @@ export class ScrollView extends common.ScrollView implements definition.ScrollVi
|
||||
var height = (bottom - top);
|
||||
|
||||
if (this.orientation === enums.Orientation.horizontal) {
|
||||
view.View.layoutChild(this, this.content, 0, 0, Math.max(this._contentMeasuredWidth, width), height);
|
||||
view.View.layoutChild(this, this.layoutView, 0, 0, Math.max(this._contentMeasuredWidth, width), height);
|
||||
}
|
||||
else {
|
||||
view.View.layoutChild(this, this.content, 0, 0, width, Math.max(this._contentMeasuredHeight, height));
|
||||
view.View.layoutChild(this, this.layoutView, 0, 0, width, Math.max(this._contentMeasuredHeight, height));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user