Skip to content

Commit

Permalink
Merge pull request wordpress-mobile#18297 from wordpress-mobile/featu…
Browse files Browse the repository at this point in the history
…re/18250-ios13-destructive-menu-item
  • Loading branch information
dvdchr authored Apr 7, 2022
2 parents 2bdc25a + 4f6a342 commit 02e551a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ private extension DashboardPromptsCardCell {
case .viewMore(let handler),
.skip(let handler),
.remove(let handler):
return .init(title: title, image: image, handler: handler)
return .init(title: title, image: image, destructive: menuAttributes.contains(.destructive), handler: handler)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ class MenuSheetViewController: UITableViewController {
let title: String
let image: UIImage?
let handler: () -> Void
let destructive: Bool

init(title: String, image: UIImage? = nil, destructive: Bool = false, handler: @escaping () -> Void) {
self.title = title
self.image = image
self.handler = handler
self.destructive = destructive
}

var foregroundColor: UIColor {
return destructive ? .error : .text
}
}

private let itemSource: [[MenuItem]]
Expand Down Expand Up @@ -96,8 +108,10 @@ extension MenuSheetViewController {
}

let cell = tableView.dequeueReusableCell(withIdentifier: Constants.cellIdentifier, for: indexPath)
cell.tintColor = .text
cell.tintColor = item.foregroundColor
cell.textLabel?.textColor = item.foregroundColor
cell.textLabel?.setText(item.title)
cell.textLabel?.numberOfLines = 0
cell.accessoryView = UIImageView(image: item.image?.withTintColor(.text))

return cell
Expand Down Expand Up @@ -131,6 +145,7 @@ private extension MenuSheetViewController {
func configureTable() {
tableView.register(UITableViewCell.self, forCellReuseIdentifier: Constants.cellIdentifier)
tableView.sectionHeaderHeight = 0
tableView.bounces = false

// draw the separators from edge to edge.
tableView.separatorInset = .zero
Expand Down

0 comments on commit 02e551a

Please sign in to comment.