-
Notifications
You must be signed in to change notification settings - Fork 5
Description
I have installed the nativescript-swipe-layout npm package and now when I try and do a:
ns build android I am getting the following error:
Module not found: Error: Can't resolve 'nativescript-swipe-layout' in C:\native-script-apps\scl-v1\src\app\swipe'....
It seems to be complaining about the import - import { ANIMATION_STATE, GESTURE_MODE, SwipeDownEventData, SwipeLayout, SwipeLeftEventData, SwipeRightEventData, SwipeUpEventData } from "nativescript-swipe-layout";
But I cannot understand why, any help would be appreciated.
Here is my component:
`import { Component, ElementRef, ViewChild } from "@angular/core";
import { CardView } from "@nstudio/nativescript-cardview";
import { registerElement } from "@nativescript/angular";
import { TNSFontIconService } from "nativescript-ngx-fonticon";
import { ANIMATION_STATE, GESTURE_MODE, SwipeDownEventData, SwipeLayout, SwipeLeftEventData, SwipeRightEventData, SwipeUpEventData } from "nativescript-swipe-layout";
registerElement("CardView", () => CardView);
registerElement('SwipeLayout', () => SwipeLayout);
@component({
selector: "swipe",
templateUrl: "swipe.component.html",
})
export class SwipeComponent {
private _swipeLayouts: Array;
private currentSwipeLayout: SwipeLayout;
public swipeLayoutAnimated: ANIMATION_STATE;
public gestureMode: GESTURE_MODE;
public cards: Array<any> = [{ // dumb cards
img: "https://img.youtube.com/vi/GGhKPm18E48/mqdefault.jpg",
test: "Batman is pretty cool right?"
},
{
img: "https://img.youtube.com/vi/GGhKPm18E48/mqdefault.jpg",
test: "Batman is pretty cool right?"
}, {
img: "https://img.youtube.com/vi/GGhKPm18E48/mqdefault.jpg",
test: "Batman is pretty cool right?"
}, {
img: "https://img.youtube.com/vi/GGhKPm18E48/mqdefault.jpg",
test: "Batman is pretty cool right?"
}, {
img: "https://img.youtube.com/vi/GGhKPm18E48/mqdefault.jpg",
test: "Batman is pretty cool right?"
}, {
img: "https://img.youtube.com/vi/GGhKPm18E48/mqdefault.jpg",
test: "Batman is pretty cool right?"
}]
constructor(private fonticon: TNSFontIconService) {
this._swipeLayouts = new Array();
this.swipeLayoutAnimated = ANIMATION_STATE.ON_EVENTS; // Will animate only on swipe down and up events
this.gestureMode = GESTURE_MODE.DRAG; // Cards will be draggable
}
swipeLayoutLoaded(event) {
this._swipeLayouts.push(<SwipeLayout>event.object); // Since it's an Array everytime a SwipeLayout load we add it
}
ngAfterViewInit(): void {
this.currentSwipeLayout = this._swipeLayouts[this._swipeLayouts.length - 1];
}
private next() {
this._swipeLayouts.pop();
this.currentSwipeLayout = this._swipeLayouts[this._swipeLayouts.length - 1];
}
swipeLeftCallback(swipeLeftEvent: SwipeLeftEventData) { // never called (not binded to the XML)
console.log('swipeLeft');
this.next();
}
swipeRightCallback(swipeRightEvent: SwipeRightEventData) { // never called (not binded to the XML)
console.log('swipeRight');
this.next();
}
swipeUpCallback(swipeUpEvent: SwipeUpEventData) { // called once the swipe up animation is done
console.log('swipeUp');
this.next();
}
swipeDownCallback(swipeDownEvent: SwipeDownEventData) { // called once the swipe down animation is done
console.log('swipeDown');
this.next();
}
decline() { // red button on tap callback
let that = this;
this.currentSwipeLayout.animateSwipeRight().then(() => {
that.next();
console.log('swipeLeft done');
});
}
like() { // blue button on tap callback
let that = this;
this.currentSwipeLayout.animateSwipeLeft().then(() => {
that.next();
console.log('swipeRight done');
});
}
super() { // green button on tap callback
let that = this;
this.currentSwipeLayout.animateSwipeUp().then(() => {
that.next();
console.log("swipeUp done");
});
}
}`