Эх сурвалжийг харах

tweak archive, pinned and unread counter (#1782)

* show 'archived link' as a normal chat

* remove 'archived link' from settings

* show archived link unread counter unobstrusive

* add option to move archive link up/down

* no bold 'Archived Chats' title

* use sightly lighter pinned background (as telegram) to have a lower difference to the archived link

* shorter 'Archived' title, as on whatsapp

* use muted gray for unread counter of muted chats

* Revert "add option to move archive link up/down"

This reverts commit 8739e5223f51bf5ff360dc3f0ddcfecb4c5a5800.

* align archive-unread-counter with title

* use smaller height for archive-link cell

* use systemBackground for chat lists

that way, archive-link, overscroll and top-stuff all have the same color
and things look much more smooth.
bjoern 2 жил өмнө
parent
commit
f4e0b9c529

+ 2 - 1
DcCore/DcCore/Helper/DcColors.swift

@@ -21,6 +21,7 @@ public struct DcColors {
     public static let checkmarkGreen = UIColor.themeColor(light: UIColor.rgb(red: 112, green: 177, blue: 92))
     public static let checkmarkGreen = UIColor.themeColor(light: UIColor.rgb(red: 112, green: 177, blue: 92))
     public static let recentlySeenDot = UIColor(hexString: "34c759")
     public static let recentlySeenDot = UIColor(hexString: "34c759")
     public static let unreadBadge = UIColor(hexString: "3792fc")
     public static let unreadBadge = UIColor(hexString: "3792fc")
+    public static let unreadBadgeMuted = UIColor.themeColor(light: UIColor.init(hexString: "b6b6bb"), dark: UIColor.init(hexString: "3b3b3b"))
     public static let defaultTextColor = UIColor.themeColor(light: .darkText, dark: .white)
     public static let defaultTextColor = UIColor.themeColor(light: .darkText, dark: .white)
     public static let grayTextColor = UIColor.themeColor(light: .darkGray, dark: coreDark05)
     public static let grayTextColor = UIColor.themeColor(light: .darkGray, dark: coreDark05)
     public static let coreDark05 = UIColor.init(hexString: "EFEFEF") // naming according to DC Android
     public static let coreDark05 = UIColor.init(hexString: "EFEFEF") // naming according to DC Android
@@ -37,7 +38,7 @@ public struct DcColors {
     public static let providerBrokenBackground = UIColor.themeColor(light: SystemColor.red.uiColor, dark: SystemColor.red.uiColor)
     public static let providerBrokenBackground = UIColor.themeColor(light: SystemColor.red.uiColor, dark: SystemColor.red.uiColor)
     public static let systemMessageBackgroundColor = UIColor.init(hexString: "65444444")
     public static let systemMessageBackgroundColor = UIColor.init(hexString: "65444444")
     public static let systemMessageFontColor = UIColor.white
     public static let systemMessageFontColor = UIColor.white
-    public static let deaddropBackground = UIColor.themeColor(light: UIColor.init(hexString: "ebebec"), dark: UIColor.init(hexString: "1a1a1c"))
+    public static let deaddropBackground = UIColor.themeColor(light: UIColor.init(hexString: "f2f2f6"), dark: UIColor.init(hexString: "1a1a1c"))
     public static let accountSwitchBackgroundColor = UIColor.themeColor(light: UIColor.init(hexString: "65CCCCCC"), dark: UIColor.init(hexString: "65444444"))
     public static let accountSwitchBackgroundColor = UIColor.themeColor(light: UIColor.init(hexString: "65CCCCCC"), dark: UIColor.init(hexString: "65444444"))
 }
 }
 
 

+ 1 - 1
deltachat-ios/AppDelegate.swift

@@ -660,7 +660,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         dcContext.setStockTranslation(id: DC_STR_CONTACT_VERIFIED, localizationKey: "contact_verified")
         dcContext.setStockTranslation(id: DC_STR_CONTACT_VERIFIED, localizationKey: "contact_verified")
         dcContext.setStockTranslation(id: DC_STR_CONTACT_NOT_VERIFIED, localizationKey: "contact_not_verified")
         dcContext.setStockTranslation(id: DC_STR_CONTACT_NOT_VERIFIED, localizationKey: "contact_not_verified")
         dcContext.setStockTranslation(id: DC_STR_CONTACT_SETUP_CHANGED, localizationKey: "contact_setup_changed")
         dcContext.setStockTranslation(id: DC_STR_CONTACT_SETUP_CHANGED, localizationKey: "contact_setup_changed")
-        dcContext.setStockTranslation(id: DC_STR_ARCHIVEDCHATS, localizationKey: "chat_archived_chats_title")
+        dcContext.setStockTranslation(id: DC_STR_ARCHIVEDCHATS, localizationKey: "chat_archived_label")
         dcContext.setStockTranslation(id: DC_STR_AC_SETUP_MSG_SUBJECT, localizationKey: "autocrypt_asm_subject")
         dcContext.setStockTranslation(id: DC_STR_AC_SETUP_MSG_SUBJECT, localizationKey: "autocrypt_asm_subject")
         dcContext.setStockTranslation(id: DC_STR_AC_SETUP_MSG_BODY, localizationKey: "autocrypt_asm_general_body")
         dcContext.setStockTranslation(id: DC_STR_AC_SETUP_MSG_BODY, localizationKey: "autocrypt_asm_general_body")
         dcContext.setStockTranslation(id: DC_STR_CANNOT_LOGIN, localizationKey: "login_error_cannot_login")
         dcContext.setStockTranslation(id: DC_STR_CANNOT_LOGIN, localizationKey: "login_error_cannot_login")

+ 45 - 14
deltachat-ios/Controller/ChatListController.swift

@@ -40,9 +40,8 @@ class ChatListController: UITableViewController {
         return searchController
         return searchController
     }()
     }()
 
 
