mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-24 22:58:13 +00:00
Select or deselect all messages in chat conversation view swift. Add delete feature.
This commit is contained in:
parent
bac7bb95f2
commit
3977c0ebd3
4 changed files with 71 additions and 14 deletions
|
|
@ -324,7 +324,7 @@
|
|||
|
||||
- (void)onDelete {
|
||||
if (_message != NULL) {
|
||||
UITableView *tableView = VIEW(ChatConversationView).tableController.tableView;
|
||||
UITableView *tableView = VIEW(ChatConversationViewSwift).tableController.tableView;
|
||||
NSIndexPath *indexPath = [tableView indexPathForCell:self];
|
||||
[tableView.dataSource tableView:tableView
|
||||
commitEditingStyle:UITableViewCellEditingStyleDelete
|
||||
|
|
@ -340,7 +340,7 @@ static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState st
|
|||
|
||||
if (!linphone_chat_message_is_outgoing(msg) || (state != LinphoneChatMessageStateFileTransferDone && state != LinphoneChatMessageStateFileTransferInProgress)) {
|
||||
LinphoneEventLog *event = (LinphoneEventLog *)linphone_chat_message_cbs_get_user_data(linphone_chat_message_get_callbacks(msg));
|
||||
ChatConversationView *view = VIEW(ChatConversationView);
|
||||
ChatConversationViewSwift *view = VIEW(ChatConversationViewSwift);
|
||||
[view.tableController updateEventEntry:event];
|
||||
[view.tableController scrollToBottom:true];
|
||||
}
|
||||
|
|
@ -767,7 +767,7 @@ static const CGFloat REPLY_OR_FORWARD_TAG_HEIGHT = 18;
|
|||
- (void)layoutSubviews {
|
||||
[super layoutSubviews];
|
||||
if (_message != nil) {
|
||||
UITableView *tableView = VIEW(ChatConversationView).tableController.tableView;
|
||||
UITableView *tableView = VIEW(ChatConversationViewSwift).tableController.tableView;
|
||||
BOOL is_outgoing = linphone_chat_message_is_outgoing(_message);
|
||||
CGRect bubbleFrame = _bubbleView.frame;
|
||||
int available_width = self.frame.size.width;
|
||||
|
|
@ -947,7 +947,7 @@ static const CGFloat REPLY_OR_FORWARD_TAG_HEIGHT = 18;
|
|||
[_messageActionsBlocks addObject:^{
|
||||
[thiz dismissPopup];
|
||||
linphone_chat_room_delete_message(linphone_chat_message_get_chat_room(message), message);
|
||||
[VIEW(ChatConversationView).tableController reloadData];
|
||||
[VIEW(ChatConversationViewSwift).tableController reloadData];
|
||||
}];
|
||||
}
|
||||
|
||||
|
|
@ -959,7 +959,7 @@ static const CGFloat REPLY_OR_FORWARD_TAG_HEIGHT = 18;
|
|||
return;
|
||||
|
||||
|
||||
[VIEW(ChatConversationView).tableController dismissMessagesPopups];
|
||||
[VIEW(ChatConversationViewSwift).tableController dismissMessagesPopups];
|
||||
[self buildActions];
|
||||
int width = 250;
|
||||
int cellHeight = 45;
|
||||
|
|
@ -969,7 +969,7 @@ static const CGFloat REPLY_OR_FORWARD_TAG_HEIGHT = 18;
|
|||
|
||||
CGRect frame = CGRectMake(
|
||||
linphone_chat_message_is_outgoing(self.message) ? screenRect.size.width - width - 10 : 10,
|
||||
(self.frame.origin.y + self.frame.size.height) - [VIEW(ChatConversationView).tableController .tableView contentOffset].y > screenRect.size.height /2 ? self.frame.origin.y - menuHeight - 10: self.frame.origin.y + self.frame.size.height,
|
||||
(self.frame.origin.y + self.frame.size.height) - [VIEW(ChatConversationViewSwift).tableController .tableView contentOffset].y > screenRect.size.height /2 ? self.frame.origin.y - menuHeight - 10: self.frame.origin.y + self.frame.size.height,
|
||||
width,
|
||||
menuHeight);
|
||||
|
||||
|
|
@ -991,11 +991,11 @@ static const CGFloat REPLY_OR_FORWARD_TAG_HEIGHT = 18;
|
|||
_popupMenu.editing = NO;
|
||||
_popupMenu.userInteractionEnabled = true;
|
||||
[_popupMenu reloadData];
|
||||
[VIEW(ChatConversationView).tableController.view addSubview:_popupMenu];
|
||||
[VIEW(ChatConversationViewSwift).tableController.view addSubview:_popupMenu];
|
||||
UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapOutsideMenu:)];
|
||||
tapGestureRecognizer.cancelsTouchesInView = NO;
|
||||
tapGestureRecognizer.numberOfTapsRequired = 1;
|
||||
[VIEW(ChatConversationView).tableController.view addGestureRecognizer:tapGestureRecognizer];
|
||||
[VIEW(ChatConversationViewSwift).tableController.view addGestureRecognizer:tapGestureRecognizer];
|
||||
}
|
||||
|
||||
-(void) dismissPopup {
|
||||
|
|
@ -1008,7 +1008,7 @@ static const CGFloat REPLY_OR_FORWARD_TAG_HEIGHT = 18;
|
|||
|
||||
|
||||
-(void) tapOutsideMenu:(UITapGestureRecognizer *) g {
|
||||
CGPoint p = [g locationInView:VIEW(ChatConversationView).tableController.view];
|
||||
CGPoint p = [g locationInView:VIEW(ChatConversationViewSwift).tableController.view];
|
||||
if (!CGRectContainsPoint(_popupMenu.frame,p)) {
|
||||
[self dismissPopup];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -107,9 +107,11 @@
|
|||
[checkBoxButton setBackgroundColor:[UIColor clearColor]];
|
||||
checkBoxButton.accessibilityLabel = NSLocalizedString(@"Checkbox", nil);
|
||||
checkBoxButton.userInteractionEnabled = NO;
|
||||
cell.userInteractionEnabled = NO;
|
||||
cell.accessoryView = checkBoxButton;
|
||||
} else {
|
||||
cell.accessoryView = nil;
|
||||
cell.userInteractionEnabled = YES;
|
||||
cell.accessoryType = UITableViewCellAccessoryNone;
|
||||
}
|
||||
_deleteButton.enabled = (_selectedItems.count != 0);
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ import DropDown
|
|||
|
||||
var activeAlertController = CustomAlertController()
|
||||
|
||||
let tableController = ChatConversationTableView()
|
||||
@objc let tableController = ChatConversationTableView()
|
||||
let refreshControl = UIRefreshControl()
|
||||
|
||||
let menu: DropDown = {
|
||||
|
|
@ -118,10 +118,14 @@ import DropDown
|
|||
tableController.chatRoom = chatRoom?.getCobject
|
||||
refreshControl.addTarget(self, action: #selector(refreshData), for: .valueChanged)
|
||||
tableController.refreshControl = refreshControl
|
||||
tableController.toggleSelectionButton = action1SelectAllButton
|
||||
}
|
||||
|
||||
override func viewWillDisappear(_ animated: Bool) {
|
||||
editModeOff()
|
||||
}
|
||||
|
||||
override func viewDidAppear(_ animated: Bool) {
|
||||
//tableController.chatRoom = chatRoom?.getCobject
|
||||
tableController.reloadData()
|
||||
}
|
||||
|
||||
|
|
@ -428,4 +432,48 @@ import DropDown
|
|||
at: .top,
|
||||
animated: false)
|
||||
}
|
||||
|
||||
override func editModeOn(){
|
||||
super.editModeOn()
|
||||
tableController.setEditing(true, animated: false)
|
||||
}
|
||||
|
||||
override func editModeOff(){
|
||||
super.editModeOff()
|
||||
tableController.setEditing(false, animated: false)
|
||||
}
|
||||
|
||||
override func selectDeselectAll(){
|
||||
super.selectDeselectAll()
|
||||
if(action1SelectAllButton.isHidden){
|
||||
tableController.onSelectionToggle(action1SelectAllButton)
|
||||
}else{
|
||||
tableController.onSelectionToggle(action1SelectAllButton)
|
||||
}
|
||||
}
|
||||
|
||||
override func deleteSelected(){
|
||||
super.deleteSelected()
|
||||
onDeleteClick()
|
||||
}
|
||||
|
||||
func onDeleteClick() {
|
||||
let msg = NSLocalizedString("Do you want to delete the selected messages?", comment: "")
|
||||
UIConfirmationDialog.show(
|
||||
withMessage: msg,
|
||||
cancelMessage: nil,
|
||||
confirmMessage: nil,
|
||||
onCancelClick: { [self] in
|
||||
onEditionChangeClick()},
|
||||
onConfirmationClick: {
|
||||
self.tableController.removeSelection(nil)
|
||||
self.editModeOff()
|
||||
self.tableController.loadData()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@objc func pressed() {
|
||||
print("")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ import linphonesw
|
|||
|
||||
topBar.addSubview(action2Delete)
|
||||
action2Delete.alignParentRight(withMargin: side_buttons_margin).matchParentHeight().done()
|
||||
action2Delete.onClickAction = action4
|
||||
action2Delete.onClickAction = deleteSelected
|
||||
action2Delete.isHidden = true
|
||||
|
||||
topBar.addSubview(action1Button)
|
||||
|
|
@ -161,10 +161,11 @@ import linphonesw
|
|||
cancelButton.isHidden = false
|
||||
action1Button.isHidden = true
|
||||
action1BisButton.isHidden = true
|
||||
action1SelectAllButton.isHidden = true
|
||||
action1DeselectAllButton.isHidden = false
|
||||
action1SelectAllButton.isHidden = false
|
||||
action1DeselectAllButton.isHidden = true
|
||||
action2Button.isHidden = true
|
||||
action2Delete.isHidden = false
|
||||
action2Delete.isEnabled = false
|
||||
}
|
||||
|
||||
func editModeOff(){
|
||||
|
|
@ -181,9 +182,15 @@ import linphonesw
|
|||
if(action1SelectAllButton.isHidden){
|
||||
action1SelectAllButton.isHidden = false
|
||||
action1DeselectAllButton.isHidden = true
|
||||
action2Delete.isEnabled = false
|
||||
}else{
|
||||
action1SelectAllButton.isHidden = true
|
||||
action1DeselectAllButton.isHidden = false
|
||||
action2Delete.isEnabled = true
|
||||
}
|
||||
}
|
||||
|
||||
func deleteSelected(){
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue