surfstudio / ReactiveDataDisplayManager

MIT License
34 stars 13 forks source link

[SPT-1555] Universal StackView #253

Open NullIsOne opened 1 year ago

NullIsOne commented 1 year ago

Что сделано?

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

Чтобы уменьшить количество сопровождающих классов при создании сложных ячеек на основе сочетания стека и уже готовых ячеек

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

Как протестировать?

github-actions[bot] commented 1 year ago
Warnings
:warning: Oops! We have found some issues. It's better to fix them to keep code clean

SwiftLint found issues

Severity File Reason
Warning BakgroundStyle.swift:32 Shorthand syntactic sugar should be used, i.e. Int? instead of Optional. (syntactic_sugar)
Warning BorderStyle.swift:42 Shorthand syntactic sugar should be used, i.e. Int? instead of Optional. (syntactic_sugar)
Error ComponentsOverviewTableViewController.swift:26 Line should be 145 characters or less: currently 589 characters (line_length)

Generated by :no_entry_sign: Danger Swift against b75c607e3522baae33d837353a9c615e057711ac

codecov-commenter commented 1 year ago

Codecov Report

Patch coverage: 13.33% and project coverage change: -40.02% :warning:

Comparison is base (cbf811a) 72.66% compared to head (ea60f8c) 32.64%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## develop #253 +/- ## ============================================ - Coverage 72.66% 32.64% -40.02% ============================================ Files 161 166 +5 Lines 4905 5113 +208 Branches 2224 2285 +61 ============================================ - Hits 3564 1669 -1895 - Misses 1221 3378 +2157 + Partials 120 66 -54 ``` | Flag | Coverage Δ | | |---|---|---| | uitests | `?` | | | unittests | `32.64% <13.33%> (-1.39%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=surfstudio#carryforward-flags-in-the-pull-request-comment) to find out more. | [Files Changed](https://app.codecov.io/gh/surfstudio/ReactiveDataDisplayManager/pull/253?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=surfstudio) | Coverage Δ | | |---|---|---| | [Source/Collection/CollectionCell+RDDM.swift](https://app.codecov.io/gh/surfstudio/ReactiveDataDisplayManager/pull/253?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=surfstudio#diff-U291cmNlL0NvbGxlY3Rpb24vQ29sbGVjdGlvbkNlbGwrUkRETS5zd2lmdA==) | `0.00% <0.00%> (-100.00%)` | :arrow_down: | | [Source/Collection/CollectionSection.swift](https://app.codecov.io/gh/surfstudio/ReactiveDataDisplayManager/pull/253?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=surfstudio#diff-U291cmNlL0NvbGxlY3Rpb24vQ29sbGVjdGlvblNlY3Rpb24uc3dpZnQ=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: | | [...rs/CalculatableHeightCollectionCellGenerator.swift](https://app.codecov.io/gh/surfstudio/ReactiveDataDisplayManager/pull/253?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=surfstudio#diff-U291cmNlL0NvbGxlY3Rpb24vR2VuZXJhdG9ycy9DYWxjdWxhdGFibGVIZWlnaHRDb2xsZWN0aW9uQ2VsbEdlbmVyYXRvci5zd2lmdA==) | `0.00% <0.00%> (-100.00%)` | :arrow_down: | | [...ors/CalculatableWidthCollectionCellGenerator.swift](https://app.codecov.io/gh/surfstudio/ReactiveDataDisplayManager/pull/253?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=surfstudio#diff-U291cmNlL0NvbGxlY3Rpb24vR2VuZXJhdG9ycy9DYWxjdWxhdGFibGVXaWR0aENvbGxlY3Rpb25DZWxsR2VuZXJhdG9yLnN3aWZ0) | `0.00% <0.00%> (ø)` | | | [...urce/Collection/Generators/CollectionContext.swift](https://app.codecov.io/gh/surfstudio/ReactiveDataDisplayManager/pull/253?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=surfstudio#diff-U291cmNlL0NvbGxlY3Rpb24vR2VuZXJhdG9ycy9Db2xsZWN0aW9uQ29udGV4dC5zd2lmdA==) | `0.00% <0.00%> (ø)` | | | [...lugins/PluginAction/CollectionFoldablePlugin.swift](https://app.codecov.io/gh/surfstudio/ReactiveDataDisplayManager/pull/253?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=surfstudio#diff-U291cmNlL0NvbGxlY3Rpb24vUGx1Z2lucy9QbHVnaW5BY3Rpb24vQ29sbGVjdGlvbkZvbGRhYmxlUGx1Z2luLnN3aWZ0) | `6.97% <0.00%> (-74.42%)` | :arrow_down: | | [...ollection/Protocols/CollectionChildrenHolder.swift](https://app.codecov.io/gh/surfstudio/ReactiveDataDisplayManager/pull/253?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=surfstudio#diff-U291cmNlL0NvbGxlY3Rpb24vUHJvdG9jb2xzL0NvbGxlY3Rpb25DaGlsZHJlbkhvbGRlci5zd2lmdA==) | `0.00% <0.00%> (ø)` | | | [...ollection/Wrapper/CollectionWrappedCell+RDDM.swift](https://app.codecov.io/gh/surfstudio/ReactiveDataDisplayManager/pull/253?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=surfstudio#diff-U291cmNlL0NvbGxlY3Rpb24vV3JhcHBlci9Db2xsZWN0aW9uV3JhcHBlZENlbGwrUkRETS5zd2lmdA==) | `0.00% <0.00%> (ø)` | | | [...rce/Collection/Wrapper/CollectionWrappedCell.swift](https://app.codecov.io/gh/surfstudio/ReactiveDataDisplayManager/pull/253?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=surfstudio#diff-U291cmNlL0NvbGxlY3Rpb24vV3JhcHBlci9Db2xsZWN0aW9uV3JhcHBlZENlbGwuc3dpZnQ=) | `0.00% <0.00%> (ø)` | | | [...urce/Common/Generators/DiffableCellGenerator.swift](https://app.codecov.io/gh/surfstudio/ReactiveDataDisplayManager/pull/253?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=surfstudio#diff-U291cmNlL0NvbW1vbi9HZW5lcmF0b3JzL0RpZmZhYmxlQ2VsbEdlbmVyYXRvci5zd2lmdA==) | `0.00% <0.00%> (ø)` | | | ... and [20 more](https://app.codecov.io/gh/surfstudio/ReactiveDataDisplayManager/pull/253?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=surfstudio) | | ... and [83 files with indirect coverage changes](https://app.codecov.io/gh/surfstudio/ReactiveDataDisplayManager/pull/253/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=surfstudio)

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

