Skip to content

Commit 2cec1cf

Browse files
author
farfromrefug
committed
Merge remote-tracking branch 'origin/master'
2 parents 729e725 + f280f1d commit 2cec1cf

22 files changed

+1637
-1338
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
## [5.3.24](https://github.com/@nativescript-community/ui-collectionview/compare/v5.3.23...v5.3.24) (2024-03-01)
7+
8+
### Bug Fixes
9+
10+
* **ios:** `autoReloadItemOnLayout` handle more cases ([630f022](https://github.com/@nativescript-community/ui-collectionview/commit/630f022a779b459f9ca04239efdfc925ab6a13d0))
11+
12+
## [5.3.23](https://github.com/@nativescript-community/ui-collectionview/compare/v5.3.22...v5.3.23) (2024-03-01)
13+
14+
### Bug Fixes
15+
16+
* **collectionview,ios:** fix `autoReloadItemOnLayout` which could trigger a lot of unneeded layouts ([a393173](https://github.com/@nativescript-community/ui-collectionview/commit/a393173825c59455ae149c886092d92673f2ee10))
17+
618
## [5.3.22](https://github.com/@nativescript-community/ui-collectionview/compare/v5.3.21...v5.3.22) (2024-02-21)
719

820
### Bug Fixes

demo-snippets/svelte/ResizeCell.svelte

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,29 @@
2525
{ index: 18, name: 'SILVER', color: '#bdc3c7' },
2626
{ index: 19, name: 'ASBESTOS', color: '#7f8c8d' }
2727
]);
28+
29+
async function resizeCell(item, event) {
30+
try {
31+
const actualItem = item;
32+
actualItem.showMenu = !actualItem.showMenu;
33+
console.log('resizeCell', actualItem.showMenu)
34+
async function animate(options = {}) {
35+
const newHeight = actualItem.showMenu ? 200 : 100;
36+
return (event.object as View).animate({ height: newHeight, ...options, duration: 300 });
37+
}
38+
39+
const updateItem = () => {
40+
if (item) {
41+
const index = this.items.findIndex((i) => i === item);
42+
// console.log('updateItem', index, item);
43+
this.items.setItem(index, item);
44+
}
45+
};
46+
await animate();
47+
} catch (error) {
48+
console.error(error);
49+
}
50+
}
2851
</script>
2952

3053
<page>
@@ -36,7 +59,16 @@
3659
the reason is that for this to work in collectionview
3760
upon resize animation the Svelte component needs to update its "height" property
3861
otherwise Collectionview bind will report wrong height on cell reuse -->
39-
<ResizeView {item}/>
62+
<gridlayout id="resizeHolder" rows="101,100" on:tap={e=>resizeCell(item,e)} height={item.showMenu === true ? 200 : 100} verticalAlignment="top">
63+
<stacklayout row="0" class="item" backgroundColor={item.color}>
64+
<label row="1" text={item.name} class="title" />
65+
<label row="1" text={item.color} class="subtitle" />
66+
</stacklayout>
67+
<stacklayout row="1" orientation="horizontal" height="100">
68+
<label text="a" width="100" height="100%" backgroundColor="red" textAlignment="center" />
69+
<label text="b" width="100" height="100%" backgroundColor="blue" textAlignment="center" />
70+
</stacklayout>
71+
</gridlayout>
4072
</Template>
4173
</collectionView>
4274
</gridLayout>

demo-snippets/svelte/ResizeView.svelte

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,41 @@
1-
<script lang="ts">
1+
<script context="module" lang="ts">
22
import { View } from '@nativescript/core';
3+
let ID = 0;
4+
</script>
5+
<script lang="ts">
36
export let item;
7+
export let height;
8+
const myId = ID++;
49
5-
$: height = item.showMenu === true ? 200 : 100;
10+
function updateheight(item) {
11+
height = item.showMenu === true ? 200 : 100;
12+
console.log('height', myId, height)
13+
}
614
715
async function resizeCell(event) {
816
try {
17+
const newValue = item.showMenu === true ? false : true;
18+
console.log('resizeCell', myId, item.showMenu, newValue)
919
async function animate(options = {}) {
10-
const newHeight = !item.showMenu ? 200 : 100;
20+
const newHeight = newValue ? 200 : 100;
1121
return (event.object as View).animate({ height: newHeight, ...options, duration: 300 });
1222
}
23+
if (__ANDROID__) {
1324
await animate();
25+
item.showMenu = newValue;
26+
27+
} else {
28+
item.showMenu = newValue;
29+
30+
}
1431
// we update it after so that the svelte component also updates its value
15-
item.showMenu = !item.showMenu;
1632
} catch (error) {
1733
console.error(error);
1834
}
1935
}
2036
</script>
2137

22-
<gridlayout rows="101,100" on:tap={resizeCell} height={height}>
38+
<gridlayout id="resizeHolder" rows="101,100" on:tap={resizeCell} {height} verticalAlignment="top">
2339
<stacklayout row="0" class="item" backgroundColor={item.color}>
2440
<label row="1" text={item.name} class="title" />
2541
<label row="1" text={item.color} class="subtitle" />

demo-snippets/svelte/SwipeMenu.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
<actionItem on:tap={refresh} ios.systemIcon="16" ios.position="right" text="refresh" android.position="popup" />
7474
</actionBar>
7575
<gridLayout rows="auto,*">
76-
<collectionView {items} row="1" rowHeight="100" automationText="collectionView">
76+
<collectionView {items} row="1" rowHeight="100" automationText="collectionView" autoReloadItemOnLayout={true}>
7777
<Template let:item>
7878
<swipemenu id={item.name} leftSwipeDistance="300" translationFunction={drawerTranslationFunction} startingSide={item.startingSide}>
7979
<gridlayout rows="*, auto" backgroundColor={item.color} class="item" prop:mainContent width="100%">

docs/assets/navigation.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)