File tree Expand file tree Collapse file tree 6 files changed +35
-2
lines changed
packages/react-native/Libraries/Text/TextInput Expand file tree Collapse file tree 6 files changed +35
-2
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ NS_ASSUME_NONNULL_BEGIN
2424
2525@property (nonatomic , assign ) BOOL contextMenuHidden;
2626@property (nonatomic , assign , readonly ) BOOL textWasPasted;
27+ @property (nonatomic , assign , readonly ) BOOL dictationRecognizing;
2728@property (nonatomic , copy , nullable ) NSString *placeholder;
2829@property (nonatomic , strong , nullable ) UIColor *placeholderColor;
2930
Original file line number Diff line number Diff line change @@ -261,6 +261,19 @@ - (BOOL)canPerformAction:(SEL)action withSender:(id)sender
261261 return [super canPerformAction: action withSender: sender];
262262}
263263
264+ #pragma mark - Dictation
265+
266+ - (void )dictationRecordingDidEnd
267+ {
268+ _dictationRecognizing = YES ;
269+ }
270+
271+ - (void )removeDictationResultPlaceholder : (id )placeholder willInsertResult : (BOOL )willInsertResult
272+ {
273+ [super removeDictationResultPlaceholder: placeholder willInsertResult: willInsertResult];
274+ _dictationRecognizing = NO ;
275+ }
276+
264277#pragma mark - Placeholder
265278
266279- (void )_invalidatePlaceholderVisibility
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ NS_ASSUME_NONNULL_BEGIN
1818@property (nonatomic , copy , nullable ) NSString *placeholder;
1919@property (nonatomic , strong , nullable ) UIColor *placeholderColor;
2020@property (nonatomic , assign , readonly ) BOOL textWasPasted;
21+ @property (nonatomic , assign , readonly ) BOOL dictationRecognizing;
2122@property (nonatomic , assign ) UIEdgeInsets textContainerInset;
2223@property (nonatomic , strong , nullable ) UIView *inputAccessoryView;
2324@property (nonatomic , strong , nullable ) UIView *inputView;
Original file line number Diff line number Diff line change @@ -119,8 +119,12 @@ - (BOOL)textOf:(NSAttributedString *)newText equals:(NSAttributedString *)oldTex
119119 }
120120 }];
121121
122- BOOL shouldFallbackToBareTextComparison =
123- [self .backedTextInputView.textInputMode.primaryLanguage isEqualToString: @" dictation" ] ||
122+ BOOL shouldFallbackDictation = [self .backedTextInputView.textInputMode.primaryLanguage isEqualToString: @" dictation" ];
123+ if (@available (iOS 16.0 , *)) {
124+ shouldFallbackDictation = self.backedTextInputView .dictationRecognizing ;
125+ }
126+
127+ BOOL shouldFallbackToBareTextComparison = shouldFallbackDictation ||
124128 [self .backedTextInputView.textInputMode.primaryLanguage isEqualToString: @" ko-KR" ] ||
125129 self.backedTextInputView .markedTextRange || self.backedTextInputView .isSecureTextEntry ||
126130 fontHasBeenUpdatedBySystem;
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ NS_ASSUME_NONNULL_BEGIN
2424@property (nonatomic , assign ) BOOL caretHidden;
2525@property (nonatomic , assign ) BOOL contextMenuHidden;
2626@property (nonatomic , assign , readonly ) BOOL textWasPasted;
27+ @property (nonatomic , assign , readonly ) BOOL dictationRecognizing;
2728@property (nonatomic , strong , nullable ) UIColor *placeholderColor;
2829@property (nonatomic , assign ) UIEdgeInsets textContainerInset;
2930@property (nonatomic , assign , getter =isEditable) BOOL editable;
Original file line number Diff line number Diff line change @@ -142,6 +142,19 @@ - (BOOL)canPerformAction:(SEL)action withSender:(id)sender
142142 return [super canPerformAction: action withSender: sender];
143143}
144144
145+ #pragma mark - Dictation
146+
147+ - (void )dictationRecordingDidEnd
148+ {
149+ _dictationRecognizing = YES ;
150+ }
151+
152+ - (void )removeDictationResultPlaceholder : (id )placeholder willInsertResult : (BOOL )willInsertResult
153+ {
154+ [super removeDictationResultPlaceholder: placeholder willInsertResult: willInsertResult];
155+ _dictationRecognizing = NO ;
156+ }
157+
145158#pragma mark - Caret Manipulation
146159
147160- (CGRect)caretRectForPosition : (UITextPosition *)position
You can’t perform that action at this time.
0 commit comments