-    private lazy var archiveCell: ActionCell = {
-        let actionCell = ActionCell()
-        return actionCell
+    private lazy var archiveCell: ContactCell = {
+        return ContactCell()
     }()
     }()
 
 
     private lazy var newButton: UIBarButtonItem = {
     private lazy var newButton: UIBarButtonItem = {
@@ -104,6 +103,18 @@ class ChatListController: UITableViewController {
                 self.handleChatListUpdate()
                 self.handleChatListUpdate()
             }
             }
         }
         }
+        if #available(iOS 13.0, *) {
+            // use the same background color as for cells and esp. the first archive-link cell
+            // to make things appear less outstanding.
+            //
+            // TODO: this initally also sets the color of the "navigation area",
+            // however, when opening+closing a chat, it is a blurry grey.
+            // the inconsistency seems to be releated to the line
+            //   navigationController?.navigationBar.scrollEdgeAppearance = navigationController?.navigationBar.standardAppearance
+            // in ChatViewController.swift - removing this, the color is preserved at the cost of more flickering ...
+            // this needs more love :)
+            self.view.backgroundColor = UIColor.systemBackground
+        }
     }
     }
 
 
     required init?(coder _: NSCoder) {
     required init?(coder _: NSCoder) {
@@ -266,7 +277,7 @@ class ChatListController: UITableViewController {
     
     
     private func setupSubviews() {
     private func setupSubviews() {
         emptyStateLabel.addCenteredTo(parentView: view)
         emptyStateLabel.addCenteredTo(parentView: view)
-        navigationItem.backButtonTitle = isArchive ? String.localized("chat_archived_chats_title") : String.localized("pref_chats")
+        navigationItem.backButtonTitle = isArchive ? String.localized("chat_archived_label") : String.localized("pref_chats")
     }
     }
 
 
     @objc
     @objc
@@ -326,7 +337,21 @@ class ChatListController: UITableViewController {
             stopTimer()
             stopTimer()
         }
         }
     }
     }
