Explorar o código

always select ActionCell on taps

- always add visual feedback on tapping ActionCells

- use deselect-animation only when no other elements pop up
B. Petersen %!s(int64=4) %!d(string=hai) anos
pai
achega
95db557425

+ 2 - 1
deltachat-ios/Controller/AccountSetupController.swift

@@ -491,6 +491,7 @@ class AccountSetupController: UITableViewController, ProgressAlertHandler {
             tableView.reloadData() // otherwise the disclosureIndicator may stay selected
             tableView.reloadData() // otherwise the disclosureIndicator may stay selected
             restoreBackup()
             restoreBackup()
         case tagDeleteAccountCell:
         case tagDeleteAccountCell:
+            tableView.deselectRow(at: indexPath, animated: false)
             deleteAccount()
             deleteAccount()
         case tagAdvancedCell:
         case tagAdvancedCell:
             toggleAdvancedSection()
             toggleAdvancedSection()
@@ -501,7 +502,7 @@ class AccountSetupController: UITableViewController, ProgressAlertHandler {
         case tagCertCheckCell:
         case tagCertCheckCell:
             showCertCheckOptions()
             showCertCheckOptions()
         case tagViewLogCell:
         case tagViewLogCell:
-            tableView.deselectRow(at: indexPath, animated: true)
+            tableView.deselectRow(at: indexPath, animated: false)
             SettingsViewController.showDebugToolkit(dcContext: dcContext)
             SettingsViewController.showDebugToolkit(dcContext: dcContext)
         default:
         default:
             break
             break

+ 1 - 2
deltachat-ios/Controller/AddGroupMembersViewController.swift

@@ -42,7 +42,6 @@ class AddGroupMembersViewController: GroupMembersViewController {
         let cell = ActionCell()
         let cell = ActionCell()
         cell.actionColor = SystemColor.blue.uiColor
         cell.actionColor = SystemColor.blue.uiColor
         cell.actionTitle = String.localized("menu_new_contact")
         cell.actionTitle = String.localized("menu_new_contact")
-        cell.selectionStyle = .none
         return cell
         return cell
     }()
     }()
 
 
@@ -129,7 +128,7 @@ class AddGroupMembersViewController: GroupMembersViewController {
         let sectionType = sections[indexPath.section]
         let sectionType = sections[indexPath.section]
         switch sectionType {
         switch sectionType {
         case .newContact:
         case .newContact:
-            tableView.deselectRow(at: indexPath, animated: true)
+            tableView.deselectRow(at: indexPath, animated: false)
             showNewContactController()
             showNewContactController()
         case .memberList:
         case .memberList:
             didSelectContactCell(at: indexPath)
             didSelectContactCell(at: indexPath)

+ 12 - 12
deltachat-ios/Controller/ContactDetailViewController.swift

@@ -14,7 +14,6 @@ class ContactDetailViewController: UITableViewController {
         let cell = ActionCell()
         let cell = ActionCell()
         cell.actionColor = SystemColor.blue.uiColor
         cell.actionColor = SystemColor.blue.uiColor
         cell.actionTitle = String.localized("send_message")
         cell.actionTitle = String.localized("send_message")
-        cell.selectionStyle = .none
         return cell
         return cell
     }()
     }()
 
 
@@ -30,7 +29,6 @@ class ContactDetailViewController: UITableViewController {
         let cell = ActionCell()
         let cell = ActionCell()
         cell.actionTitle = String.localized("encryption_info_title_desktop")
         cell.actionTitle = String.localized("encryption_info_title_desktop")
         cell.actionColor = SystemColor.blue.uiColor
         cell.actionColor = SystemColor.blue.uiColor
-        cell.selectionStyle = .none
         return cell
         return cell
     }()
     }()
 
 
@@ -38,7 +36,6 @@ class ContactDetailViewController: UITableViewController {
         let cell = ActionCell()
         let cell = ActionCell()
         cell.actionTitle = viewModel.contact.isBlocked ? String.localized("menu_unblock_contact") : String.localized("menu_block_contact")
         cell.actionTitle = viewModel.contact.isBlocked ? String.localized("menu_unblock_contact") : String.localized("menu_block_contact")
         cell.actionColor = viewModel.contact.isBlocked ? SystemColor.blue.uiColor : UIColor.red
         cell.actionColor = viewModel.contact.isBlocked ? SystemColor.blue.uiColor : UIColor.red
-        cell.selectionStyle = .none
         return cell
         return cell
     }()
     }()
 
 
@@ -46,7 +43,6 @@ class ContactDetailViewController: UITableViewController {
         let cell = ActionCell()
         let cell = ActionCell()
         cell.actionTitle = viewModel.chatIsMuted ? String.localized("menu_unmute") :  String.localized("menu_mute")
         cell.actionTitle = viewModel.chatIsMuted ? String.localized("menu_unmute") :  String.localized("menu_mute")
         cell.actionColor = SystemColor.blue.uiColor
         cell.actionColor = SystemColor.blue.uiColor
-        cell.selectionStyle = .none
         return cell
         return cell
     }()
     }()
 
 
