fossasia / badgemagic-android

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

feat: Added the Invert LED effect for transfer to the LED badge. #1065

Closed Jhalakupadhyay closed 3 weeks ago

Jhalakupadhyay commented 4 weeks ago

1064

Summary by Sourcery

Add an invert LED effect feature to the badge message system, enabling the inversion of message hex values for display on LED badges. This includes updates to the message conversion process and integration with the badge animation and effect systems.

New Features:

Enhancements:

sourcery-ai[bot] commented 4 weeks ago

Reviewer's Guide by Sourcery

This PR implements an Invert LED effect feature for LED badge displays. The implementation adds the ability to invert LED states (on/off) through a new boolean parameter isInverted that flows through the message conversion pipeline. The inversion is performed by converting hex values to binary, flipping the bits, and converting back to hex.

Updated class diagram for Converters

classDiagram
    class Converters {
        +Future<List<String>> messageTohex(String message, bool isInverted)
        +static String invertHex(String hex)
    }
    note for Converters "Added isInverted parameter to messageTohex and invertHex method"

Updated class diagram for AnimationBadgeProvider

classDiagram
    class AnimationBadgeProvider {
        +void badgeAnimation(String message, Converters converters, bool isInverted)
    }
    note for AnimationBadgeProvider "Added isInverted parameter to badgeAnimation method"

Updated class diagram for SavedBadgeProvider

classDiagram
    class SavedBadgeProvider {
        +Future<Data> getBadgeData(String text, bool flash, bool marq, bool isInverted, Speed speed, Mode mode)
    }
    note for SavedBadgeProvider "Added isInverted parameter to getBadgeData method"

File-Level Changes

Change Details Files
Added hex inversion functionality for LED display
  • Implemented invertHex method to flip bits in hexadecimal values
  • Added isInverted parameter to messageTohex method
  • Modified message conversion logic to apply inversion when needed
lib/bademagic_module/utils/converters.dart
Updated providers to support LED inversion
  • Added isInverted parameter to data generation methods
  • Modified badge animation logic to handle inverted states
  • Updated data transfer methods to include inversion parameter
lib/providers/badge_message_provider.dart
lib/providers/animation_badge_provider.dart
lib/providers/saved_badge_provider.dart
Integrated invert LED effect into UI components
  • Added InvertLEDEffect handling in effects container
  • Updated home screen to handle inverted LED states
  • Modified save badge functionality to support inversion
lib/view/widgets/effects_container.dart
lib/view/homescreen.dart
lib/view/widgets/save_badge_card.dart
lib/badge_effect/invert_led_effect.dart

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. - **Generate a pull request title:** Write `@sourcery-ai` anywhere in the pull request title to generate a 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. You can also use this command to specify where the summary should be inserted. #### Customizing Your Experience Access your [dashboard](https://app.sourcery.ai) 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 - [Contact our support team](mailto:support@sourcery.ai) for questions or feedback. - Visit our [documentation](https://docs.sourcery.ai) for detailed guides and information. - Keep in touch with the Sourcery team by following us on [X/Twitter](https://x.com/SourceryAI), [LinkedIn](https://www.linkedin.com/company/sourcery-ai/) or [GitHub](https://github.com/sourcery-ai).