Skip to content

Conversation

divyanshub024
Copy link
Member

@divyanshub024 divyanshub024 commented Sep 23, 2025

Description

Move StacAlign to Stac_core for DSL support

Type of Change

  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Code refactor
  • Build configuration change
  • Documentation
  • Chore

Summary by CodeRabbit

  • New Features

    • Added an Align widget to core widgets with JSON support, including alignment (defaults to center), widthFactor, heightFactor, and optional child.
    • Snack bar actions now include an actionType in serialized output.
  • Refactor

    • Migrated Align from parser-specific implementation to core widgets, updating exports accordingly.
    • Parser behavior updated: accepts nullable alignment and child with safer defaults, and passes width/height factors through without forced parsing.

Copy link

coderabbitai bot commented Sep 23, 2025

Walkthrough

Removes the Freezed-based StacAlign model and its JSON helpers from packages/stac, updates the align parser and exports to reference a new JsonSerializable StacAlign model added under packages/stac_core. Also updates SnackBar action serialization to include actionType in toJson.

Changes

Cohort / File(s) Summary
Remove StacAlign (Freezed) from stac
packages/stac/lib/src/parsers/widgets/stac_align/stac_align.dart, packages/stac/lib/src/parsers/widgets/stac_align/stac_align.freezed.dart, packages/stac/lib/src/parsers/widgets/stac_align/stac_align.g.dart
Deleted the Freezed-decorated StacAlign API and all generated code (mixins, copyWith, (de)serialization, enum map).
Parser updates (Align)
packages/stac/lib/src/parsers/widgets/stac_align/stac_align_parser.dart
Adjusted imports to stac_core; parsing now null-safe for alignment (defaults to center), widthFactor/heightFactor passed through with converters, child parsed via parser.
Widget barrel exports (stac)
packages/stac/lib/src/parsers/widgets/widgets.dart
Changed export from stac_align.dart to stac_align_parser.dart.
Add StacAlign model (stac_core)
packages/stac_core/lib/widgets/align/stac_align.dart, packages/stac_core/lib/widgets/align/stac_align.g.dart
Introduced JsonSerializable StacAlign with alignment, widthFactor, heightFactor, child, type getter, and (de)serialization; includes enum map.
Widget barrel exports (stac_core)
packages/stac_core/lib/widgets/widgets.dart
Added export for align/stac_align.dart.
SnackBar action serialization
packages/stac_core/lib/actions/snack_bar/stac_snack_bar_action.g.dart
toJson now includes actionType; fromJson unchanged.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Client
  participant Parser as StacAlignParser (stac)
  participant Model as StacAlign (stac_core)
  note over Model: New JsonSerializable model

  Client->>Parser: parse(json)
  Parser->>Parser: read alignment/width/height/child (null-safe)
  Parser->>Model: create StacAlign.fromJson-like data<br/>or construct with parsed fields
  Model-->>Parser: instance
  Parser-->>Client: StacAlign instance (with type)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • Potatomonsta

Poem

I hopped from Freezed to core so fine,
A tidy align, with center by design.
Widgets wink, serializers sing,
Snack bars gain an action ring.
Ears up high, I ship with cheer—
Parse, align, and disappear! 🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "refactor: Move StacAlign to Stac_core for DSL support" succinctly and accurately summarizes the main change — relocating StacAlign to stac_core to enable DSL support — and matches the changeset showing removal from packages/stac and addition under packages/stac_core. It is concise, specific, and readable, without vague terms or noise. The phrasing gives a teammate scanning history a clear sense of the primary change.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dv/stac-align

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
packages/stac/lib/src/parsers/widgets/stac_align/stac_align_parser.dart (1)

19-23: Safe defaults; can simplify once model guarantees non-null alignment

After making alignment non-null with a default in the core model (see comment on stac_align.dart), this can be simplified.

-      alignment: model.alignment?.parse ?? Alignment.center,
+      alignment: model.alignment.parse,
packages/stac_core/lib/widgets/align/stac_align.g.dart (1)

23-29: toJson forces non-null alignment; risk of runtime exception

_$StacAlignToJson uses _$StacAlignmentDirectionalEnumMap[instance.alignment]!, which will throw if a StacAlign is constructed programmatically with alignment == null. The field is nullable in the model, so this is a real foot‑gun outside of JSON construction.

Fix in the model by making alignment non‑null with a default (and add @JsonKey(defaultValue: StacAlignmentDirectional.center)), then regenerate. See suggested diff on stac_align.dart.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b38daa2 and 720ef17.

📒 Files selected for processing (9)
  • packages/stac/lib/src/parsers/widgets/stac_align/stac_align.dart (0 hunks)
  • packages/stac/lib/src/parsers/widgets/stac_align/stac_align.freezed.dart (0 hunks)
  • packages/stac/lib/src/parsers/widgets/stac_align/stac_align.g.dart (0 hunks)
  • packages/stac/lib/src/parsers/widgets/stac_align/stac_align_parser.dart (1 hunks)
  • packages/stac/lib/src/parsers/widgets/widgets.dart (1 hunks)
  • packages/stac_core/lib/actions/snack_bar/stac_snack_bar_action.g.dart (1 hunks)
  • packages/stac_core/lib/widgets/align/stac_align.dart (1 hunks)
  • packages/stac_core/lib/widgets/align/stac_align.g.dart (1 hunks)
  • packages/stac_core/lib/widgets/widgets.dart (1 hunks)
💤 Files with no reviewable changes (3)
  • packages/stac/lib/src/parsers/widgets/stac_align/stac_align.g.dart
  • packages/stac/lib/src/parsers/widgets/stac_align/stac_align.dart
  • packages/stac/lib/src/parsers/widgets/stac_align/stac_align.freezed.dart
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: analyze
🔇 Additional comments (7)
packages/stac_core/lib/actions/snack_bar/stac_snack_bar_action.g.dart (1)

29-30: No change required — actionType is a derived getter; serializing-only is intentional.

Verified: packages/stac_core/lib/actions/stac_snack_bar_action.dart defines String get actionType => ActionType.showSnackBar.name; (not a constructor field), so toJson writing it while fromJson ignores it is correct.

packages/stac/lib/src/parsers/widgets/stac_align/stac_align_parser.dart (2)

11-11: LGTM: type mapping is consistent

WidgetType.align.name correctly identifies the parser type.


14-14: LGTM: switching to core model

Using StacAlign.fromJson from stac_core is correct for the refactor.

packages/stac_core/lib/widgets/widgets.dart (1)

4-4: Expose core Align in barrel

Export looks good and maintains ordering.

packages/stac/lib/src/parsers/widgets/widgets.dart (1)

4-4: Switched to parser export

Exporting stac_align_parser.dart aligns with moving the model to core. Looks good.

packages/stac_core/lib/widgets/align/stac_align.g.dart (1)

9-16: LGTM: sensible default on deserialization

Falling back to StacAlignmentDirectional.center when alignment is missing is correct.

packages/stac_core/lib/widgets/align/stac_align.dart (1)

57-60: LGTM: stable type identifier

WidgetType.align.name matches the DSL type key and is consistent with other widgets.

@divyanshub024 divyanshub024 merged commit 1c74858 into dev Sep 23, 2025
5 checks passed
@divyanshub024 divyanshub024 deleted the dv/stac-align branch September 23, 2025 14:05
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.

2 participants