|
| 1 | +//* |
| 2 | +import Foundation |
| 3 | +import ReactBridge |
| 4 | + |
| 5 | +// MARK: - React Mock |
| 6 | + |
| 7 | +typealias RCTDirectEventBlock = ([String : Any]) -> Void |
| 8 | +typealias RCTBubblingEventBlock = ([String : Any]) -> Void |
| 9 | +typealias RCTCapturingEventBlock = ([String : Any]) -> Void |
| 10 | +typealias RCTPromiseResolveBlock = (Any) -> Void |
| 11 | +typealias RCTPromiseRejectBlock = (String, String, NSError) -> Void |
| 12 | + |
| 13 | +func RCTRegisterModule(_ cls: AnyClass) { |
| 14 | +} |
| 15 | + |
| 16 | +@objc |
| 17 | +protocol RCTBridgeModule { |
| 18 | + @objc static func moduleName() -> String! |
| 19 | + @objc static optional func requiresMainQueueSetup() -> Bool |
| 20 | + |
| 21 | + @objc optional var methodQueue: DispatchQueue { get } |
| 22 | +} |
| 23 | + |
| 24 | +class RCTEventEmitter: RCTBridgeModule { |
| 25 | + class func moduleName() -> String! { "" } |
| 26 | + class func requiresMainQueueSetup() -> Bool { false } |
| 27 | +} |
| 28 | + |
| 29 | +class RCTViewManager: NSObject { |
| 30 | + class func moduleName() -> String! { "" } |
| 31 | + class func requiresMainQueueSetup() -> Bool { false } |
| 32 | + var methodQueue: DispatchQueue { .main } |
| 33 | +} |
| 34 | + |
| 35 | +class RCTMethodInfo: NSObject { |
| 36 | + let jsName: UnsafePointer<CChar>? |
| 37 | + let objcName: UnsafePointer<CChar>? |
| 38 | + let isSync: Bool |
| 39 | + |
| 40 | + init(jsName: UnsafePointer<CChar>?, objcName: UnsafePointer<CChar>?, isSync: Bool) { |
| 41 | + self.jsName = jsName |
| 42 | + self.objcName = objcName |
| 43 | + self.isSync = isSync |
| 44 | + } |
| 45 | +} |
| 46 | + |
| 47 | +// MARK: - Sandbox |
| 48 | + |
| 49 | +@ReactModule(jsName: "Calendar") |
| 50 | +class CalendarModule: NSObject, RCTBridgeModule { |
| 51 | + @ReactMethod |
| 52 | + @objc func createEvent(title: String, location: String) { |
| 53 | + print("Create event '\(title)' at '\(location)'") |
| 54 | + } |
| 55 | + |
| 56 | + @ReactMethod |
| 57 | + @objc func createEvent2(title: String, location: String, resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) { |
| 58 | + print("Create event '\(title)' at '\(location)'") |
| 59 | + } |
| 60 | +} |
| 61 | + |
| 62 | +@ReactModule |
| 63 | +class EventEmitter: RCTEventEmitter { |
| 64 | +} |
| 65 | + |
| 66 | +@ReactView |
| 67 | +class MapView: RCTViewManager { |
| 68 | + @ReactProperty |
| 69 | + var zoomEnabled: Bool? |
| 70 | + |
| 71 | + @ReactProperty |
| 72 | + var onRegionChange: RCTBubblingEventBlock? |
| 73 | +} |
| 74 | +// */ |
0 commit comments