mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-05-02 14:16:59 +02:00
Feature - Improve the people invite screens
#904. +"Add contact" button should be added on Room Member list #905
This commit is contained in:
@@ -84,6 +84,18 @@
|
||||
*/
|
||||
@property (nonatomic) BOOL forceMatrixIdInDisplayName;
|
||||
|
||||
/**
|
||||
The type of standard accessory view the contact cells should use
|
||||
Default is UITableViewCellAccessoryNone.
|
||||
*/
|
||||
@property (nonatomic) UITableViewCellAccessoryType contactCellAccessoryType;
|
||||
|
||||
/**
|
||||
An image used to create a custom accessy view on the right side of the contact cells.
|
||||
If set, use custom view. ignore accessoryType
|
||||
*/
|
||||
@property (nonatomic) UIImage *contactCellAccessoryImage;
|
||||
|
||||
/**
|
||||
The dictionary of the ignored local contacts, the keys are their email. Empty by default.
|
||||
*/
|
||||
|
||||
@@ -122,6 +122,8 @@
|
||||
|
||||
isMultiUseNameByDisplayName = nil;
|
||||
|
||||
_contactCellAccessoryImage = nil;
|
||||
|
||||
[super destroy];
|
||||
}
|
||||
|
||||
@@ -466,6 +468,8 @@
|
||||
contactCell.accessoryView = nil;
|
||||
contactCell.contentView.alpha = 1;
|
||||
contactCell.userInteractionEnabled = YES;
|
||||
contactCell.accessoryType = UITableViewCellAccessoryNone;
|
||||
contactCell.accessoryView = nil;
|
||||
}
|
||||
|
||||
MXKContact *contact;
|
||||
@@ -502,16 +506,17 @@
|
||||
{
|
||||
[contactCell render:contact];
|
||||
|
||||
// The search displays contacts to invite. Add a plus icon to the cell
|
||||
// in order to make it more understandable for the end user
|
||||
// The search displays contacts to invite.
|
||||
if (indexPath.section == filteredLocalContactsSection || indexPath.section == filteredMatrixContactsSection)
|
||||
{
|
||||
contactCell.accessoryView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"plus_icon"]];
|
||||
// Add the right accessory view if any
|
||||
contactCell.accessoryType = self.contactCellAccessoryType;
|
||||
contactCell.accessoryView = [[UIImageView alloc] initWithImage:self.contactCellAccessoryImage];
|
||||
}
|
||||
else if (indexPath.section == searchInputSection)
|
||||
{
|
||||
// This is the text entered by the user
|
||||
// Check whether the search input is a valid email or a Matrix user ID before adding the plus icon.
|
||||
// Check whether the search input is a valid email or a Matrix user ID before adding the accessory view.
|
||||
if (![MXTools isEmailAddress:currentSearchText] && ![MXTools isMatrixUserIdentifier:currentSearchText])
|
||||
{
|
||||
contactCell.contentView.alpha = 0.5;
|
||||
@@ -519,7 +524,9 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
contactCell.accessoryView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"plus_icon"]];
|
||||
// Add the right accessory view if any
|
||||
contactCell.accessoryType = self.contactCellAccessoryType;
|
||||
contactCell.accessoryView = [[UIImageView alloc] initWithImage:self.contactCellAccessoryImage];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
HomeFilesSearchViewController *filesSearchViewController;
|
||||
MXKSearchDataSource *filesSearchDataSource;
|
||||
|
||||
ContactsTableViewController *contactsViewController;
|
||||
ContactsTableViewController *peopleSearchViewController;
|
||||
MXKContact *selectedContact;
|
||||
|
||||
// Display a gradient view above the screen
|
||||
@@ -104,9 +104,10 @@
|
||||
|
||||
// Add search People tab
|
||||
[titles addObject: NSLocalizedStringFromTable(@"search_people", @"Vector", nil)];
|
||||
contactsViewController = [ContactsTableViewController contactsTableViewController];
|
||||
contactsViewController.contactsTableViewControllerDelegate = self;
|
||||
[viewControllers addObject:contactsViewController];
|
||||
peopleSearchViewController = [ContactsTableViewController contactsTableViewController];
|
||||
peopleSearchViewController.contactsTableViewControllerDelegate = self;
|
||||
peopleSearchViewController.contactCellAccessoryType = UITableViewCellAccessoryDisclosureIndicator;
|
||||
[viewControllers addObject:peopleSearchViewController];
|
||||
|
||||
// add Files tab
|
||||
[titles addObject: NSLocalizedStringFromTable(@"search_files", @"Vector", nil)];
|
||||
@@ -129,6 +130,7 @@
|
||||
[self initializeDataSources];
|
||||
|
||||
self.searchBar.autocapitalizationType = UITextAutocapitalizationTypeNone;
|
||||
self.searchBar.placeholder = NSLocalizedStringFromTable(@"search_default_placeholder", @"Vector", nil);
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
@@ -511,9 +513,9 @@
|
||||
{
|
||||
self.backgroundImageView.hidden = ((messagesSearchDataSource.serverCount != 0) || !messagesSearchViewController.noResultsLabel.isHidden || (self.keyboardHeight == 0));
|
||||
}
|
||||
else if (self.selectedViewController == contactsViewController)
|
||||
else if (self.selectedViewController == peopleSearchViewController)
|
||||
{
|
||||
self.backgroundImageView.hidden = (([contactsViewController.tableView numberOfRowsInSection:0] != 0) || (self.keyboardHeight == 0));
|
||||
self.backgroundImageView.hidden = (([peopleSearchViewController.tableView numberOfRowsInSection:0] != 0) || (self.keyboardHeight == 0));
|
||||
}
|
||||
else if (self.selectedViewController == filesSearchViewController)
|
||||
{
|
||||
@@ -546,6 +548,15 @@
|
||||
|
||||
if (!self.searchBarHidden)
|
||||
{
|
||||
if (self.selectedViewController == peopleSearchViewController)
|
||||
{
|
||||
self.searchBar.placeholder = NSLocalizedStringFromTable(@"search_people_placeholder", @"Vector", nil);
|
||||
}
|
||||
else
|
||||
{
|
||||
self.searchBar.placeholder = NSLocalizedStringFromTable(@"search_default_placeholder", @"Vector", nil);
|
||||
}
|
||||
|
||||
[self updateSearch];
|
||||
}
|
||||
}
|
||||
@@ -1108,9 +1119,9 @@
|
||||
});
|
||||
}
|
||||
}
|
||||
else if (self.selectedViewController == contactsViewController)
|
||||
else if (self.selectedViewController == peopleSearchViewController)
|
||||
{
|
||||
[contactsViewController searchWithPattern:self.searchBar.text forceReset:NO];
|
||||
[peopleSearchViewController searchWithPattern:self.searchBar.text forceReset:NO];
|
||||
}
|
||||
else if (self.selectedViewController == filesSearchViewController)
|
||||
{
|
||||
@@ -1138,7 +1149,7 @@
|
||||
{
|
||||
[messagesSearchDataSource searchMessages:nil force:NO];
|
||||
}
|
||||
[contactsViewController searchWithPattern:nil forceReset:NO];
|
||||
[peopleSearchViewController searchWithPattern:nil forceReset:NO];
|
||||
if (filesSearchDataSource.searchText.length)
|
||||
{
|
||||
[filesSearchDataSource searchMessages:nil force:NO];
|
||||
@@ -1157,7 +1168,7 @@
|
||||
// As the public room search is local, it can be updated on each text change
|
||||
[self updateSearch];
|
||||
}
|
||||
else if (self.selectedViewController == contactsViewController)
|
||||
else if (self.selectedViewController == peopleSearchViewController)
|
||||
{
|
||||
// As the contact search is local, it can be updated on each text change
|
||||
[self updateSearch];
|
||||
|
||||
@@ -495,7 +495,7 @@
|
||||
|
||||
addParticipantButtonImageView.backgroundColor = [UIColor clearColor];
|
||||
addParticipantButtonImageView.contentMode = UIViewContentModeCenter;
|
||||
addParticipantButtonImageView.image = [UIImage imageNamed:@"create_room"];
|
||||
addParticipantButtonImageView.image = [UIImage imageNamed:@"add_participant"];
|
||||
|
||||
CGFloat side = 78.0f;
|
||||
NSLayoutConstraint* widthConstraint = [NSLayoutConstraint constraintWithItem:addParticipantButtonImageView
|
||||
@@ -545,12 +545,14 @@
|
||||
|
||||
- (void)onAddParticipantButtonPressed
|
||||
{
|
||||
// Push the contacts table screen.
|
||||
// Push the contacts picker.
|
||||
contactsPickerViewController = [ContactsTableViewController contactsTableViewController];
|
||||
|
||||
// Set delegate to handle action on member (start chat, mention)
|
||||
contactsPickerViewController.contactsTableViewControllerDelegate = self;
|
||||
contactsPickerViewController.forceMatrixIdInDisplayName = YES;
|
||||
// Add a plus icon to the contact cell in the contacts picker, in order to make it more understandable for the end user.
|
||||
contactsPickerViewController.contactCellAccessoryImage = [UIImage imageNamed:@"plus_icon"];
|
||||
|
||||
// List all the participants by their matrix user id, or a room 3pid invite token to ignore them during the contacts search.
|
||||
[contactsPickerViewController.ignoredContactsByMatrixId removeAllObjects];
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
/**
|
||||
'StartChatViewController' instance is used to prepare new room creation.
|
||||
*/
|
||||
@interface StartChatViewController : ContactsTableViewController <UISearchBarDelegate>
|
||||
@interface StartChatViewController : ContactsTableViewController <UISearchBarDelegate, ContactsTableViewControllerDelegate>
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UIView *searchBarHeader;
|
||||
@property (weak, nonatomic) IBOutlet UISearchBar *searchBarView;
|
||||
|
||||
@@ -67,6 +67,13 @@
|
||||
|
||||
// Prepare room participants
|
||||
participants = [NSMutableArray array];
|
||||
|
||||
// Assign itself as delegate
|
||||
self.contactsTableViewControllerDelegate = self;
|
||||
|
||||
// Add a plus icon to the contact cell when a search session is in progress,
|
||||
// in order to make it more understandable for the end user.
|
||||
self.contactCellAccessoryImage = [UIImage imageNamed:@"plus_icon"];;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad
|
||||
@@ -269,14 +276,14 @@
|
||||
{
|
||||
NSInteger count = 0;
|
||||
|
||||
if (section == participantsSection)
|
||||
{
|
||||
count = participants.count + 1;
|
||||
}
|
||||
else
|
||||
if (_isAddParticipantSearchBarEditing)
|
||||
{
|
||||
count = [super tableView:self.tableView numberOfRowsInSection:section];
|
||||
}
|
||||
else if (section == participantsSection)
|
||||
{
|
||||
count = participants.count + 1;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
@@ -285,7 +292,11 @@
|
||||
{
|
||||
UITableViewCell *cell;
|
||||
|
||||
if (indexPath.section == participantsSection)
|
||||
if (_isAddParticipantSearchBarEditing)
|
||||
{
|
||||
cell = [super tableView:self.tableView cellForRowAtIndexPath:indexPath];
|
||||
}
|
||||
else if (indexPath.section == participantsSection)
|
||||
{
|
||||
ContactTableViewCell* participantCell = [tableView dequeueReusableCellWithIdentifier:@"ParticipantTableViewCellId" forIndexPath:indexPath];
|
||||
|
||||
@@ -317,10 +328,6 @@
|
||||
|
||||
cell = participantCell;
|
||||
}
|
||||
else
|
||||
{
|
||||
cell = [super tableView:self.tableView cellForRowAtIndexPath:indexPath];
|
||||
}
|
||||
|
||||
return cell;
|
||||
}
|
||||
@@ -345,7 +352,7 @@
|
||||
{
|
||||
CGFloat height = 0.0;
|
||||
|
||||
if (section != participantsSection)
|
||||
if (_isAddParticipantSearchBarEditing)
|
||||
{
|
||||
height = [super tableView:self.tableView heightForHeaderInSection:section];
|
||||
}
|
||||
@@ -355,32 +362,15 @@
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
NSInteger row = indexPath.row;
|
||||
MXKContact *mxkContact;
|
||||
|
||||
if (indexPath.section == searchInputSection)
|
||||
if (_isAddParticipantSearchBarEditing)
|
||||
{
|
||||
mxkContact = [[MXKContact alloc] initMatrixContactWithDisplayName:currentSearchText andMatrixID:nil];
|
||||
[super tableView:tableView didSelectRowAtIndexPath:indexPath];
|
||||
}
|
||||
else if (indexPath.section == filteredLocalContactsSection)
|
||||
else
|
||||
{
|
||||
mxkContact = filteredLocalContacts[row];
|
||||
// Do nothing
|
||||
[tableView deselectRowAtIndexPath:indexPath animated:YES];
|
||||
}
|
||||
else if (indexPath.section == filteredMatrixContactsSection)
|
||||
{
|
||||
mxkContact = filteredMatrixContacts[row];
|
||||
}
|
||||
|
||||
if (mxkContact)
|
||||
{
|
||||
// Update here the mutable list of participants
|
||||
[participants addObject:mxkContact];
|
||||
|
||||
// Refresh display by leaving search session
|
||||
[self searchBarCancelButtonClicked:_searchBarView];
|
||||
}
|
||||
|
||||
[tableView deselectRowAtIndexPath:indexPath animated:YES];
|
||||
}
|
||||
|
||||
- (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
@@ -648,4 +638,18 @@
|
||||
[searchBar resignFirstResponder];
|
||||
}
|
||||
|
||||
#pragma mark - ContactsTableViewControllerDelegate
|
||||
|
||||
- (void)contactsTableViewController:(ContactsTableViewController *)contactsTableViewController didSelectContact:(MXKContact*)contact
|
||||
{
|
||||
if (contact)
|
||||
{
|
||||
// Update here the mutable list of participants
|
||||
[participants addObject:contact];
|
||||
}
|
||||
|
||||
// Refresh display by leaving search session
|
||||
[self searchBarCancelButtonClicked:_searchBarView];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user