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

chore: updated the badge view (aspect ratio) #1142

Closed

Conversation

Jhalakupadhyay
Copy link
Contributor

@Jhalakupadhyay Jhalakupadhyay commented Jan 4, 2025

#1095
#1108

Summary by Sourcery

Update the badge view to maintain a consistent aspect ratio across different screens and devices.

New Features:

  • Introduce a utility class BadgeUtils to manage badge dimensions and offsets.

Enhancements:

  • Maintain aspect ratio for the badge view.

Tests:

  • Remove unused code and dependencies.

Copy link
Contributor

sourcery-ai bot commented Jan 4, 2025

Reviewer's Guide by Sourcery

This PR updates the aspect ratio of the badge view to 3.2 and centers the badge preview.

Class diagram showing the updated badge view structure

classDiagram
    class BMBadge {
        -DrawBadgeProvider drawProvider
        +build()
        -handlePanUpdate()
    }
    class BadgePaint {
        -BadgeUtils badgeUtils
        -List~List~bool~~ grid
        +paint(Canvas, Size)
    }
    class BadgeUtils {
        +getBadgeOffsetBackground(Size)
        +getBadgeSize(double, double, Size)
        +getCellStartCoordinate(double, double, double, double)
    }
    BMBadge --> BadgePaint : uses
    BadgePaint --> BadgeUtils : uses
Loading

State diagram for badge view rendering process

stateDiagram-v2
    [*] --> CalculateBackground: Start Rendering
    CalculateBackground --> CalculateBadgeSize: Get offset and padding
    CalculateBadgeSize --> CalculateCellCoordinates: Determine badge dimensions
    CalculateCellCoordinates --> DrawBadge: Calculate grid positions
    DrawBadge --> [*]: Complete rendering

    note right of CalculateBadgeSize: Maintains 3.2 aspect ratio
    note right of DrawBadge: Centers badge in view
Loading

File-Level Changes

Change Details Files
Updated the badge view to maintain a 3.2 aspect ratio and centered the badge preview.
  • Wrapped the CustomPaint widget with an AspectRatio widget to enforce the 3.2 aspect ratio.
  • Added a BadgeUtils class to calculate the size and position of the badge.
  • Updated the paint method to draw the badge within the calculated boundaries.
  • Added padding around the badge to center it within the available space.
  • Removed unnecessary height and width constraints from the badge view.
lib/view/homescreen.dart
lib/view/draw_badge_screen.dart
lib/virtualbadge/view/draw_badge.dart
lib/virtualbadge/view/animated_badge.dart
lib/virtualbadge/view/badge_paint.dart
Updated the DrawBadge screen to use a SingleChildScrollView and LayoutBuilder for better responsiveness.
  • Wrapped the content of the DrawBadge screen with a SingleChildScrollView to handle overflow.
  • Used a LayoutBuilder to constrain the maximum width of the badge container.
  • Removed fixed height and width constraints from the badge container.
lib/view/draw_badge_screen.dart
Removed unused code and dependencies.
  • Removed unused byteArrayToBinaryArray, hexToBin, and binaryStringTo2DList functions from ByteArrayUtils.
  • Removed TODO comment from AboutUsScreen.
lib/bademagic_module/utils/byte_array_utils.dart
lib/view/about_us_screen.dart
Updated the navigation drawer header.
  • Added a background image to the navigation drawer header.
  • Increased the font size and added font weight to the drawer title text.
lib/view/widgets/navigation_drawer.dart
Updated the routes in the main application.
  • Added a trailing comma after the '/savedClipart' route.
lib/main.dart

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 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 @Jhalakupadhyay - I've reviewed your changes and they look great!

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.

AnimationTab(),
EffectTab(),
onTap: () {
badgeData.checkAndTransfer(
Copy link
Contributor

Choose a reason for hiding this comment

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

issue: Add validation for empty text before calling checkAndTransfer

The previous error handling for empty text fields was removed. Consider adding validation to prevent potential crashes.

@adityastic adityastic force-pushed the flutter_app branch 19 times, most recently from 92c0f62 to 093c170 Compare January 6, 2025 00:13
@adityastic adityastic force-pushed the flutter_app branch 4 times, most recently from 483256e to 60773d7 Compare January 6, 2025 01:15
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.

2 participants