diff --git a/iphone/Maps/Bookmarks/BookmarksList/BookmarksListViewController.swift b/iphone/Maps/Bookmarks/BookmarksList/BookmarksListViewController.swift index d59ab65f2c..bb791d25b9 100644 --- a/iphone/Maps/Bookmarks/BookmarksList/BookmarksListViewController.swift +++ b/iphone/Maps/Bookmarks/BookmarksList/BookmarksListViewController.swift @@ -161,6 +161,11 @@ extension BookmarksListViewController: UITableViewDelegate { } return UISwipeActionsConfiguration(actions: [deleteAction, editAction]) } + + func tableView(_ tableView: UITableView, accessoryButtonTappedForRowWith indexPath: IndexPath) { + guard let section = sections?[indexPath.section] else { fatalError() } + presenter.editItem(in: section, at: indexPath.row) + } } extension BookmarksListViewController: UISearchBarDelegate { diff --git a/iphone/Maps/Bookmarks/BookmarksList/Cells/BookmarksListCell.swift b/iphone/Maps/Bookmarks/BookmarksList/Cells/BookmarksListCell.swift index 6e8c95a5cb..06a0a041aa 100644 --- a/iphone/Maps/Bookmarks/BookmarksList/Cells/BookmarksListCell.swift +++ b/iphone/Maps/Bookmarks/BookmarksList/Cells/BookmarksListCell.swift @@ -1,8 +1,40 @@ final class BookmarksListCell: UITableViewCell { + private static let extendedImageViewTappableMargin: CGFloat = -15 + + private var trackColorDidTapAction: (() -> Void)? + + override func awakeFromNib() { + super.awakeFromNib() + setupCell() + } + + private func setupCell() { + accessoryType = .detailButton + if let imageView { + let tapGesture = UITapGestureRecognizer(target: self, action: #selector(colorDidTapAction(_:))) + imageView.addGestureRecognizer(tapGesture) + imageView.isUserInteractionEnabled = true + } + } + func config(_ bookmark: IBookmarksListItemViewModel) { imageView?.image = bookmark.image textLabel?.text = bookmark.name detailTextLabel?.text = bookmark.subtitle + trackColorDidTapAction = bookmark.colorDidTapAction + } + + @objc private func colorDidTapAction(_ sender: UITapGestureRecognizer) { + trackColorDidTapAction?() + } + + // Extends the imageView tappable area. + override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? { + if let imageView, imageView.frame.insetBy(dx: Self.extendedImageViewTappableMargin, dy: Self.extendedImageViewTappableMargin).contains(point) { + return imageView + } else { + return super.hitTest(point, with: event) + } } }