Skip to content

Conversation

samruddhi-Rahegaonkar
Copy link
Member

@samruddhi-Rahegaonkar samruddhi-Rahegaonkar commented Jun 13, 2025

Fixes #1219

Changes

  • Fixed bottom overflow issue in the delete confirmation dialog on macOS by wrapping Dialog content in a SingleChildScrollView.
  • Ensured responsive layout using ScreenUtil for padding, spacing, and font sizes.
  • Connected "OK" button in the dialog to the actual deletion logic.
  • Triggered UI update after deletion to reflect changes in the clipart list.

Screenshots / Recordings

Checklist:

  • No hard coding: I have used resources from constants.dart without hard coding any value.
  • No end of file edits: No modifications done at end of resource files.
  • Code reformatting: I have reformatted code and fixed indentation in every file included in this pull request.
  • Code analyzation: My code passes analyzations run in flutter analyze and tests run in flutter test.

Summary by Sourcery

Fix the delete confirmation dialog to prevent overflow and enable actual deletion with responsive layout, and simplify the snowflake animation grid logic

Bug Fixes:

  • Prevent bottom overflow in the delete confirmation dialog on macOS by making the content scrollable
  • Enable the OK button to trigger badge deletion and refresh the clipart list

Enhancements:

  • Adopt ScreenUtil for responsive padding, spacing, and font sizes in the dialog
  • Refactor snowflake animation to streamline frame count calculation and grid updates

Copy link
Contributor

sourcery-ai bot commented Jun 13, 2025

Reviewer's Guide

This PR refactors the delete confirmation dialog into a responsive, scrollable layout using ScreenUtil, connects the OK button to the badge deletion logic with a UI refresh, and simplifies the SnowFlakeAnimation by moving frame calculations out of the loop, handling empty grids, and condensing the canvas update.

Sequence Diagram for Badge Deletion Process

sequenceDiagram
    actor User
    participant Dialog as DeleteConfirmationDialog
    participant Logic as BadgeDeletionService
    participant UI as ClipartListUI

    User->>Dialog: Clicks "OK" button
    Dialog->>Logic: deleteBadge()
    Logic->>Logic: Performs deletion
    Logic->>UI: Trigger UI update
    UI->>UI: Refreshes list
Loading

Updated Class Diagram for DeleteBadgeDialog

classDiagram
    class DeleteBadgeDialog {
        +Widget build(BuildContext context)
        // build() method: UI structure refactored for responsiveness and to fix overflow:
        // - Root widget changed from fixed-size Container to Padding.
        // - Uses Column with MainAxisSize.min for intrinsic content sizing.
        // - Leverages ScreenUtil for responsive dimensions and font sizes.
        // - Confirmation message Text is wrapped with Expanded for better layout.
    }
    StatelessWidget <|-- DeleteBadgeDialog
Loading

Updated Class Diagram for SnowFlakeAnimation

classDiagram
    class SnowFlakeAnimation {
        +animate(int badgeHeight, int badgeWidth, int animationIndex, List<List<bool>> processGrid, List<List<bool>> canvas) void
        // animate() method: Logic refactored for clarity and performance:
        // - Frame count calculation (framesCount) is now outside the loops.
        // - Added a safeguard: framesCount defaults to 1 if calculated as 0.
        // - Current frame calculation (currentFrame) simplified.
        // - Starting column (startCol) calculation based on currentFrame.
        // - Canvas cell update logic is more direct.
    }
    BadgeAnimation <|-- SnowFlakeAnimation
Loading

File-Level Changes

Change Details Files
Refactored delete confirmation dialog for overflow fix and responsive layout
  • Replaced fixed-size Container with Padding and Column(mainAxisSize.min)
  • Applied EdgeInsets.symmetric with .h/.w and TextStyle with .sp
  • Replaced hard-coded widths/spacings with ScreenUtil-scaled SizedBox
  • Used Expanded around message text to prevent overflow
