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

(cherry picked from commit 16583c2a3b)

Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
This commit is contained in:
Mattermost Build 2021-10-10 16:42:43 +02:00 committed by GitHub
parent 992adad5a1
commit 9cfae7ab3e
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 {