StatusTableViewControllerNavigateable.swift 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. //
  2. // StatusTableViewControllerNavigateable.swift
  3. // Mastodon
  4. //
  5. // Created by MainasuK Cirno on 2021-5-19.
  6. //
  7. import os.log
  8. import UIKit
  9. import MastodonAsset
  10. import MastodonLocalization
  11. typealias StatusTableViewControllerNavigateable = StatusTableViewControllerNavigateableCore & StatusTableViewControllerNavigateableRelay
  12. protocol StatusTableViewControllerNavigateableCore: TableViewControllerNavigateableCore {
  13. var statusNavigationKeyCommands: [UIKeyCommand] { get }
  14. func statusKeyCommandHandler(_ sender: UIKeyCommand)
  15. }
  16. extension StatusTableViewControllerNavigateableCore {
  17. var overrideNavigationScrollPosition: UITableView.ScrollPosition? {
  18. get { return nil }
  19. set { }
  20. }
  21. }
  22. @objc protocol StatusTableViewControllerNavigateableRelay: TableViewControllerNavigateableRelay {
  23. func statusKeyCommandHandlerRelay(_ sender: UIKeyCommand)
  24. }
  25. enum StatusTableViewNavigation: String, CaseIterable {
  26. case openAuthorProfile
  27. case openRebloggerProfile
  28. case replyStatus
  29. case toggleReblog
  30. case toggleFavorite
  31. case toggleContentWarning
  32. case previewImage
  33. var title: String {
  34. switch self {
  35. case .openAuthorProfile: return L10n.Common.Controls.Keyboard.Timeline.openAuthorProfile
  36. case .openRebloggerProfile: return L10n.Common.Controls.Keyboard.Timeline.openRebloggerProfile
  37. case .replyStatus: return L10n.Common.Controls.Keyboard.Timeline.replyStatus
  38. case .toggleReblog: return L10n.Common.Controls.Keyboard.Timeline.toggleReblog
  39. case .toggleFavorite: return L10n.Common.Controls.Keyboard.Timeline.toggleFavorite
  40. case .toggleContentWarning: return L10n.Common.Controls.Keyboard.Timeline.toggleContentWarning
  41. case .previewImage: return L10n.Common.Controls.Keyboard.Timeline.previewImage
  42. }
  43. }
  44. // UIKeyCommand input
  45. var input: String {
  46. switch self {
  47. case .openAuthorProfile: return "p"
  48. case .openRebloggerProfile: return "p" // + option
  49. case .replyStatus: return "n" // + shift + command
  50. case .toggleReblog: return "r"
  51. case .toggleFavorite: return "f"
  52. case .toggleContentWarning: return "o"
  53. case .previewImage: return "i"
  54. }
  55. }
  56. var modifierFlags: UIKeyModifierFlags {
  57. switch self {
  58. case .openAuthorProfile: return []
  59. case .openRebloggerProfile: return [.alternate]
  60. case .replyStatus: return [.shift, .alternate]
  61. case .toggleReblog: return []
  62. case .toggleFavorite: return []
  63. case .toggleContentWarning: return []
  64. case .previewImage: return []
  65. }
  66. }
  67. var propertyList: Any {
  68. return rawValue
  69. }
  70. }