Skip to content

Conversation

nope3472
Copy link
Contributor

@nope3472 nope3472 commented Aug 30, 2025

Fixes #892

Changes

  • Added seamless, back-and-forth cycle animation with smooth left-to-right movement and return motion, including proper reset and state handling for smooth looping and transfer to the badge.
  • Unified animation selection and transfer logic for this standard animations, improving maintainability and user experience.
  • Improved the cycle animation transfer so the bicycle smoothly travels across the badge and seamlessly loops back, preventing visual glitches and ensuring continuous motion for an engaging cycling effect.

Screenshots / Recordings

image image

Checklist:

  • No hard coding: I have used resources from constants.dart without hard coding any value.
  • No end of file edits: No modifications done at end of resource files.
  • Code reformatting: I have reformatted code and fixed indentation in every file included in this pull request.
  • Code analyzation: My code passes analyzations run in flutter analyze and tests run in flutter test.

Summary by Sourcery

Add a seamless cycle animation feature by introducing CycleAnimation, wiring it through mode maps, animation provider, transfer logic, and UI controls, and ensuring smooth looping and empty-text handling for the bicycle effect.

New Features:

  • Add CycleAnimation with back-and-forth bicycle movement and wheel bounce effect
  • Implement transferCycleAnimation to stream eight frames of the cycle animation to the badge
  • Register new cycle mode in mode mappings, animation provider, and UI control

Enhancements:

  • Allow empty input when cycle mode is selected and include cycle in special-animation handling
  • Unify animation selection and transfer logic to support the new cycle animation alongside existing ones

Copy link
Contributor

sourcery-ai bot commented Aug 30, 2025

Reviewer's Guide

Introduces a new back-and-forth cycle (bicycle) animation mode with smooth looping by implementing a CycleAnimation subclass, integrating it into mode and animation mappings, adding a dedicated transferCycleAnimation function, and updating the UI for mode selection.

Class diagram for the new CycleAnimation and related changes

classDiagram
  class BadgeAnimation {
    <<abstract>>
    +processAnimation()
  }
  class CycleAnimation {
    +transferFrames()
    +processAnimation()
    -_calculateCycleX()
    -_easeInOut()
    -_shouldFlipCycle()
    -_calculateWheelBounce()
    -_drawCycle()
    static cycleMatrix
    static badgeHeight
    static badgeWidth
    static cycleHeight
    static cycleWidth
    static framesPerCycle
    static previewFramesPerCycle
  }
  BadgeAnimation <|-- CycleAnimation

  class BadgeMessageProvider {
    +transferCycleAnimation()
  }

  class AnimationBadgeProvider {
    +isSpecialAnimationSelected()
    +calculateDuration()
    +transferCycleAnimation()
  }

  CycleAnimation <.. BadgeMessageProvider : uses
  CycleAnimation <.. AnimationBadgeProvider : uses
Loading

File-Level Changes

Change Details Files
Implemented CycleAnimation class for seamless back-and-forth bike animation
  • Added ani_cycle.dart with frame generation, easing, wheel bounce, and drawing logic
  • Defined transferFrames to select 8 key frames for BLE transfer
  • Extended processAnimation to render infinite back-and-forth movement
lib/badge_animation/ani_cycle.dart
Integrated new cycle mode and transfer logic into providers and models
  • Added Mode.cycle enum entry and corresponding modeValueMap mapping
  • Updated animationMap, isSpecialAnimationSelected, calculateDuration, and transfer switch-case to include index 20
  • Introduced transferCycleAnimation in badge_message_provider with BLE transfer, hex conversion, and logging
lib/bademagic_module/models/mode.dart
lib/providers/badge_message_provider.dart
lib/providers/animation_badge_provider.dart
Added Cycle option in UI transition tab
  • Inserted AniContainer with bicycle icon for the new cycle animation at index 20
lib/view/widgets/transitiontab.dart

Assessment against linked issues

Issue Objective Addressed Explanation
#892 Implement a back and forth animation (bicycle) similar to the Python version, with smooth left-to-right and right-to-left movement.
#892 Add the back and forth animation as an option on the animation screen (middle option), with appropriate icon and selection logic.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes - here's some feedback:

  • In transferCycleAnimation you’re still using Mode.fixed for the messages—switch to Mode.cycle so the badge receives the correct animation mode.
  • The frame conversion and message-building code in transferCycleAnimation largely duplicates other transfer functions—extract it into a shared helper to reduce repetition.
  • The hard-coded transfer frame indices in ani_cycle.dart are opaque—move them into named constants or add a comment explaining why those specific frames were chosen.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In transferCycleAnimation you’re still using Mode.fixed for the messages—switch to Mode.cycle so the badge receives the correct animation mode.
- The frame conversion and message-building code in transferCycleAnimation largely duplicates other transfer functions—extract it into a shared helper to reduce repetition.
- The hard-coded transfer frame indices in ani_cycle.dart are opaque—move them into named constants or add a comment explaining why those specific frames were chosen.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Contributor

github-actions bot commented Aug 30, 2025

Build Status

Build successful. APKs to test: https://github.com/fossasia/badgemagic-app/actions/runs/17546998316/artifacts/3952271588.

Screenshots

Android Screenshots
iPhone Screenshots
iPad Screenshots

@mariobehling
Copy link
Member

@nope3472 Please respond to sourcery-ai and adjust where applicable.

Copy link
Member

@mariobehling mariobehling left a comment

Choose a reason for hiding this comment

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

Please also resolve conflicts.

@hpdang
Copy link
Member

hpdang commented Sep 8, 2025

@nope3472 can you resolve the conflict here? I also asked you last week on chat, we want to test the scrolling feature

@nope3472
Copy link
Contributor Author

nope3472 commented Sep 8, 2025

okay will do it

@nope3472
Copy link
Contributor Author

nope3472 commented Sep 8, 2025

@hpdang resolved the conflicts

@mariobehling mariobehling merged commit 48914fd into fossasia:development Sep 8, 2025
10 checks passed
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.

Implement back and forth animation
3 participants