Skip to content

feat: added transferring progress indicator with error handling. #75

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Dhruv1797
Copy link
Contributor

@Dhruv1797 Dhruv1797 commented Jun 27, 2025

Fixes: #64
added a smooth progress indicator for image transfers with better error handling. Now users can easily track transfer progress and understand any issues if they occur.

Here is the demo video:

VID_20250627_170057529.mp4

Summary by Sourcery

Implement real-time progress reporting and user feedback during E-Paper image transfers by extending the Protocol layer with progress callbacks and introducing a dedicated transfer dialog in the UI that handles animations, status updates, and error/success states.

New Features:

  • Expose progress and tag detection callbacks in Protocol.writeFrame and writeImages for granular transfer reporting
  • Add a TransferProgressDialog widget that displays NFC search animation, circular and linear progress bars, and handles error/success states
  • Integrate the transfer progress dialog into ImageEditor and await completion before closing

Enhancements:

  • Emit detailed status messages at key stages (waiting for tag, chunk writes, display refresh) to guide users through the transfer
  • Improve error handling by catching exceptions in the transfer flow and surfacing messages in the dialog

Copy link
Contributor

sourcery-ai bot commented Jun 27, 2025

Reviewer's Guide

This PR augments the NFC image transfer workflow by adding fine-grained progress and error callbacks inside the Protocol layer and introducing a modal TransferProgressDialog in the UI to visualize NFC detection, ongoing transfer progress, and failure or success states with animations.

Sequence diagram for image transfer with progress and error handling

sequenceDiagram
    actor User
    participant ImageEditor
    participant TransferProgressDialog
    participant Protocol
    participant Device

    User->>ImageEditor: Tap 'Transfer' button
    ImageEditor->>TransferProgressDialog: Show dialog
    TransferProgressDialog->>Protocol: writeImages(image, onProgress, onTagDetected)
    Protocol->>TransferProgressDialog: onProgress(0.0, "Waiting for NFC tag...")
    Protocol->>Device: NFC poll
    Device-->>Protocol: Tag detected
    Protocol->>TransferProgressDialog: onTagDetected()
    Protocol->>TransferProgressDialog: onProgress(0.1, "Tag detected! Initializing...")
    loop For each frame
        Protocol->>TransferProgressDialog: onProgress(progress, status)
        Protocol->>Device: Write frame chunk
        Device-->>Protocol: Ack
    end
    Protocol->>TransferProgressDialog: onProgress(0.95, "Refreshing display...")
    Protocol->>Device: Refresh display
    Protocol->>TransferProgressDialog: onProgress(1.0, "Transfer complete!")
    TransferProgressDialog->>User: Show success or error
Loading

File-Level Changes

Change Details Files
Add progress and tag-detection callbacks to Protocol and report transfer stages
  • Define ProgressCallback and TagDetectedCallback types
  • Extend writeFrame with optional onProgress and emit chunk-level progress
  • Extend writeImages with onProgress and onTagDetected hooks
  • Invoke callbacks at key stages (waiting for tag, tag detected, harvesting, per-frame/chunk, refresh, completion)
lib/util/protocol.dart
Integrate progress dialog into ImageEditor and update transfer trigger
  • Import TransferProgressDialog widget
  • Add _showTransferProgress wrapper to launch dialog and pass callbacks
  • Change transfer button’s onPressed to await _showTransferProgress instead of direct writeImages
lib/view/image_editor.dart
Introduce TransferProgressDialog widget with animated states and error handling
  • Create modal dialog showing NFC search, progress bar, status text
  • Implement animations (pulse for NFC, slide/scale for entry and success)
  • Manage state for tagDetected, transferComplete, errorMessage
  • Catch transferFunction exceptions and display failure UI with retry/close or success UI with Done button
lib/view/widget/transfer_progress_dialog.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. 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

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 @Dhruv1797 - I've reviewed your changes - here's some feedback:

  • The TransferProgressDialog widget is very large—consider breaking it into smaller sub-widgets or moving parts into their own files to improve readability and maintainability.
  • You should extract the hard-coded status messages in Protocol.writeImages into constants or a localization layer to keep them consistent and support future i18n.
  • Instead of exposing raw exception strings in the dialog, catch specific errors in writeImages and map them to more user-friendly messages for better UX.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The TransferProgressDialog widget is very large—consider breaking it into smaller sub-widgets or moving parts into their own files to improve readability and maintainability.
- You should extract the hard-coded status messages in Protocol.writeImages into constants or a localization layer to keep them consistent and support future i18n.
- Instead of exposing raw exception strings in the dialog, catch specific errors in writeImages and map them to more user-friendly messages for better UX.

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.

@Dhruv1797
Copy link
Contributor Author

@Vishveshwara @kienvo @AsCress @Jhalakupadhyay please have a look and review it once.

Copy link
Contributor

@Vishveshwara Vishveshwara left a comment

Choose a reason for hiding this comment

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

Hey @Dhruv1797 , please check the comments I have shared

Copy link
Member

@kienvo kienvo left a comment

Choose a reason for hiding this comment

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

Looks good!

It would be nice if we had something like a dialog telling users to hold their phone still after the transfer is done, to wait for the display to refresh.

Currently, there is no way to read the busy state of the display, so deciding to pull away the phone is up to the user's observation.

@Jhalakupadhyay
Copy link
Contributor

@Dhruv1797 we just need one progress indicator take the circular one and remove the bottom linear progress indicator.

@Dhruv1797
Copy link
Contributor Author

update: added the diplay refreshing state for average of 15sec duration, removed linear loader and user friendly error handling

Here is the updated demo video:

WhatsApp.Video.2025-07-01.at.12.45.57.PM.mp4

@kienvo @Jhalakupadhyay @Vishveshwara please review the changes once.

@Dhruv1797 Dhruv1797 requested review from kienvo and Vishveshwara July 1, 2025 07:42
Copy link
Contributor

@Vishveshwara Vishveshwara left a comment

Choose a reason for hiding this comment

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

Looks very good, well done ! can you please share a video of you transferring a small image , like a canvas drawing.

@Dhruv1797
Copy link
Contributor Author

Looks very good, well done ! can you please share a video of you transferring a small image , like a canvas drawing.

Here is the demo video of transferring small image from canvas drawing:

WhatsApp.Video.2025-07-02.at.3.03.37.PM.mp4

@Vishveshwara please check it once.

@Vishveshwara
Copy link
Contributor

Looks very good, well done ! can you please share a video of you transferring a small image , like a canvas drawing.

Here is the demo video of transferring small image from canvas drawing:

WhatsApp.Video.2025-07-02.at.3.03.37.PM.mp4
@Vishveshwara please check it once.

Looks good , but at 24th second why is it reading the nfc tag ? is it by mistake

@Dhruv1797
Copy link
Contributor Author

Looks good , but at 24th second why is it reading the nfc tag ? is it by mistake

@Vishveshwara actually, it started reading the NFC tag since I used it for NDEF operations earlier. Maybe it still has some data in its memory, which is why it’s being read now. There are no changes from the code side.

@kienvo
Copy link
Member

kienvo commented Jul 3, 2025

Looks good , but at 24th second why is it reading the nfc tag ? is it by mistake

It's Android's system service, probably has higher priority than the app.

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.

Transferring progress indicator
4 participants