PHP 7.4.33
Preview: RCTInputAccessoryView.mm Size: 1.91 KB
/var/www/uibuilder.cmshelp.dk/httpdocs/node_modules/react-native/Libraries/Text/TextInput/RCTInputAccessoryView.mm
/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

#import <React/RCTInputAccessoryView.h>

#import <React/RCTBridge.h>
#import <React/RCTTouchHandler.h>
#import <React/UIView+React.h>

#import <React/RCTInputAccessoryViewContent.h>

@interface RCTInputAccessoryView ()

// Overriding `inputAccessoryView` to `readwrite`.
@property (nonatomic, readwrite, retain) UIView *inputAccessoryView;

@end

@implementation RCTInputAccessoryView {
  BOOL _shouldBecomeFirstResponder;
}

- (instancetype)initWithBridge:(RCTBridge *)bridge
{
  if (self = [super init]) {
    _inputAccessoryView = [RCTInputAccessoryViewContent new];
    RCTTouchHandler *const touchHandler = [[RCTTouchHandler alloc] initWithBridge:bridge];
    [touchHandler attachToView:_inputAccessoryView];
  }
  return self;
}

- (BOOL)canBecomeFirstResponder
{
  return true;
}

- (void)reactSetFrame:(CGRect)frame
{
  [_inputAccessoryView reactSetFrame:frame];

  if (_shouldBecomeFirstResponder) {
    _shouldBecomeFirstResponder = NO;
    [self becomeFirstResponder];
  }
}

- (void)insertReactSubview:(UIView *)subview atIndex:(NSInteger)index
{
  [super insertReactSubview:subview atIndex:index];
  [_inputAccessoryView insertReactSubview:subview atIndex:index];
}

- (void)removeReactSubview:(UIView *)subview
{
  [super removeReactSubview:subview];
  [_inputAccessoryView removeReactSubview:subview];
}

- (void)didUpdateReactSubviews
{
  // Do nothing, as subviews are managed by `insertReactSubview:atIndex:`.
}

- (void)didSetProps:(NSArray<NSString *> *)changedProps
{
  // If the accessory view is not linked to a text input via nativeID, assume it is
  // a standalone component that should get focus whenever it is rendered.
  if (![changedProps containsObject:@"nativeID"] && !self.nativeID) {
    _shouldBecomeFirstResponder = YES;
  }
}

@end

Directory Contents

Dirs: 2 × Files: 20
Name Size Perms Modified Actions
Multiline DIR
- drwxr-xr-x 2025-03-28 11:04:43
Edit Download
- drwxr-xr-x 2025-03-28 11:04:43
Edit Download
1.70 KB lrw-r--r-- 2025-03-28 11:04:41
Edit Download
1020 B lrw-r--r-- 2025-03-28 11:04:41
Edit Download
9.99 KB lrw-r--r-- 2025-03-28 11:04:43
Edit Download
2.86 KB lrw-r--r-- 2025-03-28 11:04:41
Edit Download
691 B lrw-r--r-- 2025-03-28 11:04:41
Edit Download
11.40 KB lrw-r--r-- 2025-03-28 11:04:43
Edit Download
2.36 KB lrw-r--r-- 2025-03-28 11:04:41
Edit Download
31.96 KB lrw-r--r-- 2025-03-28 11:04:43
Edit Download
297 B lrw-r--r-- 2025-03-28 11:04:41
Edit Download
6.91 KB lrw-r--r-- 2025-03-28 11:04:43
Edit Download
285 B lrw-r--r-- 2025-03-28 11:04:41
Edit Download
539 B lrw-r--r-- 2025-03-28 11:04:43
Edit Download
373 B lrw-r--r-- 2025-03-28 11:04:41
Edit Download
1.91 KB lrw-r--r-- 2025-03-28 11:04:43
Edit Download
271 B lrw-r--r-- 2025-03-28 11:04:41
Edit Download
2.37 KB lrw-r--r-- 2025-03-28 11:04:43
Edit Download
288 B lrw-r--r-- 2025-03-28 11:04:41
Edit Download
655 B lrw-r--r-- 2025-03-28 11:04:43
Edit Download
617 B lrw-r--r-- 2025-03-28 11:04:41
Edit Download
770 B lrw-r--r-- 2025-03-28 11:04:43
Edit Download
If ZipArchive is unavailable, a .tar will be created (no compression).