diff --git a/Classes/Issues/IssueTextActionsView.swift b/Classes/Issues/IssueTextActionsView.swift index 158845c4..cc7f5f9b 100644 --- a/Classes/Issues/IssueTextActionsView.swift +++ b/Classes/Issues/IssueTextActionsView.swift @@ -44,6 +44,19 @@ final class IssueTextActionsCell: SelectableCell { imageView.frame = contentView.bounds } + func configure(operation: IssueTextActionOperation) { + imageView.image = operation.icon + imageView.accessibilityLabel = operation.name + } + + override var accessibilityLabel: String? { + get { + return contentView.subviews + .flatMap { $0.accessibilityLabel } + .reduce("", { "\($0 ?? "").\n\($1)" }) } + set { } + } + } protocol IssueTextActionsViewDelegate: class { @@ -61,6 +74,7 @@ struct IssueTextActionOperation { let icon: UIImage? let operation: Operation + let name: String } @@ -113,7 +127,7 @@ final class IssueTextActionsView: UIView, UICollectionViewDataSource, UICollecti func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: identifier, for: indexPath) as? IssueTextActionsCell else { fatalError("Wrong cell type") } - cell.imageView.image = operations[indexPath.item].icon + cell.configure(operation: operations[indexPath.item]) return cell } diff --git a/Classes/Views/IssueTextActionsView+Markdown.swift b/Classes/Views/IssueTextActionsView+Markdown.swift index 2a3dc1e3..8a17acc6 100644 --- a/Classes/Views/IssueTextActionsView+Markdown.swift +++ b/Classes/Views/IssueTextActionsView+Markdown.swift @@ -19,23 +19,56 @@ extension IssueTextActionsView { supportsImageUpload: Bool ) -> IssueTextActionsView { var operations: [IssueTextActionOperation] = [ - IssueTextActionOperation(icon: UIImage(named: "bar-eye"), operation: .execute({ [weak viewController] in + IssueTextActionOperation( + icon: UIImage(named: "bar-eye"), + operation: .execute({ [weak viewController] in let controller = IssuePreviewViewController(markdown: getMarkdownBlock(), owner: owner, repo: repo) viewController?.navigationController?.pushViewController(controller, animated: true) - })), - IssueTextActionOperation(icon: UIImage(named: "bar-bold"), operation: .wrap("**", "**")), - IssueTextActionOperation(icon: UIImage(named: "bar-italic"), operation: .wrap("_", "_")), - IssueTextActionOperation(icon: UIImage(named: "bar-code"), operation: .wrap("`", "`")), - IssueTextActionOperation(icon: UIImage(named: "bar-code-block"), operation: .wrap("```\n", "\n```")), - IssueTextActionOperation(icon: UIImage(named: "bar-strikethrough"), operation: .wrap("~~", "~~")), - IssueTextActionOperation(icon: UIImage(named: "bar-header"), operation: .line("#")), - IssueTextActionOperation(icon: UIImage(named: "bar-ul"), operation: .line("- ")), - IssueTextActionOperation(icon: UIImage(named: "bar-indent"), operation: .line(" ")), - IssueTextActionOperation(icon: UIImage(named: "bar-link"), operation: .wrap("[", "](\(UITextView.cursorToken))")) + }), + name: NSLocalizedString("Message Preview", comment: "The name of the action for previewing a message from the markdown actions bar")), + IssueTextActionOperation( + icon: UIImage(named: "bar-bold"), + operation: .wrap("**", "**"), + name: NSLocalizedString("Make text bold", comment: "The name of the action for making text bold from the markdown actions bar")), + IssueTextActionOperation( + icon: UIImage(named: "bar-italic"), + operation: .wrap("_", "_"), + name: NSLocalizedString("Make text italic", comment: "The name of the action for making text italic from the markdown actions bar")), + IssueTextActionOperation( + icon: UIImage(named: "bar-code"), + operation: .wrap("`", "`"), + name: NSLocalizedString("Make text monospaced", comment: "The name of the action for making text monospaced / appear as code from the markdown actions bar")), + IssueTextActionOperation( + icon: UIImage(named: "bar-code-block"), + operation: .wrap("```\n", "\n```"), + name: NSLocalizedString("Make text appear as code", comment: "The name of the action for making text appear as code from the markdown actions bar")), + IssueTextActionOperation( + icon: UIImage(named: "bar-strikethrough"), + operation: .wrap("~~", "~~"), + name: NSLocalizedString("Strikethrough text", comment: "The name of the action for making text strikethrough from the markdown actions bar")), + IssueTextActionOperation( + icon: UIImage(named: "bar-header"), + operation: .line("#"), + name: NSLocalizedString("Add header to text", comment: "The name of the action for making text a header from the markdown actions bar")), + IssueTextActionOperation( + icon: UIImage(named: "bar-ul"), + operation: .line("- "), + name: NSLocalizedString("Make text a list item", comment: "The name of the action for making text a list item from the markdown actions bar")), + IssueTextActionOperation( + icon: UIImage(named: "bar-indent"), + operation: .line(" "), + name: NSLocalizedString("Make text indented", comment: "The name of the action for making text indented from the markdown actions bar")), + IssueTextActionOperation( + icon: UIImage(named: "bar-link"), + operation: .wrap("[", "](\(UITextView.cursorToken))"), + name: NSLocalizedString("Wrap text as URL", comment: "The name of the action to wrap text in a markdown URL from the markdown actions bar")) ] if supportsImageUpload { - operations.append(IssueTextActionOperation(icon: UIImage(named: "bar-upload"), operation: .uploadImage)) + operations.append(IssueTextActionOperation( + icon: UIImage(named: "bar-upload"), + operation: .uploadImage, + name: NSLocalizedString("Upload Image", comment: "The name of the action to upload an image from the markdown actions bar"))) } let actions = IssueTextActionsView(operations: operations)