Skip to content

Commit

Permalink
move multi-select pin/mute to '...'
Browse files Browse the repository at this point in the history
pin/mute are arguably rarely used multi-select actions, move them to '...'.
this puts more focus on archive/delete/markread,
which are also the options directly present in other messengers.

also, that makes wrong taps less probable :)

one could also argue that pin/mute is not needed at all for multi-select,
however, as the functionality is there, let's leave that for now.
  • Loading branch information
r10s committed Oct 30, 2024
1 parent b466375 commit ca6ddd4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 30 deletions.
16 changes: 10 additions & 6 deletions deltachat-ios/Controller/ChatListViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,6 @@ class ChatListViewController: UITableViewController {

// MARK: updates
private func updateTitleAndEditingBar() {
editingBar.showUnpinning = viewModel?.hasOnlyPinnedChatsSelected(in: tableView.indexPathsForSelectedRows)
updateTitle()
}

Expand Down Expand Up @@ -1013,11 +1012,6 @@ extension ChatListViewController: ContactCellDelegate {

// MARK: - ChatListEditingBarDelegate
extension ChatListViewController: ChatListEditingBarDelegate {
func onPinButtonPressed() {
viewModel?.pinChatsToggle(indexPaths: tableView.indexPathsForSelectedRows)
setLongTapEditing(false)
}

func onDeleteButtonPressed() {
showDeleteMultipleChatConfirmationAlert()
}
Expand All @@ -1029,6 +1023,15 @@ extension ChatListViewController: ChatListEditingBarDelegate {

func onMorePressed() {
let alert = UIAlertController(title: nil, message: nil, preferredStyle: .safeActionSheet)

let onlyPinndedSelected = viewModel?.hasOnlyPinnedChatsSelected(in: tableView.indexPathsForSelectedRows) ?? false
let pinTitle = String.localized(onlyPinndedSelected ? "unpin" : "pin")
alert.addAction(UIAlertAction(title: pinTitle, style: .default) { [weak self] _ in
guard let self else { return }
viewModel?.pinChatsToggle(indexPaths: tableView.indexPathsForSelectedRows)
setLongTapEditing(false)
})

if viewModel?.hasAnyUnmutedChatSelected(in: tableView.indexPathsForSelectedRows) ?? false {
alert.addAction(UIAlertAction(title: String.localized("menu_mute"), style: .default) { [weak self] _ in
guard let self else { return }
Expand All @@ -1045,6 +1048,7 @@ extension ChatListViewController: ChatListEditingBarDelegate {
setLongTapEditing(false)
})
}

alert.addAction(UIAlertAction(title: String.localized("cancel"), style: .cancel, handler: nil))
present(alert, animated: true, completion: nil)
}
Expand Down
26 changes: 2 additions & 24 deletions deltachat-ios/View/ChatListEditingBar.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import UIKit

public protocol ChatListEditingBarDelegate: AnyObject {
func onPinButtonPressed()
func onDeleteButtonPressed()
func onArchiveButtonPressed()
func onMorePressed()
Expand All @@ -11,15 +10,6 @@ class ChatListEditingBar: UIView {

weak var delegate: ChatListEditingBarDelegate?

var showUnpinning: Bool? {
didSet {
guard let showUnpinning = showUnpinning else { return }
let imageName = showUnpinning ? "pin.slash" : "pin"
let description = showUnpinning ? String.localized("unpin") : String.localized("pin")
configureButtonLayout(pinButton, imageName: imageName, imageDescription: description)
}
}

var showArchive: Bool? {
didSet {
guard let showArchive = showArchive else { return }
Expand All @@ -40,7 +30,7 @@ class ChatListEditingBar: UIView {
}()

private lazy var mainContentView: UIStackView = {
let view = UIStackView(arrangedSubviews: [pinButton, archiveButton, deleteButton, moreButton])
let view = UIStackView(arrangedSubviews: [archiveButton, deleteButton, moreButton])
view.axis = .horizontal
view.distribution = .fillEqually
view.alignment = .fill
Expand All @@ -56,12 +46,8 @@ class ChatListEditingBar: UIView {
return createUIButton(imageName: "tray.and.arrow.down", imageDescription: String.localized("archive"))
}()

private lazy var pinButton: UIButton = {
return createUIButton(imageName: "pin", imageDescription: String.localized("pin"))
}()

private lazy var moreButton: UIButton = {
return createUIButton(imageName: "ellipsis.circle", imageDescription: String.localized("pin"))
return createUIButton(imageName: "ellipsis.circle", imageDescription: String.localized("menu_more_options"))
}()

public override init(frame: CGRect) {
Expand Down Expand Up @@ -104,10 +90,6 @@ class ChatListEditingBar: UIView {
mainContentView.constraintAlignBottomTo(self, paddingBottom: Utils.getSafeBottomLayoutInset())
])

let pinBtnGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(pinButtonPressed))
pinBtnGestureRecognizer.numberOfTapsRequired = 1
pinButton.addGestureRecognizer(pinBtnGestureRecognizer)

let deleteBtnGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(deleteButtonPressed))
deleteBtnGestureRecognizer.numberOfTapsRequired = 1
deleteButton.addGestureRecognizer(deleteBtnGestureRecognizer)
Expand All @@ -119,10 +101,6 @@ class ChatListEditingBar: UIView {
moreButton.addTarget(self, action: #selector(ChatListEditingBar.onMorePressed), for: .touchUpInside)
}

@objc func pinButtonPressed() {
delegate?.onPinButtonPressed()
}

@objc func deleteButtonPressed() {
delegate?.onDeleteButtonPressed()
}
Expand Down

0 comments on commit ca6ddd4

Please sign in to comment.