From f91c45f9d364c0f8b725315b5b15bf2a5543319f Mon Sep 17 00:00:00 2001 From: OlimpiaZurek Date: Mon, 26 Feb 2024 09:04:57 +0100 Subject: [PATCH] remove double double underscores and fix error --- .../TextInput/RCTTextInputViewConfig.js | 2 + .../Text/TextInput/Multiline/RCTUITextView.mm | 74 +++++++++---------- .../TextInput/Singleline/RCTUITextField.h | 2 + 3 files changed, 37 insertions(+), 41 deletions(-) diff --git a/packages/react-native/Libraries/Components/TextInput/RCTTextInputViewConfig.js b/packages/react-native/Libraries/Components/TextInput/RCTTextInputViewConfig.js index f91026796ce9cb..16b0024b785ba1 100644 --- a/packages/react-native/Libraries/Components/TextInput/RCTTextInputViewConfig.js +++ b/packages/react-native/Libraries/Components/TextInput/RCTTextInputViewConfig.js @@ -124,6 +124,8 @@ const RCTTextInputViewConfig = { editable: true, inputAccessoryViewID: true, caretHidden: true, + caretHeight: true, + caretYOffset: true, enablesReturnKeyAutomatically: true, placeholderTextColor: { process: require('../../StyleSheet/processColor').default, diff --git a/packages/react-native/Libraries/Text/TextInput/Multiline/RCTUITextView.mm b/packages/react-native/Libraries/Text/TextInput/Multiline/RCTUITextView.mm index 991c2590d8df12..750898c6cebfc8 100644 --- a/packages/react-native/Libraries/Text/TextInput/Multiline/RCTUITextView.mm +++ b/packages/react-native/Libraries/Text/TextInput/Multiline/RCTUITextView.mm @@ -16,35 +16,27 @@ //the UITextSelectionRect subclass needs to be created because the original version is not writable @interface CustomTextSelectionRect : UITextSelectionRect -@property (nonatomic) CGRect _rect; -@property (nonatomic) NSWritingDirection _writingDirection; -@property (nonatomic) BOOL _containsStart; // Returns YES if the rect contains the start of the selection. -@property (nonatomic) BOOL _containsEnd; // Returns YES if the rect contains the end of the selection. -@property (nonatomic) BOOL _isVertical; // Returns YES if the rect is for vertically oriented text. +@property (nonatomic, assign) CGRect rect; +@property (nonatomic, assign) NSWritingDirection writingDirection; +@property (nonatomic, assign) BOOL containsStart; // Returns YES if the rect contains the start of the selection. +@property (nonatomic, assign) BOOL containsEnd; // Returns YES if the rect contains the end of the selection. +@property (nonatomic, assign) BOOL isVertical; // Returns YES if the rect is for vertically oriented text. @end -@implementation CustomTextSelectionRect - -- (CGRect)rect { - return __rect; -} - -- (NSWritingDirection)writingDirection { - return __writingDirection; +@implementation CustomTextSelectionRect { + CGRect _customRect; + NSWritingDirection _customWritingDirection; + BOOL _customContainsStart; + BOOL _customContainsEnd; + BOOL _customIsVertical; } -- (BOOL)containsStart { - return __containsStart; -} - -- (BOOL)containsEnd { - return __containsEnd; -} - -- (BOOL)isVertical { - return __isVertical; -} +@synthesize rect = _customRect; +@synthesize writingDirection = _customWritingDirection; +@synthesize containsStart = _customContainsStart; +@synthesize containsEnd = _customContainsEnd; +@synthesize isVertical = _customIsVertical; @end @@ -360,25 +352,25 @@ - (CGRect)caretRectForPosition:(UITextPosition *)position } - (NSArray *)selectionRectsForRange:(UITextRange *)range { - NSArray *superRects = [super selectionRectsForRange:range]; - if(_caretYOffset != 0 && _caretHeight != 0) { - NSMutableArray *customTextSelectionRects = [NSMutableArray array]; - - for (UITextSelectionRect *rect in superRects) { - CustomTextSelectionRect *customTextRect = [[CustomTextSelectionRect alloc] init]; - - customTextRect._rect = CGRectMake(rect.rect.origin.x, rect.rect.origin.y + _caretYOffset, rect.rect.size.width, _caretHeight); - customTextRect._writingDirection = rect.writingDirection; - customTextRect._containsStart = rect.containsStart; - customTextRect._containsEnd = rect.containsEnd; - customTextRect._isVertical = rect.isVertical; - [customTextSelectionRects addObject:customTextRect]; - } + NSArray *superRects = [super selectionRectsForRange:range]; + if(_caretYOffset != 0 && _caretHeight != 0) { + NSMutableArray *customTextSelectionRects = [NSMutableArray array]; - return customTextSelectionRects; + for (UITextSelectionRect *rect in superRects) { + CustomTextSelectionRect *customTextRect = [[CustomTextSelectionRect alloc] init]; - } - return superRects; + customTextRect.rect = CGRectMake(rect.rect.origin.x, rect.rect.origin.y + _caretYOffset, rect.rect.size.width, _caretHeight); + customTextRect.writingDirection = rect.writingDirection; + customTextRect.containsStart = rect.containsStart; + customTextRect.containsEnd = rect.containsEnd; + customTextRect.isVertical = rect.isVertical; + [customTextSelectionRects addObject:customTextRect]; + } + + return customTextSelectionRects; + + } + return superRects; } diff --git a/packages/react-native/Libraries/Text/TextInput/Singleline/RCTUITextField.h b/packages/react-native/Libraries/Text/TextInput/Singleline/RCTUITextField.h index 91f8eb087acf87..0687407393b1e1 100644 --- a/packages/react-native/Libraries/Text/TextInput/Singleline/RCTUITextField.h +++ b/packages/react-native/Libraries/Text/TextInput/Singleline/RCTUITextField.h @@ -22,6 +22,8 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, weak) id textInputDelegate; @property (nonatomic, assign) BOOL caretHidden; +@property (nonatomic, assign) BOOL caretYOffset; +@property (nonatomic, assign) BOOL caretHeight; @property (nonatomic, assign) BOOL contextMenuHidden; @property (nonatomic, assign, readonly) BOOL textWasPasted; @property (nonatomic, assign, readonly) BOOL dictationRecognizing;