From 7738a7352b19dd3469b1b4205b9e10ea28b446e8 Mon Sep 17 00:00:00 2001 From: Benjamin Reis Date: Fri, 27 Apr 2018 10:02:50 +0200 Subject: [PATCH] begin dev --- Classes/ChatConversationImdnView.h | 40 ++++ Classes/ChatConversationImdnView.m | 181 ++++++++++++++++++ Classes/ChatConversationImdnView.xib | 121 ++++++++++++ Classes/ChatConversationInfoView.m | 2 +- Classes/ChatConversationInfoView.xib | 38 ++-- Classes/ChatConversationTableView.m | 46 ++++- .../ChatConversationImdnTableViewHeader.h | 19 ++ .../ChatConversationImdnTableViewHeader.m | 27 +++ .../ChatConversationImdnTableViewHeader.xib | 62 ++++++ Classes/LinphoneUI/TabBarView.m | 1 + .../UIChatConversationImdnTableViewCell.h | 19 ++ .../UIChatConversationImdnTableViewCell.m | 32 ++++ .../UIChatConversationImdnTableViewCell.xib | 54 ++++++ Classes/PhoneMainView.h | 1 + Resources/linphonerc-factory | 1 + linphone.xcodeproj/project.pbxproj | 30 +++ 16 files changed, 646 insertions(+), 28 deletions(-) create mode 100644 Classes/ChatConversationImdnView.h create mode 100644 Classes/ChatConversationImdnView.m create mode 100644 Classes/ChatConversationImdnView.xib create mode 100644 Classes/LinphoneUI/ChatConversationImdnTableViewHeader.h create mode 100644 Classes/LinphoneUI/ChatConversationImdnTableViewHeader.m create mode 100644 Classes/LinphoneUI/ChatConversationImdnTableViewHeader.xib create mode 100644 Classes/LinphoneUI/UIChatConversationImdnTableViewCell.h create mode 100644 Classes/LinphoneUI/UIChatConversationImdnTableViewCell.m create mode 100644 Classes/LinphoneUI/UIChatConversationImdnTableViewCell.xib diff --git a/Classes/ChatConversationImdnView.h b/Classes/ChatConversationImdnView.h new file mode 100644 index 000000000..876d8aa6d --- /dev/null +++ b/Classes/ChatConversationImdnView.h @@ -0,0 +1,40 @@ +// +// ChatConversationImdnView.h +// linphone +// +// Created by REIS Benjamin on 25/04/2018. +// + +#ifndef ChatConversationImdnView_h +#define ChatConversationImdnView_h + +#import + +#import "UICompositeView.h" +#import "UIRoundBorderedButton.h" + +@interface ChatConversationImdnView : UIViewController + +@property(nonatomic) LinphoneChatMessage *msg; +@property(nonatomic) bctbx_list_t *displayedList; +@property(nonatomic) bctbx_list_t *receivedList; +@property(nonatomic) bctbx_list_t *notReceivedList; +@property(nonatomic) CGFloat height; + +@property (weak, nonatomic) IBOutlet UIView *whiteView; +@property (weak, nonatomic) IBOutlet UIView *msgView; +@property (weak, nonatomic) IBOutlet UIImageView *msgBackgroundColorImage; +@property (weak, nonatomic) IBOutlet UIRoundedImageView *msgAvatarImage; +@property (weak, nonatomic) IBOutlet UIImageView *msgBottomBar; +@property (weak, nonatomic) IBOutlet UILabel *msgDateLabel; +@property (weak, nonatomic) IBOutlet UITextViewNoDefine *msgText; +@property (weak, nonatomic) IBOutlet UIView *readHeader; +@property (weak, nonatomic) IBOutlet UIView *deliveredHeader; +@property (weak, nonatomic) IBOutlet UIView *undeliveredHeader; +@property (weak, nonatomic) IBOutlet UIScrollView *scrollView; + +- (IBAction)onBackClick:(id)sender; + +@end + +#endif /* ChatConversationImdnView_h */ diff --git a/Classes/ChatConversationImdnView.m b/Classes/ChatConversationImdnView.m new file mode 100644 index 000000000..d82d63088 --- /dev/null +++ b/Classes/ChatConversationImdnView.m @@ -0,0 +1,181 @@ +// +// ChatConversationImdnView.m +// linphone +// +// Created by REIS Benjamin on 25/04/2018. +// + +#import + +#import "ChatConversationImdnTableViewHeader.h" +#import "ChatConversationImdnView.h" +#import "PhoneMainView.h" +#import "UIChatBubbleTextCell.h" +#import "UIChatConversationImdnTableViewCell.h" + +@implementation ChatConversationImdnView + +static UICompositeViewDescription *compositeDescription = nil; + ++ (UICompositeViewDescription *)compositeViewDescription { + if (compositeDescription == nil) { + compositeDescription = [[UICompositeViewDescription alloc] init:self.class + statusBar:StatusBarView.class + tabBar:TabBarView.class + sideMenu:SideMenuView.class + fullscreen:false + isLeftFragment:NO + fragmentWith:ChatsListView.class]; + } + return compositeDescription; +} + +- (UICompositeViewDescription *)compositeViewDescription { + return self.class.compositeViewDescription; +} + +- (void)viewDidLoad { + [super viewDidLoad]; + _msg = NULL; +} + +- (void)viewWillDisappear:(BOOL)animated { + for (UIView *view in _scrollView.subviews) { + if (view == _readHeader || view == _deliveredHeader || view == _undeliveredHeader) + continue; + + [view removeFromSuperview]; + } +} + +- (void)viewWillAppear:(BOOL)animated { + [super viewWillAppear:animated]; + const LinphoneAddress *addr = linphone_chat_message_get_from_address(_msg); + BOOL outgoing = linphone_chat_message_is_outgoing(_msg); + + _msgDateLabel.text = [NSString stringWithFormat:@"%@ - %@", + [LinphoneUtils timeToString:linphone_chat_message_get_time(_msg) withFormat:LinphoneDateChatBubble], + [FastAddressBook displayNameForAddress:addr]]; + _msgAvatarImage.image = outgoing ? [LinphoneUtils selfAvatar] : [FastAddressBook imageForAddress:addr]; + _msgText.text = [NSString stringWithUTF8String:linphone_chat_message_get_text(_msg)]; + _msgBackgroundColorImage.image = _msgBottomBar.image = [UIImage imageNamed:(outgoing ? @"color_A.png" : @"color_D.png")]; + _msgDateLabel.textColor = [UIColor colorWithPatternImage:_msgBackgroundColorImage.image]; + + [_msgView setFrame:CGRectMake(_msgView.frame.origin.x, + _msgView.frame.origin.y, + _msgView.frame.size.width, + [UIChatBubbleTextCell ViewHeightForMessage:_msg withWidth:self.view.frame.size.width].height)]; + + [_whiteView setFrame:CGRectMake(self.view.frame.origin.x, + self.view.frame.origin.y, + self.view.frame.size.width, + _msgView.frame.size.height + _msgView.frame.origin.y)]; + + _scrollView.scrollEnabled = TRUE; + _scrollView.userInteractionEnabled = TRUE; + _scrollView.showsVerticalScrollIndicator = TRUE; + + _displayedList = linphone_chat_message_get_participants_that_have_displayed(_msg); + _receivedList = linphone_chat_message_get_participants_that_have_received(_msg); + _notReceivedList = linphone_chat_message_get_participants_that_have_not_received(_msg); + + if (_displayedList) { + } + if (_receivedList) { + } + if (_notReceivedList) { + } +} + +#pragma mark - TableView + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { + NSInteger i = 0; + if (_displayedList) i++; + if (_receivedList) i++; + if (_notReceivedList) i++; + return i; +} + +- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { + return 23.0; +} + +- (UITableViewHeaderFooterView *)headerViewForSection:(NSInteger)section { + NSString *kHeaderId = NSStringFromClass(ChatConversationImdnTableViewHeader.class); + ChatConversationImdnTableViewHeader *header = [tableView dequeueReusableHeaderFooterViewWithIdentifier:kHeaderId]; + if (!header) + header = [[ChatConversationImdnTableViewHeader alloc] initWithIdentifier:kHeaderId]; + + if (section == 1) { + if (_displayedList) { + header. + } else if (_receivedList) { + + } else { + + } + } else if (section == 2) { + if (_receivedList) { + + } else { + + } + } +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + if (section == 1) { + if (_displayedList) + return bctbx_list_size(_displayedList); + else if (_receivedList) + return bctbx_list_size(_receivedList); + else + return bctbx_list_size(_notReceivedList); + } else if (section == 2) { + if (_receivedList) + return bctbx_list_size(_receivedList); + else + return bctbx_list_size(_notReceivedList); + } + return bctbx_list_size(_notReceivedList); +} + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + bctbx_list_t *list = NULL; + if (indexPath.section == 1) { + if (_displayedList) + list = _displayedList; + else if (_receivedList) + list = _receivedList; + else + list = _notReceivedList; + } else if (indexPath.section == 2) { + if (_receivedList) + list = _receivedList; + else + list = _notReceivedList; + } else + list = _notReceivedList; + + NSString *kCellId = NSStringFromClass(UIChatConversationImdnTableViewCell.class); + UIChatConversationImdnTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellId]; + if (cell == nil) { + cell = [[UIChatConversationImdnTableViewCell alloc] initWithIdentifier:kCellId]; + } + LinphoneParticipantImdnState *state = bctbx_list_nth_data(list, (int)indexPath.row); + const LinphoneParticipant *participant = linphone_participant_imdn_state_get_participant(state); + time_t time = linphone_participant_imdn_state_get_state_change_time(state); + const LinphoneAddress *addr = linphone_participant_get_address(participant); + cell.displayName.text = [FastAddressBook displayNameForAddress:addr]; + cell.avatar.image = [FastAddressBook imageForAddress:addr]; + cell.dateLabel.text = [LinphoneUtils timeToString:time withFormat:LinphoneDateChatBubble]; + + return cell; +} + +- (IBAction)onBackClick:(id)sender { + [PhoneMainView.instance popCurrentView]; +} + +@end diff --git a/Classes/ChatConversationImdnView.xib b/Classes/ChatConversationImdnView.xib new file mode 100644 index 000000000..bb39cac73 --- /dev/null +++ b/Classes/ChatConversationImdnView.xib @@ -0,0 +1,121 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Classes/ChatConversationInfoView.m b/Classes/ChatConversationInfoView.m index 4dc46ae58..1c4d42df9 100644 --- a/Classes/ChatConversationInfoView.m +++ b/Classes/ChatConversationInfoView.m @@ -126,7 +126,7 @@ static UICompositeViewDescription *compositeDescription = nil; - (void)onCreate { bctbx_list_t *addresses = NULL; - for(NSString *addr in _contacts) { + for (NSString *addr in _contacts) { LinphoneAddress *linphoneAddress = linphone_address_new(addr.UTF8String); if (!linphoneAddress) continue; diff --git a/Classes/ChatConversationInfoView.xib b/Classes/ChatConversationInfoView.xib index 919871b67..e7ef9d66d 100644 --- a/Classes/ChatConversationInfoView.xib +++ b/Classes/ChatConversationInfoView.xib @@ -1,11 +1,11 @@ - - + + - + @@ -22,29 +22,29 @@ - + - + - + - + - + - + @@ -148,11 +148,11 @@