Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.
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
82 changes: 45 additions & 37 deletions Classes/Issues/IssueManagingContextController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,43 +90,51 @@ final class IssueManagingContextController: NSObject, ContextMenuDelegate {
}

func item(_ action: Action) -> ContrastContextMenuItem {
let title: String
let icon: String

switch action {
case .labels:
title = Constants.Strings.labels
icon = "tag"
case .milestone:
title = Constants.Strings.milestone
icon = "milestone"
case .assignees:
title = Constants.Strings.assignees
icon = "person"
case .reviewers:
title = Constants.Strings.reviewers
icon = "reviewer"
case .unlock:
title = NSLocalizedString("Unlock", comment: "")
icon = "key"
case .lock:
title = NSLocalizedString("Lock", comment: "")
icon = "lock"
case .reopen:
title = Constants.Strings.reopen
icon = "sync"
case .close:
title = Constants.Strings.close
icon = "x"
}

let separator: Bool
switch action {
case .reopen, .close: separator = true
default: separator = false
}

return ContrastContextMenuItem(title: title, iconName: icon, separator: separator, action: actionBlock(action))
let title: String
let iconName: String

switch action {
case .labels:
title = Constants.Strings.labels
iconName = "tag"
case .milestone:
title = Constants.Strings.milestone
iconName = "milestone"
case .assignees:
title = Constants.Strings.assignees
iconName = "person"
case .reviewers:
title = Constants.Strings.reviewers
iconName = "reviewer"
case .unlock:
title = NSLocalizedString("Unlock", comment: "")
iconName = "key"
case .lock:
title = NSLocalizedString("Lock", comment: "")
iconName = "lock"
case .reopen:
title = Constants.Strings.reopen
iconName = "sync"
case .close:
title = Constants.Strings.close
iconName = "x"
}

let separator: Bool
switch action {
case .reopen, .close: separator = true
default: separator = false
}

let iconColor: UIColor
switch action {
case .close: iconColor = Styles.Colors.Red.medium.color
default: iconColor = Styles.Colors.Blue.medium.color
}

return ContrastContextMenuItem(title: title, iconName: iconName, iconColor: iconColor,
separator: separator, action: actionBlock(action))

}

func actionBlock(_ action: Action) -> (ContrastContextMenu) -> Void {
Expand Down
27 changes: 17 additions & 10 deletions Classes/View Controllers/ContrastContextMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,22 @@ struct ContrastContextMenuItem {

let title: String
let iconName: String?
let iconColor: UIColor?
let separator: Bool
let action: ((ContrastContextMenu) -> Void)?

init(
title: String,
iconName: String? = nil,
separator: Bool = false,
action: ((ContrastContextMenu) -> Void)? = nil
) {
self.title = title
self.iconName = iconName
self.separator = separator
self.action = action
title: String,
iconName: String? = nil,
iconColor: UIColor? = Styles.Colors.Blue.medium.color,
separator: Bool = false,
action: ((ContrastContextMenu) -> Void)? = nil
) {
self.title = title
self.iconName = iconName
self.iconColor = iconColor
self.separator = separator
self.action = action
}

}
Expand Down Expand Up @@ -90,6 +93,10 @@ final class ContrastContextMenu: UITableViewController {
if let iconName = item.iconName {
cell.imageView?.image = UIImage(named: iconName)?.withRenderingMode(.alwaysTemplate)
}

if let iconColor = item.iconColor {
cell.imageView?.tintColor = iconColor
}

if let cell = cell as? Cell {
cell.border?.isHidden = !item.separator
Expand Down