Skip to content

Conversation

Vishveshwara
Copy link
Contributor

@Vishveshwara Vishveshwara commented Mar 26, 2025

Fixes #892

Changes

  • Created Animation Tab UI to support new animations and for future custom animations.
  • Added Linear Scroll animation (left-to-right and right-to-left without flipping)
  • Added Bidirectional Scroll animation (left-to-right and right-to-left with flipping)

Screenshots / Recordings

Animation_support.vid.mp4

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 new animation capabilities to the Badge Magic application by introducing Linear Scroll and Bidirectional Scroll animations, and creating a new Animation Tab in the user interface.

New Features:

  • Introduced a new Animation Tab in the home screen to support custom animations
  • Added Linear Scroll animation with left-to-right and right-to-left movement
  • Added Bidirectional Scroll animation with left-to-right and right-to-left movement, including image flipping

Enhancements:

  • Extended the tab controller to support a fourth tab
  • Updated the UI to accommodate the new Animation Tab
  • Adjusted tab label styling for better readability

…ded new Animation Tab

- Added Linear Scroll animation (left-to-right and right-to-left without flipping)
- Added Bidirectional Scroll animation (left-to-right and right-to-left with flipping)
- Created Animation Tab UI to support new animations
Copy link
Contributor

sourcery-ai bot commented Mar 26, 2025

Reviewer's Guide by Sourcery

This pull request introduces a new 'Animation Tab' to the UI, along with two new animation options: 'Linear Scroll' and 'Bidirectional Scroll'. The 'Animation Tab' is implemented using a GridView to display available animations. The 'Linear Scroll' animation scrolls content horizontally, while the 'Bidirectional Scroll' animation scrolls content horizontally and flips the content on direction change. The tab controller and tab view have been updated to include the new tab.

Updated class diagram for HomeScreen

classDiagram
    class HomeScreen {
        -_tabController: TabController
        +initState()
        +dispose()
        +build(BuildContext context): Widget
    }

    class _HomeScreenState {
        -_tabController: TabController
        +initState()
        +dispose()
        +build(BuildContext context): Widget
        +handleTextChange()
        +handleBadgeWidthChange()
        +handleBadgeHeightChange()
    }

    class AnimationTab {
        +build(BuildContext context): Widget
    }

    class CustomAnimationTab {
        +build(BuildContext context): Widget
    }

    class EffectTab {
        +build(BuildContext context): Widget
    }

    HomeScreen -- _HomeScreenState
    _HomeScreenState *-- AnimationTab : uses
    _HomeScreenState *-- CustomAnimationTab : uses
    _HomeScreenState *-- EffectTab : uses
Loading

File-Level Changes

Change Details Files
Introduced a new tab in the UI specifically for animations, named 'Animation Tab'.
  • Added a new tab to the main screen's tab bar.
  • Created a new widget CustomAnimationTab to manage the content of the Animation Tab.
  • Implemented a GridView within the CustomAnimationTab to display available animations.
  • Added Linear Scroll and Bidirectional Scroll animations to the grid view.
lib/view/widgets/homescreentabs.dart
lib/view/homescreen.dart
Implemented 'Linear Scroll' animation, allowing content to scroll horizontally across the badge display.
  • Created a LinearScrollAnimation class that extends BadgeAnimation.
  • Implemented the processAnimation method to calculate the position of pixels for each frame of the animation.
  • Added the animation to the animationMap for selection and usage.
lib/badge_animation/ani_linear_scroll.dart
lib/providers/animation_badge_provider.dart
lib/constants.dart
Implemented 'Bidirectional Scroll' animation, which scrolls content horizontally and flips the content on direction change.
  • Created a BidirectionalScrollAnimation class, extending BadgeAnimation.
  • Implemented the processAnimation method to handle pixel positioning and flipping during animation.
  • Added the animation to the animationMap for selection and usage.
lib/badge_animation/ani_bidirectional_scroll.dart
lib/providers/animation_badge_provider.dart
lib/constants.dart
Updated the tab controller and tab view to include the new Animation Tab.
  • Increased the tab controller length to accommodate the new tab.
  • Added the CustomAnimationTab widget to the tab view's children.
  • Adjusted the UI to properly display the new tab alongside existing tabs.
lib/view/homescreen.dart

Assessment against linked issues

Issue Objective Addressed Explanation
#892 Implement a back and forth animation for the badge.
#892 Add the new animation as an option in the animation screen (middle option).

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!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

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 @Vishveshwara - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider using a PageView instead of a TabBar and TabBarView for a smoother animation between tabs.
  • Ensure the new animations are easily distinguishable from existing ones in the UI.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

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.

crossAxisCount: 3, // 3 columns
childAspectRatio: 110.w / 65.h, // width to height ratio
),
itemCount: 2, // Total items (3 rows × 3 columns)
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: Update misleading comment about total grid items.

The comment suggests there are 3 rows × 3 columns whereas the itemCount is set to 2. Consider updating the comment to accurately reflect the number of grid items or clarifying the intended design.

@Vishveshwara Vishveshwara changed the title Added Linear Scroll and Bidirectional Scroll animations, added Animation Tab feat: Added Linear Scroll and Bidirectional Scroll animations, added Animation Tab Mar 26, 2025
@Vishveshwara
Copy link
Contributor Author

@Jhalakupadhyay please review this PR.

@Jhalakupadhyay
Copy link
Contributor

@Vishveshwara how are we handling the new custom animation transfer to the badge?

@Jhalakupadhyay
Copy link
Contributor

@Vishveshwara I need you to focus on this PR first and then we can go ahead with the font let's tackle smaller problems first.

@Vishveshwara
Copy link
Contributor Author

@Vishveshwara how are we handling the new custom animation transfer to the badge?

I have used the same provider (animation_badge_provider) used for regular animations.

@Jhalakupadhyay
Copy link
Contributor

@Vishveshwara how are we handling the new custom animation transfer to the badge?

I have used the same provider (animation_badge_provider) used for regular animations.

No this will not work try and understand how we are transferring data.

@Vishveshwara
Copy link
Contributor Author

Vishveshwara commented Mar 27, 2025

@Vishveshwara how are we handling the new custom animation transfer to the badge?

I have used the same provider (animation_badge_provider) used for regular animations.

No this will not work try and understand how we are transferring data.

I have added the changes in lib/bademagic_module/models/mode.dart and also made it work on the saved badges screen.
can you please review it again @Jhalakupadhyay .

@Jhalakupadhyay
Copy link
Contributor

@Vishveshwara how are we handling the new custom animation transfer to the badge?

I have used the same provider (animation_badge_provider) used for regular animations.

No this will not work try and understand how we are transferring data.

I have added the changes in lib/bademagic_module/models/mode.dart and also made it work on the saved badges screen. can you please review it again @Jhalakupadhyay .

It is wrong, try to understand first how the badge works, you cannot create a new mode and transfer it to the badge if the firmware does not support it.

@Vishveshwara
Copy link
Contributor Author

@Jhalakupadhyay Thank you for your feedback. Since implementing this feature requires firmware modifications, could you please clarify the necessary changes in the firmware repository to support custom animations?

I came across this PR: fossasia/badgemagic-firmware#15. Should I follow the steps outlined there, or are there any additional modifications needed?

I would appreciate your guidance on how to successfully complete this PR.

@Vishveshwara
Copy link
Contributor Author

Hey @adityastic , could you please help me out with this PR.

@mariobehling
Copy link
Member

@Vishveshwara This implementation should follow the same approach as the Python library. Do you think you can make it work?

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