-    
+
+    override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
+        if indexPath.section == 0, indexPath.row == 0, let cellData = viewModel?.cellDataFor(section: 0, row: 0) {
+            switch cellData.type {
+            case .chat(let chatData):
+                if chatData.chatId == DC_CHAT_ID_ARCHIVED_LINK {
+                    return ContactCell.cellHeight * 0.7
+                }
+            default:
+                break
+            }
+        }
+        return ContactCell.cellHeight
+    }
+
     // MARK: - actions
     // MARK: - actions
     @objc func didPressNewChat() {
     @objc func didPressNewChat() {
         showNewChatController()
         showNewChatController()
@@ -377,11 +402,11 @@ class ChatListController: UITableViewController {
         case .chat(let chatData):
         case .chat(let chatData):
             let chatId = chatData.chatId
             let chatId = chatData.chatId
             if chatId == DC_CHAT_ID_ARCHIVED_LINK {
             if chatId == DC_CHAT_ID_ARCHIVED_LINK {
-                archiveCell.actionTitle = dcContext.getChat(chatId: chatId).name
-                archiveCell.backgroundColor = DcColors.chatBackgroundColor
-                return archiveCell
+                let chatCell = archiveCell
+                chatCell.updateCell(cellViewModel: cellData)
+                chatCell.delegate = self
+                return chatCell
             } else if let chatCell = tableView.dequeueReusableCell(withIdentifier: chatCellReuseIdentifier, for: indexPath) as? ContactCell {
             } else if let chatCell = tableView.dequeueReusableCell(withIdentifier: chatCellReuseIdentifier, for: indexPath) as? ContactCell {
-                // default chatCell
                 chatCell.updateCell(cellViewModel: cellData)
                 chatCell.updateCell(cellViewModel: cellData)
                 chatCell.delegate = self
                 chatCell.delegate = self
                 return chatCell
                 return chatCell
@@ -407,9 +432,17 @@ class ChatListController: UITableViewController {
         if !tableView.isEditing {
         if !tableView.isEditing {
             return indexPath
             return indexPath
         }
         }
+        guard let viewModel = viewModel else {
+            return nil
+        }
 
 
-        let cell = tableView.cellForRow(at: indexPath)
-        return cell == archiveCell ? nil : indexPath
+        let cellData = viewModel.cellDataFor(section: indexPath.section, row: indexPath.row)
+        switch cellData.type {
+        case .chat(let chatData):
+            return chatData.chatId == DC_CHAT_ID_ARCHIVED_LINK ? nil : indexPath
+        default:
+            return indexPath
+        }
     }
     }
 
 
     override func tableView(_ tableView: UITableView, didDeselectRowAt indexPath: IndexPath) {
     override func tableView(_ tableView: UITableView, didDeselectRowAt indexPath: IndexPath) {
@@ -508,10 +541,8 @@ class ChatListController: UITableViewController {
                 editingBar.showUnpinning = viewModel.hasOnlyPinnedChatsSelected(in: tableView.indexPathsForSelectedRows) ||
                 editingBar.showUnpinning = viewModel.hasOnlyPinnedChatsSelected(in: tableView.indexPathsForSelectedRows) ||
                                            viewModel.hasOnlyPinnedChatsSelected(in: initialIndexPath)
                                            viewModel.hasOnlyPinnedChatsSelected(in: initialIndexPath)
             }
             }
-            archiveCell.selectionStyle = .none
         } else {
         } else {
             removeEditingView()
             removeEditingView()
-            archiveCell.selectionStyle = .default
         }
         }
         updateTitle()
         updateTitle()
     }
     }
@@ -607,7 +638,7 @@ class ChatListController: UITableViewController {
                 navigationItem.setLeftBarButton(cancelButton, animated: true)
                 navigationItem.setLeftBarButton(cancelButton, animated: true)
             }
             }
         } else if isArchive {
         } else if isArchive {
-            titleView.text = String.localized("chat_archived_chats_title")
+            titleView.text = String.localized("chat_archived_label")
             if !handleMultiSelectionTitle() {
             if !handleMultiSelectionTitle() {
                 navigationItem.setLeftBarButton(nil, animated: true)
                 navigationItem.setLeftBarButton(nil, animated: true)
             }
             }

+ 17 - 32
deltachat-ios/Controller/Settings/SettingsViewController.swift

@@ -11,23 +11,22 @@ internal final class SettingsViewController: UITableViewController, ProgressAler
     }
     }
 
 
     private enum CellTags: Int {
     private enum CellTags: Int {
-        case profile = 0
-        case showArchive = 1
-        case showEmails = 2
-        case blockedContacts = 3
-        case notifications = 4
-        case receiptConfirmation = 5
-        case autocryptPreferences = 6
-        case sendAutocryptMessage = 7
-        case exportBackup = 8
-        case advanced = 9
-        case help = 10
-        case autodel = 11
-        case mediaQuality = 12
-        case downloadOnDemand = 13
-        case videoChat = 14
-        case connectivity = 15
-        case selectBackground = 16
+        case profile
+        case showEmails
+        case blockedContacts
+        case notifications
+        case receiptConfirmation
+        case autocryptPreferences
+        case sendAutocryptMessage
+        case exportBackup
+        case advanced
+        case help
+        case autodel
+        case mediaQuality
+        case downloadOnDemand
+        case videoChat
+        case connectivity
+        case selectBackground
     }
     }
 
 
     private var dcContext: DcContext
     private var dcContext: DcContext
@@ -53,14 +52,6 @@ internal final class SettingsViewController: UITableViewController, ProgressAler
         return cell
         return cell
     }()
     }()
 
 
