breaking: Themes refactoring#34
Conversation
… initialization and registration functions, removed unused files, and improved export structure. Updated tests and removed deprecated topic tokens.
WalkthroughThe changes remove asynchronous theme loading and specialized theme token subclasses, simplify theme initialization to accept a direct theme instance, and refactor theme preprocessing to use an abstract base class and a renamed tokenization callback. Several exports and test files related to theme loading and token specialization are deleted, consolidating and streamlining the theme system. Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant DuitRegistry
participant Theme
Caller->>DuitRegistry: initialize(theme: Theme)
DuitRegistry->>DuitRegistry: Assigns _theme = theme
Note right of DuitRegistry: No async loading or error handling
Caller->>DuitRegistry: Access theme via getter
sequenceDiagram
participant ThemePreprocessor
participant TokenizationCallback
ThemePreprocessor->>TokenizationCallback: createToken(type, themeData)
TokenizationCallback-->>ThemePreprocessor: Returns ThemeToken or null
Note right of ThemePreprocessor: Abstract base, relies on callback
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (10)
lib/src/registry_api/components/index.dart(1 hunks)lib/src/registry_api/index.dart(1 hunks)lib/src/registry_api/registry.dart(1 hunks)lib/src/ui/theme/index.dart(0 hunks)lib/src/ui/theme/preprocessor.dart(2 hunks)lib/src/ui/theme/theme_loader.dart(0 hunks)lib/src/ui/theme/theme_token.dart(0 hunks)lib/src/view_attributes/view_attribute.dart(1 hunks)test/misc.dart(0 hunks)test/theme_test.dart(0 hunks)
💤 Files with no reviewable changes (5)
- lib/src/ui/theme/index.dart
- test/theme_test.dart
- test/misc.dart
- lib/src/ui/theme/theme_token.dart
- lib/src/ui/theme/theme_loader.dart
🔇 Additional comments (7)
lib/src/registry_api/components/index.dart (1)
5-5: Export addition looks good.The addition of the
reference_target.dartexport aligns with the overall refactoring to centralize related exports under the components module.lib/src/registry_api/index.dart (1)
4-5: Export reorganization improves API structure.The centralization of component-related exports through
components/index.dartwith an explicitshowclause makes the public API more organized and explicit about what's being exported.lib/src/view_attributes/view_attribute.dart (1)
30-36: Variable renaming improves code readability.The change from
dstosourcemakes the code more self-documenting and easier to understand. The renaming is applied consistently throughout the method.lib/src/ui/theme/preprocessor.dart (3)
4-4: Typedef renaming improves clarity.The renaming from
CustomTokenizertoTokenizationCallbackis more descriptive and follows better naming conventions.
9-21: Good architectural improvement with abstract class design.Converting
ThemePreprocessorto an abstract class and makingcreateTokenabstract allows for better customization and follows the Template Method pattern. This design improvement provides more flexibility for different tokenization strategies.
43-53: Method calls updated correctly.The calls to
createToken(previously_createToken) are updated correctly to use the new abstract method signature.lib/src/registry_api/registry.dart (1)
15-24: Excellent simplification of theme management.The changes significantly improve the API by:
- Renaming
configuretoinitializefor better clarity- Removing complex asynchronous theme loading in favor of direct theme assignment
- Simplifying the theme parameter from a loader to a direct
DuitThemeinstanceThis makes the initialization process more straightforward and easier to understand.
| static FutureOr<void> initialize({ | ||
| DebugLogger? logger, | ||
| ResourceLoader<DuitTheme>? themeLoader, | ||
| DuitTheme? theme, | ||
| ComponentRegistry? componentRegistry, | ||
| }) async { |
There was a problem hiding this comment.
🧹 Nitpick (assertive)
Consider if async signature is still necessary.
The method is still marked as async and returns FutureOr<void>, but the theme assignment is now synchronous. The async behavior might only be needed for the component registry initialization. Consider whether the signature can be simplified further.
🤖 Prompt for AI Agents
In lib/src/registry_api/registry.dart around lines 15 to 19, the initialize
method is marked async and returns FutureOr<void>, but since theme assignment is
synchronous and only componentRegistry initialization might be async, review if
the method can be simplified by removing async and returning Future<void> only
if necessary. Adjust the method signature and implementation accordingly to
reflect the actual async needs, possibly by returning a Future only when
componentRegistry initialization is awaited.
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (2)
.github/workflows/post-merge.yaml(1 hunks).github/workflows/pr.yaml(1 hunks)
🧰 Additional context used
🪛 YAMLlint (1.37.1)
.github/workflows/post-merge.yaml
[error] 14-14: too many spaces inside brackets
(brackets)
[error] 14-14: too many spaces inside brackets
(brackets)
.github/workflows/pr.yaml
[error] 11-11: too many spaces inside brackets
(brackets)
[error] 11-11: too many spaces inside brackets
(brackets)
🔇 Additional comments (2)
.github/workflows/pr.yaml (1)
11-11: Confirm the new versions are available fromsubosito/flutter-action
3.29.3and3.32.7look forward-leaning. If these tags aren’t yet published on the Flutter CDN, the job will fail at runtime.
Consider running a quick manual check or letting the first CI run act as validation..github/workflows/post-merge.yaml (1)
14-14: Double-check availability of the added versions
As with the PR workflow, make sure the post-merge pipeline won’t break if these Flutter builds haven’t been propagated yet.
| fail-fast: false | ||
| matrix: | ||
| flutter-version: [ '3.24.3', '3.27.3' ] | ||
| flutter-version: [ '3.24.3', '3.27.4', '3.29.3', '3.32.7' ] |
There was a problem hiding this comment.
🧹 Nitpick (assertive)
Tighten spacing inside the list literal to appease YAML-lint
YAML-lint flags “too many spaces inside brackets”; remove the leading/trailing spaces to keep the workflow lint-clean.
- flutter-version: [ '3.24.3', '3.27.4', '3.29.3', '3.32.7' ]
+ flutter-version: ['3.24.3', '3.27.4', '3.29.3', '3.32.7']📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| flutter-version: [ '3.24.3', '3.27.4', '3.29.3', '3.32.7' ] | |
| flutter-version: ['3.24.3', '3.27.4', '3.29.3', '3.32.7'] |
🧰 Tools
🪛 YAMLlint (1.37.1)
[error] 11-11: too many spaces inside brackets
(brackets)
[error] 11-11: too many spaces inside brackets
(brackets)
🤖 Prompt for AI Agents
In .github/workflows/pr.yaml at line 11, the list assigned to flutter-version
has extra spaces inside the brackets which causes YAML-lint warnings. Remove the
spaces immediately inside the square brackets so the list items are tightly
enclosed without leading or trailing spaces, ensuring the YAML syntax is clean
and lint-compliant.
| fail-fast: false | ||
| matrix: | ||
| flutter-version: [ '3.24.3', '3.27.3' ] | ||
| flutter-version: [ '3.24.3', '3.27.4', '3.29.3', '3.32.7' ] |
There was a problem hiding this comment.
🧹 Nitpick (assertive)
Mirror the spacing fix here as well
Same lint complaint; same one-line change.
- flutter-version: [ '3.24.3', '3.27.4', '3.29.3', '3.32.7' ]
+ flutter-version: ['3.24.3', '3.27.4', '3.29.3', '3.32.7']📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| flutter-version: [ '3.24.3', '3.27.4', '3.29.3', '3.32.7' ] | |
| flutter-version: ['3.24.3', '3.27.4', '3.29.3', '3.32.7'] |
🧰 Tools
🪛 YAMLlint (1.37.1)
[error] 14-14: too many spaces inside brackets
(brackets)
[error] 14-14: too many spaces inside brackets
(brackets)
🤖 Prompt for AI Agents
In .github/workflows/post-merge.yaml at line 14, the spacing around the
flutter-version array needs to be consistent with the rest of the file to fix
the lint complaint. Adjust the spacing to match the expected format, ensuring
there are no extra spaces before or after the brackets and commas, mirroring the
spacing style used elsewhere in the workflow file.
* breaking: DuitDataSource (#32) * experiment - removing attribute support * wip * wip * wip * refacror ViewAttributes class * Added tests * wip * Added early exit from methods * Added new functions for handling JSON parsing results, improved default result return logic, and added table mapping for BlendMode and FloatingActionButtonLocation. * docs * add tests * Added tests * Removed static mapping tables for Clip, TextAlign, TextOverflow and TextWidthBasis in the DuitDataSource class. * Added new methods for JSON processing, including support for textDecorationStyle, fontWeight, fontStyle and other attributes. Improved logic for returning default values and added corresponding tests. * Added tests * Removed unused methods and added new functions to handle theme rules and image filters. Updated tests to check new features and JSON processing logic. * Upd .gitignore * wip * Upd tests, added Tween parser * Removed ventilation methods, added new functions for widget handling. Updated tests to check new features and JSON handling logic. * Refactored functions for creating InputBorder and ShapeBorder from a map, as well as corresponding lookup tables. Simplified logic for selecting the border type. * Added docs * upd actions config * wip * wip * Update test/theme_test.dart Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * clean dead code * fix * Update lib/src/view_attributes/lookup.dart Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Added export of Command.dart file to action_api and removed it from animation_api. Updated data references in DuitDataSource class to use new "stretchModes" key. Fixes to tests to match changes in step data. --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Remote commands API update (#33) * breaking: Themes refactoring (#34) * Registry API update: Added new RefWithTarget class, changed component initialization and registration functions, removed unused files, and improved export structure. Updated tests and removed deprecated topic tokens. * upd workflow * breaking: Reworking the widget model API and simplifying registration of custom widgets (#35) * Removed unused factory_record.dart file and updated component registration logic in DuitRegistry class, removed references to model factories. Updated factory getter methods to match new changes. * Small fix for tweens parser * rm unused API part * Update lib/src/registry_api/registry.dart Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * review fixes * fix --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Improve lootup tables for enums (#36) * Flutter types json encoding (#37) * Added encoding functions for: Duration, Size, EdgeInsets, TextStyle, Color, LinearGradient, BoxShadow, Offset, BoxDecoration, BorderRadius, Border, BorderSide, InputBorder, InputDecoration, VisualDensity, ScrollPhysics, ShapeBorder * wip * Added tests * Apply suggestions from code review Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Fix tests * Added docs * dart format --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * feat: action debounce and throttle configuration (#38) * Added execution options for actions: added ExecutionOptions class with throttle and debounce modifiers, updated ServerAction classes and their descendants to support the new options. Updated parsing methods and added corresponding lookup tables for execution modifiers. * - Added test - Refactor DuitDataSource methods with one-line return and fail-fast approach at lookup tables work * fix Color parsers behavior * refactoring: improved color handling in _colorFromList function Changed the typification function of the _colorFromList parameter from List<num> to List, added preprocessing of color data to ensure correct conversion. Updated the corresponding calls in the JSON parsing and processing methods in the DuitDataSource class. * feat: Fragments registration in DuitRegistry (#39) Added a new static method registerFragment for registering fragments by key and a method getFragment for receiving a fragment by key with logging in case of absence. Also added an internal registry of fragments _fragmentRegistry. * Component system refactor (#40) * Components refactoring via JSON patching instead of Map mutation * Added tests for json patching and components patches generation * Review fixes * Upd lookup table for Curves * Remover legacy API references * feat: DuitDataSource methods extension (#41) * Extend parser for BorderRadius type, added Radius type parsing, upd tests * fix tests * Added new Size parsing behavior * wip * feat: Custom json reviver (#42) * Refactor env variables, refactor analysis issues in test files, added FlutterPropertyKeys class * wip * wip * wip * Fixed analysis issues * wip * Fixed getActionDependencies and childObjects methods * Upd env variables keys * Code review fixes * Fix test * Upd post-merge workflow
Registry API update:
Summary by CodeRabbit
Refactor
Tests
Chores