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

fix: updated the draw View logic feature. #1041

Merged
merged 1 commit into from
Oct 17, 2024

Conversation

Jhalakupadhyay
Copy link
Contributor

@Jhalakupadhyay Jhalakupadhyay commented Oct 16, 2024

#1016

Summary by Sourcery

Update the draw view logic by replacing BadgeWidget with CustomPaint in badge home and draw badge views, and fix the grid update logic in DrawBadgeProvider.

Bug Fixes:

  • Fix the logic for updating the draw view grid in the DrawBadgeProvider.

Enhancements:

  • Replace BadgeWidget with CustomPaint in badge home and draw badge views for improved rendering.

Copy link

sourcery-ai bot commented Oct 16, 2024

Reviewer's Guide by Sourcery

This pull request updates the draw View logic feature, primarily by replacing the BadgeWidget with CustomPaint and introducing separate paint classes for badge home and draw badge views. It also includes changes to the grid manipulation logic and some minor adjustments to improve the overall functionality.

Updated class diagram for BadgeHomePaint and DrawBadgePaint

classDiagram
    class BadgeHomePaint {
        +List<List<bool>> grid
        +BadgeHomePaint(List<List<bool>> grid)
        +void paint(Canvas canvas, Size size)
        +bool shouldRepaint(CustomPainter oldDelegate)
    }
    class DrawBadgePaint {
        +List<List<bool>> grid
        +DrawBadgePaint(List<List<bool>> grid)
        +void paint(Canvas canvas, Size size)
        +bool shouldRepaint(CustomPainter oldDelegate)
    }
    class CustomPainter
    BadgeHomePaint --|> CustomPainter
    DrawBadgePaint --|> CustomPainter
Loading

Updated class diagram for DrawBadgeProvider

classDiagram
    class DrawBadgeProvider {
        +List<List<bool>> homeViewGrid
        +List<List<bool>> drawViewGrid
        +List<List<bool>> getGrid()
        +List<List<bool>> getDrawViewGrid()
        +void setDrawViewGrid(int row, int col)
        +void resetGrid()
    }
Loading

File-Level Changes

Change Details Files
Replaced BadgeWidget with CustomPaint for rendering
  • Introduced BadgeHomePaint class for badge home view
  • Introduced DrawBadgePaint class for draw badge view
  • Updated imports to use new paint classes
  • Removed BadgeWidget import and usage
lib/virtualbadge/view/badge_home_view.dart
lib/virtualbadge/view/draw_badge.dart
lib/virtualbadge/view/badgehome_paint.dart
lib/virtualbadge/view/draw_badge_paint.dart
Modified grid manipulation logic
  • Updated setDrawViewGrid method to toggle individual cells
  • Changed resetGrid to reset drawViewGrid instead of homeViewGrid
  • Updated grid retrieval in file saving functionality
lib/providers/badgeview_provider.dart
lib/view/draw_badge_screen.dart
Improved initialization and state management
  • Added post-frame callback for resetting grid in HomeScreen
  • Updated import order in badgeview_provider.dart
lib/view/homescreen.dart
lib/providers/badgeview_provider.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 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

@Jhalakupadhyay Jhalakupadhyay changed the title bug: updated the draw View logic feature. fix: updated the draw View logic feature. Oct 16, 2024
Copy link

@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 adding documentation to explain the custom painting approach, particularly in the BadgeHomePaint and DrawBadgePaint classes. This will help with future maintenance and understanding of the rendering logic.
  • Please provide an explanation for the architectural change from BadgeWidget to custom painting. Understanding the rationale behind this decision would be helpful for the team.
  • It's recommended to add unit tests for the new painting classes to ensure they behave correctly under various conditions and to prevent potential regressions in the future.
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.

@@ -57,7 +57,7 @@ class DrawBadgeProvider extends ChangeNotifier {

//function to reset the state of the cell
void resetGrid() {
Copy link

Choose a reason for hiding this comment

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

issue (bug_risk): Potential bug in resetGrid method

The resetGrid method is now resetting drawViewGrid instead of homeViewGrid. Is this change intentional? If not, it could lead to unexpected behavior.

@adityastic adityastic merged commit 2f507fc into fossasia:flutter_app Oct 17, 2024
6 of 7 checks passed
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