Skip to content

[SPT-1480] RDDM Accessibility optimizations#239

Merged
NullIsOne merged 20 commits intorelease/7.4from
feature/SPT-1480-optimizations
Jul 21, 2023
Merged

[SPT-1480] RDDM Accessibility optimizations#239
NullIsOne merged 20 commits intorelease/7.4from
feature/SPT-1480-optimizations

Conversation

@Ikeret
Copy link
Copy Markdown
Contributor

@Ikeret Ikeret commented Jun 22, 2023

Что сделано?

  • Переделаны стратегии

Зачем это сделано?

  • Новая организация стратегий позволит более удобно их использовать и открывает больший функционал для расширения

На что обратить внимание?

  • Еще в планах оптимизировать работу с UIAccessibilityCustomActions
  • Если изменения ок, то в конце будут исправлены тесты и Example

Пример:

Если раньше стратегии задавались очень длинно и нагроможденно

 var labelStrategy = .joined([.from(object: titleLalel), .just(", "), .from(object: offerLabel)])

var valueStrategy = .joined([
    .just("Количество: \(stepper.value), по цене "),
    .from(object: priceLabel),
    .just(oldPriceLabel.text.map { ". Старая цена \($0)" })
])

то теперь станет это проще

var labelStrategy = .merge(titleLabel.text, offerLabel.text, separator: ", ")

var valueStrategy = .merge(
    "Количество: \(stepper.value), по цене ", 
    priceLabel.text, 
    oldPriceLabel.text.map { ". Старая цена \($0)" }
)

@Ikeret Ikeret requested review from Golubeykov and NullIsOne June 22, 2023 12:46
@Ikeret Ikeret self-assigned this Jun 22, 2023
@github-actions
Copy link
Copy Markdown

github-actions bot commented Jun 22, 2023

Warnings
⚠️ Oops! We have found some issues. It's better to fix them to keep code clean

SwiftLint found issues

Severity File Reason
Warning AccessibilityItemWrapper.swift:18 Redundant explicit declaration of default types should be avoided (redundant_default_type)
Warning AccessibilityItem+Invalidation.swift:90 Line should be 145 characters or less: currently 158 characters (line_length)

Generated by 🚫 Danger Swift against 72f69d7

@Ikeret Ikeret marked this pull request as draft June 22, 2023 12:54
Copy link
Copy Markdown
Collaborator

@NullIsOne NullIsOne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

преаппрув
хороший генерик

}
/// a reference value from object.
/// - parameter keyPath: specified keypath from value would be taken.
public static func from<T>(_ object: T, keyPath: KeyPath<T, ValueType?>) -> Self {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Вот тут хорошо что от привязки к NSObject ушли.
Это ограничивало варианты источников

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Да, теперь работает с любым объектом, можно передавать свои классы и указывать их поля)

@Ikeret
Copy link
Copy Markdown
Contributor Author

Ikeret commented Jul 4, 2023

  • Добавлен контейнер для итемов, который позволит задавать в ячейке чайлд accessibility итемы
  • Добавлен враппер для итема, позволит оборачивать в AccessibilityItem вьюшки, к которым нет доступа (к примеру вью из библиотек)
  • Немного обновлены стратегии
  • Исправлен Example

Осталось:

  • придумать удобный способ задания UIAccessibilityCustomActions
  • подумать над частичной инвалидацией параметров
  • подумать как использовать логику для обычных вью (сейчас можно использовать вью итемы в контейнере, но логика изменения в плагине остается)
  • возможно стоит вынести всю Accessibility логику в отдельный таргет/либу (оторвать от RDDM 😢)
  • добавить/обновить документацию по новой логике

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jul 4, 2023

Codecov Report

Patch coverage: 58.83% and project coverage change: +26.70 🎉

Comparison is base (d604813) 36.56% compared to head (eca573b) 63.26%.

❗ Current head eca573b differs from pull request most recent head 0a4f73b. Consider uploading reports for the commit 0a4f73b to get more accurate results

Additional details and impacted files
@@               Coverage Diff                @@
##           release/7.4     #239       +/-   ##
================================================
+ Coverage        36.56%   63.26%   +26.70%     
================================================
  Files              143      151        +8     
  Lines             5303     5491      +188     
  Branches          2437     2497       +60     
