fossasia / badgemagic-android

Badge Magic with LEDs - Android App https://play.google.com/apps/testing/org.fossasia.badgemagic
Apache License 2.0
1.84k stars 204 forks source link

feat: Added animation mode #1009

Closed Jhalakupadhyay closed 1 week ago

Jhalakupadhyay commented 2 weeks ago

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:

Enhancements:

Chores:

sourcery-ai[bot] commented 2 weeks ago

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](https://app.sourcery.ai): - Enable or disable the Sourcery-generated pull request summary or reviewer's guide; - Change the review language; - You can always [contact us](mailto:support@sourcery.ai) if you have any questions or feedback.