Browse Source

Merge pull request #1242 from deltachat/unify-selectionStyle

unify visiual feedback
bjoern 4 years ago
parent
commit
61f70d7751

+ 1 - 5
deltachat-ios/Controller/AccountSetup/CertificateCheckController.swift

@@ -25,7 +25,6 @@ class CertificateCheckController: UITableViewController {
         return options.map({
             let cell = UITableViewCell(style: .default, reuseIdentifier: nil)
             cell.textLabel?.text =  ValueConverter.convertHexToString(value: $0)
-            cell.selectionStyle = .none
             return cell
         })
     }
@@ -62,6 +61,7 @@ class CertificateCheckController: UITableViewController {
     }
 
     override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
+        tableView.deselectRow(at: indexPath, animated: true) // animated as no other elements pop up
         if indexPath.section == 0 {
             let row = indexPath.row
             selectItem(at: row)
@@ -80,15 +80,11 @@ class CertificateCheckController: UITableViewController {
     }
 
     private func selectItem(at index: Int? ) {
-        // unselect old cell
-        // select new cell
-        // update value
         if let oldIndex = selectedIndex {
             let cell = tableView.cellForRow(at: IndexPath.init(row: oldIndex, section: 0))
             cell?.accessoryType = .none
         }
         if let newIndex = index {
-            // activate accesoryType on selected cell
             let cell = tableView.cellForRow(at: IndexPath.init(row: newIndex, section: 0))
             cell?.accessoryType = .checkmark
             currentValue = options[newIndex]

+ 1 - 3
deltachat-ios/Controller/AccountSetup/SecuritySettingsController.swift

@@ -24,7 +24,6 @@ class SecuritySettingsController: UITableViewController {
         return options.map {
             let cell = UITableViewCell(style: .default, reuseIdentifier: nil)
             cell.textLabel?.text = SecurityConverter.getSocketName(value: $0)
-            cell.selectionStyle = .none
             return cell
         }
     }
@@ -73,11 +72,10 @@ class SecuritySettingsController: UITableViewController {
     }
 
     override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
-        // uselect old
+        tableView.deselectRow(at: indexPath, animated: true) // animated as no other elements pop up
         if let cell = tableView.cellForRow(at: IndexPath(item: selectedIndex, section: 0)) {
             cell.accessoryType = .none
         }
-        // select new
         if let cell = tableView.cellForRow(at: indexPath) {
             cell.accessoryType = .checkmark
         }

+ 5 - 7
deltachat-ios/Controller/AccountSetupController.swift

@@ -187,7 +187,6 @@ class AccountSetupController: UITableViewController, ProgressAlertHandler {
         let cell = UITableViewCell(style: .value1, reuseIdentifier: nil)
         cell.textLabel?.text = String.localized("login_imap_security")
         cell.accessoryType = .disclosureIndicator
-        cell.selectionStyle = .none
         cell.tag = tagImapSecurityCell
         return cell
     }()
@@ -253,7 +252,6 @@ class AccountSetupController: UITableViewController, ProgressAlertHandler {
         cell.textLabel?.text = String.localized("login_smtp_security")
         cell.tag = tagSmtpSecurityCell
         cell.accessoryType = .disclosureIndicator
-        cell.selectionStyle = .none
         return cell
     }()
 
@@ -264,7 +262,6 @@ class AccountSetupController: UITableViewController, ProgressAlertHandler {
         cell.detailTextLabel?.text = certCheckType
         cell.tag = tagCertCheckCell
         cell.accessoryType = .disclosureIndicator
-        cell.selectionStyle = .none
         return cell
     }()
 
@@ -491,17 +488,18 @@ class AccountSetupController: UITableViewController, ProgressAlertHandler {
             tableView.reloadData() // otherwise the disclosureIndicator may stay selected
             restoreBackup()
         case tagDeleteAccountCell:
+            tableView.deselectRow(at: indexPath, animated: false)
             deleteAccount()
         case tagAdvancedCell:
             toggleAdvancedSection()
         case tagImapSecurityCell:
             showImapSecurityOptions()
         case tagSmtpSecurityCell:
-            showSmptpSecurityOptions()
+            showSmtpSecurityOptions()
         case tagCertCheckCell:
             showCertCheckOptions()
         case tagViewLogCell:
-            tableView.deselectRow(at: indexPath, animated: true)
+            tableView.deselectRow(at: indexPath, animated: false)
             SettingsViewController.showDebugToolkit(dcContext: dcContext)
         default:
             break
@@ -857,9 +855,9 @@ class AccountSetupController: UITableViewController, ProgressAlertHandler {
         navigationController?.pushViewController(securitySettingsController, animated: true)
     }
 
-    private func showSmptpSecurityOptions() {
+    private func showSmtpSecurityOptions() {
         let securitySettingsController = SecuritySettingsController(dcContext: dcContext,
-                                                                    title: String.localized("login_imap_security"),
+                                                                    title: String.localized("login_smtp_security"),
                                                                     type: SecurityType.SMTPSecurity)
         navigationController?.pushViewController(securitySettingsController, animated: true)
     }

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

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

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

@@ -14,14 +14,12 @@ class ContactDetailViewController: UITableViewController {
         let cell = ActionCell()
         cell.actionColor = SystemColor.blue.uiColor
         cell.actionTitle = String.localized("send_message")
-        cell.selectionStyle = .none
         return cell
     }()
 
     private lazy var ephemeralMessagesCell: UITableViewCell = {
         let cell = UITableViewCell(style: .value1, reuseIdentifier: nil)
         cell.textLabel?.text = String.localized("ephemeral_messages")
-        cell.selectionStyle = .none
         cell.accessoryType = .disclosureIndicator
         return cell
     }()
@@ -30,7 +28,6 @@ class ContactDetailViewController: UITableViewController {
         let cell = ActionCell()
         cell.actionTitle = String.localized("encryption_info_title_desktop")
         cell.actionColor = SystemColor.blue.uiColor
-        cell.selectionStyle = .none
         return cell
     }()
 
@@ -38,7 +35,6 @@ class ContactDetailViewController: UITableViewController {
         let cell = ActionCell()
         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.selectionStyle = .none
         return cell
     }()
 
@@ -46,7 +42,6 @@ class ContactDetailViewController: UITableViewController {
         let cell = ActionCell()
         cell.actionTitle = viewModel.chatIsMuted ? String.localized("menu_unmute") :  String.localized("menu_mute")
         cell.actionColor = SystemColor.blue.uiColor
-        cell.selectionStyle = .none
         return cell
     }()
 
@@ -54,7 +49,6 @@ class ContactDetailViewController: UITableViewController {
         let cell = ActionCell()
         cell.actionTitle = viewModel.chatIsArchived ? String.localized("menu_unarchive_chat") :  String.localized("menu_archive_chat")
         cell.actionColor = SystemColor.blue.uiColor
-        cell.selectionStyle = .none
         return cell
     }()
 
@@ -62,7 +56,6 @@ class ContactDetailViewController: UITableViewController {
         let cell = ActionCell()
         cell.actionTitle = String.localized("menu_delete_chat")
         cell.actionColor = UIColor.red
-        cell.selectionStyle = .none
         return cell
     }()
 
@@ -194,11 +187,11 @@ class ContactDetailViewController: UITableViewController {
         let type = viewModel.typeFor(section: indexPath.section)
         switch type {
         case .chatOptions:
-            handleChatOption(for: indexPath.row)
+            handleChatOption(indexPath: indexPath)
         case .statusArea:
             break
         case .chatActions:
-            handleChatAction(for: indexPath.row)
+            handleChatAction(indexPath: indexPath)
         case .sharedChats:
             let chatId = viewModel.getSharedChatIdAt(indexPath: indexPath)
             showChat(chatId: chatId)
@@ -251,22 +244,26 @@ class ContactDetailViewController: UITableViewController {
     }
 
     // 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 {
         case .archiveChat:
+            tableView.deselectRow(at: indexPath, animated: true) // animated as no other elements pop up
             toggleArchiveChat()
         case .showEncrInfo:
+            tableView.deselectRow(at: indexPath, animated: false)
             showEncrInfoAlert()
         case .blockContact:
+            tableView.deselectRow(at: indexPath, animated: false)
             toggleBlockContact()
         case .deleteChat:
+            tableView.deselectRow(at: indexPath, animated: false)
             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 {
         case .documents:
             showDocuments()
@@ -275,6 +272,7 @@ class ContactDetailViewController: UITableViewController {
         case .ephemeralMessages:
             showEphemeralMessagesController()
         case .muteChat:
+            tableView.deselectRow(at: indexPath, animated: false)
             if viewModel.chatIsMuted {
                 self.viewModel.context.setChatMuteDuration(chatId: self.viewModel.chatId, duration: 0)
                 muteChatCell.actionTitle = String.localized("menu_mute")
@@ -283,6 +281,7 @@ class ContactDetailViewController: UITableViewController {
                 showMuteAlert()
             }
         case .startChat:
+            tableView.deselectRow(at: indexPath, animated: false)
             let contactId = viewModel.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) {
         guard let cell = tableView.cellForRow(at: indexPath) else { return }
         if cell.tag == tagAccountSettingsCell {
-            tableView.deselectRow(at: indexPath, animated: true)
+            tableView.deselectRow(at: indexPath, animated: false)
             guard let nc = navigationController else { return }
             let accountSetupVC = AccountSetupController(dcContext: dcContext, editView: true)
             nc.pushViewController(accountSetupVC, animated: true)

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

@@ -108,7 +108,6 @@ class GroupChatDetailViewController: UIViewController {
     private lazy var ephemeralMessagesCell: UITableViewCell = {
         let cell = UITableViewCell(style: .value1, reuseIdentifier: nil)
         cell.textLabel?.text = String.localized("ephemeral_messages")
-        cell.selectionStyle = .none
         cell.accessoryType = .disclosureIndicator
         return cell
     }()
@@ -117,7 +116,6 @@ class GroupChatDetailViewController: UIViewController {
         let cell = ActionCell()
         cell.actionTitle = self.chat.isMuted ? String.localized("menu_unmute") :  String.localized("menu_mute")
         cell.actionColor = SystemColor.blue.uiColor
-        cell.selectionStyle = .none
         return cell
     }()
 
@@ -126,7 +124,6 @@ class GroupChatDetailViewController: UIViewController {
         let cell = ActionCell()
         cell.actionTitle = chat.isArchived ? String.localized("menu_unarchive_chat") :  String.localized("menu_archive_chat")
         cell.actionColor = UIColor.systemBlue
-        cell.selectionStyle = .none
         return cell
     }()
 
@@ -142,7 +139,6 @@ class GroupChatDetailViewController: UIViewController {
         let cell = ActionCell()
         cell.actionTitle = String.localized("menu_delete_chat")
         cell.actionColor = UIColor.red
-        cell.selectionStyle = .none
         return cell
     }()
 
@@ -449,6 +445,7 @@ extension GroupChatDetailViewController: UITableViewDelegate, UITableViewDataSou
             case .ephemeralMessages:
                 showEphemeralMessagesController()
             case .muteChat:
+                tableView.deselectRow(at: indexPath, animated: false)
                 if chat.isMuted {
                     dcContext.setChatMuteDuration(chatId: chatId, duration: 0)
                     muteChatCell.actionTitle = String.localized("menu_mute")
@@ -465,7 +462,7 @@ extension GroupChatDetailViewController: UITableViewDelegate, UITableViewDataSou
             } else {
                 let memberId = getGroupMemberIdFor(row)
                 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 {
                     showContactDetail(of: memberId)
                 }
@@ -473,10 +470,13 @@ extension GroupChatDetailViewController: UITableViewDelegate, UITableViewDataSou
         case .chatActions:
             switch chatActions[row] {
             case .archiveChat:
+                tableView.deselectRow(at: indexPath, animated: true) // animated as no other elements pop up
                 toggleArchiveChat()
             case .leaveGroup:
+                tableView.deselectRow(at: indexPath, animated: false)
                 showLeaveGroupConfirmationAlert()
             case .deleteChat:
+                tableView.deselectRow(at: indexPath, animated: false)
                 showDeleteChatConfirmationAlert()
             }
         }

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

@@ -137,7 +137,7 @@ class GroupMembersViewController: UITableViewController {
     func didSelectContactCell(at indexPath: IndexPath) {
         let row = indexPath.row
         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)
             if selectedContactIds.contains(contactId) {
                 selectedContactIds.remove(contactId)

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

@@ -10,7 +10,6 @@ class MediaQualityController: UITableViewController {
         return options.map({
             let cell = UITableViewCell(style: .default, reuseIdentifier: nil)
             cell.textLabel?.text = MediaQualityController.getValString(val: $0)
-            cell.selectionStyle = .none
             return cell
         })
     }()
@@ -53,6 +52,8 @@ class MediaQualityController: UITableViewController {
     }
 
     override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
+        tableView.deselectRow(at: indexPath, animated: true) // animated as no other elements pop up
+
         let oldSelectedCell = tableView.cellForRow(at: IndexPath.init(row: dcContext.getConfigInt("media_quality"), section: 0))
         oldSelectedCell?.accessoryType = .none
 

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

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

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

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

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

@@ -54,7 +54,6 @@ class SettingsAutodelSetController: UITableViewController {
         return autodelOptions.map({
             let cell = UITableViewCell(style: .default, reuseIdentifier: nil)
             cell.textLabel?.text = String.localized($0.descr)
-            cell.selectionStyle = .none
             cell.accessoryType = $0.value==currVal ? .checkmark : .none
             return cell
         })
@@ -112,6 +111,8 @@ class SettingsAutodelSetController: UITableViewController {
     }
 
     override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
+        tableView.deselectRow(at: indexPath, animated: false)
+
         let oldSelectedCell = tableView.cellForRow(at: IndexPath.init(row: self.valToIndex(val: self.currVal), section: 0))
         let newSelectedCell = tableView.cellForRow(at: IndexPath.init(row: indexPath.row, section: 0))
         let newVal = self.autodelOptions[indexPath.row].value

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

@@ -10,7 +10,6 @@ class SettingsClassicViewController: UITableViewController {
         return options.map({
             let cell = UITableViewCell(style: .default, reuseIdentifier: nil)
             cell.textLabel?.text = SettingsClassicViewController.getValString(val: $0)
-            cell.selectionStyle = .none
             return cell
         })
     }
@@ -55,6 +54,8 @@ class SettingsClassicViewController: UITableViewController {
     }
 
     override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
+        tableView.deselectRow(at: indexPath, animated: true) // animated as no other elements pop up
+
         let oldSelectedCell = tableView.cellForRow(at: IndexPath.init(row: dcContext.showEmails, section: 0))
         oldSelectedCell?.accessoryType = .none
 

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

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

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

@@ -24,7 +24,6 @@ class SettingsEphemeralMessageController: UITableViewController {
         return options.map({
             let cell = UITableViewCell(style: .default, reuseIdentifier: nil)
             cell.textLabel?.text = SettingsEphemeralMessageController.getValString(val: $0)
-            cell.selectionStyle = .none
             return cell
         })
     }
@@ -98,6 +97,8 @@ class SettingsEphemeralMessageController: UITableViewController {
     }
     
     override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
+        tableView.deselectRow(at: indexPath, animated: true) // animated as no other elements pop up
+
         let oldSelectedCell = tableView.cellForRow(at: IndexPath.init(row: currentIndex, section: 0))
         oldSelectedCell?.accessoryType = .none
 

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

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

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

@@ -143,7 +143,6 @@ class ContactCell: UITableViewCell {
     override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
         super.init(style: style, reuseIdentifier: reuseIdentifier)
         setupSubviews()
-        selectionStyle = .default
         configureCompressionPriority()
     }