@@ -54,7 +50,6 @@ class ContactDetailViewController: UITableViewController {
         let cell = ActionCell()
         let cell = ActionCell()
         cell.actionTitle = viewModel.chatIsArchived ? String.localized("menu_unarchive_chat") :  String.localized("menu_archive_chat")
         cell.actionTitle = viewModel.chatIsArchived ? String.localized("menu_unarchive_chat") :  String.localized("menu_archive_chat")
         cell.actionColor = SystemColor.blue.uiColor
         cell.actionColor = SystemColor.blue.uiColor
-        cell.selectionStyle = .none
         return cell
         return cell
     }()
     }()
 
 
@@ -62,7 +57,6 @@ class ContactDetailViewController: UITableViewController {
         let cell = ActionCell()
         let cell = ActionCell()
         cell.actionTitle = String.localized("menu_delete_chat")
         cell.actionTitle = String.localized("menu_delete_chat")
         cell.actionColor = UIColor.red
         cell.actionColor = UIColor.red
-        cell.selectionStyle = .none
         return cell
         return cell
     }()
     }()
 
 
@@ -194,11 +188,11 @@ class ContactDetailViewController: UITableViewController {
         let type = viewModel.typeFor(section: indexPath.section)
         let type = viewModel.typeFor(section: indexPath.section)
         switch type {
         switch type {
         case .chatOptions:
         case .chatOptions:
-            handleChatOption(for: indexPath.row)
+            handleChatOption(indexPath: indexPath)
         case .statusArea:
         case .statusArea:
             break
             break
         case .chatActions:
         case .chatActions:
-            handleChatAction(for: indexPath.row)
+            handleChatAction(indexPath: indexPath)
         case .sharedChats:
         case .sharedChats:
             let chatId = viewModel.getSharedChatIdAt(indexPath: indexPath)
             let chatId = viewModel.getSharedChatIdAt(indexPath: indexPath)
             showChat(chatId: chatId)
             showChat(chatId: chatId)
@@ -251,22 +245,26 @@ class ContactDetailViewController: UITableViewController {
     }
     }
 
 
     // MARK: - actions
     // MARK: - actions
-    private func handleChatAction(for index: Int) {
-        let action = viewModel.chatActionFor(row: index)
+    private func handleChatAction(indexPath: IndexPath) {
+        let action = viewModel.chatActionFor(row: indexPath.row)
         switch action {
         switch action {
         case .archiveChat:
         case .archiveChat:
+            tableView.deselectRow(at: indexPath, animated: true) // animated as no other elements pop up
             toggleArchiveChat()
             toggleArchiveChat()
         case .showEncrInfo:
         case .showEncrInfo:
+            tableView.deselectRow(at: indexPath, animated: false)
             showEncrInfoAlert()
             showEncrInfoAlert()
         case .blockContact:
         case .blockContact:
+            tableView.deselectRow(at: indexPath, animated: false)
             toggleBlockContact()
             toggleBlockContact()
         case .deleteChat:
         case .deleteChat:
+            tableView.deselectRow(at: indexPath, animated: false)
             showDeleteChatConfirmationAlert()
             showDeleteChatConfirmationAlert()
         }
         }
     }
     }
 
 
-    private func handleChatOption(for index: Int) {
-        let action = viewModel.chatOptionFor(row: index)
+    private func handleChatOption(indexPath: IndexPath) {
+        let action = viewModel.chatOptionFor(row: indexPath.row)
         switch action {
         switch action {
         case .documents:
         case .documents:
             showDocuments()
             showDocuments()
@@ -275,6 +273,7 @@ class ContactDetailViewController: UITableViewController {
         case .ephemeralMessages:
         case .ephemeralMessages:
             showEphemeralMessagesController()
             showEphemeralMessagesController()
         case .muteChat:
         case .muteChat:
+            tableView.deselectRow(at: indexPath, animated: false)
             if viewModel.chatIsMuted {
             if viewModel.chatIsMuted {
                 self.viewModel.context.setChatMuteDuration(chatId: self.viewModel.chatId, duration: 0)
                 self.viewModel.context.setChatMuteDuration(chatId: self.viewModel.chatId, duration: 0)
                 muteChatCell.actionTitle = String.localized("menu_mute")
                 muteChatCell.actionTitle = String.localized("menu_mute")
@@ -283,6 +282,7 @@ class ContactDetailViewController: UITableViewController {
                 showMuteAlert()
                 showMuteAlert()
             }
             }
         case .startChat:
         case .startChat:
+            tableView.deselectRow(at: indexPath, animated: false)
             let contactId = viewModel.contactId
             let contactId = viewModel.contactId
             chatWith(contactId: contactId)
             chatWith(contactId: contactId)
         }
         }

+ 1 - 1
deltachat-ios/Controller/EditSettingsController.swift

@@ -116,7 +116,7 @@ class EditSettingsController: UITableViewController, MediaPickerDelegate {
     override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
     override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
         guard let cell = tableView.cellForRow(at: indexPath) else { return }
         guard let cell = tableView.cellForRow(at: indexPath) else { return }
         if cell.tag == tagAccountSettingsCell {
         if cell.tag == tagAccountSettingsCell {
-            tableView.deselectRow(at: indexPath, animated: true)
+            tableView.deselectRow(at: indexPath, animated: false)
             guard let nc = navigationController else { return }
             guard let nc = navigationController else { return }
             let accountSetupVC = AccountSetupController(dcContext: dcContext, editView: true)
             let accountSetupVC = AccountSetupController(dcContext: dcContext, editView: true)
             nc.pushViewController(accountSetupVC, animated: true)
             nc.pushViewController(accountSetupVC, animated: true)

+ 5 - 4
deltachat-ios/Controller/GroupChatDetailViewController.swift

@@ -117,7 +117,6 @@ class GroupChatDetailViewController: UIViewController {
         let cell = ActionCell()
         let cell = ActionCell()
         cell.actionTitle = self.chat.isMuted ? String.localized("menu_unmute") :  String.localized("menu_mute")
         cell.actionTitle = self.chat.isMuted ? String.localized("menu_unmute") :  String.localized("menu_mute")
         cell.actionColor = SystemColor.blue.uiColor
         cell.actionColor = SystemColor.blue.uiColor
-        cell.selectionStyle = .none
         return cell
         return cell
     }()
     }()
 
 
@@ -126,7 +125,6 @@ class GroupChatDetailViewController: UIViewController {
         let cell = ActionCell()
         let cell = ActionCell()
         cell.actionTitle = chat.isArchived ? String.localized("menu_unarchive_chat") :  String.localized("menu_archive_chat")
         cell.actionTitle = chat.isArchived ? String.localized("menu_unarchive_chat") :  String.localized("menu_archive_chat")
         cell.actionColor = UIColor.systemBlue
         cell.actionColor = UIColor.systemBlue
-        cell.selectionStyle = .none
         return cell
         return cell
     }()
     }()
 
 
@@ -142,7 +140,6 @@ class GroupChatDetailViewController: UIViewController {
         let cell = ActionCell()
         let cell = ActionCell()
         cell.actionTitle = String.localized("menu_delete_chat")
         cell.actionTitle = String.localized("menu_delete_chat")
         cell.actionColor = UIColor.red
         cell.actionColor = UIColor.red
-        cell.selectionStyle = .none
         return cell
         return cell
     }()
     }()
 
 
@@ -449,6 +446,7 @@ extension GroupChatDetailViewController: UITableViewDelegate, UITableViewDataSou
             case .ephemeralMessages:
             case .ephemeralMessages:
                 showEphemeralMessagesController()
                 showEphemeralMessagesController()
             case .muteChat:
             case .muteChat:
+                tableView.deselectRow(at: indexPath, animated: false)
                 if chat.isMuted {
                 if chat.isMuted {
                     dcContext.setChatMuteDuration(chatId: chatId, duration: 0)
                     dcContext.setChatMuteDuration(chatId: chatId, duration: 0)
                     muteChatCell.actionTitle = String.localized("menu_mute")
                     muteChatCell.actionTitle = String.localized("menu_mute")
@@ -465,7 +463,7 @@ extension GroupChatDetailViewController: UITableViewDelegate, UITableViewDataSou
             } else {
             } else {
                 let memberId = getGroupMemberIdFor(row)
                 let memberId = getGroupMemberIdFor(row)
                 if memberId == DC_CONTACT_ID_SELF {
                 if memberId == DC_CONTACT_ID_SELF {
-                    tableView.deselectRow(at: indexPath, animated: true)
+                    tableView.deselectRow(at: indexPath, animated: true) // animated as no other elements pop up
                 } else {
                 } else {
                     showContactDetail(of: memberId)
                     showContactDetail(of: memberId)
                 }
                 }
@@ -473,10 +471,13 @@ extension GroupChatDetailViewController: UITableViewDelegate, UITableViewDataSou
         case .chatActions:
         case .chatActions:
             switch chatActions[row] {
             switch chatActions[row] {
             case .archiveChat:
             case .archiveChat:
+                tableView.deselectRow(at: indexPath, animated: true) // animated as no other elements pop up
                 toggleArchiveChat()
                 toggleArchiveChat()
             case .leaveGroup:
             case .leaveGroup:
+                tableView.deselectRow(at: indexPath, animated: false)
                 showLeaveGroupConfirmationAlert()
                 showLeaveGroupConfirmationAlert()
             case .deleteChat:
             case .deleteChat:
+                tableView.deselectRow(at: indexPath, animated: false)
                 showDeleteChatConfirmationAlert()
                 showDeleteChatConfirmationAlert()
             }
             }
         }
         }

+ 1 - 1
deltachat-ios/Controller/GroupMembersViewController.swift

@@ -137,7 +137,7 @@ class GroupMembersViewController: UITableViewController {
     func didSelectContactCell(at indexPath: IndexPath) {
     func didSelectContactCell(at indexPath: IndexPath) {
         let row = indexPath.row
         let row = indexPath.row
         if let cell = tableView.cellForRow(at: indexPath) {
         if let cell = tableView.cellForRow(at: indexPath) {
-            tableView.deselectRow(at: indexPath, animated: true)
+            tableView.deselectRow(at: indexPath, animated: true) // animated as no other elements pop up
             let contactId = contactIdByRow(row)
             let contactId = contactIdByRow(row)
             if selectedContactIds.contains(contactId) {
             if selectedContactIds.contains(contactId) {
                 selectedContactIds.remove(contactId)
                 selectedContactIds.remove(contactId)

+ 1 - 0
deltachat-ios/Controller/NewGroupController.swift

@@ -219,6 +219,7 @@ class NewGroupController: UITableViewController, MediaPickerDelegate {
         let section = indexPath.section
         let section = indexPath.section
         let row = indexPath.row
         let row = indexPath.row
         if section == sectionInvite {
         if section == sectionInvite {
+            tableView.deselectRow(at: indexPath, animated: false)
             if row == sectionInviteRowAddMembers {
             if row == sectionInviteRowAddMembers {
                 var contactsWithoutSelf = contactIdsForGroup
                 var contactsWithoutSelf = contactIdsForGroup
                 contactsWithoutSelf.remove(Int(DC_CONTACT_ID_SELF))
                 contactsWithoutSelf.remove(Int(DC_CONTACT_ID_SELF))

+ 1 - 1
deltachat-ios/Controller/SettingsAutodelOverviewController.swift

@@ -99,7 +99,7 @@ class SettingsAutodelOverviewController: UITableViewController {
             safe_fatalError()
             safe_fatalError()
             return
             return
         }
         }
-        tableView.deselectRow(at: indexPath, animated: false) // to achieve highlight effect
+        tableView.deselectRow(at: indexPath, animated: false)
 
 
         switch cellTag {
         switch cellTag {
         case .autodelDevice:
         case .autodelDevice:

+ 1 - 5
deltachat-ios/Controller/SettingsController.swift

@@ -150,7 +150,6 @@ internal final class SettingsViewController: UITableViewController, ProgressAler
         let cell = ActionCell()
         let cell = ActionCell()
         cell.tag = CellTags.sendAutocryptMessage.rawValue
         cell.tag = CellTags.sendAutocryptMessage.rawValue
         cell.actionTitle = String.localized("autocrypt_send_asm_title")
         cell.actionTitle = String.localized("autocrypt_send_asm_title")
-        cell.selectionStyle = .default
         return cell
         return cell
     }()
     }()
 
 
@@ -158,7 +157,6 @@ internal final class SettingsViewController: UITableViewController, ProgressAler
         let cell = ActionCell()
         let cell = ActionCell()
         cell.tag = CellTags.exportBackup.rawValue
         cell.tag = CellTags.exportBackup.rawValue
         cell.actionTitle = String.localized("export_backup_desktop")
         cell.actionTitle = String.localized("export_backup_desktop")
-        cell.selectionStyle = .default
         return cell
         return cell
     }()
     }()
 
 
@@ -166,7 +164,6 @@ internal final class SettingsViewController: UITableViewController, ProgressAler
         let cell = ActionCell()
         let cell = ActionCell()
         cell.tag = CellTags.advanced.rawValue
         cell.tag = CellTags.advanced.rawValue
         cell.actionTitle = String.localized("menu_advanced")
         cell.actionTitle = String.localized("menu_advanced")
-        cell.selectionStyle = .default
         return cell
         return cell
     }()
     }()
 
 
@@ -174,7 +171,6 @@ internal final class SettingsViewController: UITableViewController, ProgressAler
         let cell = ActionCell()
         let cell = ActionCell()
         cell.tag = CellTags.help.rawValue
         cell.tag = CellTags.help.rawValue
         cell.actionTitle = String.localized("menu_help")
         cell.actionTitle = String.localized("menu_help")
-        cell.selectionStyle = .default
         return cell
         return cell
     }()
     }()
 
 
@@ -278,7 +274,7 @@ internal final class SettingsViewController: UITableViewController, ProgressAler
             safe_fatalError()
             safe_fatalError()
             return
             return
         }
         }
-        tableView.deselectRow(at: indexPath, animated: false) // to achieve highlight effect
+        tableView.deselectRow(at: indexPath, animated: false)
 
 
         switch cellTag {
         switch cellTag {
         case .profile: showEditSettingsController()
         case .profile: showEditSettingsController()

+ 0 - 1
deltachat-ios/View/ActionCell.swift

@@ -32,7 +32,6 @@ class ActionCell: UITableViewCell {
     override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
     override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
         super.init(style: style, reuseIdentifier: reuseIdentifier)
         super.init(style: style, reuseIdentifier: reuseIdentifier)
         setupSubviews()
         setupSubviews()
-        selectionStyle = .none
     }
     }
 
 
     required init?(coder _: NSCoder) {
     required init?(coder _: NSCoder) {