From 5f555521d0b05be03a5834ec687fdb50d6f2d396 Mon Sep 17 00:00:00 2001 From: ryanzhao Date: Wed, 13 Nov 2019 14:54:26 +1100 Subject: [PATCH] mention function '@' fixed --- .../ConversationView/ConversationInputToolbar.m | 12 ++++++++++++ .../ConversationView/ConversationViewController.m | 7 ++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m b/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m index 434a07316..075c133b3 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m @@ -1107,6 +1107,12 @@ const CGFloat kMaxTextViewHeight = 98; [self.mentionCandidateSelectionView setPublicChatChannel:publicChat.channel]; } self.mentionCandidateSelectionView.mentionCandidates = mentionCandidates; + // Add animation +// [UIView animateWithDuration:0.5f animations:^{ +// self.mentionCandidateSelectionViewSizeConstraint.constant = 6 + MIN(mentionCandidates.count, 4) * 52; +// [self setNeedsLayout]; +// [self layoutIfNeeded]; +// }]; self.mentionCandidateSelectionViewSizeConstraint.constant = 6 + MIN(mentionCandidates.count, 4) * 52; [self setNeedsLayout]; [self layoutIfNeeded]; @@ -1115,6 +1121,12 @@ const CGFloat kMaxTextViewHeight = 98; - (void)hideMentionCandidateSelectionView { + // Add animation +// [UIView animateWithDuration:0.5f animations:^{ +// self.mentionCandidateSelectionViewSizeConstraint.constant = 0; +// [self setNeedsLayout]; +// [self layoutIfNeeded]; +// }]; self.mentionCandidateSelectionViewSizeConstraint.constant = 0; [self setNeedsLayout]; [self layoutIfNeeded]; diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index 0f6f822e4..932614b9f 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -3802,7 +3802,12 @@ typedef enum : NSUInteger { if (newText.length > 0) { NSUInteger lastCharacterIndex = newText.length - 1; unichar lastCharacter = [newText characterAtIndex:lastCharacterIndex]; - if (lastCharacter == '@') { + // Check if there is a whitespace before '@' or the '@' is the first character + unichar secondLastCharacter = ' '; + if (lastCharacterIndex > 0) { + secondLastCharacter = [newText characterAtIndex:lastCharacterIndex - 1]; + } + if (lastCharacter == '@' && [NSCharacterSet.whitespaceAndNewlineCharacterSet characterIsMember:secondLastCharacter]) { NSArray *mentionCandidates = [LKAPI getMentionCandidatesFor:@"" in:self.thread.uniqueId]; self.currentMentionStartIndex = (NSInteger)lastCharacterIndex; [self.inputToolbar showMentionCandidateSelectionViewFor:mentionCandidates in:self.thread];