From 9e9e23befb0159456e6f2011dcb4ef4f1135d117 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Thu, 8 Oct 2015 13:48:44 +0200 Subject: [PATCH] rework chats / checkboxes --- Classes/Base.lproj/ChatsListView.xib | 126 ++++++++++--------- Classes/ChatsListView.h | 8 +- Classes/ChatsListView.m | 23 ++-- Classes/LinphoneUI/Base.lproj/UIChatCell.xib | 42 +++---- Classes/LinphoneUI/UIChatCell.h | 1 - Classes/LinphoneUI/UIChatCell.m | 15 ++- 6 files changed, 112 insertions(+), 103 deletions(-) diff --git a/Classes/Base.lproj/ChatsListView.xib b/Classes/Base.lproj/ChatsListView.xib index 62551e36b..7fa0676fd 100644 --- a/Classes/Base.lproj/ChatsListView.xib +++ b/Classes/Base.lproj/ChatsListView.xib @@ -1,5 +1,5 @@ - + @@ -8,22 +8,11 @@ - - - - - - - - - - - @@ -40,17 +29,59 @@ - + + + - - - @@ -122,14 +117,27 @@ + + + + + + + + + + + - - + + + - - - + + + + diff --git a/Classes/ChatsListView.h b/Classes/ChatsListView.h index ec82cd363..357f55609 100644 --- a/Classes/ChatsListView.h +++ b/Classes/ChatsListView.h @@ -28,14 +28,10 @@ } @property(nonatomic, strong) IBOutlet ChatsListTableView *tableController; -@property(nonatomic, strong) IBOutlet UIButton *editButton; -@property(weak, nonatomic) IBOutlet UIButton *toggleSelectionButton; -@property(weak, nonatomic) IBOutlet UIButton *backButton; @property(weak, nonatomic) IBOutlet UIButton *addButton; -@property(weak, nonatomic) IBOutlet UIButton *deleteButton; - (IBAction)onAddClick:(id)event; -- (IBAction)onEditToggle:(id)event; -- (IBAction)onSelectionToggle:(id)sender; +- (IBAction)onEditionChangeClick:(id)sender; +- (IBAction)onDeleteClick:(id)sender; @end diff --git a/Classes/ChatsListView.m b/Classes/ChatsListView.m index 5c45b6bd5..f36ee978c 100644 --- a/Classes/ChatsListView.m +++ b/Classes/ChatsListView.m @@ -79,17 +79,24 @@ static UICompositeViewDescription *compositeDescription = nil; [view setChatRoom:NULL]; } -- (void)setEditing:(BOOL)editing { - [_tableController setEditing:editing animated:TRUE]; - _toggleSelectionButton.hidden = _backButton.hidden = _deleteButton.hidden = !editing; - _addButton.hidden = _editButton.hidden = editing; +- (IBAction)onEditionChangeClick:(id)sender { + _addButton.hidden = self.tableController.isEditing; } -- (IBAction)onEditToggle:(id)event { - [self setEditing:!_tableController.isEditing]; +- (IBAction)onDeleteClick:(id)sender { + NSString *msg = + [NSString stringWithFormat:NSLocalizedString(@"Are you sure that you want to delete %d conversations?", nil), + _tableController.selectedItems.count]; + [UIConfirmationDialog ShowWithMessage:msg + onCancelClick:^() { + [self onEditionChangeClick:nil]; + } + onConfirmationClick:^() { + [_tableController removeSelection]; + [_tableController loadData]; + [self onEditionChangeClick:nil]; + }]; } -- (IBAction)onSelectionToggle:(id)sender { -} @end diff --git a/Classes/LinphoneUI/Base.lproj/UIChatCell.xib b/Classes/LinphoneUI/Base.lproj/UIChatCell.xib index aa702af7d..0cddd7ce6 100644 --- a/Classes/LinphoneUI/Base.lproj/UIChatCell.xib +++ b/Classes/LinphoneUI/Base.lproj/UIChatCell.xib @@ -1,5 +1,5 @@ - + @@ -16,16 +16,24 @@ - - + + - - + + + - @@ -75,8 +75,8 @@ - - + + diff --git a/Classes/LinphoneUI/UIChatCell.h b/Classes/LinphoneUI/UIChatCell.h index dffbfebc2..e2d9257a7 100644 --- a/Classes/LinphoneUI/UIChatCell.h +++ b/Classes/LinphoneUI/UIChatCell.h @@ -31,7 +31,6 @@ @property(nonatomic, strong) IBOutlet UIRoundedImageView *avatarImage; @property (nonatomic, strong) IBOutlet UILabel* addressLabel; @property (nonatomic, strong) IBOutlet UILabel* chatContentLabel; -@property (nonatomic, strong) IBOutlet UIButton * deleteButton; @property(weak, nonatomic) IBOutlet UILabel *chatLatestTimeLabel; @property(weak, nonatomic) IBOutlet UIIconButton *unreadCountButton; diff --git a/Classes/LinphoneUI/UIChatCell.m b/Classes/LinphoneUI/UIChatCell.m index e5c8e9285..3133ba4cb 100644 --- a/Classes/LinphoneUI/UIChatCell.m +++ b/Classes/LinphoneUI/UIChatCell.m @@ -27,7 +27,6 @@ @synthesize avatarImage; @synthesize addressLabel; @synthesize chatContentLabel; -@synthesize deleteButton; @synthesize unreadCountButton; #pragma mark - Lifecycle Functions @@ -37,10 +36,11 @@ NSArray *arrayOfViews = [[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self.class) owner:self options:nil]; - if ([arrayOfViews count] >= 1) { - - [self.contentView addSubview:[arrayOfViews objectAtIndex:0]]; - } + // resize cell to match .nib size. It is needed when resized the cell to + // correctly adapt its height too + UIView *sub = ((UIView *)[arrayOfViews objectAtIndex:0]); + [self setFrame:CGRectMake(0, 0, sub.frame.size.width, sub.frame.size.height)]; + [self addSubview:sub]; } return self; } @@ -114,11 +114,10 @@ [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:0.3]; } - [super setEditing:editing animated:animated]; if (editing) { - [deleteButton setAlpha:1.0f]; + [unreadCountButton setAlpha:0.0f]; } else { - [deleteButton setAlpha:0.0f]; + [unreadCountButton setAlpha:1.0f]; } if (animated) { [UIView commitAnimations];