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

fix: delete symbol issue fixed #1078

Closed Dhruv80576 closed 3 weeks ago

Dhruv80576 commented 3 weeks ago

fix #1068 Deleting symbols from between issue resolved now we can delete symbols from between the text also. Please find the video below to verify

https://github.com/user-attachments/assets/ba08ad22-f9d3-4cc2-bc36-1a71a7ba0f18

Summary by Sourcery

Fix the issue with deleting symbols from between text in the inline image provider and enhance the functionality by adding a method to move the cursor to the end of the text.

Bug Fixes:

Enhancements:

sourcery-ai[bot] commented 3 weeks ago

Reviewer's Guide by Sourcery

This PR fixes an issue with deleting symbols between text by implementing a new deletion handling mechanism in the InlineImageProvider class. The implementation adds cursor management and text manipulation functionality, along with keyboard event handling for backspace operations.

Sequence diagram for handling backspace in text field

sequenceDiagram
    actor User
    participant HomeScreen
    participant InlineImageProvider
    User->>HomeScreen: Press backspace
    HomeScreen->>InlineImageProvider: handleDelete()
    InlineImageProvider->>InlineImageProvider: Determine start and end
    alt Deleting a single character
        InlineImageProvider->>InlineImageProvider: Check for placeholder
        InlineImageProvider->>InlineImageProvider: deleteInlineImage(start-1, start)
    end
    InlineImageProvider->>HomeScreen: Update text field

Updated class diagram for InlineImageProvider

classDiagram
    class InlineImageProvider {
        +void moveCursorToEnd()
        +void deleteInlineImage(int start, int end)
        +void handleDelete()
    }
    note for InlineImageProvider "New methods added for cursor management and deletion handling"

File-Level Changes

Change Details Files
Added new text manipulation and cursor management methods to handle symbol deletion
  • Implemented moveCursorToEnd method to handle cursor positioning
  • Added deleteInlineImage method to handle text manipulation during deletion
  • Implemented handleDelete method to manage both single character and selection deletions
  • Added logic to handle special placeholder symbols (<<...>>) during deletion
lib/providers/imageprovider.dart
Enhanced text input field with keyboard event handling
  • Wrapped ExtendedTextField with KeyboardListener widget
  • Added backspace key event detection
  • Connected keyboard events to the new handleDelete functionality
lib/view/homescreen.dart

Assessment against linked issues

Issue Objective Addressed Explanation
#1068 Fix the ability to delete symbols from the EditText on homepage

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).