Skip to content

Commit 2a599fa

Browse files
committed
draft native implementation
1 parent 0e067f4 commit 2a599fa

4 files changed

Lines changed: 44 additions & 0 deletions

File tree

packages/react-native/Libraries/Text/TextInput/RCTBackedTextInputViewProtocol.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ NS_ASSUME_NONNULL_BEGIN
1616

1717
@property (nonatomic, copy, nullable) NSAttributedString *attributedText;
1818
@property (nonatomic, copy, nullable) NSString *placeholder;
19+
@property (nonatomic, assign) BOOL disableKeyboardShortcuts;
1920
@property (nonatomic, strong, nullable) UIColor *placeholderColor;
2021
@property (nonatomic, assign, readonly) BOOL textWasPasted;
2122
@property (nonatomic, assign, readonly) BOOL dictationRecognizing;

packages/react-native/Libraries/Text/TextInput/RCTBaseTextInputViewManager.mm

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,27 @@ @implementation RCTBaseTextInputViewManager {
3232

3333
#pragma mark - Unified <TextInput> properties
3434

35+
// Map the JS property to the custom setter method
36+
RCT_EXPORT_VIEW_PROPERTY(disableKeyboardShortcuts, BOOL)
37+
38+
//// Custom setter method
39+
//- (void)setDisableKeyboardShortcuts:(BOOL)disable forView:(UIView *)view
40+
//{
41+
// // Log the call to this method
42+
// NSLog(@"setDisableKeyboardShortcuts called with value: %d", disable);
43+
//
44+
// view.inputAssistantItem.leadingBarButtonGroups = @[];
45+
// view.inputAssistantItem.trailingBarButtonGroups = @[];
46+
//
47+
//// if ([view respondsToSelector:@selector(inputAssistantItem)]) {
48+
//// UITextInputAssistantItem *inputAssistantItem = [view inputAssistantItem];
49+
//// if (disable) {
50+
//// inputAssistantItem.leadingBarButtonGroups = @[];
51+
//// inputAssistantItem.trailingBarButtonGroups = @[];
52+
//// }
53+
//// }
54+
//}
55+
3556
RCT_REMAP_VIEW_PROPERTY(autoCapitalize, backedTextInputView.autocapitalizationType, UITextAutocapitalizationType)
3657
RCT_REMAP_VIEW_PROPERTY(autoCorrect, backedTextInputView.autocorrectionType, UITextAutocorrectionType)
3758
RCT_REMAP_VIEW_PROPERTY(contextMenuHidden, backedTextInputView.contextMenuHidden, BOOL)

packages/react-native/Libraries/Text/TextInput/Singleline/RCTUITextField.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ NS_ASSUME_NONNULL_BEGIN
3333
@property (nonatomic, assign, readonly) CGFloat zoomScale;
3434
@property (nonatomic, assign, readonly) CGPoint contentOffset;
3535
@property (nonatomic, assign, readonly) UIEdgeInsets contentInset;
36+
@property (nonatomic, assign) BOOL disableKeyboardShortcuts;
3637

3738
@end
3839

packages/react-native/Libraries/Text/TextInput/Singleline/RCTUITextField.mm

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,31 @@ - (void)setTextContainerInset:(UIEdgeInsets)textContainerInset
5757

5858
- (void)setPlaceholder:(NSString *)placeholder
5959
{
60+
NSLog(@"setPlaceholder called with value: %@", placeholder);
61+
6062
[super setPlaceholder:placeholder];
6163
[self _updatePlaceholder];
6264
}
6365

66+
- (BOOL)disableKeyboardShortcuts
67+
{
68+
// Log the call to this method
69+
NSLog(@"setDisableKeyboardShortcuts called with value: %d", self.disableKeyboardShortcuts);
70+
71+
return self.disableKeyboardShortcuts;
72+
}
73+
74+
- (void)setDisableKeyboardShortcuts:(BOOL)disableKeyboardShortcuts
75+
{
76+
// Log the call to this method
77+
NSLog(@"setDisableKeyboardShortcuts called with value: %d", disableKeyboardShortcuts);
78+
79+
if (disableKeyboardShortcuts) {
80+
self.inputAssistantItem.leadingBarButtonGroups = @[];
81+
self.inputAssistantItem.trailingBarButtonGroups = @[];
82+
}
83+
}
84+
6485
- (void)setPlaceholderColor:(UIColor *)placeholderColor
6586
{
6687
_placeholderColor = placeholderColor;

0 commit comments

Comments
 (0)