mention function '@' fixed

This commit is contained in:
ryanzhao 2019-11-13 14:54:26 +11:00
parent 1ffb8908cc
commit 5f555521d0
2 changed files with 18 additions and 1 deletions

View File

@ -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];

View File

@ -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<LKMention *> *mentionCandidates = [LKAPI getMentionCandidatesFor:@"" in:self.thread.uniqueId];
self.currentMentionStartIndex = (NSInteger)lastCharacterIndex;
[self.inputToolbar showMentionCandidateSelectionViewFor:mentionCandidates in:self.thread];