Message preview fix

This commit is contained in:
Ali 2023-10-24 17:38:04 +04:00
parent f8060fa83d
commit d7546f6751
4 changed files with 25 additions and 9 deletions

View File

@ -226,12 +226,12 @@ final class ChatSendMessageActionSheetControllerNode: ViewControllerTracingNode,
self.messageClipNode.transform = CATransform3DMakeScale(1.0, -1.0, 1.0)
self.messageBackgroundNode = ASImageNode()
self.messageBackgroundNode.isUserInteractionEnabled = true
self.fromMessageTextNode = ChatInputTextNode()
self.fromMessageTextNode = ChatInputTextNode(disableTiling: true)
self.fromMessageTextNode.textView.isScrollEnabled = false
self.fromMessageTextNode.isUserInteractionEnabled = false
self.fromMessageTextScrollView = UIScrollView()
self.fromMessageTextScrollView.isUserInteractionEnabled = false
self.toMessageTextNode = ChatInputTextNode()
self.toMessageTextNode = ChatInputTextNode(disableTiling: true)
self.toMessageTextNode.textView.isScrollEnabled = false
self.toMessageTextNode.isUserInteractionEnabled = false
self.toMessageTextScrollView = UIScrollView()

View File

@ -20,6 +20,8 @@
@property (nonatomic, copy) bool (^ _Nullable shouldReturn)();
@property (nonatomic, copy) void (^ _Nullable backspaceWhileEmpty)();
- (instancetype _Nonnull)initWithFrame:(CGRect)frame textContainer:(NSTextContainer * _Nullable)textContainer disableTiling:(bool)disableTiling;
@end
#endif /* Lottie_h */

View File

@ -14,6 +14,22 @@
@implementation ChatInputTextViewImpl
- (instancetype _Nonnull)initWithFrame:(CGRect)frame textContainer:(NSTextContainer * _Nullable)textContainer disableTiling:(bool)disableTiling {
self = [super initWithFrame:frame textContainer:textContainer];
if (self != nil) {
if (disableTiling) {
SEL selector = NSSelectorFromString(@"_disableTiledViews");
if (selector && [self respondsToSelector:selector]) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
[self performSelector:selector];
#pragma clang diagnostic pop
}
}
}
return self;
}
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender
{
if (_shouldRespondToAction) {
@ -59,8 +75,7 @@
}
}
- (void)paste:(id)sender
{
- (void)paste:(id)sender {
if (_shouldPaste == nil || _shouldPaste()) {
[super paste:sender];
}

View File

@ -120,11 +120,11 @@ open class ChatInputTextNode: ASDisplayNode, UITextViewDelegate {
}
}
override public init() {
public init(disableTiling: Bool = false) {
super.init()
self.setViewBlock({
return ChatInputTextView()
return ChatInputTextView(disableTiling: disableTiling)
})
self.textView.delegate = self
@ -355,7 +355,7 @@ public final class ChatInputTextView: ChatInputTextViewImpl, NSLayoutManagerDele
}
}
public init() {
public init(disableTiling: Bool) {
self.customTextContainer = ChatInputTextContainer(size: CGSize(width: 100.0, height: 100000.0))
self.customLayoutManager = NSLayoutManager()
self.customTextStorage = NSTextStorage()
@ -368,7 +368,7 @@ public final class ChatInputTextView: ChatInputTextViewImpl, NSLayoutManagerDele
self.measurementTextStorage.addLayoutManager(self.measurementLayoutManager)
self.measurementLayoutManager.addTextContainer(self.measurementTextContainer)
super.init(frame: CGRect(), textContainer: self.customTextContainer)
super.init(frame: CGRect(), textContainer: self.customTextContainer, disableTiling: disableTiling)
self.textContainerInset = UIEdgeInsets()
self.backgroundColor = nil
@ -755,7 +755,6 @@ private final class QuoteBackgroundView: UIView {
if self.theme != theme {
self.theme = theme
self.backgroundColor = theme.background
self.iconView.tintColor = theme.foreground
}