From ff5177d32f095011b194d3e3abcd7cf075c6d5bd Mon Sep 17 00:00:00 2001 From: Benjamin Reis Date: Fri, 10 Nov 2017 15:58:28 +0100 Subject: [PATCH] add wait view when creating a chat room --- .../Base.lproj/ChatConversationCreateView.xib | 17 +++++++++++++++-- Classes/ChatConversationCreateView.h | 3 +-- Classes/ChatConversationCreateView.m | 7 ++++++- Classes/ChatConversationInfoView.h | 1 + Classes/ChatConversationInfoView.m | 9 +++++++-- Classes/ChatConversationInfoView.xib | 13 +++++++++++++ 6 files changed, 43 insertions(+), 7 deletions(-) diff --git a/Classes/Base.lproj/ChatConversationCreateView.xib b/Classes/Base.lproj/ChatConversationCreateView.xib index ac8f27212..2ef20c05f 100644 --- a/Classes/Base.lproj/ChatConversationCreateView.xib +++ b/Classes/Base.lproj/ChatConversationCreateView.xib @@ -1,11 +1,11 @@ - + - + @@ -19,6 +19,7 @@ + @@ -144,6 +145,18 @@ + diff --git a/Classes/ChatConversationCreateView.h b/Classes/ChatConversationCreateView.h index d74e865b3..8b337f5ca 100644 --- a/Classes/ChatConversationCreateView.h +++ b/Classes/ChatConversationCreateView.h @@ -19,13 +19,12 @@ @property(strong, nonatomic) IBOutlet ChatConversationCreateTableView *tableController; @property(strong, nonatomic) IBOutlet ChatConversationCreateCollectionViewController *collectionController; @property (weak, nonatomic) IBOutlet UICollectionView *collectionView; - @property(weak, nonatomic) IBOutlet UIIconButton *backButton; @property (weak, nonatomic) IBOutlet UIIconButton *nextButton; - @property (weak, nonatomic) IBOutlet UIIconButton *allButton; @property (weak, nonatomic) IBOutlet UIIconButton *linphoneButton; @property (weak, nonatomic) IBOutlet UIImageView *selectedButtonImage; +@property (weak, nonatomic) IBOutlet UIView *waitView; @property(nonatomic) Boolean isForEditing; diff --git a/Classes/ChatConversationCreateView.m b/Classes/ChatConversationCreateView.m index ea401a4c8..1be3469b9 100644 --- a/Classes/ChatConversationCreateView.m +++ b/Classes/ChatConversationCreateView.m @@ -58,6 +58,7 @@ static UICompositeViewDescription *compositeDescription = nil; - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; + _waitView.hidden = YES; if(_tableController.contactsGroup.count == 0) { if (!_isForEditing) _nextButton.enabled = FALSE; @@ -76,12 +77,14 @@ static UICompositeViewDescription *compositeDescription = nil; #pragma mark - Chat room functions void create_chat_room_state_changed(LinphoneChatRoom *cr, LinphoneChatRoomState newState) { + ChatConversationCreateView *view = (__bridge ChatConversationCreateView *)linphone_chat_room_cbs_get_user_data(linphone_chat_room_get_callbacks(cr)); switch (newState) { case LinphoneChatRoomStateCreated: LOGI(@"Chat room [%p] created on server.", cr); - [(__bridge ChatConversationCreateView *)linphone_chat_room_cbs_get_user_data(linphone_chat_room_get_callbacks(cr)) onChatRoomCreated:cr]; + [view onChatRoomCreated:cr]; break; case LinphoneChatRoomStateCreationFailed: + view.waitView.hidden = YES; LOGE(@"Chat room [%p] could not be created on server.", cr); break; default: @@ -91,11 +94,13 @@ void create_chat_room_state_changed(LinphoneChatRoom *cr, LinphoneChatRoomState - (void)onChatRoomCreated:(LinphoneChatRoom *)cr { ChatConversationView *view = VIEW(ChatConversationView); + _waitView.hidden = YES; view.chatRoom = cr; [PhoneMainView.instance changeCurrentView:view.compositeViewDescription]; } - (void)createChatRoom { + _waitView.hidden = NO; LinphoneChatRoom *room = linphone_core_create_client_group_chat_room(LC, "dummy subject"); NSString *addr = _tableController.contactsDict.allKeys[0]; LinphoneAddress *linphoneAddress = linphone_address_new(addr.UTF8String); diff --git a/Classes/ChatConversationInfoView.h b/Classes/ChatConversationInfoView.h index 9893e83fb..5f2baa25c 100644 --- a/Classes/ChatConversationInfoView.h +++ b/Classes/ChatConversationInfoView.h @@ -27,6 +27,7 @@ @property (weak, nonatomic) IBOutlet UIIconButton *addButton; @property (weak, nonatomic) IBOutlet UITextField *nameLabel; @property (weak, nonatomic) IBOutlet UITableView *tableView; +@property (weak, nonatomic) IBOutlet UIView *waitView; - (IBAction)onNextClick:(id)sender; - (IBAction)onBackClick:(id)sender; diff --git a/Classes/ChatConversationInfoView.m b/Classes/ChatConversationInfoView.m index 59825c50a..9a351b921 100644 --- a/Classes/ChatConversationInfoView.m +++ b/Classes/ChatConversationInfoView.m @@ -59,6 +59,7 @@ static UICompositeViewDescription *compositeDescription = nil; - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; + _waitView.hidden = YES; _nameLabel.text = _room && linphone_chat_room_get_subject(_room) ? [NSString stringWithUTF8String:linphone_chat_room_get_subject(_room)] : @""; @@ -90,6 +91,7 @@ static UICompositeViewDescription *compositeDescription = nil; #pragma mark - next functions - (void)onCreate { + _waitView.hidden = NO; LinphoneChatRoom *room = linphone_core_create_client_group_chat_room(LC, _nameLabel.text.UTF8String); if(!room) { return; @@ -282,23 +284,26 @@ static UICompositeViewDescription *compositeDescription = nil; #pragma mark - chat room callbacks - (void)goToChatRoom:(LinphoneChatRoom *)cr { + _waitView.hidden = YES; ChatConversationView *view = VIEW(ChatConversationView); view.chatRoom = cr; [PhoneMainView.instance changeCurrentView:view.compositeViewDescription]; } void chat_room_state_changed(LinphoneChatRoom *cr, LinphoneChatRoomState newState) { + ChatConversationInfoView *view = (__bridge ChatConversationInfoView *)linphone_chat_room_cbs_get_user_data(linphone_chat_room_get_callbacks(cr)); switch (newState) { case LinphoneChatRoomStateCreated: LOGI(@"Chat room [%p] created on server.", cr); - [(__bridge ChatConversationInfoView *)linphone_chat_room_cbs_get_user_data(linphone_chat_room_get_callbacks(cr)) goToChatRoom:cr]; + [view goToChatRoom:cr]; break; case LinphoneChatRoomStateCreationFailed: + view.waitView.hidden = YES; LOGE(@"Chat room [%p] could not be created on server.", cr); break; case LinphoneChatRoomStateTerminated: LOGI(@"Chat room [%p] has been terminated.", cr); - [(__bridge ChatConversationInfoView *)linphone_chat_room_cbs_get_user_data(linphone_chat_room_get_callbacks(cr)) goToChatRoom:cr]; + [view goToChatRoom:cr]; break; default: break; diff --git a/Classes/ChatConversationInfoView.xib b/Classes/ChatConversationInfoView.xib index 9463a7eea..86646888d 100644 --- a/Classes/ChatConversationInfoView.xib +++ b/Classes/ChatConversationInfoView.xib @@ -18,6 +18,7 @@ + @@ -147,6 +148,18 @@ +