mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-04-30 17:36:22 +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 {
|
- (void)onDelete {
|
||||||
if (_message != NULL) {
|
if (_message != NULL) {
|
||||||
UITableView *tableView = VIEW(ChatConversationView).tableController.tableView;
|
UITableView *tableView = VIEW(ChatConversationViewSwift).tableController.tableView;
|
||||||
NSIndexPath *indexPath = [tableView indexPathForCell:self];
|
NSIndexPath *indexPath = [tableView indexPathForCell:self];
|
||||||
[tableView.dataSource tableView:tableView
|
[tableView.dataSource tableView:tableView
|
||||||
commitEditingStyle:UITableViewCellEditingStyleDelete
|
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)) {
|
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));
|
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 updateEventEntry:event];
|
||||||
[view.tableController scrollToBottom:true];
|
[view.tableController scrollToBottom:true];
|
||||||
}
|
}
|
||||||
|
|
@ -767,7 +767,7 @@ static const CGFloat REPLY_OR_FORWARD_TAG_HEIGHT = 18;
|
||||||
- (void)layoutSubviews {
|
- (void)layoutSubviews {
|
||||||
[super layoutSubviews];
|
[super layoutSubviews];
|
||||||
if (_message != nil) {
|
if (_message != nil) {
|
||||||
UITableView *tableView = VIEW(ChatConversationView).tableController.tableView;
|
UITableView *tableView = VIEW(ChatConversationViewSwift).tableController.tableView;
|
||||||
BOOL is_outgoing = linphone_chat_message_is_outgoing(_message);
|
BOOL is_outgoing = linphone_chat_message_is_outgoing(_message);
|
||||||
CGRect bubbleFrame = _bubbleView.frame;
|
CGRect bubbleFrame = _bubbleView.frame;
|
||||||
int available_width = self.frame.size.width;
|
int available_width = self.frame.size.width;
|
||||||
|
|
@ -947,7 +947,7 @@ static const CGFloat REPLY_OR_FORWARD_TAG_HEIGHT = 18;
|
||||||
[_messageActionsBlocks addObject:^{
|
[_messageActionsBlocks addObject:^{
|
||||||
[thiz dismissPopup];
|
[thiz dismissPopup];
|
||||||
linphone_chat_room_delete_message(linphone_chat_message_get_chat_room(message), message);
|
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;
|
return;
|
||||||
|
|
||||||
|
|
||||||
[VIEW(ChatConversationView).tableController dismissMessagesPopups];
|
[VIEW(ChatConversationViewSwift).tableController dismissMessagesPopups];
|
||||||
[self buildActions];
|
[self buildActions];
|
||||||
int width = 250;
|
int width = 250;
|
||||||
int cellHeight = 45;
|
int cellHeight = 45;
|
||||||
|
|
@ -969,7 +969,7 @@ static const CGFloat REPLY_OR_FORWARD_TAG_HEIGHT = 18;
|
||||||
|
|
||||||
CGRect frame = CGRectMake(
|
CGRect frame = CGRectMake(
|
||||||
linphone_chat_message_is_outgoing(self.message) ? screenRect.size.width - width - 10 : 10,
|
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,
|
width,
|
||||||
menuHeight);
|
menuHeight);
|
||||||
|
|
||||||
|
|
@ -991,11 +991,11 @@ static const CGFloat REPLY_OR_FORWARD_TAG_HEIGHT = 18;
|
||||||
_popupMenu.editing = NO;
|
_popupMenu.editing = NO;
|
||||||
_popupMenu.userInteractionEnabled = true;
|
_popupMenu.userInteractionEnabled = true;
|
||||||
[_popupMenu reloadData];
|
[_popupMenu reloadData];
|
||||||
[VIEW(ChatConversationView).tableController.view addSubview:_popupMenu];
|
[VIEW(ChatConversationViewSwift).tableController.view addSubview:_popupMenu];
|
||||||
UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapOutsideMenu:)];
|
UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapOutsideMenu:)];
|
||||||
tapGestureRecognizer.cancelsTouchesInView = NO;
|
tapGestureRecognizer.cancelsTouchesInView = NO;
|
||||||
tapGestureRecognizer.numberOfTapsRequired = 1;
|
tapGestureRecognizer.numberOfTapsRequired = 1;
|
||||||
[VIEW(ChatConversationView).tableController.view addGestureRecognizer:tapGestureRecognizer];
|
[VIEW(ChatConversationViewSwift).tableController.view addGestureRecognizer:tapGestureRecognizer];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void) dismissPopup {
|
-(void) dismissPopup {
|
||||||
|
|
@ -1008,7 +1008,7 @@ static const CGFloat REPLY_OR_FORWARD_TAG_HEIGHT = 18;
|
||||||
|
|
||||||
|
|
||||||
-(void) tapOutsideMenu:(UITapGestureRecognizer *) g {
|
-(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)) {
|
if (!CGRectContainsPoint(_popupMenu.frame,p)) {
|
||||||
[self dismissPopup];
|
[self dismissPopup];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -107,9 +107,11 @@
|
||||||
[checkBoxButton setBackgroundColor:[UIColor clearColor]];
|
[checkBoxButton setBackgroundColor:[UIColor clearColor]];
|
||||||
checkBoxButton.accessibilityLabel = NSLocalizedString(@"Checkbox", nil);
|
checkBoxButton.accessibilityLabel = NSLocalizedString(@"Checkbox", nil);
|
||||||
checkBoxButton.userInteractionEnabled = NO;
|
checkBoxButton.userInteractionEnabled = NO;
|
||||||
|
cell.userInteractionEnabled = NO;
|
||||||
cell.accessoryView = checkBoxButton;
|
cell.accessoryView = checkBoxButton;
|
||||||
} else {
|
} else {
|
||||||
cell.accessoryView = nil;
|
cell.accessoryView = nil;
|
||||||
|
cell.userInteractionEnabled = YES;
|
||||||
cell.accessoryType = UITableViewCellAccessoryNone;
|
cell.accessoryType = UITableViewCellAccessoryNone;
|
||||||
}
|
}
|
||||||
_deleteButton.enabled = (_selectedItems.count != 0);
|
_deleteButton.enabled = (_selectedItems.count != 0);
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ import DropDown
|
||||||
|
|
||||||
var activeAlertController = CustomAlertController()
|
var activeAlertController = CustomAlertController()
|
||||||
|
|
||||||
let tableController = ChatConversationTableView()
|
@objc let tableController = ChatConversationTableView()
|
||||||
let refreshControl = UIRefreshControl()
|
let refreshControl = UIRefreshControl()
|
||||||
|
|
||||||
let menu: DropDown = {
|
let menu: DropDown = {
|
||||||
|
|
@ -118,10 +118,14 @@ import DropDown
|
||||||
tableController.chatRoom = chatRoom?.getCobject
|
tableController.chatRoom = chatRoom?.getCobject
|
||||||
refreshControl.addTarget(self, action: #selector(refreshData), for: .valueChanged)
|
refreshControl.addTarget(self, action: #selector(refreshData), for: .valueChanged)
|
||||||
tableController.refreshControl = refreshControl
|
tableController.refreshControl = refreshControl
|
||||||
|
tableController.toggleSelectionButton = action1SelectAllButton
|
||||||
|
}
|
||||||
|
|
||||||
|
override func viewWillDisappear(_ animated: Bool) {
|
||||||
|
editModeOff()
|
||||||
}
|
}
|
||||||
|
|
||||||
override func viewDidAppear(_ animated: Bool) {
|
override func viewDidAppear(_ animated: Bool) {
|
||||||
//tableController.chatRoom = chatRoom?.getCobject
|
|
||||||
tableController.reloadData()
|
tableController.reloadData()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -428,4 +432,48 @@ import DropDown
|
||||||
at: .top,
|
at: .top,
|
||||||
animated: false)
|
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)
|
topBar.addSubview(action2Delete)
|
||||||
action2Delete.alignParentRight(withMargin: side_buttons_margin).matchParentHeight().done()
|
action2Delete.alignParentRight(withMargin: side_buttons_margin).matchParentHeight().done()
|
||||||
action2Delete.onClickAction = action4
|
action2Delete.onClickAction = deleteSelected
|
||||||
action2Delete.isHidden = true
|
action2Delete.isHidden = true
|
||||||
|
|
||||||
topBar.addSubview(action1Button)
|
topBar.addSubview(action1Button)
|
||||||
|
|
@ -161,10 +161,11 @@ import linphonesw
|
||||||
cancelButton.isHidden = false
|
cancelButton.isHidden = false
|
||||||
action1Button.isHidden = true
|
action1Button.isHidden = true
|
||||||
action1BisButton.isHidden = true
|
action1BisButton.isHidden = true
|
||||||
action1SelectAllButton.isHidden = true
|
action1SelectAllButton.isHidden = false
|
||||||
action1DeselectAllButton.isHidden = false
|
action1DeselectAllButton.isHidden = true
|
||||||
action2Button.isHidden = true
|
action2Button.isHidden = true
|
||||||
action2Delete.isHidden = false
|
action2Delete.isHidden = false
|
||||||
|
action2Delete.isEnabled = false
|
||||||
}
|
}
|
||||||
|
|
||||||
func editModeOff(){
|
func editModeOff(){
|
||||||
|
|
@ -181,9 +182,15 @@ import linphonesw
|
||||||
if(action1SelectAllButton.isHidden){
|
if(action1SelectAllButton.isHidden){
|
||||||
action1SelectAllButton.isHidden = false
|
action1SelectAllButton.isHidden = false
|
||||||
action1DeselectAllButton.isHidden = true
|
action1DeselectAllButton.isHidden = true
|
||||||
|
action2Delete.isEnabled = false
|
||||||
}else{
|
}else{
|
||||||
action1SelectAllButton.isHidden = true
|
action1SelectAllButton.isHidden = true
|
||||||
action1DeselectAllButton.isHidden = false
|
action1DeselectAllButton.isHidden = false
|
||||||
|
action2Delete.isEnabled = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func deleteSelected(){
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue