diff --git a/React/Base/RCTTouchEvent.h b/React/Base/RCTTouchEvent.h new file mode 100644 index 000000000..5fe3951dc --- /dev/null +++ b/React/Base/RCTTouchEvent.h @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +#import + +#import "RCTEventDispatcher.h" + +/** + * Represents a touch event, which may be composed of several touches (one for every finger). + * For more information on contents of passed data structures see RCTTouchHandler. + */ +@interface RCTTouchEvent : NSObject + +- (instancetype)initWithEventName:(NSString *)eventName + reactTouches:(NSArray *)reactTouches + changedIndexes:(NSArray *)changedIndexes NS_DESIGNATED_INITIALIZER; +@end diff --git a/React/Base/RCTTouchEvent.m b/React/Base/RCTTouchEvent.m new file mode 100644 index 000000000..780a7bec0 --- /dev/null +++ b/React/Base/RCTTouchEvent.m @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +#import "RCTTouchEvent.h" + +@implementation RCTTouchEvent +{ + NSArray *_reactTouches; + NSArray *_changedIndexes; +} + +@synthesize eventName = _eventName; +@synthesize viewTag = _viewTag; + +- (instancetype)initWithEventName:(NSString *)eventName + reactTouches:(NSArray *)reactTouches + changedIndexes:(NSArray *)changedIndexes +{ + if (self = [super init]) { + _eventName = eventName; + _reactTouches = reactTouches; + _changedIndexes = changedIndexes; + } + return self; +} + +RCT_NOT_IMPLEMENTED(- (instancetype)init) + +#pragma mark - RCTEvent + +- (BOOL)canCoalesce +{ + return NO; +} + +- (id)coalesceWithEvent:(id)newEvent +{ + return newEvent; +} + ++ (NSString *)moduleDotMethod +{ + return @"RCTEventEmitter.receiveTouches"; +} + +- (NSArray *)arguments +{ + return @[RCTNormalizeInputEventName(_eventName), _reactTouches, _changedIndexes]; +} + +@end