Skip to content

Commit bde5855

Browse files
committed
feat: add events for old arch
1 parent c428532 commit bde5855

File tree

4 files changed

+51
-10
lines changed

4 files changed

+51
-10
lines changed

packages/react-native-bottom-tabs/ios/PageSelectedEvent.swift renamed to packages/react-native-bottom-tabs/ios/Events/PageSelectedEvent.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,26 @@ import React
44
private var key: NSString
55
@objc public var viewTag: NSNumber
66
@objc public var coalescingKey: UInt16
7-
7+
88
@objc public var eventName: String {
99
return "onPageSelected"
1010
}
11-
11+
1212
@objc public init(reactTag: NSNumber, key: NSString, coalescingKey: UInt16) {
1313
self.viewTag = reactTag
1414
self.key = key
1515
self.coalescingKey = coalescingKey
1616
super.init()
1717
}
18-
18+
1919
@objc public func canCoalesce() -> Bool {
2020
return false
2121
}
22-
22+
2323
@objc public class func moduleDotMethod() -> String {
2424
return "RCTEventEmitter.receiveEvent"
2525
}
26-
26+
2727
@objc public func arguments() -> [Any] {
2828
return [
2929
viewTag,
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import React
2+
3+
@objc public class TabBarMeasuredEvent: NSObject, RCTEvent {
4+
private var height: NSInteger
5+
@objc public var viewTag: NSNumber
6+
@objc public var coalescingKey: UInt16
7+
8+
@objc public var eventName: String {
9+
return "onTabBarMeasured"
10+
}
11+
12+
@objc public init(reactTag: NSNumber, height: NSInteger, coalescingKey: UInt16) {
13+
self.viewTag = reactTag
14+
self.height = height
15+
self.coalescingKey = coalescingKey
16+
super.init()
17+
}
18+
19+
@objc public func canCoalesce() -> Bool {
20+
return false
21+
}
22+
23+
@objc public class func moduleDotMethod() -> String {
24+
return "RCTEventEmitter.receiveEvent"
25+
}
26+
27+
@objc public func arguments() -> [Any] {
28+
return [
29+
viewTag,
30+
RCTNormalizeInputEventName(eventName) ?? eventName,
31+
[
32+
"height": height
33+
]
34+
]
35+
}
36+
}

packages/react-native-bottom-tabs/ios/TabLongPressedEvent.swift renamed to packages/react-native-bottom-tabs/ios/Events/TabLongPressedEvent.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,26 @@ protocol RCTEvent {}
88
private var key: NSString
99
@objc public var viewTag: NSNumber
1010
@objc public var coalescingKey: UInt16
11-
11+
1212
@objc public var eventName: String {
1313
return "onTabLongPress"
1414
}
15-
15+
1616
@objc public init(reactTag: NSNumber, key: NSString, coalescingKey: UInt16) {
1717
self.viewTag = reactTag
1818
self.key = key
1919
self.coalescingKey = coalescingKey
2020
super.init()
2121
}
22-
22+
2323
@objc public func canCoalesce() -> Bool {
2424
return false
2525
}
26-
26+
2727
@objc public class func moduleDotMethod() -> String {
2828
return "RCTEventEmitter.receiveEvent"
2929
}
30-
30+
3131
@objc public func arguments() -> [Any] {
3232
return [
3333
viewTag,

packages/react-native-bottom-tabs/ios/RCTTabViewViewManager.mm

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ - (void)onPageSelectedWithKey:(NSString *)key reactTag:(NSNumber *)reactTag {
6060
[self.bridge.eventDispatcher sendEvent:event];
6161
}
6262

63+
- (void)onTabBarMeasuredWithHeight:(NSInteger)height reactTag:(NSNumber *)reactTag {
64+
auto event = [[TabBarMeasuredEvent alloc] initWithReactTag:reactTag height:height coalescingKey:_coalescingKey++];
65+
[self.bridge.eventDispatcher sendEvent:event];
66+
}
67+
6368
- (UIView *)view
6469
{
6570
return [[TabViewProvider alloc] initWithDelegate:self];

0 commit comments

Comments
 (0)