@nativescript-community/ui-collectionview 4.0.44 → 4.0.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +38 -0
- package/README.md +188 -95
- package/angular/bundles/nativescript-community-ui-collectionview-angular.umd.js +44 -24
- package/angular/bundles/nativescript-community-ui-collectionview-angular.umd.js.map +1 -1
- package/angular/collectionview-comp.d.ts +4 -4
- package/angular/esm2015/collectionview-comp.js +2 -2
- package/angular/esm2015/index.js +2 -2
- package/angular/fesm2015/nativescript-community-ui-collectionview-angular.js +22 -21
- package/angular/fesm2015/nativescript-community-ui-collectionview-angular.js.map +1 -1
- package/angular/index.d.ts +3 -3
- package/angular/package.json +2 -2
- package/{collectionview-common.d.ts → index-common.d.ts} +1 -1
- package/{collectionview-common.js → index-common.js} +1 -1
- package/index-common.js.map +1 -0
- package/{collectionview.android.d.ts → index.android.d.ts} +2 -2
- package/{collectionview.android.js → index.android.js} +11 -8
- package/index.android.js.map +1 -0
- package/{collectionview.d.ts → index.d.ts} +2 -2
- package/{collectionview.ios.d.ts → index.ios.d.ts} +2 -3
- package/{collectionview.ios.js → index.ios.js} +4 -11
- package/index.ios.js.map +1 -0
- package/package.json +7 -6
- package/platforms/android/AndroidManifest.xml +0 -0
- package/platforms/android/include.gradle +1 -1
- package/platforms/android/java/com/nativescript/collectionview/Adapter.java +0 -0
- package/platforms/android/java/com/nativescript/collectionview/AdapterInterface.java +0 -0
- package/platforms/android/java/com/nativescript/collectionview/CollectionViewCellHolder.java +0 -0
- package/platforms/android/java/com/nativescript/collectionview/GridLayoutManager.java +0 -0
- package/platforms/android/java/com/nativescript/collectionview/OnScrollListener.java +0 -0
- package/platforms/android/java/com/nativescript/collectionview/PreCachingGridLayoutManager.java +0 -0
- package/platforms/android/java/com/nativescript/collectionview/RecyclerView.java +0 -0
- package/platforms/android/java/com/nativescript/collectionview/SizeChangedListener.java +0 -0
- package/platforms/android/java/com/nativescript/collectionview/SpanSizeLookup.java +0 -0
- package/platforms/android/native-api-usage.json +25 -0
- package/platforms/android/res/layout/collectionview.xml +0 -0
- package/react/index.d.ts +8 -8
- package/react/index.js +1 -1
- package/react/index.js.map +1 -1
- package/references.d.ts +0 -0
- package/svelte/index.d.ts +1 -1
- package/svelte/index.js +6 -3
- package/svelte/index.js.map +1 -1
- package/typings/arv.d.ts +0 -0
- package/vue/component.d.ts +0 -0
- package/vue/component.js +1 -7
- package/vue/component.js.map +1 -1
- package/vue/index.d.ts +0 -0
- package/vue/index.js +1 -1
- package/vue/index.js.map +1 -1
- package/LICENSE +0 -201
- package/angular/bundles/nativescript-community-ui-collectionview-angular.umd.min.js +0 -2
- package/angular/bundles/nativescript-community-ui-collectionview-angular.umd.min.js.map +0 -1
- package/collectionview-common.js.map +0 -1
- package/collectionview.android.js.map +0 -1
- package/collectionview.ios.js.map +0 -1
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,44 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
5
5
|
|
6
|
+
## [4.0.48](https://github.com/nativescript-community/ui-collectionview/compare/v4.0.47...v4.0.48) (2021-11-25)
|
7
|
+
|
8
|
+
**Note:** Version bump only for package @nativescript-community/ui-collectionview
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
## [4.0.47](https://github.com/nativescript-community/ui-collectionview/compare/v4.0.46...v4.0.47) (2021-11-10)
|
15
|
+
|
16
|
+
|
17
|
+
### Bug Fixes
|
18
|
+
|
19
|
+
* file permissions ([52babd6](https://github.com/nativescript-community/ui-collectionview/commit/52babd68e7c64a0fded8433deac53cb08d5b3885))
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
## [4.0.46](https://github.com/nativescript-community/ui-collectionview/compare/v4.0.45...v4.0.46) (2021-10-21)
|
26
|
+
|
27
|
+
**Note:** Version bump only for package @nativescript-community/ui-collectionview
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
## [4.0.45](https://github.com/nativescript-community/ui-collectionview/compare/v4.0.44...v4.0.45) (2021-09-22)
|
34
|
+
|
35
|
+
|
36
|
+
### Bug Fixes
|
37
|
+
|
38
|
+
* **collectionview:** android fix for gradle 7.0 ([ded3a35](https://github.com/nativescript-community/ui-collectionview/commit/ded3a35033375ce950e1bb77e2d0dff1527e5701))
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
|
6
44
|
## [4.0.44](https://github.com/nativescript-community/ui-collectionview/compare/v4.0.43...v4.0.44) (2021-08-29)
|
7
45
|
|
8
46
|
|
package/README.md
CHANGED
@@ -1,90 +1,129 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
1
|
+
<!-- ⚠️ This README has been generated from the file(s) "blueprint.md" ⚠️-->
|
2
|
+
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
3
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
4
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
5
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
6
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
7
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
8
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
9
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
10
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
11
|
+
DO NOT EDIT THIS READEME DIRECTLY! Edit "bluesprint.md" instead.
|
12
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
13
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
14
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
15
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
16
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
17
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
18
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
19
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
20
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
21
|
+
<h1 align="center">@nativescript-community/ui-collectionview</h1>
|
22
|
+
<p align="center">
|
23
|
+
<a href="https://npmcharts.com/compare/@nativescript-community/ui-collectionview?minimal=true"><img alt="Downloads per month" src="https://img.shields.io/npm/dm/@nativescript-community/ui-collectionview.svg" height="20"/></a>
|
24
|
+
<a href="https://www.npmjs.com/package/@nativescript-community/ui-collectionview"><img alt="NPM Version" src="https://img.shields.io/npm/v/@nativescript-community/ui-collectionview.svg" height="20"/></a>
|
25
|
+
</p>
|
26
|
+
|
27
|
+
<p align="center">
|
28
|
+
<b>Allows you to easily add a collection view (grid list view) to your projects. Supports vertical and horizontal modes, templating, and more.</b></br>
|
29
|
+
<sub><sub>
|
30
|
+
</p>
|
31
|
+
|
32
|
+
<br />
|
33
|
+
|
34
|
+
|
35
|
+
| <img src="https://github.com/nativescript-community/ui-collectionview/raw/master/images/demo-ios.gif" height="500" /> | <img src="https://github.com/nativescript-community/ui-collectionview/raw/master/images/demo-android.gif" height="500" /> |
|
36
|
+
| --- | ----------- |
|
37
|
+
| iOS Demo | Android Demo |
|
38
|
+
|
39
|
+
|
40
|
+
[](#table-of-contents)
|
41
|
+
|
15
42
|
## Table of Contents
|
16
43
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
44
|
+
* [Installation](#installation)
|
45
|
+
* [API](#api)
|
46
|
+
* [Events](#events)
|
47
|
+
* [Properties](#properties)
|
48
|
+
* [Methods](#methods)
|
49
|
+
* [Usage](#usage)
|
50
|
+
* [Simple Example](#simple-example)
|
51
|
+
* [Templates Example](#templates-example)
|
52
|
+
* [Usage in Angular](#usage-in-angular)
|
53
|
+
* [Simple Example](#simple-example-1)
|
54
|
+
* [Templates Example](#templates-example-1)
|
55
|
+
* [Usage in Vue](#usage-in-vue)
|
56
|
+
* [Simple Example](#simple-example-2)
|
57
|
+
* [Usage in Svelte](#usage-in-svelte)
|
58
|
+
* [Simple Example](#simple-example-3)
|
59
|
+
* [Usage in React](#usage-in-react)
|
60
|
+
* [Simple Example](#simple-example-4)
|
61
|
+
* [Demos](#demos)
|
62
|
+
* [Demos and Development](#demos-and-development)
|
63
|
+
* [Setup](#setup)
|
64
|
+
* [Build](#build)
|
65
|
+
* [Demos](#demos-1)
|
66
|
+
* [Questions](#questions)
|
67
|
+
|
68
|
+
|
69
|
+
[](#installation)
|
70
|
+
|
27
71
|
## Installation
|
28
|
-
|
29
72
|
Run the following command from the root of your project:
|
30
73
|
|
31
74
|
`ns plugin add @nativescript-community/ui-collectionview`
|
32
75
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
There is no additional configuration needed!
|
38
|
-
|
76
|
+
|
77
|
+
[](#api)
|
78
|
+
|
39
79
|
## API
|
40
80
|
|
41
81
|
### Events
|
42
82
|
|
43
|
-
| Property | Description
|
44
|
-
| ------------------- |
|
45
|
-
| itemLoading | Triggered when generating an item in the CollectionView.
|
46
|
-
| itemTap | Triggered when the user taps on an item in the CollectionView.
|
47
|
-
| loadMoreItems | Triggered when the generated items reached the end of the items property.
|
48
|
-
| scroll | Triggered on collectionview scroll.
|
49
|
-
| scrollEnd | Triggered on collectionview scroll end.
|
50
|
-
| itemReorderStarting
|
51
|
-
| itemReorderStarted
|
52
|
-
| itemReordered | Triggered when a reorder finished.
|
53
|
-
| dataPopulated | Triggered when a refresh has been called.
|
83
|
+
| Property | Description |
|
84
|
+
| ------------------- | ---------------------------------------------------------------------------- |
|
85
|
+
| itemLoading | Triggered when generating an item in the CollectionView. |
|
86
|
+
| itemTap | Triggered when the user taps on an item in the CollectionView. |
|
87
|
+
| loadMoreItems | Triggered when the generated items reached the end of the items property. |
|
88
|
+
| scroll | Triggered on collectionview scroll. |
|
89
|
+
| scrollEnd | Triggered on collectionview scroll end. |
|
90
|
+
| itemReorderStarting | Triggered when a reorder is starting. Changing the `returnValue` of the event data allows you to cancel it |
|
91
|
+
| itemReorderStarted | Triggered when a reorder started. |
|
92
|
+
| itemReordered | Triggered when a reorder finished. |
|
93
|
+
| dataPopulated | Triggered when a refresh has been called. |
|
94
|
+
|
95
|
+
|
54
96
|
|
55
97
|
### Properties
|
56
98
|
|
57
|
-
| Property
|
58
|
-
|
|
59
|
-
| ios
|
60
|
-
| android
|
61
|
-
| items
|
62
|
-
| itemTemplate
|
63
|
-
| rowHeight
|
64
|
-
| colWidth
|
65
|
-
| spanSize
|
66
|
-
|
|
67
|
-
|
|
68
|
-
| isScrollEnabled | `boolean` | enable/disable CollectionView scroll |
|
69
|
-
| reverseLayout | `boolean` | enable/disable CollectionView reversed layout (for message like views) |
|
70
|
-
| loadMoreThreshold | `number` | set the loadMore threshold (called on the `item.length - loadMoreThreshold` item appearing) |
|
71
|
-
| reorderEnabled | `boolean` | enable/disable CollectionView reorder feature |
|
72
|
-
| reorderLongPressEnabled | `boolean` | enable/disable CollectionView longpress to reorder |
|
73
|
-
| scrollBarIndicatorVisible | `boolean` | enable/disable CollectionView scrollBars |
|
74
|
-
| nestedScrollingEnabled | `boolean` | (Android) enable/disable CollectionView nested scrolling |
|
99
|
+
| Property | Type | Description |
|
100
|
+
| ------------- | ------------------------------------------------ | ------------------------------------------------------- |
|
101
|
+
| ios | [UICollectionView](https://tinyurl.com/y4ugbfgc) | Gets the native iOS view that represents the user interface for this component. Valid only when running on iOS. |
|
102
|
+
| android | [android.support.v7.widget.RecyclerView](https://tinyurl.com/lvqebpq) | Gets the native android widget that represents the user interface for this component. Valid only when running on Android OS. |
|
103
|
+
| items | `array` or `ItemsSource` | Gets or sets the items collection of the CollectionView. The items property can be set to an array or an object defining length and getItem(index) method. |
|
104
|
+
| itemTemplate | `string` | Gets or sets the item template of the CollectionView. |
|
105
|
+
| rowHeight | `PercentLength` | Gets or sets the height for every row in the CollectionView. |
|
106
|
+
| colWidth | `PercentLength` | Gets or sets the width for every column in the CollectionView. |
|
107
|
+
| spanSize | `function` | Triggered when an item is loaded. Returns the number of columns that the element should occupy taking into account `colWidth` when the device is vertical and `rowHeight` when horizontal. Parameters: (item, index: number). |
|
108
|
+
| scrollOffset | `number` | Gets the current scroll. |
|
109
|
+
| orientation | `vertical` or `horizontal` | Sets the orientation of the CollectionView. Defaults to `vertical`. |
|
75
110
|
|
76
111
|
### Methods
|
77
112
|
|
78
113
|
| Name | Return | Description |
|
79
114
|
| ------------------------------------------------------ | ------ | ---------------------------------------------------------------------------------------------------------------------- |
|
80
115
|
| refresh() | `void` | Forces the CollectionView to reload all its items. |
|
116
|
+
| refreshVisibleItem() | `void` | Forces CollectionView to reload visible items. |
|
81
117
|
| scrollToIndex(index: number, animated: boolean = true) | `void` | Scrolls the CollectionView to the item with the given index. This can be either animated or not. Defaults to animated. |
|
118
|
+
| isItemAtIndexVisible(index: number) | `boolean` | Returns a boolean indicating whether the item is visible. |
|
82
119
|
|
120
|
+
|
121
|
+
[](#usage)
|
122
|
+
|
83
123
|
## Usage
|
84
|
-
|
85
124
|
You need to add `xmlns:gv="@nativescript-community/ui-collectionview"` to your page tag, and then simply use `<gv:CollectionView/>` in order to add the widget to your page. Use `<gv:Gridview.itemTemplate/>` to specify the template for each cell:
|
86
125
|
|
87
|
-
### Simple Example
|
126
|
+
### Simple Example
|
88
127
|
|
89
128
|
Create a simple array of objects in your JS/TS file.
|
90
129
|
|
@@ -107,46 +146,46 @@ const items = [
|
|
107
146
|
<!-- test-page.xml -->
|
108
147
|
<Page xmlns="http://schemas.nativescript.org/tns.xsd" xmlns:gv="@nativescript-community/ui-collectionview" loaded="pageLoaded">
|
109
148
|
<GridLayout>
|
110
|
-
<gv:CollectionView items="
|
149
|
+
<gv:CollectionView items="items" colWidth="50%" rowHeight="100">
|
111
150
|
<gv:CollectionView.itemTemplate>
|
112
|
-
<Label text="
|
151
|
+
<Label text="value" verticalAlignment="center"/>
|
113
152
|
</gv:CollectionView.itemTemplate>
|
114
153
|
</gv:CollectionView>
|
115
154
|
</GridLayout>
|
116
155
|
</Page>
|
117
156
|
```
|
118
157
|
|
119
|
-
### Templates Example
|
120
|
-
|
158
|
+
### Templates Example
|
121
159
|
You can also have multiple templates the same way you add them in the builtin `ListView` control:
|
122
|
-
|
123
160
|
```xml
|
124
|
-
<gv:CollectionView id="gv" row="0" class="
|
125
|
-
colWidth="
|
161
|
+
<gv:CollectionView id="gv" row="0" class="cssClass" items="items"
|
162
|
+
colWidth="colWidth" rowHeight="rowHeight" itemTemplateSelector="templateSelector"
|
126
163
|
itemTap="gridViewItemTap" itemLoading="gridViewItemLoading" loadMoreItems="gridViewLoadMoreItems">
|
127
164
|
<gv:CollectionView.itemTemplates>
|
128
165
|
<template key="odd">
|
129
166
|
<GridLayout backgroundColor="#33ffff" style="margin: 10 10 0 0">
|
130
|
-
<Label text="
|
167
|
+
<Label text="value" verticalAlignment="center"/>
|
131
168
|
</GridLayout>
|
132
169
|
</template>
|
133
170
|
|
134
171
|
<template key="even">
|
135
172
|
<GridLayout backgroundColor="#33ffff" rows="auto, auto" style="margin: 10 10 0 0">
|
136
|
-
<Label row="0" text="
|
137
|
-
<Label row="1" text="
|
173
|
+
<Label row="0" text="value" verticalAlignment="center"/>
|
174
|
+
<Label row="1" text="value" verticalAlignment="center"/>
|
138
175
|
</GridLayout>
|
139
176
|
</template>
|
140
177
|
</gv:CollectionView.itemTemplates>
|
141
178
|
</gv:CollectionView>
|
142
179
|
```
|
143
|
-
|
144
180
|
```ts
|
145
181
|
export function templateSelector(item: any, index: number, items: any) {
|
146
|
-
return index % 2 === 0 ?
|
182
|
+
return index % 2 === 0 ? "even" : "odd";
|
147
183
|
}
|
148
184
|
```
|
149
185
|
|
186
|
+
|
187
|
+
[](#usage-in-angular)
|
188
|
+
|
150
189
|
## Usage in Angular
|
151
190
|
|
152
191
|
Import the module into your project.
|
@@ -160,8 +199,7 @@ import { CollectionViewModule } from '@nativescript-community/ui-collectionview/
|
|
160
199
|
],
|
161
200
|
})
|
162
201
|
```
|
163
|
-
|
164
|
-
### Simple Example:
|
202
|
+
### Simple Example
|
165
203
|
|
166
204
|
Create a simple array of objects in your Typescript file.
|
167
205
|
|
@@ -181,7 +219,6 @@ items = [
|
|
181
219
|
```
|
182
220
|
|
183
221
|
Add the following to your component HTML.
|
184
|
-
|
185
222
|
```xml
|
186
223
|
<CollectionView [items]="items" colWidth="50%" rowHeight="100">
|
187
224
|
<ng-template let-item="item">
|
@@ -190,33 +227,31 @@ Add the following to your component HTML.
|
|
190
227
|
</CollectionView>
|
191
228
|
```
|
192
229
|
|
193
|
-
### Templates Example
|
194
|
-
|
230
|
+
### Templates Example
|
195
231
|
If you want to use multiple item templates, you can do that very similarly to how you do it for the builtin `ListView` control. The only difference is that due to current limitations instead of using the `nsTemplateKey` directive you need to use the `cvTemplateKey` directive that comes from the CollectionView. (In a future version, once the framework allows it this will be changed and you will be able to use the same directive for the `CollectionView` as well)
|
196
|
-
|
197
232
|
```html
|
198
233
|
<CollectionView row="1" [items]="items" colWidth="33%" rowHeight="100" [itemTemplateSelector]="templateSelector">
|
199
234
|
<ng-template cvTemplateKey="Defender" let-item="item" let-odd="odd">
|
200
235
|
<StackLayout [nsRouterLink]="['/item', item.id]" borderColor="blue" borderWidth="2" borderRadius="5" verticalAlignment="stretch" class="list-group-item" [class.odd]="odd">
|
201
|
-
|
236
|
+
<Label verticalAlignment="center" [text]="item.name" class="list-group-item-text" textWrap="true"></Label>
|
202
237
|
</StackLayout>
|
203
238
|
</ng-template>
|
204
239
|
|
205
240
|
<ng-template cvTemplateKey="Goalkeeper" let-item="item" let-odd="odd">
|
206
241
|
<StackLayout [nsRouterLink]="['/item', item.id]" borderColor="black" borderWidth="2" borderRadius="5" verticalAlignment="stretch" class="list-group-item" [class.odd]="odd">
|
207
|
-
|
242
|
+
<Label verticalAlignment="center" [text]="item.name" class="list-group-item-text" textWrap="true"></Label>
|
208
243
|
</StackLayout>
|
209
244
|
</ng-template>
|
210
245
|
|
211
246
|
<ng-template cvTemplateKey="Midfielder" let-item="item" let-odd="odd">
|
212
247
|
<StackLayout [nsRouterLink]="['/item', item.id]" borderColor="yellow" borderWidth="2" borderRadius="5" verticalAlignment="stretch" class="list-group-item" [class.odd]="odd">
|
213
|
-
|
248
|
+
<Label verticalAlignment="center" [text]="item.name" class="list-group-item-text" textWrap="true"></Label>
|
214
249
|
</StackLayout>
|
215
250
|
</ng-template>
|
216
251
|
|
217
252
|
<ng-template cvTemplateKey="Forward" let-item="item" let-odd="odd">
|
218
253
|
<StackLayout [nsRouterLink]="['/item', item.id]" borderColor="red" borderWidth="2" borderRadius="5" verticalAlignment="stretch" class="list-group-item" [class.odd]="odd">
|
219
|
-
|
254
|
+
<Label verticalAlignment="center" [text]="item.name" class="list-group-item-text" textWrap="true"></Label>
|
220
255
|
</StackLayout>
|
221
256
|
</ng-template>
|
222
257
|
</CollectionView>
|
@@ -224,6 +259,9 @@ If you want to use multiple item templates, you can do that very similarly to ho
|
|
224
259
|
|
225
260
|
For a more complete example, look in the `demo-ng` directory.
|
226
261
|
|
262
|
+
|
263
|
+
[](#usage-in-vue)
|
264
|
+
|
227
265
|
## Usage in Vue
|
228
266
|
|
229
267
|
Register the plugin in your `app.ts`.
|
@@ -233,8 +271,7 @@ import CollectionView from '@nativescript-community/ui-collectionview/vue';
|
|
233
271
|
Vue.use(CollectionView);
|
234
272
|
```
|
235
273
|
|
236
|
-
### Simple Example
|
237
|
-
|
274
|
+
### Simple Example
|
238
275
|
In your component, add the following to make a simple array of objects.
|
239
276
|
|
240
277
|
```typescript
|
@@ -256,7 +293,7 @@ export default {
|
|
256
293
|
return {
|
257
294
|
itemList: items
|
258
295
|
};
|
259
|
-
}
|
296
|
+
},
|
260
297
|
// ...
|
261
298
|
};
|
262
299
|
```
|
@@ -277,6 +314,9 @@ Then add the following XML to your component.
|
|
277
314
|
|
278
315
|
For a more complete example, look in the `demo-vue` directory.
|
279
316
|
|
317
|
+
|
318
|
+
[](#usage-in-svelte)
|
319
|
+
|
280
320
|
## Usage in Svelte
|
281
321
|
|
282
322
|
Register the plugin in your `app.ts`.
|
@@ -286,7 +326,7 @@ import CollectionViewElement from '@nativescript-community/ui-collectionview/sve
|
|
286
326
|
CollectionViewElement.register();
|
287
327
|
```
|
288
328
|
|
289
|
-
### Simple Example
|
329
|
+
### Simple Example
|
290
330
|
|
291
331
|
In you component, add the following to import Svelte `Templates` and to create a simple array of objects.
|
292
332
|
|
@@ -310,8 +350,8 @@ const items = [
|
|
310
350
|
Then add the following XML to your component:
|
311
351
|
|
312
352
|
```xml
|
313
|
-
<collectionView
|
314
|
-
{items}
|
353
|
+
<collectionView
|
354
|
+
{items}
|
315
355
|
colWidth="50%"
|
316
356
|
rowHeight="100"
|
317
357
|
>
|
@@ -323,6 +363,9 @@ Then add the following XML to your component:
|
|
323
363
|
|
324
364
|
For a more complete example, look in the `demo-svelte` directory.
|
325
365
|
|
366
|
+
|
367
|
+
[](#usage-in-react)
|
368
|
+
|
326
369
|
## Usage in React
|
327
370
|
|
328
371
|
Register the plugin in your `app.ts`.
|
@@ -332,7 +375,7 @@ import { registerCollectionView } from '@nativescript-community/ui-collectionvie
|
|
332
375
|
registerCollectionView();
|
333
376
|
```
|
334
377
|
|
335
|
-
### Simple Example
|
378
|
+
### Simple Example
|
336
379
|
|
337
380
|
In your component, add the following code to create a simple list.
|
338
381
|
|
@@ -358,19 +401,24 @@ interface Item {
|
|
358
401
|
color: string;
|
359
402
|
}
|
360
403
|
|
361
|
-
const cellFactory = (item: Item) =>
|
404
|
+
const cellFactory = (item: Item) => (
|
405
|
+
<label text={item.name} />
|
406
|
+
);
|
362
407
|
|
363
408
|
export function First() {
|
364
|
-
return
|
409
|
+
return (
|
410
|
+
<CollectionView items={items} colWidth="50%" rowHeight="100" cellFactory={cellFactory} width="100%" height="100%" />
|
411
|
+
);
|
365
412
|
}
|
366
413
|
```
|
367
414
|
|
368
415
|
For a more complete example, look in the `demo-react` directory.
|
369
416
|
|
417
|
+
|
418
|
+
[](#demos)
|
419
|
+
|
370
420
|
## Demos
|
371
|
-
|
372
421
|
This repository includes Angular, Vue.js, and Svelte demos. In order to run these execute the following in your shell:
|
373
|
-
|
374
422
|
```shell
|
375
423
|
$ git clone https://github.com/@nativescript-community/ui-collectionview
|
376
424
|
$ cd ui-collectionview
|
@@ -380,3 +428,48 @@ $ npm run build # && npm run build.angular
|
|
380
428
|
$ cd demo-ng # or demo-vue or demo-svelte
|
381
429
|
$ ns run ios|android
|
382
430
|
```
|
431
|
+
|
432
|
+
|
433
|
+
[](#demos-and-development)
|
434
|
+
|
435
|
+
## Demos and Development
|
436
|
+
|
437
|
+
|
438
|
+
### Setup
|
439
|
+
|
440
|
+
To run the demos, you must clone this repo **recursively**.
|
441
|
+
|
442
|
+
```
|
443
|
+
git clone https://github.com/@nativescript-community/ui-collectionview.git --recursive
|
444
|
+
```
|
445
|
+
|
446
|
+
**Install Dependencies:**
|
447
|
+
```bash
|
448
|
+
npm i # or 'yarn install' or 'pnpm install'
|
449
|
+
```
|
450
|
+
|
451
|
+
**Interactive Menu:**
|
452
|
+
|
453
|
+
To start the interactive menu, run `npm start` (or `yarn start` or `pnpm start`). This will list all of the commonly used scripts.
|
454
|
+
|
455
|
+
### Build
|
456
|
+
|
457
|
+
```bash
|
458
|
+
npm run build
|
459
|
+
|
460
|
+
npm run build.angular # or for Angular
|
461
|
+
```
|
462
|
+
|
463
|
+
### Demos
|
464
|
+
|
465
|
+
```bash
|
466
|
+
npm run demo.[ng|react|svelte|vue].[ios|android]
|
467
|
+
|
468
|
+
npm run demo.svelte.ios # Example
|
469
|
+
```
|
470
|
+
|
471
|
+
[](#questions)
|
472
|
+
|
473
|
+
## Questions
|
474
|
+
|
475
|
+
If you have any questions/issues/comments please feel free to create an issue or start a conversation in the [NativeScript Community Discord](https://nativescript.org/discord).
|