Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 44 additions & 43 deletions api-reports/NativeScript.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -870,17 +870,17 @@ export class Frame extends View {

// @public
export interface GestureEventData extends EventData {
android: any
ios: any /* UIGestureRecognizer */;
type: GestureTypes;
view: View;
}
android: any
ios: any /* UIGestureRecognizer */;
type: GestureTypes;
view: View;
}

// @public
export interface GestureEventDataWithState extends GestureEventData {
// (undocumented)
state: number;
}
}

// @public
export class GesturesObserver {
Expand All @@ -897,15 +897,15 @@ export class GesturesObserver {
observe(type: GestureTypes);

type: GestureTypes;
}
}

// @public
export enum GestureStateTypes {
began,
cancelled,
changed,
ended
}
}

// @public
export enum GestureTypes {
Expand All @@ -917,7 +917,7 @@ export enum GestureTypes {
swipe,
tap,
touch
}
}

// @public
export class GridLayout extends LayoutBase {
Expand Down Expand Up @@ -1011,49 +1011,49 @@ export const Http: {

// @public
export interface HttpContent {
raw: any;
raw: any;

toArrayBuffer: () => ArrayBuffer;
toArrayBuffer: () => ArrayBuffer;

toFile: (destinationFilePath?: string) => File;
toFile: (destinationFilePath?: string) => File;

toImage: () => Promise<ImageSource>;
toImage: () => Promise<ImageSource>;

toJSON: (encoding?: HttpResponseEncoding) => any;
toJSON: (encoding?: HttpResponseEncoding) => any;

toString: (encoding?: HttpResponseEncoding) => string;
toString: (encoding?: HttpResponseEncoding) => string;
}

// @public
export interface HttpRequestOptions {
content?: string | FormData | ArrayBuffer;
content?: string | FormData | ArrayBuffer;

dontFollowRedirects?: boolean;
dontFollowRedirects?: boolean;

headers?: any;
headers?: any;

method: string;
method: string;

timeout?: number;
timeout?: number;

url: string;
url: string;
}

// @public
export interface HttpResponse {
content?: HttpContent;
content?: HttpContent;

headers: Headers;
headers: Headers;

statusCode: number;
statusCode: number;
}

// @public (undocumented)
export enum HttpResponseEncoding {
// (undocumented)
GBK,
// (undocumented)
UTF8
// (undocumented)
GBK,
// (undocumented)
UTF8
}

// @public
Expand Down Expand Up @@ -1646,7 +1646,7 @@ export interface PanGestureEventData extends GestureEventDataWithState {
deltaX: number;
// (undocumented)
deltaY: number;
}
}

// @public
export interface ParserEvent {
Expand Down Expand Up @@ -1702,7 +1702,7 @@ export interface PinchGestureEventData extends GestureEventDataWithState {

// (undocumented)
scale: number;
}
}

// @public
export class Placeholder extends View {
Expand Down Expand Up @@ -1767,7 +1767,7 @@ export class Repeater extends CustomLayoutView {
export interface RotationGestureEventData extends GestureEventDataWithState {
// (undocumented)
rotation: number;
}
}

// @public
export module Screen {
Expand Down Expand Up @@ -2172,13 +2172,13 @@ export enum SwipeDirection {
left,
right,
up
}
}

// @public
export interface SwipeGestureEventData extends GestureEventData {
// (undocumented)
direction: SwipeDirection;
}
}

// @public
export class Switch extends View {
Expand Down Expand Up @@ -2417,6 +2417,15 @@ export class TabViewItem extends ViewBase {
public view: View;
}

// @public
export interface TapGestureEventData extends GestureEventData {
getPointerCount(): number;

getX(): number;

getY(): number;
}

// @public
export interface Template {
(): View;
Expand Down Expand Up @@ -2536,20 +2545,12 @@ export interface TimerInfo {
}

// @public
export interface TouchGestureEventData extends GestureEventData {
export interface TouchGestureEventData extends TapGestureEventData {
action: "up" | "move" | "down" | "cancel";

// Warning: (ae-forgotten-export) The symbol "Pointer" needs to be exported by the entry point index.d.ts
getActivePointers(): Array<Pointer>;

getAllPointers(): Array<Pointer>;

getPointerCount(): number;

getX(): number;

getY(): number;
}
}

// @public (undocumented)
export const Trace: {
Expand Down
42 changes: 16 additions & 26 deletions nativescript-core/ui/gestures/gestures.android.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Definitions.
import { DoubleTapGestureEventData, GestureEventData, GestureEventDataWithState, PanGestureEventData, RotationGestureEventData, SwipeGestureEventData } from ".";
import { GestureEventData, TapGestureEventData, SwipeGestureEventData, PanGestureEventData, RotationGestureEventData, GestureEventDataWithState } from ".";
import { View, EventData } from "../core/view";

// Types.
Expand Down Expand Up @@ -71,14 +71,14 @@ function initializeTapAndDoubleTapGestureListener() {
if (this._target.getGestureObservers(GestureTypes.doubleTap)) {
this._tapTimeoutId = timer.setTimeout(() => {
if (this._type & GestureTypes.tap) {
const args = _getArgs(GestureTypes.tap, this._target, motionEvent);
const args = _getTapArgs(GestureTypes.tap, this._target, motionEvent);
_executeCallback(this._observer, args);
}
timer.clearTimeout(this._tapTimeoutId);
}, TapAndDoubleTapGestureListenerImpl.DoubleTapTimeout);
} else {
if (this._type & GestureTypes.tap) {
const args = _getArgs(GestureTypes.tap, this._target, motionEvent);
const args = _getTapArgs(GestureTypes.tap, this._target, motionEvent);
_executeCallback(this._observer, args);
}
}
Expand All @@ -89,7 +89,7 @@ function initializeTapAndDoubleTapGestureListener() {
timer.clearTimeout(this._tapTimeoutId);
}
if (this._type & GestureTypes.doubleTap) {
const args = _getDoubleTapArgs(this._target, motionEvent);
const args = _getTapArgs(GestureTypes.doubleTap, this._target, motionEvent);
_executeCallback(this._observer, args);
}
}
Expand Down Expand Up @@ -372,15 +372,18 @@ export class GesturesObserver extends GesturesObserverBase {
}
}

function _getArgs(type: GestureTypes, view: View, e: android.view.MotionEvent): GestureEventData {
return <GestureEventData>{
type: type,
view: view,
android: e,
ios: undefined,
object: view,
eventName: toString(type),
};
function _getTapArgs(type: GestureTypes, view: View, e: android.view.MotionEvent): TapGestureEventData {
return <TapGestureEventData>{
type: type,
view: view,
android: e,
ios: undefined,
object: view,
eventName: toString(type),
getPointerCount: () => e.getPointerCount(),
getX: () => layout.toDeviceIndependentPixels(e.getX()),
getY: () => layout.toDeviceIndependentPixels(e.getY())
};
}

function _getLongPressArgs(type: GestureTypes, view: View, state: GestureStateTypes, e: android.view.MotionEvent): GestureEventDataWithState {
Expand All @@ -395,19 +398,6 @@ function _getLongPressArgs(type: GestureTypes, view: View, state: GestureStateTy
};
}

function _getDoubleTapArgs(view: View, e: android.view.MotionEvent): DoubleTapGestureEventData {
return <DoubleTapGestureEventData>{
type: GestureTypes.doubleTap,
view: view,
android: e,
getX: () => e.getX() / layout.getDisplayDensity(),
getY: () => e.getY() / layout.getDisplayDensity(),
ios: undefined,
object: view,
eventName: toString(GestureTypes.doubleTap),
};
}

function _getSwipeArgs(direction: SwipeDirection, view: View,
initialEvent: android.view.MotionEvent, currentEvent: android.view.MotionEvent): SwipeGestureEventData {
return <SwipeGestureEventData>{
Expand Down
Loading