mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Merge pull request #6790 from NativeScript/release-5.1.2
release: cut the 5.1.2 release
This commit is contained in:
10
CHANGELOG.md
10
CHANGELOG.md
@@ -1,3 +1,13 @@
|
|||||||
|
<a name="5.1.2"></a>
|
||||||
|
## [5.1.2](https://github.com/NativeScript/NativeScript/compare/5.1.1...5.1.2) (2019-01-13)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **list-view-android:** app crashes on ListView item template change ([#6634](https://github.com/NativeScript/NativeScript/issues/6634)) ([e03f5f9](https://github.com/NativeScript/NativeScript/commit/e03f5f9))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a name="5.1.1"></a>
|
<a name="5.1.1"></a>
|
||||||
## [5.1.1](https://github.com/NativeScript/NativeScript/compare/5.1.0...5.1.1) (2018-12-19)
|
## [5.1.1](https://github.com/NativeScript/NativeScript/compare/5.1.0...5.1.1) (2018-12-19)
|
||||||
|
|
||||||
|
|||||||
21
apps/app/ui-tests-app/list-view/dynamic-templates.ts
Normal file
21
apps/app/ui-tests-app/list-view/dynamic-templates.ts
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import { Page } from "tns-core-modules/ui/page";
|
||||||
|
import { ViewModel } from "./main-view-model";
|
||||||
|
|
||||||
|
export function pageLoaded(args) {
|
||||||
|
let page = <Page>args.object;
|
||||||
|
const viewModel = new ViewModel();
|
||||||
|
|
||||||
|
page.bindingContext = {
|
||||||
|
"items": viewModel.items
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.onItemTap = function (args) {
|
||||||
|
const list = args.object;
|
||||||
|
let index = args.index;
|
||||||
|
let listArray = list.page.bindingContext["items"];
|
||||||
|
let currentItem = listArray.getItem(index);
|
||||||
|
|
||||||
|
currentItem.age = currentItem.age + 1;
|
||||||
|
listArray.setItem(index, currentItem);
|
||||||
|
}
|
||||||
14
apps/app/ui-tests-app/list-view/dynamic-templates.xml
Normal file
14
apps/app/ui-tests-app/list-view/dynamic-templates.xml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<Page loaded="pageLoaded">
|
||||||
|
<GridLayout id="grid-layout">
|
||||||
|
<ListView id="lv1" items="{{ items }}" itemTemplateSelector="age % 2 === 0 ? 'green':'red'" itemTap="onItemTap">
|
||||||
|
<ListView.itemTemplates>
|
||||||
|
<template key="red">
|
||||||
|
<Label text="{{ name + ' ' + id }}" style.backgroundColor="red"/>
|
||||||
|
</template>
|
||||||
|
<template key="green">
|
||||||
|
<Label text="{{ name + ' ' + id }}" style.backgroundColor="green"/>
|
||||||
|
</template>
|
||||||
|
</ListView.itemTemplates>
|
||||||
|
</ListView>
|
||||||
|
</GridLayout>
|
||||||
|
</Page>
|
||||||
@@ -13,6 +13,7 @@ export function loadExamples() {
|
|||||||
const examples = new Map<string, string>();
|
const examples = new Map<string, string>();
|
||||||
examples.set("list-view-templates", "list-view/list-view");
|
examples.set("list-view-templates", "list-view/list-view");
|
||||||
examples.set("images-template", "list-view/images-template");
|
examples.set("images-template", "list-view/images-template");
|
||||||
|
examples.set("dynamic-templates", "list-view/dynamic-templates");
|
||||||
examples.set("bindings", "list-view/listview-binding");
|
examples.set("bindings", "list-view/listview-binding");
|
||||||
examples.set("listview-bg-separator-color", "list-view/listview-bg-separator-color");
|
examples.set("listview-bg-separator-color", "list-view/listview-bg-separator-color");
|
||||||
examples.set("csslv", "list-view/csslv");
|
examples.set("csslv", "list-view/csslv");
|
||||||
|
|||||||
@@ -4,11 +4,13 @@ import { ObservableArray } from "tns-core-modules/data/observable-array";
|
|||||||
export class Item extends Observable {
|
export class Item extends Observable {
|
||||||
private _name: string;
|
private _name: string;
|
||||||
private _id: number;
|
private _id: number;
|
||||||
|
private _age: number;
|
||||||
|
|
||||||
constructor(name: string, id: number) {
|
constructor(name: string, id: number, age: number) {
|
||||||
super();
|
super();
|
||||||
this._name = name;
|
this._name = name;
|
||||||
this._id = id;
|
this._id = id;
|
||||||
|
this._age = age;
|
||||||
}
|
}
|
||||||
|
|
||||||
get name(): string {
|
get name(): string {
|
||||||
@@ -33,6 +35,17 @@ export class Item extends Observable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get age(): number {
|
||||||
|
return this._age;
|
||||||
|
}
|
||||||
|
|
||||||
|
set age(value: number) {
|
||||||
|
if (this._age !== value) {
|
||||||
|
this._age = value;
|
||||||
|
this.notifyPropertyChange("age", value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public toString() {
|
public toString() {
|
||||||
return `${this.name} ${this.id}`;
|
return `${this.name} ${this.id}`;
|
||||||
}
|
}
|
||||||
@@ -44,7 +57,7 @@ export class ViewModel extends Observable {
|
|||||||
get items(): ObservableArray<Item> {
|
get items(): ObservableArray<Item> {
|
||||||
this._items = new ObservableArray<Item>();
|
this._items = new ObservableArray<Item>();
|
||||||
for (let i = 0; i < 100; i++) {
|
for (let i = 0; i < 100; i++) {
|
||||||
this._items.push(new Item(`Item`, i));
|
this._items.push(new Item(`Item`, i, 0));
|
||||||
}
|
}
|
||||||
return this._items;
|
return this._items;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "tns-core-modules",
|
"name": "tns-core-modules",
|
||||||
"description": "Telerik NativeScript Core Modules",
|
"description": "Telerik NativeScript Core Modules",
|
||||||
"version": "5.1.1",
|
"version": "5.1.2",
|
||||||
"homepage": "https://www.nativescript.org",
|
"homepage": "https://www.nativescript.org",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|||||||
@@ -66,6 +66,11 @@ export abstract class ListViewBase extends ContainerView implements ListViewDefi
|
|||||||
});
|
});
|
||||||
this._itemTemplateSelector = (item: any, index: number, items: any) => {
|
this._itemTemplateSelector = (item: any, index: number, items: any) => {
|
||||||
item["$index"] = index;
|
item["$index"] = index;
|
||||||
|
|
||||||
|
if (this._itemTemplateSelectorBindable.bindingContext === item) {
|
||||||
|
this._itemTemplateSelectorBindable.bindingContext = null;
|
||||||
|
}
|
||||||
|
|
||||||
this._itemTemplateSelectorBindable.bindingContext = item;
|
this._itemTemplateSelectorBindable.bindingContext = item;
|
||||||
return this._itemTemplateSelectorBindable.get("templateKey");
|
return this._itemTemplateSelectorBindable.get("templateKey");
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "tns-platform-declarations",
|
"name": "tns-platform-declarations",
|
||||||
"version": "5.1.1",
|
"version": "5.1.2",
|
||||||
"description": "Platform-specific TypeScript declarations for NativeScript for accessing native objects",
|
"description": "Platform-specific TypeScript declarations for NativeScript for accessing native objects",
|
||||||
"main": "",
|
"main": "",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user