Feature/2865 participant sorting

This commit is contained in:
Frank Rotermund
2022-06-01 13:53:23 +00:00
parent bb46c57a02
commit 067b7e26c4
10 changed files with 385 additions and 187 deletions
@@ -270,6 +270,9 @@
self.bottomImageView.hidden = (screenOrientation == UIInterfaceOrientationLandscapeLeft || screenOrientation == UIInterfaceOrientationLandscapeRight);
[self refreshUserEncryptionTrustLevel];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onKeyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onKeyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
}
- (void)viewWillDisappear:(BOOL)animated
@@ -280,6 +283,9 @@
[self hideNavigationBarBorder:NO];
self.bottomImageView.hidden = YES;
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil];
}
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id <UIViewControllerTransitionCoordinator>)coordinator
@@ -438,10 +444,16 @@
}
if (BwiBuildSettings.bwiUserLabelsMemberDetailsVisible) {
self.roomMemberUserIdLabel.text = [self tmpUserLabel];
NSString* userLabel = [self tmpUserLabel];
if (userLabel) {
self.roomMemberUserIdLabel.text = [NSString stringWithFormat:NSLocalizedStringFromTable(@"bwi_room_member_details_userlabel", @"Bwi", nil), self.mxRoom.summary.displayname, userLabel];
} else {
self.roomMemberUserIdLabel.text = nil;
}
}
}
// Complete data update and reload table view
[super updateMemberInfo];
}
@@ -1529,14 +1541,14 @@
functionCell.mxkTextField.text = [self tmpUserLabel];
functionCell.mxkTextField.keyboardType = UIKeyboardTypeDefault;
functionCell.mxkTextField.clearButtonMode = UITextFieldViewModeAlways;
functionCell.mxkTextField.rightViewMode = UITextFieldViewModeAlways;
functionCell.mxkTextField.autocorrectionType = UITextAutocorrectionTypeNo;
functionCell.mxkTextField.spellCheckingType = UITextSpellCheckingTypeNo;
functionCell.mxkButton.enabled = YES;
[functionCell.mxkButton addTarget:self action:@selector(onBwiUserLabelButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
bwiUserLabelTextField = functionCell.mxkTextField;
bwiUserLabelTextField.delegate = self;
bwiUserLabelTextField = functionCell.mxkTextField;
bwiUserLabelButton = functionCell.mxkButton;
@@ -1553,12 +1565,37 @@
[self.bwiUserLabelService setCompletion:^(BOOL success) {
if (success) {
dispatch_after( dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
[weakself updateUserLabelButtonText];
[weakself updateMemberInfo];
});
}
}];
if (permFunction) {
[self.bwiUserLabelService setUserLabelWithUserLabel:nil user:self.mxRoomMember.userId];
bwiUserLabelTextField.text = nil;
} else {
[self.bwiUserLabelService setUserLabelWithUserLabel:bwiUserLabelTextField.text user:self.mxRoomMember.userId];
}
}
- (void)onBwiUserLabelKeyboardReturn:(id)sender {
MXWeakify(self);
[self.bwiUserLabelService setCompletion:^(BOOL success) {
if (success) {
dispatch_after( dispatch_time(DISPATCH_TIME_NOW, 0.2 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
[weakself updateUserLabelButtonText];
[weakself updateMemberInfo];
});
} else {
[weakself updateUserLabelButtonText];
[weakself updateMemberInfo];
}
}];
if (permFunction && [permFunction isEqualToString:bwiUserLabelTextField.text]) {
if (bwiUserLabelTextField.text.length == 0) {
[self.bwiUserLabelService setUserLabelWithUserLabel:nil user:self.mxRoomMember.userId];
bwiUserLabelTextField.text = nil;
} else {
@@ -1586,12 +1623,11 @@
}
- (void)updateUserLabelButtonText {
NSString* tmpFunction = bwiUserLabelTextField.text;
NSString* permFunction = [self.bwiUserLabelService getUserLabelWithUser:self.mxRoomMember.userId];
NSString* title;
if (permFunction && [permFunction isEqualToString:tmpFunction]) {
if (permFunction) {
title = NSLocalizedStringFromTable(@"bwi_room_member_userlabels_button_delete", @"Bwi", nil);
} else {
title = NSLocalizedStringFromTable(@"bwi_room_member_userlabels_button_save", @"Bwi", nil);
@@ -1601,10 +1637,38 @@
[bwiUserLabelButton setTitle:title forState:UIControlStateHighlighted];
}
#pragma mark bwi textfield delegate
#pragma mark - bwi textfield delegate
-(void) textFieldDidChangeSelection:(UITextField *)textField {
[self updateUserLabelButtonText];
}
-(BOOL) textFieldShouldReturn:(UITextField*)textField {
[self onBwiUserLabelKeyboardReturn:textField];
return YES;
}
#pragma mark - bwi keyboard handling
- (void)onKeyboardWillShow:(NSNotification *)notif {
if (self.keyboardHeight <= 0) {
[super onKeyboardWillShow:notif];
CGRect frame = self.tableView.frame;
frame.origin.y -= self.keyboardHeight;
self.tableView.frame = frame;
}
}
- (void)onKeyboardWillHide:(NSNotification *)notif {
if (self.keyboardHeight > 0) {
CGFloat height = self.keyboardHeight;
[super onKeyboardWillHide:notif];
CGRect frame = self.tableView.frame;
frame.origin.y += height;
self.tableView.frame = frame;
}
}
@end