Проверка шаблона шины для iOS
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

149 lines
2.8KB

  1. import Foundation
  2. import MPAKX
  3. public extension MeetupId {
  4. /*
  5. static func shouldEnableJoin(_ c: MeetupIdContext) -> Bool? {
  6. guard !c.isLoading.value else { return nil }
  7. if
  8. c.textUI.isRecent,
  9. let sid = formatId(c.textUI.value)
  10. {
  11. return sid.count > 2
  12. }
  13. if c.join {
  14. return false
  15. }
  16. if
  17. c.isLoading.isRecent,
  18. !c.isLoading.value
  19. {
  20. return true
  21. }
  22. return nil
  23. }
  24. */
  25. static func shouldManyEnableJoin(_ c: MeetupIdContext) -> MPAK.Many<Bool>? {
  26. var d = [String: Bool]()
  27. // TODO: Когда копировать dict isLoading?
  28. if c.textUI.isRecent {
  29. for id in c.textUI.keys {
  30. guard
  31. c.isLoading.dict[id] == nil
  32. let text = c.testTextUI.dict[id]
  33. else {
  34. continue
  35. }
  36. let sid = formatId(text)
  37. d[id] = sid.count > 2
  38. }
  39. if !d.isEmpty {
  40. return .init(Set(d.keys), d)
  41. }
  42. }
  43. /*
  44. if c.join,
  45. !c.isLoading.value
  46. {
  47. return false
  48. }
  49. if
  50. c.isLoading.isRecent,
  51. !c.isLoading.value
  52. !c.isLoading.value
  53. {
  54. return true
  55. }
  56. */
  57. return nil
  58. }
  59. /*
  60. static func shouldFinishLoading(_ c: MeetupIdContext) -> Bool? {
  61. guard
  62. c.isLoading.isRecent,
  63. c.isLoading.value
  64. else {
  65. return nil
  66. }
  67. return true
  68. }
  69. */
  70. /*
  71. это ещё конвертнуть надо в Many
  72. static func shouldResetLoading(_ c: MeetupIdContext) -> Bool? {
  73. if
  74. c.join,
  75. !c.isLoading.value
  76. {
  77. return true
  78. }
  79. if
  80. c.finishLoading,
  81. c.isLoading.value
  82. {
  83. return false
  84. }
  85. return nil
  86. }
  87. */
  88. /*
  89. static func shouldResetText(_ c: MeetupIdContext) -> String? {
  90. guard c.textUI.isRecent else { return nil }
  91. return formatId(c.textUI.value)
  92. }
  93. */
  94. static func shouldManyFinishLoading(_ c: MeetupIdContext) -> MPAK.Many<Bool>? {
  95. guard c.isLoading.isRecent else { return nil }
  96. var keys = Set<String>()
  97. for id in c.isLoading.keys {
  98. if
  99. let isLoading = c.isLoading.dict[id],
  100. isLoading
  101. {
  102. keys.insert(id)
  103. }
  104. }
  105. let d = [String: Bool]()
  106. return MPAK.Many(keys, d)
  107. }
  108. static func shouldManyResetText(_ c: MeetupIdContext) -> MPAK.Many<String>? {
  109. guard !c.textUI.keys.isEmpty else { return nil }
  110. var d = [String: String]()
  111. for id in c.textUI.keys {
  112. let text = c.textUI.dict[id] ?? ""
  113. d[id] = formatId(text)
  114. }
  115. return MPAK.Many(c.textUI.keys, d)
  116. }
  117. static func shouldManyTestResetText(_ c: MeetupIdContext) -> MPAK.Many<String>? {
  118. guard !c.testTextUI.keys.isEmpty else { return nil }
  119. var d = [String: String]()
  120. for id in c.testTextUI.keys {
  121. let text = c.testTextUI.dict[id] ?? ""
  122. d[id] = formatId(text)
  123. }
  124. return MPAK.Many(c.testTextUI.keys, d)
  125. }
  126. }