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