-
Notifications
You must be signed in to change notification settings - Fork 422
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(iOS): Migrate RCTOnPageScrollEvent to swift
- Loading branch information
1 parent
b7e4af4
commit 89e0a5b
Showing
8 changed files
with
68 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import Foundation | ||
import React | ||
|
||
public protocol RCTEvent {} | ||
|
||
@objc public class RCTOnPageScroll: NSObject, RCTEvent { | ||
private var position: NSNumber | ||
private var offset: NSNumber | ||
@objc public var viewTag: NSNumber | ||
@objc public var coalescingKey: UInt16 | ||
|
||
@objc public var eventName: String { | ||
return "onPageScroll" | ||
} | ||
|
||
@objc public init(reactTag: NSNumber, position: NSNumber, offset: NSNumber, coalescingKey: UInt16) { | ||
self.viewTag = reactTag | ||
self.position = position | ||
self.offset = offset | ||
self.coalescingKey = coalescingKey | ||
super.init() | ||
} | ||
|
||
@objc public func canCoalesce() -> Bool { | ||
return true | ||
} | ||
|
||
public func coalesce(with newEvent: RCTEvent) -> RCTEvent { | ||
return newEvent | ||
} | ||
|
||
@objc public class func moduleDotMethod() -> String { | ||
return "RCTEventEmitter.receiveEvent" | ||
} | ||
|
||
@objc public func arguments() -> [Any] { | ||
return [ | ||
viewTag, | ||
RCTNormalizeInputEventName(eventName) ?? eventName, | ||
[ | ||
"position": position, | ||
"offset": offset | ||
] | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#import <React/RCTViewManager.h> | ||
#import <React/RCTUIManager.h> | ||
#import <React/UIView+React.h> | ||
#import <React/RCTUtils.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters