Skip to content

feat: create StylePhaseAnimator #620

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

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open

Conversation

tilucasoli
Copy link
Collaborator

@tilucasoli tilucasoli commented Jun 4, 2025

Description

Adds a new StylePhaseAnimator widget to orchestrate style transitions through multiple phases and exposes it in the experimental API.

Example

enum HeartAnimationPhases implements PhaseVariant {
  initial,
  pulse;

  @override
  Variant get variant => Variant(name);
}

class HeartAnimation extends StatefulWidget {
  const HeartAnimation({
    super.key,
  });

  @override
  State<HeartAnimation> createState() => _HeartAnimationState();
}

class _HeartAnimationState extends State<HeartAnimation> {
  final matrix = Matrix4.identity()..scale(2.0);

  @override
  Widget build(BuildContext context) {
    final baseStyle = Style(
      $with.transform(Matrix4.identity()..scale(1.5)),
      $text.fontSize(50),
      $text.color.red(),
    );

    return StylePhaseAnimator(
      phases: {
        HeartAnimationPhases.initial: baseStyle,
        HeartAnimationPhases.pulse: Style(
          baseStyle(),
          $with.transform(matrix),
        ),
      },
      animation: (_) => const PhaseAnimationData(
        duration: Duration(milliseconds: 300),
        curve: Curves.easeInOut,
      ),
      builder: (context, style) => const Box(
        inherit: true,
        child: StyledText('♥️'),
      ),
    );
  }
}

Changes

  • Introduces PhaseAnimationData, PhaseVariant, and the StylePhaseAnimator widget with a configurable animation sequence.
  • Updates the experimental.dart barrel file to export the new animator.
  • Adds logic to cycle through style variants on trigger changes with customizable delays and curves.

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?

Copy link

docs-page bot commented Jun 4, 2025

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

docs.page/btwld/mix~620

Documentation is deployed and generated using docs.page.

Copy link
Contributor

@Copilot 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

Adds a new StylePhaseAnimator widget to orchestrate style transitions through multiple phases and exposes it in the experimental API.

  • Introduces PhaseAnimationData, PhaseVariant, and the StylePhaseAnimator widget with a configurable animation sequence.
  • Updates the experimental.dart barrel file to export the new animator.
  • Adds logic to cycle through style variants on trigger changes with customizable delays and curves.

Reviewed Changes

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

File Description
packages/mix/lib/src/experiemental/style_phase_animator.dart New widget and helpers for phase-based style animations
packages/mix/lib/experimental.dart Export the new style phase animator in the experimental API
Comments suppressed due to low confidence (1)

packages/mix/lib/src/experiemental/style_phase_animator.dart:52

  • The constructor doc references a 'child' parameter which no longer exists; it should reference 'builder' instead.
/// The [phases], [animation], [child] and [trigger] parameters must not be null.

@tilucasoli tilucasoli force-pushed the feat/StylePhaseAnimator branch from 354be60 to 7f8ea4e Compare June 9, 2025 19:27
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.

1 participant