From 2a76503aa6d1cb802aacf48cd3774d0b3085ba05 Mon Sep 17 00:00:00 2001 From: Benjamin Reis Date: Thu, 5 Oct 2017 11:27:15 +0200 Subject: [PATCH] polishing chat creation view --- Classes/ChatConversationCreateTableView.m | 44 ++++++++++++++++-- Classes/ChatConversationCreateView.m | 8 +++- .../UIChatCreateCollectionViewCell.m | 12 +++++ Resources/images/next_disabled.png | Bin 0 -> 410 bytes Resources/images/next_disabled@2x.png | Bin 0 -> 761 bytes linphone.xcodeproj/project.pbxproj | 20 ++++---- 6 files changed, 72 insertions(+), 12 deletions(-) create mode 100644 Resources/images/next_disabled.png create mode 100644 Resources/images/next_disabled@2x.png diff --git a/Classes/ChatConversationCreateTableView.m b/Classes/ChatConversationCreateTableView.m index 349cb4832..84c334061 100644 --- a/Classes/ChatConversationCreateTableView.m +++ b/Classes/ChatConversationCreateTableView.m @@ -44,7 +44,8 @@ NSString *address = (NSString *)key; NSString *name = [FastAddressBook displayNameForContact:value]; Contact *contact = [LinphoneManager.instance.fastAddressBook.addressBookMap objectForKey:address]; - Boolean linphoneContact = (contact.friend && linphone_presence_model_get_basic_status(linphone_friend_get_presence_model(contact.friend)) == LinphonePresenceBasicStatusOpen); + Boolean linphoneContact = [FastAddressBook contactHasValidSipDomain:contact] + || (contact.friend && linphone_presence_model_get_basic_status(linphone_friend_get_presence_model(contact.friend)) == LinphonePresenceBasicStatusOpen); BOOL add = _allFilter || linphoneContact; if (((filter.length == 0) @@ -87,7 +88,8 @@ cell.displayNameLabel.text = [_contacts.allValues objectAtIndex:indexPath.row]; LinphoneAddress *addr = [LinphoneUtils normalizeSipOrPhoneAddress:[_contacts.allKeys objectAtIndex:indexPath.row]]; Contact *contact = [LinphoneManager.instance.fastAddressBook.addressBookMap objectForKey:[_contacts.allKeys objectAtIndex:indexPath.row]]; - Boolean linphoneContact = (contact.friend && linphone_presence_model_get_basic_status(linphone_friend_get_presence_model(contact.friend)) == LinphonePresenceBasicStatusOpen); + Boolean linphoneContact = [FastAddressBook contactHasValidSipDomain:contact] + || (contact.friend && linphone_presence_model_get_basic_status(linphone_friend_get_presence_model(contact.friend)) == LinphonePresenceBasicStatusOpen); cell.linphoneImage.hidden = !linphoneContact; if (addr) { cell.addressLabel.text = [NSString stringWithUTF8String:linphone_address_as_string_uri_only(addr)]; @@ -116,6 +118,43 @@ [_contactsDict removeObjectForKey:cell.addressLabel.text]; } cell.selectedImage.hidden = !cell.selectedImage.hidden; + _controllerNextButton.enabled = (_contactsGroup.count > 0); + if (_contactsGroup.count > 1 || (_contactsGroup.count == 1 && cell.selectedImage.hidden)) { + [UIView animateWithDuration:0.2 + delay:0 + options:UIViewAnimationOptionCurveEaseOut + animations:^{ + [tableView setFrame:CGRectMake(tableView.frame.origin.x, + _collectionView.frame.origin.y + _collectionView.frame.size.height, + tableView.frame.size.width, + tableView.frame.size.height)]; + + } + completion:nil]; + } else if (_contactsGroup.count == 1 && !cell.selectedImage.hidden) { + [UIView animateWithDuration:0.2 + delay:0 + options:UIViewAnimationOptionCurveEaseOut + animations:^{ + [tableView setFrame:CGRectMake(tableView.frame.origin.x, + _collectionView.frame.origin.y + _collectionView.frame.size.height, + tableView.frame.size.width, + tableView.frame.size.height - _collectionView.frame.size.height)]; + + } + completion:nil]; + } else { + [UIView animateWithDuration:0.2 + delay:0 + options:UIViewAnimationOptionCurveEaseOut + animations:^{ + [tableView setFrame:CGRectMake(tableView.frame.origin.x, + _searchBar.frame.origin.y + _searchBar.frame.size.height, + tableView.frame.size.width, + tableView.frame.size.height + _collectionView.frame.size.height)]; + } + completion:nil]; + } [_collectionView reloadData]; if(!cell.selectedImage.hidden) { index = _contactsGroup.count-1; @@ -129,7 +168,6 @@ animated:YES]; } }); - _controllerNextButton.enabled = (_contactsGroup.count > 0); } - (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText { diff --git a/Classes/ChatConversationCreateView.m b/Classes/ChatConversationCreateView.m index da24de20c..ae54d8e5d 100644 --- a/Classes/ChatConversationCreateView.m +++ b/Classes/ChatConversationCreateView.m @@ -53,11 +53,15 @@ static UICompositeViewDescription *compositeDescription = nil; [_collectionView setCollectionViewLayout:layout]; _tableController.collectionView = _collectionView; _tableController.controllerNextButton = _nextButton; - _nextButton.enabled = FALSE; } - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; + _nextButton.enabled = FALSE; + _tableController.tableView.frame = CGRectMake(_tableController.tableView.frame.origin.x, + _tableController.searchBar.frame.origin.y + _tableController.searchBar.frame.size.height, + _tableController.tableView.frame.size.width, + _tableController.tableView.frame.size.height + _collectionView.frame.size.height); [_collectionView reloadData]; [self changeView:ContactsAll]; } @@ -65,6 +69,8 @@ static UICompositeViewDescription *compositeDescription = nil; #pragma mark - searchBar delegate - (IBAction)onBackClick:(id)sender { + [_tableController.contactsDict removeAllObjects]; + [_tableController.contactsGroup removeAllObjects]; [PhoneMainView.instance popCurrentView]; } diff --git a/Classes/LinphoneUI/UIChatCreateCollectionViewCell.m b/Classes/LinphoneUI/UIChatCreateCollectionViewCell.m index 3b832cfb5..49b53cfc2 100644 --- a/Classes/LinphoneUI/UIChatCreateCollectionViewCell.m +++ b/Classes/LinphoneUI/UIChatCreateCollectionViewCell.m @@ -33,6 +33,18 @@ - (void) onDelete { [_controller.tableController.contactsGroup removeObject:_uri]; [_controller.tableController.contactsDict removeObjectForKey:_uri]; + if (_controller.tableController.contactsGroup.count == 0) { + [UIView animateWithDuration:0.2 + delay:0 + options:UIViewAnimationOptionCurveEaseOut + animations:^{ + [_controller.tableController.tableView setFrame:CGRectMake(_controller.tableController.tableView.frame.origin.x, + _controller.tableController.searchBar.frame.origin.y + _controller.tableController.searchBar.frame.size.height, + _controller.tableController.tableView.frame.size.width, + _controller.tableController.tableView.frame.size.height + _controller.collectionView.frame.size.height)]; + } + completion:nil]; + } [_controller.collectionView reloadData]; [_controller.tableController.tableView reloadData]; _controller.tableController.controllerNextButton.enabled = (_controller.tableController.contactsGroup.count > 0); diff --git a/Resources/images/next_disabled.png b/Resources/images/next_disabled.png new file mode 100644 index 0000000000000000000000000000000000000000..48df90f00d9794c8817ab9587dfa5888ac3e0bab GIT binary patch literal 410 zcmV;L0cHM)P);}TAus~qt!RR)K4fHzC&TG*N_;gAV>=B9N&!6HqL&W zJ!>-O5OU+!$-#3l%Qhk(5V*!&-^@0pd>~idh+Ek0ko?pFz%X?p(S+qzoN1^7fKWMO zQHLcqjwiRQ0f3O5NR(lvTi(Y|X#gOEoVd(3o9*d+q5%Lv&fFzzvfQ~`Y5_nl+HSQJ_f?bj{D1eHocr&&f`!&jO52E|$=Abp-Uw|mfUx9-cxp7-`aJ=X@7Kf4 zws9{2?Gq6InQ&__Jx_$b7{G}({n*3+3|VRpoJcVMx)aOS)=2@nEY;843&jBF#g?z- zNCO(BYT%6(1E43L`%#8fK!{RxXIoUk&`OmrX>n~hUvq8I?ZsL_{&#HEVWffp$TfHSdt zkrydI7p2UIqxMRhDsY^`~m!ecVcSmAdGb&_NLWGdNe?=0{NR?$t zZ5CIKfxyya#C@(vz;0QtDiuvpPM*R^N2uO%YmFu;07i7|3q!5^PL^iUnLqXJ+X$3q zu$!0l=^!Kqp);NS6lTyW%Ib8(!Z*BqdAG@Kw)_JUdHK!s-dy&oq6}J3c$~EUv3>N{ zu~Sm}XYyepceH#PGX zkihC+@tvWrV*|iCS42No1gP z>{|_AEaNx~BIkei&4n}Ay>uM>lxIuDm%zQkANk@H$594|A0_f9FWuL2o`?lYBm$WO rzSy7bIU^RFi;BawK%V^TIJ4I;M_u9EQ{G