Skip to content
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

feat: Added animation mode #1009

Closed

Conversation

Jhalakupadhyay
Copy link
Contributor

@Jhalakupadhyay Jhalakupadhyay commented Sep 18, 2024

Summary by Sourcery

Add a new animation mode for badges, introducing multiple animation effects and refactor the badge drawing logic to use a new provider for improved flexibility and control.

New Features:

  • Introduce a new animation mode for badges, allowing for various animation effects such as left, right, up, down, fixed, snowflake, and custom animations.

Enhancements:

  • Refactor the badge drawing logic to use a new provider, BadgeViewProvider, replacing the previous DrawBadgeProvider.
  • Implement a new grid system for badge animations, improving the flexibility and control over badge display.

Chores:

  • Remove unused logging statements to clean up the codebase.

Copy link
Contributor

sourcery-ai bot commented Sep 18, 2024

Reviewer's Guide by Sourcery

This pull request implements an animation mode for a badge display system. It introduces new animation types, refactors existing code to support animations, and adds utility functions for handling animations and conversions between different data representations.

File-Level Changes

Change Details Files
Implemented new animation system with various animation types
  • Added new animation classes (LeftAnimation, RightAnimation, UpAnimation, DownAnimation, FixedAnimation, SnowFlakeAnimation, AniAnimation)
  • Created an abstract BadgeAnimation class for common animation logic
  • Implemented animation speed control and frame calculation
lib/badge_animation/ani_animation.dart
lib/badge_animation/ani_snowflake.dart
lib/badge_animation/anim_left.dart
lib/badge_animation/ani_right.dart
lib/badge_animation/ani_up.dart
lib/badge_animation/ani_dpwn.dart
lib/badge_animation/ani_fixed.dart
lib/badge_animation/animation_abstract.dart
Refactored DrawBadgeProvider to support new animation system
  • Renamed DrawBadgeProvider to BadgeViewProvider
  • Added methods for managing animation state and grid updates
  • Implemented timer-based animation updates
lib/providers/badgeview_provider.dart
Added utility functions for data conversion and manipulation
  • Implemented byteArrayToBinaryArray function
  • Added hexToBin function for hex to binary conversion
  • Created binaryStringTo2DList function for converting binary strings to 2D lists
lib/bademagic_module/utils/byte_array_utils.dart
Updated UI components to support new animation system
  • Modified BadgeWidget to use new grid data structure
  • Updated BMBadge and BMBadgeHome to work with new animation system
  • Refactored HomeScreen to support animation mode
lib/virtualbadge/widgets/badge_widget.dart
lib/virtualbadge/view/draw_badge.dart
lib/virtualbadge/view/badge_home_view.dart
lib/view/homescreen.dart
Added constants for animation speeds and effects
  • Defined constants for base animation speed, marquee speed, and flash speed
  • Implemented aniSpeedStrategy function for calculating animation speed based on speed level
lib/constants.dart

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

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

Overall Comments:

  • Consider refactoring the DrawBadgeProvider class to reduce its responsibilities and improve maintainability.
  • Look for opportunities to reduce code duplication across animation classes, possibly by introducing a common base class or utility functions.
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 to tell me if it was helpful.

}
}

void changeGridValue(List<List<int>> newGrid) {
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: Refactor animation logic for improved clarity and maintainability

The changeGridValue method contains complex animation logic. Consider breaking it down into smaller, more focused functions for each animation type or aspect. This will improve readability and make the code easier to maintain and debug.

  void changeGridValue(List<List<int>> newGrid) {
    _animateGridChange(newGrid);
  }

  void _animateGridChange(List<List<int>> newGrid) {
    int badgeWidth = homeViewGrid[0].length;
    int badgeHeight = homeViewGrid.length;
    // ... rest of the animation logic
  }

@Jhalakupadhyay Jhalakupadhyay deleted the feature/ani_animation branch September 22, 2024 09:42
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.

1 participant