Skip to content

breaking: Themes refactoring#34

Merged
lesleysin merged 2 commits into
v4from
themes-rework
Jul 20, 2025
Merged

breaking: Themes refactoring#34
lesleysin merged 2 commits into
v4from
themes-rework

Conversation

@lesleysin

@lesleysin lesleysin commented Jul 17, 2025

Copy link
Copy Markdown
Member

Registry API update:

  • Replaced RefWithTarget class
  • Changed component initialization and registration functions
  • Removed unused files
  • Improved export structure
  • Updated tests and removed deprecated topic tokens.

Summary by CodeRabbit

  • Refactor

    • Simplified theme initialization by removing asynchronous theme loading and related error handling.
    • Streamlined theme token system, retaining only base and generic token implementations.
    • Consolidated and updated export statements for improved API clarity.
    • Updated theme preprocessing to use an abstract token creation method.
  • Tests

    • Removed theme-related test suites and custom theme token test classes.
  • Chores

    • Deleted obsolete theme loader classes and associated exports.
    • Expanded Flutter versions tested in GitHub Actions workflows for broader coverage.

… initialization and registration functions, removed unused files, and improved export structure. Updated tests and removed deprecated topic tokens.
@lesleysin lesleysin self-assigned this Jul 17, 2025
@coderabbitai

coderabbitai Bot commented Jul 17, 2025

Copy link
Copy Markdown

Walkthrough

The 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

File(s) Change Summary
lib/src/registry_api/components/index.dart Added export for reference_target.dart.
lib/src/registry_api/index.dart Removed direct export of reference_target.dart; updated components export to include RefWithTarget.
lib/src/registry_api/registry.dart Simplified theme initialization: removed async loader, renamed configure to initialize, updated signature.
lib/src/ui/theme/index.dart Removed export of theme_loader.dart.
lib/src/ui/theme/preprocessor.dart Renamed typedef, made ThemePreprocessor abstract, made createToken abstract and public.
lib/src/ui/theme/theme_loader.dart Deleted file; removed AssetThemeLoader and StaticThemeLoader classes.
lib/src/ui/theme/theme_token.dart Removed all specialized ThemeToken subclasses and related constants; kept only base and generic tokens.
lib/src/view_attributes/view_attribute.dart Renamed local variable ds to source in factory constructor.
test/misc.dart, test/theme_test.dart Deleted test files for theme tokens and theme system.
.github/workflows/post-merge.yaml Expanded Flutter versions tested in matrix from 2 to 4, updating and adding versions.
.github/workflows/pr.yaml Expanded Flutter versions tested in matrix from 2 to 4, updating and adding versions.

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
Loading
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
Loading

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f4de132 and 610404d.

📒 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.dart export 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.dart with an explicit show clause 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 ds to source makes 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 CustomTokenizer to TokenizationCallback is more descriptive and follows better naming conventions.


9-21: Good architectural improvement with abstract class design.

Converting ThemePreprocessor to an abstract class and making createToken abstract 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 configure to initialize for better clarity
  • Removing complex asynchronous theme loading in favor of direct theme assignment
  • Simplifying the theme parameter from a loader to a direct DuitTheme instance

This makes the initialization process more straightforward and easier to understand.

Comment on lines +15 to 19
static FutureOr<void> initialize({
DebugLogger? logger,
ResourceLoader<DuitTheme>? themeLoader,
DuitTheme? theme,
ComponentRegistry? componentRegistry,
}) async {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 610404d and 63ed53f.

📒 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 from subosito/flutter-action
3.29.3 and 3.32.7 look 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.

Comment thread .github/workflows/pr.yaml
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' ]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 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.

Suggested 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']
🧰 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' ]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 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.

Suggested 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']
🧰 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.

@lesleysin
lesleysin merged commit 2a7e4d0 into v4 Jul 20, 2025
5 checks passed
@lesleysin
lesleysin deleted the themes-rework branch July 20, 2025 12:47
@coderabbitai coderabbitai Bot mentioned this pull request Aug 3, 2025
lesleysin added a commit that referenced this pull request Nov 5, 2025
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant