Skip to content

Commit 4d21a11

Browse files
committed
fix: Fix ListView itemTap not being triggered
1 parent 0b02a11 commit 4d21a11

File tree

4 files changed

+30
-3
lines changed

4 files changed

+30
-3
lines changed

demo/app/main-page.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
/* eslint-disable no-console */
22
import {
33
EventData,
4+
ItemEventData,
5+
ListView,
46
Observable,
57
ObservableArray,
68
Page,
@@ -28,4 +30,23 @@ export function onStar(e: EventData) {
2830

2931
export function onDelete(e: EventData) {
3032
console.log("DELETE", (e.object as ViewBase).bindingContext);
33+
}
34+
35+
export function onItemTap(e: ItemEventData) {
36+
console.log(e.index);
37+
}
38+
39+
40+
export function nullifyTableViewSeparatorInsets(args: ItemEventData) {
41+
if (global.isIOS) {
42+
args.ios.separatorInset = UIEdgeInsetsZero;
43+
args.ios.layoutMargins = UIEdgeInsetsZero;
44+
args.ios.preservesSuperviewLayoutMargins = false;
45+
}
46+
}
47+
48+
export function nullifyEmptyCells(e: EventData) {
49+
if (global.isIOS) {
50+
((e.object as ListView).ios as UITableView).tableFooterView = UIView.alloc().initWithFrame(CGRectZero);
51+
}
3152
}

demo/app/main-page.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
<Page xmlns="http://schemas.nativescript.org/tns.xsd" xmlns:sv="nativescript-swipe-view" navigatingTo="navigatingTo" >
22
<ActionBar title="Swipe View" icon="" />
33

4-
<ListView items="{{ items }}">
4+
<ListView
5+
items="{{ items }}"
6+
loaded="nullifyEmptyCells"
7+
itemLoading="nullifyTableViewSeparatorInsets"
8+
itemTap="onItemTap">
59
<ListView.itemTemplate>
610
<sv:SwipeView>
711
<sv:SwipeView.leftActionsTemplate>

src/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nativescript-swipe-view",
3-
"version": "1.1.0",
3+
"version": "1.2.0",
44
"description": "NativeScript plugin to connect with Azure Notification Hubs",
55
"main": "dist/swipe-view",
66
"typings": "swipe-view.d.ts",

src/swipe-view.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,10 @@ export class SwipeView extends GridLayout implements definition.SwipeView {
9999
this._resetTransition();
100100
}
101101
});
102+
this.parent?.on("itemTap", this._resetTransition.bind(this));
103+
102104
this.on("pan", this._onPan.bind(this));
103-
this.on("tap", this._resetTransition.bind(this));
105+
this._swipeView.on("tap", this._resetTransition.bind(this));
104106
}
105107

106108
public onUnloaded(): void {

0 commit comments

Comments
 (0)