-
Notifications
You must be signed in to change notification settings - Fork 2
breaking: DuitDataSource #32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…lt result return logic, and added table mapping for BlendMode and FloatingActionButtonLocation.
…extWidthBasis in the DuitDataSource class.
…rationStyle, fontWeight, fontStyle and other attributes. Improved logic for returning default values and added corresponding tests.
…and image filters. Updated tests to check new features and JSON processing logic.
… Updated tests to check new features and JSON handling logic.
…map, as well as corresponding lookup tables. Simplified logic for selecting the border type.
WalkthroughThis update removes the generic attribute parsing and attribute interface system, consolidating attribute handling around the Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant ViewAttribute
participant DuitRegistry
participant DuitDataSource
Client->>ViewAttribute: from(type, json, id, tag)
ViewAttribute->>DuitRegistry: theme (for tag/type)
DuitRegistry-->>ViewAttribute: theme token (optional)
ViewAttribute->>DuitDataSource: (wraps payload map)
ViewAttribute-->>Client: ViewAttribute instance (with DuitDataSource payload)
sequenceDiagram
participant EventFactory
participant DuitDataSource
EventFactory->>DuitDataSource: fromJson(json)
DuitDataSource-->>EventFactory: getString/getMap/getDuration, etc.
EventFactory-->>EventFactory: Construct event instance with extracted fields
sequenceDiagram
participant ActionFactory
participant DuitDataSource
ActionFactory->>DuitDataSource: fromJson(json)
DuitDataSource-->>ActionFactory: getString/getActionDependencies, etc.
ActionFactory-->>ActionFactory: Construct action instance with extracted fields
🪧 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 17
🔭 Outside diff range comments (3)
lib/src/ui/tree_element.dart (1)
11-12: Update documentation to reflect removed generic parameter.The documentation still references the removed generic type parameter
T. This needs to be updated to reflect the current non-generic implementation.-/// Type parameter: -/// - [T]: The type of the data associated with the `UIElementController` and `ViewAttribute`.test/misc.dart (1)
39-39: Fix typo in class name.The class name contains a grammatical error.
-final class OverridedTextThemeToken extends ThemeToken { +final class OverriddenTextThemeToken extends ThemeToken {lib/src/view_attributes/view_attribute.dart (1)
87-142: Refactor deprecated method to avoid code duplication.The deprecated
createAttributesmethod contains duplicate theme application logic. Consider refactoring it to delegate to the newfromfactory method.@Deprecated("Use .from instead") static ViewAttribute createAttributes( String type, Map<String, dynamic>? json, String? tag, { String? id, }) { assert(json != null); assert(id != null); - - final ignoreTheme = json!["ignoreTheme"] ?? false; - var value = json; - - if (!ignoreTheme) { - final themeKey = json["theme"] as String?; - final overrideRule = ThemeOverrideRule.fromString(json["overrideRule"]); - - if (themeKey != null) { - ThemeToken token; - - if (tag != null) { - token = DuitRegistry.theme.getToken( - themeKey, - tag, - ); - } else { - token = DuitRegistry.theme.getToken( - themeKey, - type, - ); - } - - if (token is UnknownThemeToken) { - return ViewAttribute._( - id: id!, - payload: Map<String, dynamic>.from(value), - ); - } - - if (overrideRule == ThemeOverrideRule.themeOverlay) { - value = { - ...token.widgetTheme, - ...value, - }; - } else { - value.addAll( - token.widgetTheme, - ); - } - } - } - - return ViewAttribute._( - id: id!, - payload: Map<String, dynamic>.from(value), - ); + return ViewAttribute.from(type, json!, id!, tag: tag); }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (22)
.gitignore(1 hunks)lib/src/action_api/event.dart(2 hunks)lib/src/animation_api/index.dart(1 hunks)lib/src/animation_api/tween.dart(1 hunks)lib/src/animation_api/tween_description.dart(1 hunks)lib/src/driver_api/ui_controller.dart(3 hunks)lib/src/misc/annotations.dart(1 hunks)lib/src/misc/index.dart(1 hunks)lib/src/registry_api/attributes_factory.dart(0 hunks)lib/src/registry_api/factory_record.dart(0 hunks)lib/src/registry_api/index.dart(0 hunks)lib/src/registry_api/registry.dart(0 hunks)lib/src/ui/theme/theme_override_rule.dart(0 hunks)lib/src/ui/tree_element.dart(1 hunks)lib/src/view_attributes/attribute_parser.dart(0 hunks)lib/src/view_attributes/attributes.dart(0 hunks)lib/src/view_attributes/index.dart(1 hunks)lib/src/view_attributes/lookup.dart(1 hunks)lib/src/view_attributes/view_attribute.dart(3 hunks)pubspec.yaml(1 hunks)test/misc.dart(1 hunks)test/theme_test.dart(6 hunks)
💤 Files with no reviewable changes (7)
- lib/src/registry_api/index.dart
- lib/src/registry_api/factory_record.dart
- lib/src/ui/theme/theme_override_rule.dart
- lib/src/view_attributes/attributes.dart
- lib/src/registry_api/attributes_factory.dart
- lib/src/view_attributes/attribute_parser.dart
- lib/src/registry_api/registry.dart
🔇 Additional comments (11)
lib/src/animation_api/index.dart (1)
6-7: LGTM: Clean API expansion.The new exports properly expand the animation API with tween functionality while maintaining consistency with the existing export pattern.
lib/src/view_attributes/index.dart (1)
2-2: LGTM: API refactoring in progress.The addition of the
data_source.dartexport aligns with the attribute handling refactoring mentioned in the AI summary. The export follows the existing pattern.test/theme_test.dart (3)
68-78: API change looks consistent.The test method call has been properly updated to match the new ViewAttribute API signature.
89-99: API change looks consistent.The test method call has been properly updated to match the new ViewAttribute API signature.
50-58: Verified: All ViewAttribute.createAttributes calls use the new signatureA project-wide search confirmed every invocation—including the three in
test/theme_test.dart—now includes theidparameter and omits the generic type. No legacy signatures remain.lib/src/ui/tree_element.dart (2)
24-24: LGTM: Generic parameter removal is clean.The removal of the generic type parameter aligns with the broader type system simplification mentioned in the AI summary.
29-30: LGTM: Property types updated consistently.The property types have been properly updated to match the non-generic class definition.
lib/src/action_api/event.dart (1)
18-18: Good optimization with const constructor.Making the
ServerEventconstructorconstenables compile-time optimizations.lib/src/animation_api/tween_description.dart (1)
79-83: Good validation for group tweens.The assertions properly validate that group tweens have the required structure.
lib/src/view_attributes/view_attribute.dart (1)
24-69: Well-structured theme handling implementation.The new
fromfactory constructor properly handles theme token application with clear logic for theme overlays and fallbacks.lib/src/view_attributes/lookup.dart (1)
1-2: Verify thatdata_source.dartre-exports Flutter typesThis part file relies on many Flutter classes (
TextAlign,Curves, …) but has no imports itself.
Please make suredata_source.dart, the library file, includesimport 'package:flutter/material.dart'; import 'dart:ui';or equivalent; otherwise the build will fail.
There was a problem hiding this comment.
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
📒 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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🔭 Outside diff range comments (2)
lib/src/view_attributes/view_attribute.dart (1)
87-143: Remove deprecated method to eliminate code duplication.The deprecated
createAttributesmethod contains logic that duplicates the newfromfactory constructor. Since it's already marked as deprecated, consider removing it entirely to reduce maintenance burden and avoid inconsistencies.If immediate removal isn't feasible, simplify it to delegate to the new method:
- @Deprecated("Use .from instead") - static ViewAttribute createAttributes( - String type, - Map<String, dynamic>? json, - String? tag, { - String? id, - }) { - assert(json != null); - assert(id != null); - - final ignoreTheme = json!["ignoreTheme"] ?? false; - var value = json; - - if (!ignoreTheme) { - final themeKey = json["theme"] as String?; - final overrideRule = ThemeOverrideRule.fromString(json["overrideRule"]); - - if (themeKey != null) { - ThemeToken token; - - if (tag != null) { - token = DuitRegistry.theme.getToken( - themeKey, - tag, - ); - } else { - token = DuitRegistry.theme.getToken( - themeKey, - type, - ); - } - - if (token is UnknownThemeToken) { - return ViewAttribute._( - id: id!, - payload: Map<String, dynamic>.from(value), - ); - } - - if (overrideRule == ThemeOverrideRule.themeOverlay) { - value = { - ...token.widgetTheme, - ...value, - }; - } else { - value.addAll( - token.widgetTheme, - ); - } - } - } - - return ViewAttribute._( - id: id!, - payload: Map<String, dynamic>.from(value), - ); - } + @Deprecated("Use .from instead") + static ViewAttribute createAttributes( + String type, + Map<String, dynamic>? json, + String? tag, { + String? id, + }) { + assert(json != null); + assert(id != null); + return ViewAttribute.from(type, json!, id!, tag: tag); + }lib/src/action_api/action_parser.dart (1)
5-6: Update documentation to reflect DuitDataSource usage.The documentation still references
ServerActionJsonViewwhich has been replaced withDuitDataSource.-/// It uses a [ServerActionJsonView] to parse the JSON map into a concrete action -/// object based on the [ExecutionType] of the action. +/// It uses a [DuitDataSource] to parse the JSON map into a concrete action +/// object based on the [ExecutionType] of the action.
♻️ Duplicate comments (2)
lib/src/animation_api/tween_description.dart (1)
1-437: Past review comments appear outdated.The previous review comments mention a typo ("forvard" → "forward") and a large
fromJsonmethod that don't exist in the current implementation. These comments seem to reference an earlier version of the file.lib/src/view_attributes/view_attribute.dart (1)
75-80: Remove commented-out code.The
cast<R>()method is commented out. Remove it entirely if this functionality is no longer needed.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (11)
lib/src/action_api/action.dart(2 hunks)lib/src/action_api/action_parser.dart(1 hunks)lib/src/action_api/event.dart(8 hunks)lib/src/action_api/index.dart(0 hunks)lib/src/action_api/server_action_view.dart(0 hunks)lib/src/animation_api/index.dart(1 hunks)lib/src/animation_api/tween_description.dart(1 hunks)lib/src/animation_api/tween_type.dart(1 hunks)lib/src/driver_api/dependency.dart(0 hunks)lib/src/driver_api/script_def.dart(0 hunks)lib/src/view_attributes/view_attribute.dart(3 hunks)
💤 Files with no reviewable changes (4)
- lib/src/action_api/index.dart
- lib/src/driver_api/dependency.dart
- lib/src/driver_api/script_def.dart
- lib/src/action_api/server_action_view.dart
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: test (3.27.3)
🔇 Additional comments (7)
lib/src/animation_api/tween_type.dart (1)
1-12: Well-structured enum for tween type categorization.The
TweenTypeenum provides a clear categorization of different animation types. The naming convention is consistent and the values align well with Flutter's built-in tween types.lib/src/animation_api/index.dart (1)
6-7: Appropriate exports for new animation API components.The new export statements properly expose the tween description system and tween type enum, making them available as part of the public animation API.
lib/src/animation_api/tween_description.dart (2)
1-67: Excellent base class design with comprehensive documentation.The
DuitTweenDescription<T>base class provides a solid foundation for the animation system. The generic type parameter, thorough documentation, and practical examples make this highly usable and maintainable.
151-437: Consistent and well-documented specialized tween classes.All the specialized tween description classes follow a consistent pattern and provide excellent documentation with practical examples. The use of
final classappropriately prevents further inheritance where not needed.lib/src/action_api/action.dart (2)
105-113: LGTM!The migration to
DuitDataSourcefor JSON parsing is correctly implemented.
133-140: LGTM!The migration to
DuitDataSourceis consistent with the rest of the codebase.lib/src/action_api/event.dart (1)
48-51: LGTM!Good defensive programming with the null-safe default for missing updates.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
|
bugbot run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ BugBot reviewed your changes and found no bugs!
BugBot free trial expires on July 22, 2025
You have used $0.00 of your $50.00 spend limit so far. Manage your spend limit in the Cursor dashboard.
Was this report helpful? Give feedback by reacting with 👍 or 👎
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
♻️ Duplicate comments (2)
lib/src/animation_api/tween_description.dart (1)
125-130: Add documentation for placeholder values in TweenDescriptionGroup constructor.The constructor uses placeholder values (
""foranimatedPropKey,nullforbegin/end, andCurves.linearforcurve) since groups don't animate specific properties directly. This design choice should be documented to clarify the intent for future maintainers.) : super( + // Placeholder values since groups don't animate specific properties animatedPropKey: "", end: null, begin: null, curve: Curves.linear, );lib/src/view_attributes/lookup.dart (1)
1143-1150: String keys use PascalCase while other tables use camelCase.The shape-border lookup table uses
"RoundedRectangleBorder"etc., which is inconsistent with the camelCase pattern used throughout the rest of the file. Either update the keys to camelCase to maintain consistency with other lookup tables, or document this intentional deviation clearly.const _shapeBorderTypeStringLookupTable = <String, ShapeBorder Function(Map<String, dynamic> value)>{ - "RoundedRectangleBorder": DuitDataSource._roundedRectangleBorderFromMap, - "CircleBorder": DuitDataSource._circleBorderFromMap, - "StadiumBorder": DuitDataSource._stadiumBorderFromMap, - "BeveledRectangleBorder": DuitDataSource._beveledRectangleBorderFromMap, - "ContinuousRectangleBorder": DuitDataSource._continuousRectangleBorderFromMap, + "roundedRectangleBorder": DuitDataSource._roundedRectangleBorderFromMap, + "circleBorder": DuitDataSource._circleBorderFromMap, + "stadiumBorder": DuitDataSource._stadiumBorderFromMap, + "beveledRectangleBorder": DuitDataSource._beveledRectangleBorderFromMap, + "continuousRectangleBorder": DuitDataSource._continuousRectangleBorderFromMap,
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (3)
lib/src/animation_api/tween_description.dart(1 hunks)lib/src/view_attributes/lookup.dart(1 hunks)test/misc.dart(0 hunks)
💤 Files with no reviewable changes (1)
- test/misc.dart
🔇 Additional comments (1)
lib/src/view_attributes/lookup.dart (1)
1-1151: Excellent centralized approach to enum mappings.This file provides a comprehensive and well-organized centralized location for Flutter enum mappings. The consistent pattern of providing both integer and string lookup tables offers good flexibility for different data sources, and the extensive documentation makes the supported values clear for each enum type.
| final class TweenDescription extends DuitTweenDescription<double> { | ||
| /// Creates a new tween description for double-based animations. | ||
| TweenDescription({ | ||
| required super.animatedPropKey, | ||
| required super.duration, | ||
| required super.begin, | ||
| required super.end, | ||
| required super.curve, | ||
| required super.trigger, | ||
| required super.method, | ||
| required super.reverseOnRepeat, | ||
| super.interval, | ||
| }); | ||
| } | ||
|
|
||
| /// Description for a [ColorTween] animation that animates between Color values. | ||
| /// | ||
| /// This class is used for animating color properties such as background color, | ||
| /// text color, border color, and other color-based values. | ||
| /// | ||
| /// Example usage: | ||
| /// ```dart | ||
| /// final colorTween = ColorTweenDescription( | ||
| /// animatedPropKey: 'backgroundColor', | ||
| /// duration: Duration(milliseconds: 300), | ||
| /// begin: Colors.red, | ||
| /// end: Colors.blue, | ||
| /// curve: Curves.easeInOut, | ||
| /// trigger: AnimationTrigger.onHover, | ||
| /// method: AnimationMethod.forward, | ||
| /// reverseOnRepeat: true, | ||
| /// ); | ||
| /// ``` | ||
| final class ColorTweenDescription extends DuitTweenDescription<Color> { | ||
| /// Creates a new color tween description. | ||
| ColorTweenDescription({ | ||
| required super.animatedPropKey, | ||
| required super.duration, | ||
| required super.begin, | ||
| required super.end, | ||
| required super.curve, | ||
| required super.trigger, | ||
| required super.method, | ||
| required super.reverseOnRepeat, | ||
| super.interval, | ||
| }); | ||
| } | ||
|
|
||
| /// Description for a [TextStyleTween] animation that animates between TextStyle values. | ||
| /// | ||
| /// This class is used for animating text style properties such as font size, | ||
| /// font weight, color, and other text-related styling. | ||
| /// | ||
| /// Example usage: | ||
| /// ```dart | ||
| /// final textStyleTween = TextStyleTweenDescription( | ||
| /// animatedPropKey: 'textStyle', | ||
| /// duration: Duration(milliseconds: 400), | ||
| /// begin: TextStyle(fontSize: 14, color: Colors.black), | ||
| /// end: TextStyle(fontSize: 18, color: Colors.blue, fontWeight: FontWeight.bold), | ||
| /// curve: Curves.easeInOut, | ||
| /// trigger: AnimationTrigger.onFocus, | ||
| /// method: AnimationMethod.forward, | ||
| /// reverseOnRepeat: false, | ||
| /// ); | ||
| /// ``` | ||
| final class TextStyleTweenDescription extends DuitTweenDescription<TextStyle> { | ||
| /// Creates a new text style tween description. | ||
| TextStyleTweenDescription({ | ||
| required super.animatedPropKey, | ||
| required super.duration, | ||
| required super.begin, | ||
| required super.end, | ||
| required super.curve, | ||
| required super.trigger, | ||
| required super.method, | ||
| required super.reverseOnRepeat, | ||
| super.interval, | ||
| }); | ||
| } | ||
|
|
||
| /// Description for a [DecorationTween] animation that animates between Decoration values. | ||
| /// | ||
| /// This class is used for animating decoration properties such as borders, | ||
| /// backgrounds, shadows, and other decorative elements. | ||
| /// | ||
| /// Example usage: | ||
| /// ```dart | ||
| /// final decorationTween = DecorationTweenDescription( | ||
| /// animatedPropKey: 'decoration', | ||
| /// duration: Duration(milliseconds: 600), | ||
| /// begin: BoxDecoration( | ||
| /// color: Colors.white, | ||
| /// borderRadius: BorderRadius.circular(8), | ||
| /// ), | ||
| /// end: BoxDecoration( | ||
| /// color: Colors.blue, | ||
| /// borderRadius: BorderRadius.circular(20), | ||
| /// boxShadow: [BoxShadow(color: Colors.black26, blurRadius: 10)], | ||
| /// ), | ||
| /// curve: Curves.easeInOut, | ||
| /// trigger: AnimationTrigger.onTap, | ||
| /// method: AnimationMethod.forward, | ||
| /// reverseOnRepeat: true, | ||
| /// ); | ||
| /// ``` | ||
| final class DecorationTweenDescription | ||
| extends DuitTweenDescription<Decoration> { | ||
| /// Creates a new decoration tween description. | ||
| DecorationTweenDescription({ | ||
| required super.animatedPropKey, | ||
| required super.duration, | ||
| required super.begin, | ||
| required super.end, | ||
| required super.curve, | ||
| required super.trigger, | ||
| required super.method, | ||
| required super.reverseOnRepeat, | ||
| super.interval, | ||
| }); | ||
| } | ||
|
|
||
| /// Description for an [AlignmentTween] animation that animates between AlignmentGeometry values. | ||
| /// | ||
| /// This class is used for animating alignment properties such as positioning | ||
| /// of widgets within their containers. | ||
| /// | ||
| /// Example usage: | ||
| /// ```dart | ||
| /// final alignmentTween = AlignmentTweenDescription( | ||
| /// animatedPropKey: 'alignment', | ||
| /// duration: Duration(milliseconds: 500), | ||
| /// begin: Alignment.topLeft, | ||
| /// end: Alignment.bottomRight, | ||
| /// curve: Curves.easeInOut, | ||
| /// trigger: AnimationTrigger.onTap, | ||
| /// method: AnimationMethod.forward, | ||
| /// reverseOnRepeat: true, | ||
| /// ); | ||
| /// ``` | ||
| final class AlignmentTweenDescription | ||
| extends DuitTweenDescription<AlignmentGeometry> { | ||
| /// Creates a new alignment tween description. | ||
| AlignmentTweenDescription({ | ||
| required super.animatedPropKey, | ||
| required super.duration, | ||
| required super.begin, | ||
| required super.end, | ||
| required super.curve, | ||
| required super.trigger, | ||
| required super.method, | ||
| required super.reverseOnRepeat, | ||
| super.interval, | ||
| }); | ||
| } | ||
|
|
||
| /// Description for an [EdgeInsetsTween] animation that animates between EdgeInsetsGeometry values. | ||
| /// | ||
| /// This class is used for animating padding and margin properties. | ||
| /// | ||
| /// Example usage: | ||
| /// ```dart | ||
| /// final edgeInsetsTween = EdgeInsetsTweenDescription( | ||
| /// animatedPropKey: 'padding', | ||
| /// duration: Duration(milliseconds: 300), | ||
| /// begin: EdgeInsets.all(8), | ||
| /// end: EdgeInsets.all(16), | ||
| /// curve: Curves.easeInOut, | ||
| /// trigger: AnimationTrigger.onHover, | ||
| /// method: AnimationMethod.forward, | ||
| /// reverseOnRepeat: true, | ||
| /// ); | ||
| /// ``` | ||
| final class EdgeInsetsTweenDescription | ||
| extends DuitTweenDescription<EdgeInsetsGeometry> { | ||
| /// Creates a new edge insets tween description. | ||
| EdgeInsetsTweenDescription({ | ||
| required super.animatedPropKey, | ||
| required super.duration, | ||
| required super.begin, | ||
| required super.end, | ||
| required super.curve, | ||
| required super.trigger, | ||
| required super.method, | ||
| required super.reverseOnRepeat, | ||
| super.interval, | ||
| }); | ||
| } | ||
|
|
||
| /// Description for a [BoxConstraintsTween] animation that animates between BoxConstraints values. | ||
| /// | ||
| /// This class is used for animating constraint properties such as minimum and maximum | ||
| /// width and height of widgets. | ||
| /// | ||
| /// Example usage: | ||
| /// ```dart | ||
| /// final boxConstraintsTween = BoxConstraintsTweenDescription( | ||
| /// animatedPropKey: 'constraints', | ||
| /// duration: Duration(milliseconds: 400), | ||
| /// begin: BoxConstraints(minWidth: 100, minHeight: 50), | ||
| /// end: BoxConstraints(minWidth: 200, minHeight: 100), | ||
| /// curve: Curves.easeInOut, | ||
| /// trigger: AnimationTrigger.onTap, | ||
| /// method: AnimationMethod.forward, | ||
| /// reverseOnRepeat: false, | ||
| /// ); | ||
| /// ``` | ||
| final class BoxConstraintsTweenDescription | ||
| extends DuitTweenDescription<BoxConstraints> { | ||
| /// Creates a new box constraints tween description. | ||
| BoxConstraintsTweenDescription({ | ||
| required super.animatedPropKey, | ||
| required super.duration, | ||
| required super.begin, | ||
| required super.end, | ||
| required super.curve, | ||
| required super.trigger, | ||
| required super.method, | ||
| required super.reverseOnRepeat, | ||
| super.interval, | ||
| }); | ||
| } | ||
|
|
||
| /// Description for a [SizeTween] animation that animates between Size values. | ||
| /// | ||
| /// This class is used for animating size properties of widgets. | ||
| /// | ||
| /// Example usage: | ||
| /// ```dart | ||
| /// final sizeTween = SizeTweenDescription( | ||
| /// animatedPropKey: 'size', | ||
| /// duration: Duration(milliseconds: 500), | ||
| /// begin: Size(100, 50), | ||
| /// end: Size(200, 100), | ||
| /// curve: Curves.easeInOut, | ||
| /// trigger: AnimationTrigger.onTap, | ||
| /// method: AnimationMethod.forward, | ||
| /// reverseOnRepeat: true, | ||
| /// ); | ||
| /// ``` | ||
| final class SizeTweenDescription extends DuitTweenDescription<Size> { | ||
| /// Creates a new size tween description. | ||
| SizeTweenDescription({ | ||
| required super.animatedPropKey, | ||
| required super.duration, | ||
| required super.begin, | ||
| required super.end, | ||
| required super.curve, | ||
| required super.trigger, | ||
| required super.method, | ||
| required super.reverseOnRepeat, | ||
| super.interval, | ||
| }); | ||
| } | ||
|
|
||
| /// Description for a [BorderTween] animation that animates between Border values. | ||
| /// | ||
| /// This class is used for animating border properties such as border width, | ||
| /// border color, and border style. | ||
| /// | ||
| /// Example usage: | ||
| /// ```dart | ||
| /// final borderTween = BorderTweenDescription( | ||
| /// animatedPropKey: 'border', | ||
| /// duration: Duration(milliseconds: 300), | ||
| /// begin: Border.all(color: Colors.grey, width: 1), | ||
| /// end: Border.all(color: Colors.blue, width: 3), | ||
| /// curve: Curves.easeInOut, | ||
| /// trigger: AnimationTrigger.onFocus, | ||
| /// method: AnimationMethod.forward, | ||
| /// reverseOnRepeat: false, | ||
| /// ); | ||
| /// ``` | ||
| final class BorderTweenDescription extends DuitTweenDescription<Border> { | ||
| /// Creates a new border tween description. | ||
| BorderTweenDescription({ | ||
| required super.animatedPropKey, | ||
| required super.duration, | ||
| required super.begin, | ||
| required super.end, | ||
| required super.curve, | ||
| required super.trigger, | ||
| required super.method, | ||
| required super.reverseOnRepeat, | ||
| super.interval, | ||
| }); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
Consider reducing code duplication in tween description classes.
The specific tween description classes (TweenDescription, ColorTweenDescription, etc.) follow an identical pattern with only the generic type parameter changing. While the current explicit approach provides excellent type safety and developer experience, consider if a factory method or builder pattern could reduce the repetitive boilerplate code.
Example approach:
// Factory method approach
static TweenDescription<T> create<T>({
required String animatedPropKey,
required Duration duration,
required T begin,
required T end,
// ... other parameters
}) => TweenDescription<T>(...);However, keep the current approach if explicit typing and clear class names are prioritized for API clarity.
🤖 Prompt for AI Agents
In lib/src/animation_api/tween_description.dart from lines 151 to 437, the
multiple tween description classes have repetitive constructors differing only
by their generic type. To reduce duplication, consider implementing a generic
factory method or builder pattern that takes the generic type as a parameter and
returns the appropriate tween description instance. This will centralize the
construction logic and eliminate boilerplate while preserving type safety.
However, if explicit class names and clear API readability are more important,
you may keep the current explicit class definitions.
| /// Lookup table for [FloatingActionButtonLocation] values by [int] type key. | ||
| /// | ||
| /// Maps integer identifiers to [FloatingActionButtonLocation] values for FAB location. | ||
| /// Supported values: 0-17 (см. порядок FloatingActionButtonLocation). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
Replace non-English text in documentation.
The comment contains Russian text that should be translated to English for consistency and accessibility.
-/// Supported values: 0-17 (см. порядок FloatingActionButtonLocation).
+/// Supported values: 0-17 (see FloatingActionButtonLocation enum order).📝 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.
| /// Supported values: 0-17 (см. порядок FloatingActionButtonLocation). | |
| /// Supported values: 0-17 (see FloatingActionButtonLocation enum order). |
🤖 Prompt for AI Agents
In lib/src/view_attributes/lookup.dart at line 927, the comment contains Russian
text "см. порядок FloatingActionButtonLocation" which should be translated to
English. Replace the Russian phrase with its English equivalent, such as "see
the order of FloatingActionButtonLocation," to maintain consistency and
accessibility in the documentation.
| /// Lookup table for [BlendMode] values by [int] type key. | ||
| /// | ||
| /// Maps integer identifiers to [BlendMode] enum values for blend mode. | ||
| /// Supported values: 0-28 (см. порядок BlendMode). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
Replace non-English text in documentation.
The comment contains Russian text that should be translated to English for consistency and accessibility.
-/// Supported values: 0-28 (см. порядок BlendMode).
+/// Supported values: 0-28 (see BlendMode enum order).📝 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.
| /// Supported values: 0-28 (см. порядок BlendMode). | |
| /// Supported values: 0-28 (see BlendMode enum order). |
🤖 Prompt for AI Agents
In lib/src/view_attributes/lookup.dart at line 696, replace the Russian text
"см. порядок BlendMode" in the comment with its English equivalent, such as "see
the order of BlendMode," to ensure the documentation is fully in English and
accessible to all developers.
…nimation_api. Updated data references in DuitDataSource class to use new "stretchModes" key. Fixes to tests to match changes in step data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
♻️ Duplicate comments (2)
lib/src/driver_api/ui_controller.dart (2)
15-15: Breaking change: ViewAttribute no longer generic.The change from
ViewAttribute<T>to non-genericViewAttributeis consistent with the removal of generic type parameters across the codebase. This simplification aligns with the introduction ofDuitDataSourcefor attribute handling.
71-71: Breaking change: updateState parameter type simplified.The change from
ViewAttribute<T>toMap<String, dynamic>simplifies the state update mechanism and is consistent with the removal of generic type parameters. This change makes the API more straightforward to use.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (4)
lib/src/action_api/index.dart(1 hunks)lib/src/animation_api/command.dart(0 hunks)lib/src/animation_api/index.dart(1 hunks)lib/src/driver_api/ui_controller.dart(4 hunks)
💤 Files with no reviewable changes (1)
- lib/src/animation_api/command.dart
🔇 Additional comments (3)
lib/src/animation_api/index.dart (1)
5-6: Approve export changes
- Verified existence of new exports:
- lib/src/animation_api/tween_description.dart
- lib/src/animation_api/tween_type.dart
- These exports align with the architectural refactor: animation API now focuses on tween descriptions, while command functionality resides in the action API.
LGTM.
lib/src/driver_api/ui_controller.dart (2)
90-106: Command handling methods updated consistently.The updates to
listenCommandandemitCommandmethods to handleRemoteCommandinstead ofAnimationCommandare implemented consistently:
- Method signatures correctly use
RemoteCommand- Documentation comments updated to reflect the new command type
- The functionality remains the same with the new command type
49-49: RemoteCommand import verified via public API barrelImporting
package:duit_kernel/duit_kernel.dartbrings inRemoteCommand(re-exported fromaction_api/index.dart), so no additional imports are needed.
| export 'server_action_view.dart'; | ||
| export 'event_parser.dart'; | ||
| export 'action_parser.dart'; | ||
| export 'command.dart'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Verify the new export and ensure breaking changes are handled properly.
The addition of command.dart export aligns with the architectural shift mentioned in the PR summary. However, since this is a breaking change that replaces the previous server_action_view.dart export, please ensure:
- The
command.dartfile exists and contains the expectedRemoteCommandclass - All consumers of the previous
ServerActionJsonViewextension have been updated to use the new command system - Documentation or migration guides are provided for the breaking changes
🏁 Script executed:
#!/bin/bash
# Verify the command.dart file exists and contains expected exports
if [ -f "lib/src/action_api/command.dart" ]; then
echo "✓ command.dart file exists"
echo "--- Content of command.dart ---"
cat lib/src/action_api/command.dart
else
echo "✗ command.dart file does not exist"
fi
# Search for any remaining references to ServerActionJsonView
echo "--- Searching for ServerActionJsonView references ---"
rg "ServerActionJsonView" --type dart
# Search for usages of the old server_action_view import
echo "--- Searching for server_action_view import references ---"
rg "server_action_view" --type dartLength of output: 1073
Remove remaining ServerActionJsonView dependency in the parser
The new command.dart export is correct and the file contains the RemoteCommand definition. However, there is still a reference to the old ServerActionJsonView in the codebase:
• lib/src/action_api/action_parser.dart
• Line containing "ServerActionJsonView" – update this to use the new command-based parsing approach (e.g. map JSON to RemoteCommand instances).
Please refactor the parser to eliminate the old JSON-view extension and ensure all consumers are updated to the new command system. Also verify that any migration docs or examples are updated to guide users through this breaking change.
🤖 Prompt for AI Agents
In lib/src/action_api/index.dart at line 8, you have correctly exported
command.dart which contains RemoteCommand, but the old ServerActionJsonView is
still referenced in lib/src/action_api/action_parser.dart. Locate the line
referencing ServerActionJsonView in action_parser.dart and refactor it to parse
JSON directly into RemoteCommand instances instead. Remove all dependencies on
ServerActionJsonView and update any related migration documentation or examples
to reflect this change to the new command-based parsing system.
| /// This class serves as the base class for all ViewController objects in your application. | ||
| /// It provides common properties and methods that can be used by subclasses. | ||
| abstract interface class UIElementController<T> { | ||
| abstract interface class UIElementController { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Breaking change: Generic type parameter removed.
The removal of the generic type parameter <T> from UIElementController is a breaking change that simplifies the API. This change is consistent with the broader refactor to remove generic constraints from the attribute system.
Ensure this breaking change is documented in your CHANGELOG.md and migration guide.
🏁 Script executed:
#!/bin/bash
# Check for documentation of breaking changes
fd -t f "CHANGELOG.md" .
fd -t f "MIGRATION.md" .
rg -i "breaking" CHANGELOG.md || echo "No breaking changes documented in CHANGELOG.md"Length of output: 197
Document Breaking Changes for UIController API
The removal of generics from UIElementController (and related types) is intentional but currently undocumented.
Tasks:
- Update CHANGELOG.md:
- Under “Unreleased” (or next version), add a Breaking Changes section listing:
UIElementController<T>→UIElementController(no generics)ViewAttribute<T>→ViewAttribute(no generics)StreamController<AnimationCommand>→StreamController<RemoteCommand>updateState(ViewAttribute<T>)→updateState(Map<String, dynamic>)- Methods updated to handle
RemoteCommandinstead ofAnimationCommand
- Under “Unreleased” (or next version), add a Breaking Changes section listing:
- Add or update MIGRATION.md (or a migration guide) with steps for clients to adapt to these API changes.
🤖 Prompt for AI Agents
In lib/src/driver_api/ui_controller.dart at line 10, the removal of generics
from UIElementController and related types is a breaking change that is not yet
documented. Update the CHANGELOG.md file under the “Unreleased” or next version
section by adding a Breaking Changes subsection that lists all the API changes
including the removal of generics from UIElementController and ViewAttribute,
the change from StreamController<AnimationCommand> to
StreamController<RemoteCommand>, the update of updateState parameter from
ViewAttribute<T> to Map<String, dynamic>, and method updates to handle
RemoteCommand instead of AnimationCommand. Additionally, create or update
MIGRATION.md or a migration guide with clear instructions for clients on how to
adapt their code to these API changes.
* 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
Summary by CodeRabbit
New Features
Breaking Changes
Bug Fixes
Chores
.gitignoreto exclude coverage reports.Tests