Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modern buttons & button icons #2584

Merged
merged 20 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unreleased

- Improve "All media empty" and "Block contact" wordings (#2580)
- Unify buttons and icons (#2584)
- Fix: Allow to share contacts that do not have a chat (#2583)


Expand Down
1 change: 1 addition & 0 deletions deltachat-ios/Controller/AccountSwitchViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class AccountSwitchViewController: UITableViewController {
private lazy var addAccountCell: ActionCell = {
let cell = ActionCell()
cell.actionTitle = String.localized("add_account")
cell.imageView?.image = UIImage(systemName: "plus")
return cell
}()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class AddGroupMembersViewController: GroupMembersViewController {
private lazy var newContactCell: ActionCell = {
let cell = ActionCell()
cell.actionColor = UIColor.systemBlue
cell.imageView?.image = UIImage(systemName: "highlighter")
cell.actionTitle = String.localized("menu_new_classic_contact")
return cell
}()
Expand Down
33 changes: 15 additions & 18 deletions deltachat-ios/Controller/ContactDetailViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ContactDetailViewController: UITableViewController {

private lazy var startChatCell: ActionCell = {
let cell = ActionCell()
cell.actionColor = UIColor.systemBlue
cell.imageView?.image = UIImage(systemName: "paperplane")
cell.actionTitle = String.localized("send_message")
return cell
}()
Expand All @@ -49,19 +49,15 @@ 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
}()

private lazy var shareContactCell: ActionCell = {
let cell = ActionCell()
cell.imageView?.image = UIImage(systemName: "square.and.arrow.up")
cell.actionTitle = String.localized("menu_share")
cell.actionColor = UIColor.systemBlue
return cell
}()

Expand All @@ -75,34 +71,38 @@ 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()
let image = if #available(iOS 16.0, *) { "eraser" } else { "rectangle.portrait" }
cell.imageView?.image = UIImage(systemName: image)
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 @@ -367,7 +367,7 @@ class ContactDetailViewController: UITableViewController {
@objc private func shareContact() {
guard let vcardData = viewModel.context.makeVCard(contactIds: [viewModel.contactId]) else { return }

RelayHelper.shared.setForwardVCard(dialogTitle: String.localized("forward_to"), vcardData: vcardData)
RelayHelper.shared.setForwardVCard(vcardData: vcardData)
navigationController?.popToRootViewController(animated: true)
}

Expand Down Expand Up @@ -436,6 +436,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 +460,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
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@ class EphemeralMessagesViewController: UITableViewController {
}

override func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String? {
return String.localized("ephemeral_messages_hint")
if !dcContext.getChat(chatId: chatId).isSelfTalk { // the hint refers to "all member of the chat", this is weird for "Saved Messages"
return String.localized("ephemeral_messages_hint")
}
return nil
}

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
Expand Down
27 changes: 15 additions & 12 deletions deltachat-ios/Controller/GroupChatDetailViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,20 +87,24 @@ class GroupChatDetailViewController: UIViewController {

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

private lazy var cloneChatCell: ActionCell = {
let cell = ActionCell()
let image = if #available(iOS 15.0, *) { "rectangle.portrait.on.rectangle.portrait" } else { "square.on.square" }
cell.imageView?.image = UIImage(systemName: image)
cell.actionTitle = String.localized("clone_chat")
cell.actionColor = UIColor.systemBlue
return cell
}()

private lazy var leaveGroupCell: ActionCell = {
let cell = ActionCell()
let image = if #available(iOS 15.0, *) { "rectangle.portrait.and.arrow.right" } else { "arrow.right.square" }
cell.imageView?.image = UIImage(systemName: image)
cell.actionTitle = String.localized("menu_leave_group")
cell.actionColor = UIColor.systemRed
return cell
Expand All @@ -115,13 +119,16 @@ class GroupChatDetailViewController: UIViewController {

private lazy var clearChatCell: ActionCell = {
let cell = ActionCell()
let image = if #available(iOS 16.0, *) { "eraser" } else { "rectangle.portrait" }
cell.imageView?.image = UIImage(systemName: image)
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 @@ -163,12 +170,8 @@ class GroupChatDetailViewController: UIViewController {
}

let isOnHomescreen = chatIdsOnHomescreen.contains(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 Down Expand Up @@ -369,11 +372,8 @@ class GroupChatDetailViewController: UIViewController {
onHomescreen = true
}

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")
}

@objc func editButtonPressed() {
Expand Down Expand Up @@ -402,6 +402,7 @@ class GroupChatDetailViewController: UIViewController {
}
dcContext.archiveChat(chatId: chat.id, archive: !archivedBefore)
if archivedBefore {
archiveChatCell.imageView?.image = UIImage(systemName: "tray.and.arrow.down")
archiveChatCell.actionTitle = String.localized("menu_archive_chat")
} else {
self.navigationController?.popToRootViewController(animated: false)
Expand Down Expand Up @@ -549,9 +550,11 @@ extension GroupChatDetailViewController: UITableViewDelegate, UITableViewDataSou
}
if row == membersRowAddMembers {
actionCell.actionTitle = String.localized(chat.isBroadcast ? "add_recipients" : "group_add_members")
actionCell.imageView?.image = UIImage(systemName: "plus")
actionCell.actionColor = UIColor.systemBlue
} else if row == membersRowQrInvite {
actionCell.actionTitle = String.localized("qrshow_join_group_title")
actionCell.imageView?.image = UIImage(systemName: "qrcode")
actionCell.actionColor = UIColor.systemBlue
}
return actionCell
Expand Down
12 changes: 12 additions & 0 deletions deltachat-ios/Controller/NewChatViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -150,19 +150,24 @@ class NewChatViewController: UITableViewController {

switch newOptions[row] {
case .scanQRCode:
actionCell.imageView?.image = UIImage(systemName: "qrcode")
actionCell.actionTitle = String.localized("menu_new_contact")
case .newGroup:
actionCell.imageView?.image = UIImage(systemName: "plus")
actionCell.actionTitle = String.localized("menu_new_group")
case .newBroadcastList:
actionCell.imageView?.image = UIImage(systemName: "plus")
actionCell.actionTitle = String.localized("new_broadcast_list")
case .newContact:
actionCell.imageView?.image = UIImage(systemName: "highlighter")
actionCell.actionTitle = String.localized("menu_new_classic_contact")
}

return actionCell
} else if section == sectionInviteFriends {
guard let actionCell = tableView.dequeueReusableCell(withIdentifier: ActionCell.reuseIdentifier, for: indexPath) as? ActionCell else { fatalError("No Action Cell") }

actionCell.imageView?.image = UIImage(systemName: "heart")
actionCell.actionTitle = String.localized("invite_friends")
return actionCell

Expand All @@ -175,6 +180,13 @@ class NewChatViewController: UITableViewController {
}
}

override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
if section == sectionContacts {
return String.localized("chat_with")
}
return nil
}

override func tableView(_: UITableView, didSelectRowAt indexPath: IndexPath) {
let row = indexPath.row
let section = indexPath.section
Expand Down
1 change: 1 addition & 0 deletions deltachat-ios/Controller/NewGroupController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ class NewGroupController: UITableViewController, MediaPickerDelegate {
case .invite:
guard let actionCell = tableView.dequeueReusableCell(withIdentifier: ActionCell.reuseIdentifier, for: indexPath) as? ActionCell else { fatalError("No ActionCell") }
if inviteRows[row] == .addMembers {
actionCell.imageView?.image = UIImage(systemName: "plus")
actionCell.actionTitle = String.localized(createBroadcast ? "add_recipients" : "group_add_members")
actionCell.actionColor = UIColor.systemBlue
actionCell.isUserInteractionEnabled = true
Expand Down
2 changes: 1 addition & 1 deletion deltachat-ios/Controller/QrPageController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class QrPageController: UIPageViewController {
self?.pasteFromClipboard()
})
if dcContext.isChatmail == false {
actions.append(UIAction(title: String.localized("menu_new_classic_contact"), image: UIImage(systemName: "pencil")) { [weak self] _ in
actions.append(UIAction(title: String.localized("menu_new_classic_contact"), image: UIImage(systemName: "highlighter")) { [weak self] _ in
guard let self else { return }
self.navigationController?.pushViewController(NewContactController(dcContext: self.dcContext), animated: true)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,10 @@ internal final class NotificationsViewController: UITableViewController {
})
}()

private lazy var systemSettingsCell: UITableViewCell = {
let cell = UITableViewCell(style: .value1, reuseIdentifier: nil)
private lazy var systemSettingsCell: ActionCell = {
let cell = ActionCell()
cell.tag = CellTags.systemSettings.rawValue
cell.textLabel?.text = String.localized("system_settings")
cell.accessoryType = .disclosureIndicator
return cell
}()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class ProxySettingsViewController: UITableViewController {

addProxyCell = ActionCell()
addProxyCell.actionTitle = String.localized("proxy_add")
addProxyCell.imageView?.image = UIImage(systemName: "plus")
toggleProxyCell = SwitchCell(textLabel: String.localized("proxy_use_proxy"), on: dcContext.isProxyEnabled)

super.init(style: .insetGrouped)
Expand Down
5 changes: 3 additions & 2 deletions deltachat-ios/Helper/RelayHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ class RelayHelper {

// forwarding messages

func setForwardVCard(dialogTitle: String, vcardData: Data) {
self.dialogTitle = dialogTitle
func setForwardVCard(vcardData: Data) {
finishRelaying()
self.dialogTitle = String.localized("chat_share_with_title")
self.forwardVCardData = vcardData
}

Expand Down
32 changes: 6 additions & 26 deletions deltachat-ios/View/ActionCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,45 +8,25 @@ class ActionCell: UITableViewCell {

var actionTitle: String? {
didSet {
actionLabel.text = actionTitle
textLabel?.text = actionTitle
}
}

var actionColor: UIColor? {
didSet {
actionLabel.textColor = actionColor ?? UIColor.systemBlue
textLabel?.textColor = actionColor ?? UIColor.systemBlue
if let imageView {
imageView.tintColor = actionColor ?? UIColor.systemBlue
}
}
}

private lazy var actionLabel: UILabel = {
let label = UILabel()
label.text = actionTitle
label.textColor = UIColor.systemBlue
label.font = .preferredFont(forTextStyle: .body)
label.adjustsFontForContentSizeCategory = true
label.textAlignment = .center
label.numberOfLines = 0
return label
}()

override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
setupSubviews()
textLabel?.textColor = UIColor.systemBlue
}

required init?(coder _: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

private func setupSubviews() {
contentView.addSubview(actionLabel)
actionLabel.translatesAutoresizingMaskIntoConstraints = false
contentView.addConstraints([
actionLabel.constraintAlignLeadingTo(contentView, paddingLeading: 12),
actionLabel.constraintAlignTrailingTo(contentView, paddingTrailing: 12),
actionLabel.constraintAlignTopTo(contentView, paddingTop: 12),
actionLabel.constraintAlignBottomTo(contentView, paddingBottom: 12)

])
}
}
4 changes: 2 additions & 2 deletions deltachat-ios/ViewModel/ContactDetailViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ class ContactDetailViewModel {
if chatExists {
if !isDeviceTalk {
chatOptions.append(.ephemeralMessages)
chatOptions.append(.startChat)
}

if isSavedMessages == false && isDeviceTalk == false {
if !isSavedMessages && !isDeviceTalk {
chatOptions.append(.startChat)
chatOptions.append(.shareContact)
}

Expand Down
Loading