Merge branch 'master' into fb63merge

This commit is contained in:
Eloy Durán 2020-09-30 12:22:37 +02:00
Родитель 4272792ea6 cfc858340c
Коммит d30beed6c3
7 изменённых файлов: 62 добавлений и 1 удалений

Просмотреть файл

@ -27,6 +27,7 @@ Pod::Spec.new do |s|
s.platforms = { :ios => "10.0", :tvos => "10.0", :osx => "10.13" } # TODO(macOS GH#214)
s.source = source
s.source_files = "**/*.{h,m}"
s.ios.exclude_files = "**/macOS/*" # TODO(macOS ISS#2323203)
s.preserve_paths = "package.json", "LICENSE", "LICENSE-docs"
s.header_dir = "RCTText"

Просмотреть файл

@ -9,11 +9,15 @@
#import <React/RCTBridge.h>
#import <React/RCTUITextField.h>
#include <React/RCTUITextField.h>
#if TARGET_OS_OSX // [TODO(macOS ISS#2323203)
#include <React/RCTUISecureTextField.h>
#endif // ]TODO(macOS ISS#2323203)
@implementation RCTSinglelineTextInputView
{
RCTUITextField *_backedTextInputView;
BOOL _useSecureTextField; // TODO(macOS ISS#2323203)
}
- (instancetype)initWithBridge:(RCTBridge *)bridge
@ -53,6 +57,22 @@
((RCTUITextField*)self.backedTextInputView).frame = UIEdgeInsetsInsetRect(self.bounds, reactBorderInsets);
[self setNeedsLayout];
}
- (void)setUseSecureTextField:(BOOL)useSecureTextField {
if (_useSecureTextField != useSecureTextField) {
_useSecureTextField = useSecureTextField;
RCTUITextField *previousTextField = _backedTextInputView;
if (useSecureTextField) {
_backedTextInputView = [[RCTUISecureTextField alloc] initWithFrame:self.bounds];
} else {
_backedTextInputView = [[RCTUITextField alloc] initWithFrame:self.bounds];
}
_backedTextInputView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
_backedTextInputView.textInputDelegate = self;
_backedTextInputView.text = previousTextField.text;
[self replaceSubview:previousTextField with:_backedTextInputView];
}
}
#endif // ]TODO(macOS ISS#2323203)
@end

Просмотреть файл

@ -29,4 +29,6 @@ RCT_EXPORT_MODULE()
return [[RCTSinglelineTextInputView alloc] initWithBridge:self.bridge];
}
RCT_REMAP_OSX_VIEW_PROPERTY(secureTextEntry, useSecureTextField, BOOL) // TODO(macOS ISS#2323203)
@end

Просмотреть файл

@ -17,7 +17,11 @@ NS_ASSUME_NONNULL_BEGIN
/*
* Just regular UITextField... but much better!
*/
#if RCT_SUBCLASS_SECURETEXTFIELD
@interface RCTUISecureTextField : NSSecureTextField <RCTBackedTextInputViewProtocol>
#else
@interface RCTUITextField : UITextField <RCTBackedTextInputViewProtocol>
#endif
- (instancetype)initWithCoder:(NSCoder *)decoder NS_UNAVAILABLE;

Просмотреть файл

@ -15,7 +15,13 @@
#if TARGET_OS_OSX // [TODO(macOS ISS#2323203)
#if RCT_SUBCLASS_SECURETEXTFIELD
#define RCTUITextFieldCell RCTUISecureTextFieldCell
@interface RCTUISecureTextFieldCell : NSSecureTextFieldCell
#else
@interface RCTUITextFieldCell : NSTextFieldCell
#endif
@property (nonatomic, assign) UIEdgeInsets textContainerInset;
@property (nonatomic, getter=isAutomaticTextReplacementEnabled) BOOL automaticTextReplacementEnabled;
@ -74,7 +80,11 @@
@end
#endif // ]TODO(macOS ISS#2323203)
#ifdef RCT_SUBCLASS_SECURETEXTFIELD
@implementation RCTUISecureTextField {
#else
@implementation RCTUITextField {
#endif
RCTBackedTextFieldDelegateAdapter *_textInputDelegateAdapter;
NSDictionary<NSAttributedStringKey, id> *_defaultTextAttributes;
}

Просмотреть файл

@ -0,0 +1,12 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// TODO(macOS ISS#2323203)
#define RCT_SUBCLASS_SECURETEXTFIELD 1
#include <React/RCTUITextField.h>

Просмотреть файл

@ -0,0 +1,12 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// TODO(macOS ISS#2323203)
#define RCT_SUBCLASS_SECURETEXTFIELD 1
#include "../RCTUITextField.m"