Merge pull request #6790 from NativeScript/release-5.1.2

release: cut the 5.1.2 release
This commit is contained in:
Svetoslav
2019-01-13 20:27:47 +02:00
committed by GitHub
8 changed files with 69 additions and 5 deletions

View File

@@ -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>
## [5.1.1](https://github.com/NativeScript/NativeScript/compare/5.1.0...5.1.1) (2018-12-19)

View 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);
}

View 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>

View File

@@ -13,6 +13,7 @@ export function loadExamples() {
const examples = new Map<string, string>();
examples.set("list-view-templates", "list-view/list-view");
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("listview-bg-separator-color", "list-view/listview-bg-separator-color");
examples.set("csslv", "list-view/csslv");

View File

@@ -4,11 +4,13 @@ import { ObservableArray } from "tns-core-modules/data/observable-array";
export class Item extends Observable {
private _name: string;
private _id: number;
private _age: number;
constructor(name: string, id: number) {
constructor(name: string, id: number, age: number) {
super();
this._name = name;
this._id = id;
this._age = age;
}
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() {
return `${this.name} ${this.id}`;
}
@@ -44,7 +57,7 @@ export class ViewModel extends Observable {
get items(): ObservableArray<Item> {
this._items = new ObservableArray<Item>();
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;
}

View File

@@ -1,7 +1,7 @@
{
"name": "tns-core-modules",
"description": "Telerik NativeScript Core Modules",
"version": "5.1.1",
"version": "5.1.2",
"homepage": "https://www.nativescript.org",
"repository": {
"type": "git",
@@ -52,4 +52,4 @@
}
}
}
}
}

View File

@@ -66,6 +66,11 @@ export abstract class ListViewBase extends ContainerView implements ListViewDefi
});
this._itemTemplateSelector = (item: any, index: number, items: any) => {
item["$index"] = index;
if (this._itemTemplateSelectorBindable.bindingContext === item) {
this._itemTemplateSelectorBindable.bindingContext = null;
}
this._itemTemplateSelectorBindable.bindingContext = item;
return this._itemTemplateSelectorBindable.get("templateKey");
};

View File

@@ -1,6 +1,6 @@
{
"name": "tns-platform-declarations",
"version": "5.1.1",
"version": "5.1.2",
"description": "Platform-specific TypeScript declarations for NativeScript for accessing native objects",
"main": "",
"scripts": {