Various improvements

This commit is contained in:
Ali
2023-10-26 15:43:40 +04:00
parent 107b5bf63a
commit a954e9b31c
7 changed files with 114 additions and 27 deletions

View File

@@ -12,6 +12,12 @@
@end
@interface ChatInputTextViewImpl () <UIGestureRecognizerDelegate> {
UIGestureRecognizer *_tapRecognizer;
}
@end
@implementation ChatInputTextViewImpl
- (instancetype _Nonnull)initWithFrame:(CGRect)frame textContainer:(NSTextContainer * _Nullable)textContainer disableTiling:(bool)disableTiling {
@@ -26,10 +32,40 @@
#pragma clang diagnostic pop
}
}
if (@available(iOS 17.0, *)) {
} else {
_tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(workaroundTapGesture:)];
_tapRecognizer.cancelsTouchesInView = false;
_tapRecognizer.delaysTouchesBegan = false;
_tapRecognizer.delaysTouchesEnded = false;
_tapRecognizer.delegate = self;
[self addGestureRecognizer:_tapRecognizer];
}
}
return self;
}
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
return true;
}
- (void)workaroundTapGesture:(UITapGestureRecognizer *)recognizer {
if (recognizer.state == UIGestureRecognizerStateEnded) {
static Class promptClass = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
promptClass = NSClassFromString([[NSString alloc] initWithFormat:@"%@AutocorrectInlinePrompt", @"UI"]);
});
UIView *result = [self hitTest:[recognizer locationInView:self] withEvent:nil];
if (result != nil && [result class] == promptClass) {
if (_dropAutocorrectioniOS16) {
_dropAutocorrectioniOS16();
}
}
}
}
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender
{
if (_shouldRespondToAction) {