mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 20:11:24 +08:00
Merge pull request #571 from NativeScript/hhristov/layout-fix
Fix ListView module to check for layoutBase instead of Layout
This commit is contained in:
@ -144,6 +144,8 @@
|
||||
<TypeScriptCompile Include="apps\animations\model.ts" />
|
||||
<TypeScriptCompile Include="apps\orientation-demo\main-page.ts" />
|
||||
<TypeScriptCompile Include="apps\tests\ui\animation\animation-tests.ts" />
|
||||
<TypeScriptCompile Include="apps\tests\xml-declaration\inherited-base-page.ts" />
|
||||
<TypeScriptCompile Include="apps\tests\xml-declaration\inherited-page.ts" />
|
||||
<TypeScriptCompile Include="ui\animation\animation.d.ts" />
|
||||
<TypeScriptCompile Include="ui\animation\animation-common.ts">
|
||||
<DependentUpon>animation.d.ts</DependentUpon>
|
||||
@ -917,6 +919,7 @@
|
||||
</Content>
|
||||
<Content Include="apps\tests\test-icon.png" />
|
||||
<Content Include="apps\tests\ui\style\test.css" />
|
||||
<Content Include="apps\tests\xml-declaration\inherited-page.xml" />
|
||||
<Content Include="apps\tests\xml-declaration\mymodulewithxml\my-control-no-js.xml">
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
@ -1924,7 +1927,7 @@
|
||||
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
|
||||
</WebProjectProperties>
|
||||
</FlavorProperties>
|
||||
<UserProperties ui_2scroll-view_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2editable-text-demo_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2absolute-layout-demo_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2gallery-app_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2content-view_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2web-view_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2layouts_2linear-layout_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2layouts_2absolute-layout_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2layouts_2dock-layout_2package_1json__JSONSchema="" ui_2layouts_2grid-layout_2package_1json__JSONSchema="" ui_2layouts_2wrap-layout_2package_1json__JSONSchema="http://json.schemastore.org/package" />
|
||||
<UserProperties ui_2layouts_2wrap-layout_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2layouts_2grid-layout_2package_1json__JSONSchema="" ui_2layouts_2dock-layout_2package_1json__JSONSchema="" ui_2layouts_2absolute-layout_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2layouts_2linear-layout_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2web-view_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2content-view_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2gallery-app_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2absolute-layout-demo_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2editable-text-demo_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2scroll-view_2package_1json__JSONSchema="http://json.schemastore.org/package" />
|
||||
</VisualStudio>
|
||||
</ProjectExtensions>
|
||||
</Project>
|
||||
</Project>
|
@ -271,14 +271,6 @@ export class View extends viewCommon.View {
|
||||
public onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void {
|
||||
var view = this._nativeView;
|
||||
if (view) {
|
||||
var width = utils.layout.getMeasureSpecSize(widthMeasureSpec);
|
||||
var widthMode = utils.layout.getMeasureSpecMode(widthMeasureSpec);
|
||||
|
||||
var height = utils.layout.getMeasureSpecSize(heightMeasureSpec);
|
||||
var heightMode = utils.layout.getMeasureSpecMode(heightMeasureSpec);
|
||||
|
||||
trace.write(this + " :onMeasure: " + utils.layout.getMode(widthMode) + " " + width + ", " + utils.layout.getMode(heightMode) + " " + height, trace.categories.Layout);
|
||||
|
||||
view.measure(widthMeasureSpec, heightMeasureSpec);
|
||||
this.setMeasuredDimension(view.getMeasuredWidth(), view.getMeasuredHeight());
|
||||
}
|
||||
@ -288,7 +280,6 @@ export class View extends viewCommon.View {
|
||||
var view = this._nativeView;
|
||||
if (view) {
|
||||
this.layoutNativeView(left, top, right, bottom);
|
||||
trace.write(this + " :onLayout: " + left + ", " + top + ", " + (right - left) + ", " + (bottom - top), trace.categories.Layout);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -152,8 +152,6 @@ export class View extends viewCommon.View {
|
||||
height = Number.POSITIVE_INFINITY;
|
||||
}
|
||||
|
||||
trace.write(this + " :onMeasure: " + utils.layout.getMode(widthMode) + " " + width + ", " + utils.layout.getMode(heightMode) + " " + height, trace.categories.Layout);
|
||||
|
||||
var nativeSize = view.sizeThatFits(CGSizeMake(width, height));
|
||||
|
||||
var measureWidth = Math.max(nativeSize.width, this.minWidth);
|
||||
@ -167,7 +165,7 @@ export class View extends viewCommon.View {
|
||||
}
|
||||
|
||||
public onLayout(left: number, top: number, right: number, bottom: number): void {
|
||||
trace.write(this + " :onLayout: " + left + ", " + top + ", " + (right - left) + ", " + (bottom - top), trace.categories.Layout);
|
||||
//
|
||||
}
|
||||
|
||||
public layoutNativeView(left: number, top: number, right: number, bottom: number): void {
|
||||
@ -238,13 +236,6 @@ export class CustomLayoutView extends View {
|
||||
|
||||
public onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void {
|
||||
// Don't call super because it will set MeasureDimension. This method must be overriden and calculate its measuredDimensions.
|
||||
|
||||
var width = utils.layout.getMeasureSpecSize(widthMeasureSpec);
|
||||
var widthMode = utils.layout.getMeasureSpecMode(widthMeasureSpec);
|
||||
|
||||
var height = utils.layout.getMeasureSpecSize(heightMeasureSpec);
|
||||
var heightMode = utils.layout.getMeasureSpecMode(heightMeasureSpec);
|
||||
trace.write(this + " :onMeasure: " + utils.layout.getMode(widthMode) + " " + width + ", " + utils.layout.getMode(heightMode) + " " + height, trace.categories.Layout);
|
||||
}
|
||||
|
||||
public _addViewToNativeVisualTree(child: View, atIndex: number): boolean {
|
||||
|
@ -71,7 +71,6 @@ export class Image extends imageCommon.Image {
|
||||
|
||||
var height = utils.layout.getMeasureSpecSize(heightMeasureSpec);
|
||||
var heightMode = utils.layout.getMeasureSpecMode(heightMeasureSpec);
|
||||
trace.write(this + " :onMeasure: " + utils.layout.getMode(widthMode) + " " + width + ", " + utils.layout.getMode(heightMode) + " " + height, trace.categories.Layout);
|
||||
|
||||
var nativeWidth = this.imageSource ? this.imageSource.width : 0;
|
||||
var nativeHeight = this.imageSource ? this.imageSource.height : 0;
|
||||
|
@ -4,7 +4,6 @@ import dependencyObservable = require("ui/core/dependency-observable");
|
||||
import proxy = require("ui/core/proxy");
|
||||
import utils = require("utils/utils");
|
||||
import viewModule = require("ui/core/view");
|
||||
import trace = require("trace");
|
||||
|
||||
function onTextWrapPropertyChanged(data: dependencyObservable.PropertyChangeData) {
|
||||
var label = <Label>data.object;
|
||||
@ -95,8 +94,6 @@ export class Label extends common.Label {
|
||||
height = Number.POSITIVE_INFINITY;
|
||||
}
|
||||
|
||||
trace.write(this + " :onMeasure: " + utils.layout.getMode(widthMode) + " " + width + ", " + utils.layout.getMode(heightMode) + " " + height, trace.categories.Layout);
|
||||
|
||||
var nativeSize = nativeView.sizeThatFits(CGSizeMake(width, height));
|
||||
var labelWidth = nativeSize.width;
|
||||
if (!this.textWrap) {
|
||||
|
@ -55,17 +55,9 @@ export class Layout extends layoutBase.LayoutBase implements definition.Layout {
|
||||
|
||||
public onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void {
|
||||
// Don't call super because it will trigger measure again.
|
||||
|
||||
var width = utils.layout.getMeasureSpecSize(widthMeasureSpec);
|
||||
var widthMode = utils.layout.getMeasureSpecMode(widthMeasureSpec);
|
||||
|
||||
var height = utils.layout.getMeasureSpecSize(heightMeasureSpec);
|
||||
var heightMode = utils.layout.getMeasureSpecMode(heightMeasureSpec);
|
||||
trace.write(this + " :onMeasure: " + utils.layout.getMode(widthMode) + " " + width + ", " + utils.layout.getMode(heightMode) + " " + height, trace.categories.Layout);
|
||||
}
|
||||
|
||||
public onLayout(left: number, top: number, right: number, bottom: number): void {
|
||||
// Don't call super because it will trigger layout again.
|
||||
trace.write(this + " :onLayout: " + left + ", " + top + ", " + (right - left) + ", " + (bottom - top), trace.categories.Layout);
|
||||
}
|
||||
}
|
@ -1,7 +1,5 @@
|
||||
import definition = require("ui/layouts/layout");
|
||||
import layoutBase = require("ui/layouts/layout-base");
|
||||
import trace = require("trace");
|
||||
import utils = require("utils/utils");
|
||||
|
||||
export class Layout extends layoutBase.LayoutBase implements definition.Layout {
|
||||
|
||||
@ -24,12 +22,5 @@ export class Layout extends layoutBase.LayoutBase implements definition.Layout {
|
||||
|
||||
public onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void {
|
||||
// Don't call super because it will measure the native element.
|
||||
|
||||
var width = utils.layout.getMeasureSpecSize(widthMeasureSpec);
|
||||
var widthMode = utils.layout.getMeasureSpecMode(widthMeasureSpec);
|
||||
|
||||
var height = utils.layout.getMeasureSpecSize(heightMeasureSpec);
|
||||
var heightMode = utils.layout.getMeasureSpecMode(heightMeasureSpec);
|
||||
trace.write(this + " :onMeasure: " + utils.layout.getMode(widthMode) + " " + width + ", " + utils.layout.getMode(heightMode) + " " + height, trace.categories.Layout);
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
import observable = require("data/observable");
|
||||
import common = require("ui/list-view/list-view-common");
|
||||
import viewModule = require("ui/core/view");
|
||||
import layout = require("ui/layouts/layout");
|
||||
import layoutBaseModule = require("ui/layouts/layout-base");
|
||||
import stackLayout = require("ui/layouts/stack-layout");
|
||||
import proxy = require("ui/core/proxy");
|
||||
import dependencyObservable = require("ui/core/dependency-observable");
|
||||
@ -199,7 +199,7 @@ class ListViewAdapter extends android.widget.BaseAdapter {
|
||||
|
||||
if (args.view) {
|
||||
if (!args.view.parent) {
|
||||
if (args.view instanceof layout.Layout) {
|
||||
if (args.view instanceof layoutBaseModule.LayoutBase) {
|
||||
this._listView._addView(args.view);
|
||||
convertView = args.view.android;
|
||||
} else {
|
||||
|
4
ui/repeater/repeater.d.ts
vendored
4
ui/repeater/repeater.d.ts
vendored
@ -4,7 +4,7 @@
|
||||
declare module "ui/repeater" {
|
||||
import view = require("ui/core/view");
|
||||
import dependencyObservable = require("ui/core/dependency-observable");
|
||||
import layoutModule = require("ui/layouts/layout");
|
||||
import layoutBaseModule = require("ui/layouts/layout-base");
|
||||
|
||||
/**
|
||||
* Represents a UI Repeater component.
|
||||
@ -39,7 +39,7 @@ declare module "ui/repeater" {
|
||||
/**
|
||||
* Gets or set the items layout of the Repeater. Default value is StackLayout with orientation="vertical".
|
||||
*/
|
||||
itemsLayout: layoutModule.Layout;
|
||||
itemsLayout: layoutBaseModule.LayoutBase;
|
||||
|
||||
/**
|
||||
* Forces the Repeater to reload all its items.
|
||||
|
@ -6,7 +6,7 @@ import observable = require("data/observable");
|
||||
import observableArray = require("data/observable-array");
|
||||
import weakEvents = require("ui/core/weak-event-listener");
|
||||
import types = require("utils/types");
|
||||
import layoutModule = require("ui/layouts/layout");
|
||||
import layoutBaseModule = require("ui/layouts/layout-base");
|
||||
import stackLayoutModule = require("ui/layouts/stack-layout");
|
||||
import builder = require("ui/builder");
|
||||
import utils = require("utils/utils");
|
||||
@ -93,10 +93,10 @@ export class Repeater extends viewModule.CustomLayoutView implements definition.
|
||||
this._setValue(Repeater.itemTemplateProperty, value);
|
||||
}
|
||||
|
||||
get itemsLayout(): layoutModule.Layout {
|
||||
get itemsLayout(): layoutBaseModule.LayoutBase {
|
||||
return this._getValue(Repeater.itemsLayoutProperty);
|
||||
}
|
||||
set itemsLayout(value: layoutModule.Layout) {
|
||||
set itemsLayout(value: layoutBaseModule.LayoutBase) {
|
||||
this._setValue(Repeater.itemsLayoutProperty, value);
|
||||
}
|
||||
|
||||
@ -211,7 +211,7 @@ export class Repeater extends viewModule.CustomLayoutView implements definition.
|
||||
}
|
||||
}
|
||||
|
||||
function clearItemsLayout(itemsLayout: layoutModule.Layout) {
|
||||
function clearItemsLayout(itemsLayout: layoutBaseModule.LayoutBase) {
|
||||
if (!types.isNullOrUndefined(itemsLayout)) {
|
||||
var i: number = itemsLayout.getChildrenCount();
|
||||
if (i > 0) {
|
||||
|
1
ui/ui.d.ts
vendored
1
ui/ui.d.ts
vendored
@ -22,6 +22,7 @@ declare module "ui" {
|
||||
export * from "ui/image";
|
||||
export * from "ui/image-cache";
|
||||
export * from "ui/label";
|
||||
export * from "ui/layouts/layout-base";
|
||||
export * from "ui/layouts/layout";
|
||||
export * from "ui/layouts/absolute-layout";
|
||||
export * from "ui/layouts/dock-layout";
|
||||
|
Reference in New Issue
Block a user