ActiveLabel.swift 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. //extension ActiveEntity {
  2. //
  3. // var accessibilityLabelDescription: String {
  4. // switch self.type {
  5. // case .email: return L10n.Common.Controls.Status.Tag.email
  6. // case .hashtag: return L10n.Common.Controls.Status.Tag.hashtag
  7. // case .mention: return L10n.Common.Controls.Status.Tag.mention
  8. // case .url: return L10n.Common.Controls.Status.Tag.url
  9. // case .emoji: return L10n.Common.Controls.Status.Tag.emoji
  10. // }
  11. // }
  12. //
  13. // var accessibilityValueDescription: String {
  14. // switch self.type {
  15. // case .email(let text, _): return text
  16. // case .hashtag(let text, _): return text
  17. // case .mention(let text, _): return text
  18. // case .url(_, let trimmed, _, _): return trimmed
  19. // case .emoji(let text, _, _): return text
  20. // }
  21. // }
  22. //
  23. // func accessibilityElement(in accessibilityContainer: Any) -> ActiveLabelAccessibilityElement? {
  24. // if case .emoji = self.type {
  25. // return nil
  26. // }
  27. //
  28. // let element = ActiveLabelAccessibilityElement(accessibilityContainer: accessibilityContainer)
  29. // element.accessibilityTraits = .button
  30. // element.accessibilityLabel = accessibilityLabelDescription
  31. // element.accessibilityValue = accessibilityValueDescription
  32. // return element
  33. // }
  34. //}
  35. //final class ActiveLabelAccessibilityElement: UIAccessibilityElement {
  36. // var index: Int!
  37. //}
  38. //
  39. // MARK: - UIAccessibilityContainer
  40. //extension ActiveLabel {
  41. //
  42. // func createAccessibilityElements() -> [UIAccessibilityElement] {
  43. // var elements: [UIAccessibilityElement] = []
  44. //
  45. // let element = ActiveLabelAccessibilityElement(accessibilityContainer: self)
  46. // element.accessibilityTraits = .staticText
  47. // element.accessibilityLabel = accessibilityLabel
  48. // element.accessibilityFrame = superview!.convert(frame, to: nil)
  49. // element.accessibilityLanguage = accessibilityLanguage
  50. // elements.append(element)
  51. //
  52. // for entity in activeEntities {
  53. // guard let element = entity.accessibilityElement(in: self) else { continue }
  54. // var glyphRange = NSRange()
  55. // layoutManager.characterRange(forGlyphRange: entity.range, actualGlyphRange: &glyphRange)
  56. // let rect = layoutManager.boundingRect(forGlyphRange: glyphRange, in: textContainer)
  57. // element.accessibilityFrame = self.convert(rect, to: nil)
  58. // element.accessibilityContainer = self
  59. // elements.append(element)
  60. // }
  61. //
  62. // return elements
  63. // }
  64. //
  65. //}