lib/view/widgets/badge_delete_dialog.dart
Simplified snowflake animation frame calculation and canvas update
  • Moved framesCount computation outside nested loops and ensured minimum of 1
  • Changed frame selection to animationIndex % framesCount
  • Rewrote nested loops to set canvas via a single ternary isInGrid check
  • Removed obsolete variables and inline comments to streamline logic
lib/badge_animation/ani_snowflake.dart

Assessment against linked issues

Issue Objective Addressed Explanation
#1219 Fix the bottom overflow error in the delete confirmation dialog on macOS and iPad.
#1219 Ensure the 'OK' button in the delete confirmation dialog actually deletes the selected clipart item.
#1219 Update the UI to reflect the deleted item after clicking 'OK'.

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. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the 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 exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

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

@samruddhi-Rahegaonkar samruddhi-Rahegaonkar changed the title Issue#1219 fix: macOS, iPad Delete Action Fails and Causes Bottom Overflow Error in Confirmation Dialog Jun 13, 2025
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 @samruddhi-Rahegaonkar - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments

### Comment 1
<location> `lib/view/widgets/badge_delete_dialog.dart:38` </location>
<code_context>
-                  width: 20,
+                Expanded(
+                  child: Text(
+                    'Are you sure want to delete this badge?',
+                    style: TextStyle(fontSize: 14.sp),
+                  ),
</code_context>

<issue_to_address>
Fix grammar in confirmation message

Change the prompt to: “Are you sure you want to delete this badge?”
</issue_to_address>

<suggested_fix>
<<<<<<< SEARCH
                  child: Text(
                    'Are you sure want to delete this badge?',
                    style: TextStyle(fontSize: 14.sp),
                  ),
=======
                  child: Text(
                    'Are you sure you want to delete this badge?',
                    style: TextStyle(fontSize: 14.sp),
                  ),
>>>>>>> REPLACE

</suggested_fix>

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.

Comment on lines 37 to 31
child: Text(
'Are you sure want to delete this badge?',
style: TextStyle(fontSize: 14.sp),
),
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick (typo): Fix grammar in confirmation message

Change the prompt to: “Are you sure you want to delete this badge?”

Suggested change
child: Text(
'Are you sure want to delete this badge?',
style: TextStyle(fontSize: 14.sp),
),
child: Text(
'Are you sure you want to delete this badge?',
style: TextStyle(fontSize: 14.sp),
),

Copy link
Contributor

github-actions bot commented Jun 13, 2025

Build Status

Build successful. APKs to test: https://github.com/fossasia/badgemagic-app/actions/runs/16625096560/artifacts/3649326250.

Screenshots (Android)

Screenshots (iPhone)

Screenshots (iPad)

Copy link
Contributor

@nope3472 nope3472 left a comment

Choose a reason for hiding this comment

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

Dropping fixed dimensions risks content overflow or clipping (especially with longer/localized text) and may reduce touch‐target areas below accessibility guidelines.

… in Confirmation Dialog

fix: according to review
@hpdang
Copy link
Member

hpdang commented Jul 8, 2025

@nope3472 please review this again

Copy link
Contributor

@nope3472 nope3472 left a comment

Choose a reason for hiding this comment

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

LGTM Great work

@hpdang
Copy link
Member

hpdang commented Jul 30, 2025

@samruddhi-Rahegaonkar please update the branch so we can merge

@samruddhi-Rahegaonkar
Copy link
Member Author

@samruddhi-Rahegaonkar please update the branch so we can merge

Done 👍

@hpdang
Copy link
Member

hpdang commented Jul 31, 2025

@Jhalakupadhyay we need an approval from you to merge this

@hpdang hpdang merged commit 854bf07 into fossasia:development Jul 31, 2025
6 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.

macOS, iPad Delete Action Fails and Causes Bottom Overflow Error in Confirmation Dialog
4 participants