================================================
+ Hits              1939     3474     +1535     
+ Misses            3283     1886     -1397     
- Partials            81      131       +50     
Flag Coverage Δ
uitests 48.11% <51.97%> (?)
unittests 35.36% <18.31%> (-1.20%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...llection/DataSource/BaseCollectionDataSource.swift 77.41% <0.00%> (+38.70%) ⬆️
...Collection/Modifier/CollectionCommonModifier.swift 46.03% <0.00%> (+3.43%) ⬆️
...llection/Modifier/CollectionDiffableModifier.swift 51.47% <0.00%> (+51.47%) ⬆️
.../Collection/Protocols/CollectionFoldableItem.swift 0.00% <0.00%> (ø)
Source/Protocols/Modifier/Modifier.swift 10.00% <0.00%> (-1.12%) ⬇️
...cessibility/Container/AccessibilityContainer.swift 0.00% <0.00%> (ø)
...ssibility/Container/AccessibilityItemWrapper.swift 0.00% <0.00%> (ø)
...ators/Accessibility/Item/AccessibilityAction.swift 0.00% <0.00%> (ø)
...lity/Modifier/AccessibilityContainerModifier.swift 0.00% <0.00%> (ø)
...ce/Protocols/Plugins/Generators/FoldableItem.swift 0.00% <0.00%> (ø)
... and 42 more

... and 49 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@NullIsOne NullIsOne force-pushed the feature/SPT-1480-optimizations branch 2 times, most recently from f40ba86 to 02f5b2c Compare July 12, 2023 13:49
@NullIsOne
Copy link
Copy Markdown
Collaborator

Апдейт

  • 🛠️ придумать удобный способ задания UIAccessibilityCustomActions
  • 🛠️ подумать над частичной инвалидацией параметров
  • ✅ подумать как использовать логику для обычных вью (сейчас можно использовать вью итемы в контейнере, но логика изменения в плагине остается)
    Достаточно вызвать modify и при необходимости настроить инвалидатор. (проверено на Playbook)
    Опишу способы использования в доке.
  • ❌ возможно стоит вынести всю Accessibility логику в отдельный таргет/либу (оторвать от RDDM 😢)
    В 7.4 зарелизим в RDDM. В 8.0 вынесем как podspec и package product для SPM.
    Такой подход необходим для уменьшения издержек от поддержки 7.3.x/7.4 и develop.
  • 🛠️ добавить/обновить документацию по новой логике

@NullIsOne
Copy link
Copy Markdown
Collaborator

Апдейт

✅ придумать удобный способ задания UIAccessibilityCustomActions
Создана AccessibilityActionsStrategy и структура враппер AccessibilityAction
Применение в ПР appTemplate
✅ 50/50 подумать над частичной инвалидацией параметров
Добавлен базовый инвалидатор, который не лезет за генератором. Полезно в playbook например.
Инвалидацию label, value, traits, actions отдельно друг от друга мешает сделать AccessibilityModifier который берет все из AccessibilityItem
Оптимизируем этот момент в 8.0

Осталось
🛠️ добавить/обновить документацию по новой логике

@NullIsOne
Copy link
Copy Markdown
Collaborator

Переделал включенный по-умолчанию acessibilityPlugin
Поправил документацию
Готово к review

@NullIsOne NullIsOne marked this pull request as ready for review July 18, 2023 09:00
@NullIsOne NullIsOne self-assigned this Jul 18, 2023
@NullIsOne NullIsOne requested a review from kombatkos July 18, 2023 09:08
Copy link
Copy Markdown
Contributor Author

@Ikeret Ikeret left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Есть небольшой вопрос по ContainerModifier, ну а так все круто)

open var modifierType: AccessibilityModifierType = AccessibilityItemModifier.self

required public init(
parentView: UIView,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тут required будет мешать, надо отдельный инит required public init(parentView: UIView) добавить, а стратегии и так open

required нужен, чтобы обязательно инициализировать через super.init(accessibilityContainer: parentView) - без него итем не будет корректно отображаться (опыт с прошлого проекта)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

имею в виду один инит required public init(parentView: UIView), а второй как сейчас, но не required

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

добавил not required init

public extension AccessibilityStrategyProvider {
var valueStrategy: AccessibilityStringStrategy { .ignored }
var traitsStrategy: AccessibilityTraitsStrategy { .ignored }
var actionsStrategy: AccessibilityActionsStrategy { .ignored }
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это хорошо, .ignored не хватало, позволят использовать стандартное accessibilityActions при необходимости

return
}

item.isAccessibilityElement = !item.isAccessibilityIgnored
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не совсем уверен нужно ли тут убирать isAccessibilityElement

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Нашему контейнеру не нужно быть AccessibilityElement.
Если помнишь по опыту TDW AccessibilityElement, который содержит AccessibilityElement перекрывает child элементы.
При отладке на проекте это подтвердилось и с AccessibilityContainer.

// MARK: - Private Properties

private lazy var adapter = collectionView.rddm.baseBuilder
.add(plugin: .accessibility())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Этот контроллер не рабочий

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В каком плане?
По a11y там минимальная адаптация с указанием "some image".
Там layout который к левой или к правой стороне прижимает. И больше никакой логики.

Simulator Screenshot - iPhone 14 Pro - 2023-07-21 at 12 52 36

Simulator Screenshot - iPhone 14 Pro - 2023-07-21 at 12 53 02

Или в прошлых версиях iOS другой эффект был?

@NullIsOne NullIsOne force-pushed the feature/SPT-1480-optimizations branch from 0a4f73b to 72f69d7 Compare July 19, 2023 12:03
@NullIsOne NullIsOne merged commit 5462585 into release/7.4 Jul 21, 2023
@NullIsOne NullIsOne deleted the feature/SPT-1480-optimizations branch July 21, 2023 11:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants