Skip to content

Conversation

@tilucasoli
Copy link
Collaborator

Description

Updated gradient mix classes to accept lists of color property tokens instead of direct color lists, enabling dynamic color resolution. Example usage now demonstrates color tokens for primary and secondary colors, improving theme flexibility and consistency.

Changes

List specific changes made in this PR.

Review Checklist

  • Testing: Have you tested your changes, including unit tests and integration tests for affected code?
  • Breaking Changes: Does this change introduce breaking changes affecting existing code or users?
  • Documentation Updates: Are all relevant documentation files (e.g. README, API docs) updated to reflect the changes in this PR?
  • Website Updates: Is the website containing the updates you make on documentation?

Additional Information (optional)

Is there any additional context or documentation that might be helpful for reviewers?

Updated gradient mix classes to accept lists of color property tokens instead of direct color lists, enabling dynamic color resolution. Example usage now demonstrates color tokens for primary and secondary colors, improving theme flexibility and consistency.
@tilucasoli tilucasoli requested a review from Copilot October 14, 2025 21:35
@docs-page
Copy link

docs-page bot commented Oct 14, 2025

To view this pull requests documentation preview, visit the following URL:

docs.page/btwld/mix~773

Documentation is deployed and generated using docs.page.

@vercel
Copy link
Contributor

vercel bot commented Oct 14, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
mix-docs Ready Ready Preview Comment Oct 14, 2025 9:36pm

@github-actions github-actions bot added the mix label Oct 14, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Refactors gradient color handling in the Mix package to support dynamic color tokens instead of static color lists. This enables better theme flexibility and consistency by allowing gradient colors to be resolved at runtime from token-based color systems.

  • Changed gradient mix classes to accept lists of color property tokens (List<Prop<Color>>) instead of direct color lists
  • Updated test assertions to verify individual color token resolution rather than list-based comparisons
  • Modified example to demonstrate usage with ColorToken instances and MixScope for theme management

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
packages/mix/lib/src/properties/painting/gradient_mix.dart Refactored core gradient classes to handle color tokens, updated property types and resolution logic
packages/mix/test/src/properties/painting/gradient_mix_test.dart Updated test expectations to verify individual color token resolution patterns
packages/mix/example/lib/api/gradients/gradient_linear.dart Added example demonstrating color tokens with MixScope for theme-based gradient colors

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +192 to +198
$colors?.map((e) => MixOps.resolve(context, e)!).toList() ??
defaultValue.colors;

return LinearGradient(
begin: MixOps.resolve(context, $begin) ?? defaultValue.begin,
end: MixOps.resolve(context, $end) ?? defaultValue.end,
colors: MixOps.resolve(context, $colors) ?? defaultValue.colors,
colors: colors,
Copy link

Copilot AI Oct 14, 2025

Choose a reason for hiding this comment

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

The non-null assertion operator (!) on MixOps.resolve(context, e) could cause a runtime exception if resolution returns null. Consider handling the null case explicitly or document why null resolution is impossible here.

Copilot uses AI. Check for mistakes.
Comment on lines +391 to +393
final colors =
$colors?.map((e) => MixOps.resolve(context, e)!).toList() ??
defaultValue.colors;
Copy link

Copilot AI Oct 14, 2025

Choose a reason for hiding this comment

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

The non-null assertion operator (!) on MixOps.resolve(context, e) could cause a runtime exception if resolution returns null. Consider handling the null case explicitly or document why null resolution is impossible here.

Suggested change
final colors =
$colors?.map((e) => MixOps.resolve(context, e)!).toList() ??
defaultValue.colors;
final colors = $colors != null
? $colors
.map((e) => MixOps.resolve(context, e))
.whereType<Color>()
.toList()
: defaultValue.colors;

Copilot uses AI. Check for mistakes.
@override
SweepGradient resolve(BuildContext context) {
final colors =
$colors?.map((e) => MixOps.resolve(context, e)!).toList() ??
Copy link

Copilot AI Oct 14, 2025

Choose a reason for hiding this comment

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

The non-null assertion operator (!) on MixOps.resolve(context, e) could cause a runtime exception if resolution returns null. Consider handling the null case explicitly or document why null resolution is impossible here.

Suggested change
$colors?.map((e) => MixOps.resolve(context, e)!).toList() ??
$colors?.map((e) => MixOps.resolve(context, e)).whereType<Color>().toList() ??

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants