1/* 2 * Copyright (c) Meta Platforms, Inc. and affiliates. 3 * 4 * This source code is licensed under the MIT license found in the 5 * LICENSE file in the root directory of this source tree. 6 */ 7 8#import "ABI47_0_0RCTWrapperExampleView.h" 9 10#import <ABI47_0_0RCTWrapper/ABI47_0_0RCTWrapper.h> 11 12@implementation ABI47_0_0RCTWrapperExampleView { 13 NSTimer *_timer; 14 CGSize _intrinsicContentSize; 15} 16 17- (instancetype)initWithFrame:(CGRect)frame 18{ 19 if (self = [super initWithFrame:frame]) { 20 self.backgroundColor = [UIColor whiteColor]; 21 22 _intrinsicContentSize = CGSizeMake(64, 64); 23 _timer = [NSTimer scheduledTimerWithTimeInterval:1.0 24 target:self 25 selector:@selector(tick) 26 userInfo:nil 27 repeats:YES]; 28 29 UITapGestureRecognizer *gestureRecognizer = 30 [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tick)]; 31 [self addGestureRecognizer:gestureRecognizer]; 32 } 33 return self; 34} 35 36- (void)tick 37{ 38 _intrinsicContentSize.width = 32 + arc4random() % 128; 39 _intrinsicContentSize.height = 32 + arc4random() % 128; 40 41 [self invalidateIntrinsicContentSize]; 42 [self.superview setNeedsLayout]; 43} 44 45- (CGSize)intrinsicContentSize 46{ 47 return _intrinsicContentSize; 48} 49 50- (CGSize)sizeThatFits:(CGSize)size 51{ 52 return CGSizeMake( 53 MIN(size.width, _intrinsicContentSize.width), 54 MIN(size.height, _intrinsicContentSize.height) 55 ); 56} 57 58@end 59 60ABI47_0_0RCT_WRAPPER_FOR_VIEW(ABI47_0_0RCTWrapperExampleView) 61