forked from callstack/react-native-bottom-tabs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRCTBottomAccessoryComponentView.mm
More file actions
76 lines (60 loc) · 2.19 KB
/
RCTBottomAccessoryComponentView.mm
File metadata and controls
76 lines (60 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#ifdef RCT_NEW_ARCH_ENABLED
#import "RCTBottomAccessoryComponentView.h"
#import <react/renderer/components/RNCTabView/ComponentDescriptors.h>
#import <react/renderer/components/RNCTabView/EventEmitters.h>
#import <react/renderer/components/RNCTabView/Props.h>
#import <react/renderer/components/RNCTabView/RCTComponentViewHelpers.h>
#import <React/RCTFabricComponentsPlugins.h>
#if __has_include("react_native_bottom_tabs/react_native_bottom_tabs-Swift.h")
#import "react_native_bottom_tabs/react_native_bottom_tabs-Swift.h"
#else
#import "react_native_bottom_tabs-Swift.h"
#endif
using namespace facebook::react;
@interface RCTBottomAccessoryComponentView () <BottomAccessoryProviderDelegate> {
BottomAccessoryProvider* bottomAccessoryProvider;
}
@end
@implementation RCTBottomAccessoryComponentView
+ (ComponentDescriptorProvider)componentDescriptorProvider
{
return concreteComponentDescriptorProvider<BottomAccessoryViewComponentDescriptor>();
}
- (instancetype)initWithFrame:(CGRect)frame
{
if (self = [super initWithFrame:frame]) {
static const auto defaultProps = std::make_shared<const BottomAccessoryViewProps>();
if (@available(iOS 26.0, *)) {
bottomAccessoryProvider = [[BottomAccessoryProvider alloc] initWithDelegate:self];
}
}
return self;
}
- (void)setFrame:(CGRect)frame
{
[super setFrame:frame];
auto eventEmitter = std::static_pointer_cast<const BottomAccessoryViewEventEmitter>(_eventEmitter);
if (eventEmitter) {
// TODO: Rewrite this to emit synchronous layout events using shadow nodes
eventEmitter->onNativeLayout(BottomAccessoryViewEventEmitter::OnNativeLayout {
.height = frame.size.height,
.width = frame.size.width
});
}
}
// MARK: BottomAccessoryProviderDelegate
- (void)onPlacementChangedWithPlacement:(NSString *)placement
{
auto eventEmitter = std::static_pointer_cast<const BottomAccessoryViewEventEmitter>(_eventEmitter);
if (eventEmitter) {
eventEmitter->onPlacementChanged(BottomAccessoryViewEventEmitter::OnPlacementChanged {
.placement = std::string([placement UTF8String])
});
}
}
Class<RCTComponentViewProtocol> BottomAccessoryViewCls(void)
{
return RCTBottomAccessoryComponentView.class;
}
@end
#endif