-    private lazy var showArchiveCell: UITableViewCell = {
-        let cell = UITableViewCell(style: .value1, reuseIdentifier: nil)
-        cell.tag = CellTags.showArchive.rawValue
-        cell.textLabel?.text = String.localized("chat_archived_chats_title")
-        cell.accessoryType = .disclosureIndicator
-        return cell
-    }()
-
     private lazy var showEmailsCell: UITableViewCell = {
     private lazy var showEmailsCell: UITableViewCell = {
         let cell = UITableViewCell(style: .value1, reuseIdentifier: nil)
         let cell = UITableViewCell(style: .value1, reuseIdentifier: nil)
         cell.tag = CellTags.showEmails.rawValue
         cell.tag = CellTags.showEmails.rawValue
@@ -228,7 +219,7 @@ internal final class SettingsViewController: UITableViewController, ProgressAler
         let preferencesSection = SectionConfigs(
         let preferencesSection = SectionConfigs(
             headerTitle: String.localized("pref_chats_and_media"),
             headerTitle: String.localized("pref_chats_and_media"),
             footerTitle: String.localized("pref_read_receipts_explain"),
             footerTitle: String.localized("pref_read_receipts_explain"),
-            cells: [showArchiveCell, showEmailsCell, blockedContactsCell, mediaQualityCell, downloadOnDemandCell,
+            cells: [showEmailsCell, blockedContactsCell, mediaQualityCell, downloadOnDemandCell,
                     autodelCell, videoChatInstanceCell, notificationCell, receiptConfirmationCell]
                     autodelCell, videoChatInstanceCell, notificationCell, receiptConfirmationCell]
         )
         )
         let appearanceSection = SectionConfigs(
         let appearanceSection = SectionConfigs(
@@ -344,7 +335,6 @@ internal final class SettingsViewController: UITableViewController, ProgressAler
 
 
         switch cellTag {
         switch cellTag {
         case .profile: showEditSettingsController()
         case .profile: showEditSettingsController()
-        case .showArchive: showArchivedCharts()
         case .showEmails: showClassicMail()
         case .showEmails: showClassicMail()
         case .blockedContacts: showBlockedContacts()
         case .blockedContacts: showBlockedContacts()
         case .autodel: showAutodelOptions()
         case .autodel: showAutodelOptions()
@@ -569,11 +559,6 @@ internal final class SettingsViewController: UITableViewController, ProgressAler
         navigationController?.pushViewController(videoInstanceController, animated: true)
         navigationController?.pushViewController(videoInstanceController, animated: true)
     }
     }
 
 
-    private func showArchivedCharts() {
-        guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else { return }
-        appDelegate.appCoordinator.showArchivedChats()
-    }
-
     private func showBlockedContacts() {
     private func showBlockedContacts() {
         let blockedContactsController = BlockedContactsViewController(dcContext: dcContext)
         let blockedContactsController = BlockedContactsViewController(dcContext: dcContext)
         navigationController?.pushViewController(blockedContactsController, animated: true)
         navigationController?.pushViewController(blockedContactsController, animated: true)

+ 18 - 8
deltachat-ios/View/ContactCell.swift

@@ -252,11 +252,12 @@ class ContactCell: UITableViewCell {
         avatar.setName(name)
         avatar.setName(name)
     }
     }
 
 
-    func setStatusIndicators(unreadCount: Int, status: Int, visibility: Int32, isLocationStreaming: Bool, isMuted: Bool, isContactRequest: Bool) {
+    func setStatusIndicators(unreadCount: Int, status: Int, visibility: Int32, isLocationStreaming: Bool, isMuted: Bool, isContactRequest: Bool, isArchiveLink: Bool) {
+        unreadMessageCounter.backgroundColor = isMuted || isArchiveLink ? DcColors.unreadBadgeMuted : DcColors.unreadBadge
+
         if isLargeText {
         if isLargeText {
             unreadMessageCounter.setCount(unreadCount)
             unreadMessageCounter.setCount(unreadCount)
             unreadMessageCounter.isHidden = unreadCount == 0 || isContactRequest
             unreadMessageCounter.isHidden = unreadCount == 0 || isContactRequest
-            unreadMessageCounter.backgroundColor = isMuted ? .gray : .red
             pinnedIndicator.isHidden = true
             pinnedIndicator.isHidden = true
             deliveryStatusIndicator.isHidden = true
             deliveryStatusIndicator.isHidden = true
             archivedIndicator.isHidden = true
             archivedIndicator.isHidden = true
@@ -266,14 +267,14 @@ class ContactCell: UITableViewCell {
 
 
         if visibility == DC_CHAT_VISIBILITY_ARCHIVED {
         if visibility == DC_CHAT_VISIBILITY_ARCHIVED {
             pinnedIndicator.isHidden = true
             pinnedIndicator.isHidden = true
-            unreadMessageCounter.isHidden = true
+            unreadMessageCounter.setCount(unreadCount)
+            unreadMessageCounter.isHidden = isContactRequest || unreadCount <= 0
             deliveryStatusIndicator.isHidden = true
             deliveryStatusIndicator.isHidden = true
             archivedIndicator.isHidden = false
             archivedIndicator.isHidden = false
         } else if unreadCount > 0 {
         } else if unreadCount > 0 {
             pinnedIndicator.isHidden = !(visibility == DC_CHAT_VISIBILITY_PINNED)
             pinnedIndicator.isHidden = !(visibility == DC_CHAT_VISIBILITY_PINNED)
             unreadMessageCounter.setCount(unreadCount)
             unreadMessageCounter.setCount(unreadCount)
             unreadMessageCounter.isHidden = isContactRequest
             unreadMessageCounter.isHidden = isContactRequest
-            unreadMessageCounter.backgroundColor = isMuted ? .gray : DcColors.unreadBadge
             deliveryStatusIndicator.isHidden = true
             deliveryStatusIndicator.isHidden = true
             archivedIndicator.isHidden = true
             archivedIndicator.isHidden = true
         } else {
         } else {
@@ -333,7 +334,13 @@ class ContactCell: UITableViewCell {
             let visibility = chat.visibility
             let visibility = chat.visibility
             isArchived = visibility == DC_CHAT_VISIBILITY_ARCHIVED
             isArchived = visibility == DC_CHAT_VISIBILITY_ARCHIVED
             // text bold if chat contains unread messages - otherwise hightlight search results if needed
             // text bold if chat contains unread messages - otherwise hightlight search results if needed
-            if chatData.unreadMessages > 0 {
+            if chatData.chatId == DC_CHAT_ID_ARCHIVED_LINK {
+                titleLabel.text = cellViewModel.title
+                // for archived links, move unread counter to top line (bottom line is not used)
+                // this hack is also the reason we do not reuse the archive-link together with the normal chats
+                bottomlineStackView.removeArrangedSubview(unreadMessageCounter)
+                toplineStackView.addArrangedSubview(unreadMessageCounter)
+            } else if chatData.unreadMessages > 0 {
                 titleLabel.attributedText = cellViewModel.title.bold(fontSize: titleLabel.font.pointSize)
                 titleLabel.attributedText = cellViewModel.title.bold(fontSize: titleLabel.font.pointSize)
             } else {
             } else {
                 titleLabel.attributedText = cellViewModel.title.boldAt(indexes: cellViewModel.titleHighlightIndexes, fontSize: titleLabel.font.pointSize)
                 titleLabel.attributedText = cellViewModel.title.boldAt(indexes: cellViewModel.titleHighlightIndexes, fontSize: titleLabel.font.pointSize)
@@ -358,7 +365,8 @@ class ContactCell: UITableViewCell {
                                 visibility: visibility,
                                 visibility: visibility,
                                 isLocationStreaming: chat.isSendingLocations,
                                 isLocationStreaming: chat.isSendingLocations,
                                 isMuted: chat.isMuted,
                                 isMuted: chat.isMuted,
-                                isContactRequest: isContactRequest)
+                                isContactRequest: isContactRequest,
+                                isArchiveLink: chatData.chatId == DC_CHAT_ID_ARCHIVED_LINK)
 
 
         case .contact(let contactData):
         case .contact(let contactData):
             let contact = cellViewModel.dcContext.getContact(id: contactData.contactId)
             let contact = cellViewModel.dcContext.getContact(id: contactData.contactId)
@@ -376,7 +384,8 @@ class ContactCell: UITableViewCell {
                                 visibility: 0,
                                 visibility: 0,
                                 isLocationStreaming: false,
                                 isLocationStreaming: false,
                                 isMuted: false,
                                 isMuted: false,
-                                isContactRequest: false)
+                                isContactRequest: false,
+                                isArchiveLink: false)
         case .profile:
         case .profile:
             let contact = cellViewModel.dcContext.getContact(id: Int(DC_CONTACT_ID_SELF))
             let contact = cellViewModel.dcContext.getContact(id: Int(DC_CONTACT_ID_SELF))
             titleLabel.text = cellViewModel.title
             titleLabel.text = cellViewModel.title
@@ -394,7 +403,8 @@ class ContactCell: UITableViewCell {
             visibility: 0,
             visibility: 0,
             isLocationStreaming: false,
             isLocationStreaming: false,
             isMuted: false,
             isMuted: false,
-            isContactRequest: false)
+            isContactRequest: false,
+            isArchiveLink: false)
         }
         }
 
 
         accessibilityLabel = (titleLabel.text != nil ? ((titleLabel.text ?? "")+"\n") : "")
         accessibilityLabel = (titleLabel.text != nil ? ((titleLabel.text ?? "")+"\n") : "")