import * as TKUnit from "../../tk-unit"; import * as helper from "../../ui-helper"; import { UITest } from "../../ui-test"; import { getResources as appGetResources } from "@nativescript/core/application"; import { Observable, EventData } from "@nativescript/core/data/observable"; import { isFunction, isUndefined } from "@nativescript/core/utils/types"; import { isAndroid, isIOS } from "@nativescript/core/platform"; import { GC } from "@nativescript/core/utils/utils"; import { Page } from "@nativescript/core/ui/page"; import { View, KeyedTemplate } from "@nativescript/core/ui/core/view"; import { MyButton, MyStackLayout } from "../layouts/layout-helper"; // >> article-require-listview-module import { ListView, ItemEventData } from "@nativescript/core/ui/list-view"; // << article-require-listview-module // >> article-require-modules-listview import { ObservableArray } from "@nativescript/core/data/observable-array"; import { Label } from "@nativescript/core/ui/label"; // << article-require-modules-listview // >> article-item-tap function listViewItemTap(args) { var itemIndex = args.index; // >> (hide) console.log(itemIndex); // << (hide) } exports.listViewItemTap = listViewItemTap; // << article-item-tap // >> article-load-items function listViewLoadMoreItems(args) { // Expand your collection bound to the ListView with more items here! } // << article-load-items listViewLoadMoreItems("test"); // function loaded(args) { // args.object.bindingContext = { items: [1,2,3,4,5] }; // } // exports.loaded = loaded; var FEW_ITEMS = [0, 1, 2]; var MANY_ITEMS = new Array(100); for (var i = 0; i < 100; i++) { MANY_ITEMS.push(i); } export class ListViewTest extends UITest { public create(): ListView { return new ListView(); } public test_recycling() { helper.nativeView_recycling_test(() => new ListView()); } public test_default_TNS_values() { // >> article-create-listview var listView = new ListView(); // << article-create-listview TKUnit.assert(isUndefined(listView.items), "Default listView.items should be undefined"); } public test_set_items_to_array_loads_all_items(done) { var listView = this.testView; var indexes = {}; // >> article-listview-array var colors = ["red", "green", "blue"]; listView.items = colors; listView.on(ListView.itemLoadingEvent, function (args: ItemEventData) { if (!args.view) { // Create label if it is not already created. args.view = new Label(); } (