This commit is contained in:
Niels Andriesse 2019-10-10 15:29:44 +11:00
parent 21aa2f6464
commit 6b08367d6b
4 changed files with 13 additions and 12 deletions

View File

@ -3,7 +3,7 @@
@objc(LKUserSelectionView)
final class UserSelectionView : UIView, UITableViewDataSource, UITableViewDelegate {
@objc var users: [String] = [] { didSet { tableView.reloadData() } }
@objc var users: [String] = [] { didSet { tableView.reloadData(); tableView.contentOffset = CGPoint.zero } }
@objc var hasGroupContext = false
@objc var delegate: UserSelectionViewDelegate?
@ -15,7 +15,7 @@ final class UserSelectionView : UIView, UITableViewDataSource, UITableViewDelega
result.register(Cell.self, forCellReuseIdentifier: "Cell")
result.separatorStyle = .none
result.backgroundColor = .clear
result.contentInset = UIEdgeInsets(top: 10, leading: 0, bottom: 0, trailing: 0)
result.contentInset = UIEdgeInsets(top: 6, leading: 0, bottom: 0, trailing: 0)
return result
}()
@ -101,12 +101,12 @@ private extension UserSelectionView {
stackView.axis = .horizontal
stackView.alignment = .center
stackView.spacing = 16
stackView.set(.height, to: 44)
stackView.set(.height, to: 36)
contentView.addSubview(stackView)
stackView.pin(.leading, to: .leading, of: contentView, withInset: 16)
stackView.pin(.top, to: .top, of: contentView, withInset: 4)
stackView.pin(.top, to: .top, of: contentView, withInset: 8)
contentView.pin(.trailing, to: .trailing, of: stackView, withInset: 16)
contentView.pin(.bottom, to: .bottom, of: stackView, withInset: 4)
contentView.pin(.bottom, to: .bottom, of: stackView, withInset: 8)
stackView.set(.width, to: UIScreen.main.bounds.width - 2 * 16)
// Set up the moderator icon image view
moderatorIconImageView.set(.width, to: 20)

View File

@ -1095,7 +1095,7 @@ const CGFloat kMaxTextViewHeight = 98;
{
self.userSelectionView.hasGroupContext = thread.isGroupThread; // Must happen before setting the users
self.userSelectionView.users = users;
self.userSelectionViewSizeConstraint.constant = 10 + MIN(users.count, 4) * 52;
self.userSelectionViewSizeConstraint.constant = 6 + MIN(users.count, 4) * 52;
[self setNeedsLayout];
[self layoutIfNeeded];
}

View File

@ -3769,10 +3769,9 @@ typedef enum : NSUInteger {
- (void)textViewDidChange:(UITextView *)textView
{
if (textView.text.length > 0) {
[self.typingIndicators didStartTypingOutgoingInputInThread:self.thread];
}
NSUInteger currentEndIndex = (textView.text.length != 0) ? textView.text.length - 1 : 0;
if (textView.text.length == 0) { return; }
[self.typingIndicators didStartTypingOutgoingInputInThread:self.thread];
NSUInteger currentEndIndex = textView.text.length - 1;
unichar lastCharacter = [textView.text characterAtIndex:currentEndIndex];
NSMutableCharacterSet *allowedCharacters = NSMutableCharacterSet.lowercaseLetterCharacterSet;
[allowedCharacters formUnionWithCharacterSet:NSCharacterSet.uppercaseLetterCharacterSet];

View File

@ -322,9 +322,11 @@ public final class LokiAPI : NSObject {
candidates.sort { $0.displayName < $1.displayName }
if query.count >= 2 {
// Filter out any non-matching candidates
candidates = candidates.filter { $0.displayName.contains(query) }
candidates = candidates.filter { $0.displayName.lowercased().contains(query.lowercased()) }
// Sort based on where in the candidate the query occurs
candidates.sort { $0.displayName.range(of: query)!.lowerBound < $1.displayName.range(of: query)!.lowerBound }
candidates.sort {
$0.displayName.lowercased().range(of: query.lowercased())!.lowerBound < $1.displayName.lowercased().range(of: query.lowercased())!.lowerBound
}
}
// Return
return candidates.map { $0.id } // Inefficient to do this and then look up the display name again later, but easy to interface with Obj-C