Skip to content

Commit

Permalink
add icons to contact's action cells
Browse files Browse the repository at this point in the history
  • Loading branch information
r10s committed Feb 4, 2025
1 parent c3335b9 commit 37eb023
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
26 changes: 11 additions & 15 deletions deltachat-ios/Controller/ContactDetailViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,8 @@ class ContactDetailViewController: UITableViewController {
}

let isOnHomescreen = chatIdsOnHomescreen.contains(viewModel.chatId)
if isOnHomescreen {
cell.actionTitle = String.localized("remove_from_widget")
} else {
cell.actionTitle = String.localized("add_to_widget")
}
cell.actionColor = UIColor.systemBlue
cell.imageView?.image = UIImage(systemName: isOnHomescreen ? "minus.square" : "plus.square")
cell.actionTitle = String.localized(isOnHomescreen ? "remove_from_widget" : "add_to_widget")
return cell
}()

Expand All @@ -75,34 +71,37 @@ class ContactDetailViewController: UITableViewController {

private lazy var showEncrInfoCell: ActionCell = {
let cell = ActionCell()
cell.imageView?.image = UIImage(systemName: "info.circle")
cell.actionTitle = String.localized("encryption_info_title_desktop")
cell.actionColor = UIColor.systemBlue
return cell
}()

private lazy var blockContactCell: ActionCell = {
let cell = ActionCell()
cell.imageView?.image = UIImage(systemName: "nosign")
cell.actionTitle = viewModel.contact.isBlocked ? String.localized("menu_unblock_contact") : String.localized("menu_block_contact")
cell.actionColor = viewModel.contact.isBlocked ? UIColor.systemBlue : UIColor.systemRed
cell.actionColor = UIColor.systemRed
return cell
}()

private lazy var archiveChatCell: ActionCell = {
let cell = ActionCell()
cell.imageView?.image = UIImage(systemName: viewModel.chatIsArchived ? "tray.and.arrow.up" : "tray.and.arrow.down")
cell.actionTitle = viewModel.chatIsArchived ? String.localized("menu_unarchive_chat") : String.localized("menu_archive_chat")
cell.actionColor = UIColor.systemBlue
return cell
}()

private lazy var clearChatCell: ActionCell = {
let cell = ActionCell()
cell.imageView?.image = UIImage(systemName: "line.diagonal")
cell.actionTitle = String.localized("clear_chat")
cell.actionColor = UIColor.systemRed
return cell
}()

private lazy var deleteChatCell: ActionCell = {
let cell = ActionCell()
cell.imageView?.image = UIImage(systemName: "trash")
cell.actionTitle = String.localized("menu_delete_chat")
cell.actionColor = UIColor.systemRed
return cell
Expand Down Expand Up @@ -436,6 +435,7 @@ class ContactDetailViewController: UITableViewController {
if archived {
self.navigationController?.popToRootViewController(animated: false)
} else {
archiveChatCell.imageView?.image = UIImage(systemName: "tray.and.arrow.down")
archiveChatCell.actionTitle = String.localized("menu_archive_chat")
}
}
Expand All @@ -459,16 +459,12 @@ class ContactDetailViewController: UITableViewController {
guard #available(iOS 17, *) else { return }

let onHomescreen = viewModel.toggleChatInHomescreenWidget()
if onHomescreen {
homescreenWidgetCell.actionTitle = String.localized("remove_from_widget")
} else {
homescreenWidgetCell.actionTitle = String.localized("add_to_widget")
}
homescreenWidgetCell.imageView?.image = UIImage(systemName: onHomescreen ? "minus.square" : "plus.square")
homescreenWidgetCell.actionTitle = String.localized(onHomescreen ? "remove_from_widget" : "add_to_widget")
}

private func updateBlockContactCell() {
blockContactCell.actionTitle = viewModel.contact.isBlocked ? String.localized("menu_unblock_contact") : String.localized("menu_block_contact")
blockContactCell.actionColor = viewModel.contact.isBlocked ? UIColor.systemBlue : UIColor.systemRed
}


Expand Down
3 changes: 3 additions & 0 deletions deltachat-ios/View/ActionCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ class ActionCell: UITableViewCell {
var actionColor: UIColor? {
didSet {
textLabel?.textColor = actionColor ?? UIColor.systemBlue
if let imageView {
imageView.tintColor = actionColor ?? UIColor.systemBlue
}
}
}

Expand Down

0 comments on commit 37eb023

Please sign in to comment.