Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 41 additions & 2 deletions ios/RNNReactButtonView.mm
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#import "RNNReactButtonView.h"
#import <React/RCTSurface.h>

@implementation RNNReactButtonView
@implementation RNNReactButtonView {
NSLayoutConstraint *_widthConstraint;
NSLayoutConstraint *_heightConstraint;
}

- (instancetype)initWithHost:(RCTHost *)host
moduleName:(NSString *)moduleName
Expand All @@ -10,15 +14,50 @@ - (instancetype)initWithHost:(RCTHost *)host
reactViewReadyBlock:(RNNReactViewReadyCompletionBlock)reactViewReadyBlock {
self = [super initWithHost:host moduleName:moduleName initialProperties:initialProperties eventEmitter:eventEmitter sizeMeasureMode:convertToSurfaceSizeMeasureMode(RCTRootViewSizeFlexibilityWidthAndHeight) reactViewReadyBlock:reactViewReadyBlock];
[host.surfacePresenter addObserver:self];
self.backgroundColor = UIColor.clearColor;
self.backgroundColor = [UIColor clearColor];

if (@available(iOS 26.0, *)) {
if (![self designRequiresCompatibility]) {
self.translatesAutoresizingMaskIntoConstraints = NO;
_widthConstraint = [self.widthAnchor constraintEqualToConstant:0];
_heightConstraint = [self.heightAnchor constraintEqualToConstant:0];
_widthConstraint.priority = UILayoutPriorityDefaultHigh;
_heightConstraint.priority = UILayoutPriorityDefaultHigh;
_widthConstraint.active = YES;
_heightConstraint.active = YES;
}
}

return self;
}

- (BOOL)designRequiresCompatibility {
static BOOL checked = NO;
static BOOL result = NO;
if (!checked) {
checked = YES;
result = [[[NSBundle mainBundle] objectForInfoDictionaryKey:@"UIDesignRequiresCompatibility"] boolValue];
}
return result;
}

- (void)didMountComponentsWithRootTag:(NSInteger)rootTag {
if (self.surface.rootTag == rootTag) {
[super didMountComponentsWithRootTag:rootTag];
[self sizeToFit];
if (@available(iOS 26.0, *)) {
if (![self designRequiresCompatibility]) {
[self updateConstraintsToFitSize];
}
}
}
}

- (void)updateConstraintsToFitSize {
CGSize size = self.frame.size;
if (size.width > 0 && size.height > 0) {
_widthConstraint.constant = size.width;
_heightConstraint.constant = size.height;
}
}

Expand Down