NullIsOne commented 1 year ago

Обновил синтаксис. По-моему уже лучше, но не идеал конечно.

2 проблемы, с которыми столкнулся

  1. resultBuilder не позволяет использовать статические инициализаторы Решено также как в Editor.Property классе передачей типа: равно точки входа на фабрику (ViewContext, TableContext, CollectionContext). Контексты можно расширять своими функциями и шорткатами.
  2. generic функции надо конкретизировать Пришлось в generic функцию добавить параметр для конкретизации. it.viewNib(type: TitleTableViewCell.self, model: "1") против TitleTableViewCell.rddm.viewGenerator(with: "1", and: .nib) Надо оценить насколько это интуитивно.

Таким образом контекст определяет для какой коллекции нужен генератор. Генераторы создаются через контекст.

В случае со стеком вернул в примере установку children вместо выноса в отдельный параметр, чтобы исключить неочевидные ошибки и конфликты при построении стека и для более древовидной структуры.

NullIsOne commented 1 year ago

Очередное обновление и сразу 2 варианта синтаксиса.

  1. it.gen(CellOrViewType.self, model: Model) Снимок экрана 2023-07-26 в 18 19 09 Полностью рабочий, но читаемость все еще далека.
  2. CellOrViewType.build(in: Context, with: Model) Снимок экрана 2023-07-26 в 18 31 48 По сути extension к предыдущему решению. Есть проблема с TableCell классами. Они не выходят на создание baseGenerator из-за чего получаем краш TableWrappedCell<SomeOtherCell> вместо генератора для SomeOtherCell.

Пока склоняюсь ко второму варианту, но его еще надо починить.

Кстати, оба варианта (плюс предыдущий) заваливают варнингами типа такого Снимок экрана 2023-07-26 в 18 18 40 Это напоминает о том, что если уж надо какую-то верстку из ячейки запинуть в стек, то лучше отрефакторить, вынеся необходимый кусок во вью. Отобразить ячейку возможно, но могут быть проблемы с ресайзом, что впринципе и показывает a11y аудит.

NullIsOne commented 1 year ago

Убрал ready for review и поставил blocker.

Изменений много. Их надо влить чтобы не мучаться потом с конфликтами.

Синтаксис оригинала достигнут. Добавлена возможность декорировать и трансформировать генераторы.

Тесты на Xcode 15 с performAccessibilityAudit успешны. Снимок экрана 2023-08-01 в 12 05 00