Fix send message with physical keyboard on iPad 15 (#5737)

This commit is contained in:
Elias Nahum 2021-10-10 10:49:11 -03:00 committed by GitHub
parent 42071314d3
commit 16583c2a3b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -146,15 +146,29 @@ NSString* const NOTIFICATION_UPDATE_BADGE_ACTION = @"update_badge";
*/
RNHWKeyboardEvent *hwKeyEvent = nil;
- (NSMutableArray<UIKeyCommand *> *)keyCommands {
NSMutableArray *keys = [NSMutableArray new];
if (hwKeyEvent == nil) {
hwKeyEvent = [[RNHWKeyboardEvent alloc] init];
}
NSMutableArray *commands = [NSMutableArray new];
if ([hwKeyEvent isListening]) {
[keys addObject: [UIKeyCommand keyCommandWithInput:@"\r" modifierFlags:0 action:@selector(sendEnter:)]];
[keys addObject: [UIKeyCommand keyCommandWithInput:@"\r" modifierFlags:UIKeyModifierShift action:@selector(sendShiftEnter:)]];
UIKeyCommand *enter = [UIKeyCommand keyCommandWithInput:@"\r" modifierFlags:0 action:@selector(sendEnter:)];
UIKeyCommand *shiftEnter = [UIKeyCommand keyCommandWithInput:@"\r" modifierFlags:UIKeyModifierShift action:@selector(sendShiftEnter:)];
if (@available(iOS 13.0, *)) {
[enter setTitle:@"Send message"];
[shiftEnter setTitle:@"Add new line"];
}
if (@available(iOS 15.0, *)) {
[enter setWantsPriorityOverSystemBehavior:YES];
[shiftEnter setWantsPriorityOverSystemBehavior:YES];
}
[commands addObject: enter];
[commands addObject: shiftEnter];
}
return keys;
return commands;
}
- (void)sendEnter:(UIKeyCommand *)sender {