Skip to content

Commit

Permalink
fix: Fix ListView itemTap not being triggered
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterStaev committed Apr 3, 2023
1 parent 0b02a11 commit 4d21a11
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
21 changes: 21 additions & 0 deletions demo/app/main-page.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/* eslint-disable no-console */
import {
EventData,
ItemEventData,
ListView,
Observable,
ObservableArray,
Page,
Expand Down Expand Up @@ -28,4 +30,23 @@ export function onStar(e: EventData) {

export function onDelete(e: EventData) {
console.log("DELETE", (e.object as ViewBase).bindingContext);
}

export function onItemTap(e: ItemEventData) {
console.log(e.index);
}


export function nullifyTableViewSeparatorInsets(args: ItemEventData) {
if (global.isIOS) {
args.ios.separatorInset = UIEdgeInsetsZero;
args.ios.layoutMargins = UIEdgeInsetsZero;
args.ios.preservesSuperviewLayoutMargins = false;
}
}

export function nullifyEmptyCells(e: EventData) {
if (global.isIOS) {
((e.object as ListView).ios as UITableView).tableFooterView = UIView.alloc().initWithFrame(CGRectZero);
}
}
6 changes: 5 additions & 1 deletion demo/app/main-page.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<Page xmlns="http://schemas.nativescript.org/tns.xsd" xmlns:sv="nativescript-swipe-view" navigatingTo="navigatingTo" >
<ActionBar title="Swipe View" icon="" />

<ListView items="{{ items }}">
<ListView
items="{{ items }}"
loaded="nullifyEmptyCells"
itemLoading="nullifyTableViewSeparatorInsets"
itemTap="onItemTap">
<ListView.itemTemplate>
<sv:SwipeView>
<sv:SwipeView.leftActionsTemplate>
Expand Down
2 changes: 1 addition & 1 deletion src/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nativescript-swipe-view",
"version": "1.1.0",
"version": "1.2.0",
"description": "NativeScript plugin to connect with Azure Notification Hubs",
"main": "dist/swipe-view",
"typings": "swipe-view.d.ts",
Expand Down
4 changes: 3 additions & 1 deletion src/swipe-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,10 @@ export class SwipeView extends GridLayout implements definition.SwipeView {
this._resetTransition();
}
});
this.parent?.on("itemTap", this._resetTransition.bind(this));

this.on("pan", this._onPan.bind(this));
this.on("tap", this._resetTransition.bind(this));
this._swipeView.on("tap", this._resetTransition.bind(this));
}

public onUnloaded(): void {
Expand Down

0 comments on commit 4d21a11

Please sign in to comment.