Skip to content

Conversation

Dhruv1797
Copy link
Contributor

@Dhruv1797 Dhruv1797 commented Jul 11, 2025

Fixes #84

Changes

added the Employee ID Card Generator feature where users can generate employee ID cards, apply filters, and transfer them to the ePaper.

Note for code review: The main code logic is in employee_id_controller.dart only. Please refer to this file for the code logic review; all rest of the code is just UI work.

Screenshots / Recordings

Here is the screen recording of employee id card generator feature:

employee_id_card_generator.mp4

Here is the image output on the epaper display:

image

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

Introduce a complete Employee ID Card generation workflow, including UI screens, dialogs, and controller logic, integrated into the image editor to allow users to input details, pick and preview profile images, generate the card as a PNG, and transfer it to the ePaper display.

New Features:

  • Add Employee ID Card Generator screen with form inputs and details preview
  • Implement dialogs for selecting and removing profile images and previewing the generated ID card
  • Provide profile image picker and employee details form with validation
  • Capture, rotate, and generate ID card image and integrate transfer to the ePaper device via the image editor

Enhancements:

  • Extend StringConstants with labels and messages for the ID card feature

Copy link
Contributor

sourcery-ai bot commented Jul 11, 2025

Reviewer's Guide

This PR implements a new Employee ID Card Generator feature by introducing a dedicated controller, screen, and supporting UI widgets, integrating it into the existing image editor flow, and expanding string constants for the new UI.

Sequence diagram for Employee ID Card generation and transfer

sequenceDiagram
    actor User
    participant ImageEditor as ImageEditor
    participant EmployeeIdGeneratorScreen as EmployeeIdGeneratorScreen
    participant EmployeeIdController as EmployeeIdController
    participant EPD as ePaperDisplay

    User->>ImageEditor: Tap 'ID Card' action
    ImageEditor->>EmployeeIdGeneratorScreen: Open EmployeeIdGeneratorScreen
    EmployeeIdGeneratorScreen->>EmployeeIdController: User fills form, picks image
    User->>EmployeeIdGeneratorScreen: Tap 'Generate' button
    EmployeeIdGeneratorScreen->>EmployeeIdController: generateIdCard()
    EmployeeIdController->>EmployeeIdController: Validate form, render ID card
    EmployeeIdController->>EmployeeIdController: Show preview dialog
    User->>EmployeeIdController: Confirm preview
    EmployeeIdController-->>EmployeeIdGeneratorScreen: Return generated ID card bytes
    EmployeeIdGeneratorScreen-->>ImageEditor: Return ID card bytes
    ImageEditor->>EPD: Transfer ID card image to ePaper
    ImageEditor->>ImageEditor: Save finalized image
Loading

Class diagram for Employee ID Card Generator core types

classDiagram
    class EmployeeIdController {
      - ImagePicker _picker
      - TextEditingController nameController
      - TextEditingController idController
      - TextEditingController designationController
      - TextEditingController departmentController
      - TextEditingController emailController
      - TextEditingController phoneController
      - TextEditingController companyController
      - bool _isGenerating
      - Uint8List? _profileImage
      + bool get isGenerating
      + Uint8List? get profileImage
      + pickProfileImage(context)
      + removeProfileImage(context)
      + generateIdCard(context, formKey, cardKey, epdHeight, epdWidth)
    }

    class EmployeeDetailsForm {
      + EmployeeIdController controller
      + GlobalKey<FormState> formKey
      + VoidCallback onChanged
    }

    class ProfileImagePicker {
      + EmployeeIdController controller
      + VoidCallback onTap
      + VoidCallback? onRemove
    }

    class IdCardPreview {
      + EmployeeIdController controller
    }

    EmployeeDetailsForm --> EmployeeIdController
    ProfileImagePicker --> EmployeeIdController
    IdCardPreview --> EmployeeIdController
Loading

Class diagram for Employee ID Card Generator dialogs

classDiagram
    class ImageSourceDialog {
      + String? title
      + String? subtitle
    }
    class PreviewDialog {
      + img.Image originalImage
      + int epdHeight
      + int epdWidth
      + String? title
      + String? subtitle
    }
    class RemoveProfileImageDialog {
      + String? title
      + String? subtitle
    }
Loading

File-Level Changes

Change Details Files
Integrated ID card generator entry point into the image editor
  • Added an “ID Card” action button in the bottom menu
  • Launched EmployeeIdGeneratorScreen on tap and updated the editor image with returned bytes
lib/view/image_editor.dart
Expanded application constants for new UI copy
  • Added labels and messages for card preview, dialogs, form fields, and buttons
  • Referenced all new strings from StringConstants to avoid hard-coding
lib/constants/string_constants.dart
Introduced end-to-end ID card generator feature
  • Created EmployeeIdController with image pick, remove, and generate logic using RepaintBoundary and image package
  • Built EmployeeIdGeneratorScreen with fade animation, form submission, and image capture workflow
  • Developed modular UI widgets: selection and confirmation dialogs, form fields, profile picker, generate button, and card preview
lib/employee_id_generator/controller/employee_id_controller.dart
lib/employee_id_generator/employee_id_generator_screen.dart
lib/employee_id_generator/widgets/dialogs/image_source_dialog.dart
lib/employee_id_generator/widgets/dialogs/remove_image_dialog.dart
lib/employee_id_generator/widgets/dialogs/id_card_preview_dialog.dart
lib/employee_id_generator/widgets/employee_details_form/employee_details_form.dart
lib/employee_id_generator/widgets/employee_details_form/employee_form_field.dart
lib/employee_id_generator/widgets/employee_details_form/profile_image_picker.dart
lib/employee_id_generator/widgets/id_card_preview/id_card_preview.dart
lib/employee_id_generator/widgets/id_card_preview/card_details_row.dart
lib/employee_id_generator/widgets/generate_button.dart

Assessment against linked issues

Issue Objective Addressed Explanation

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 and found some issues that need to be addressed.

Blocking issues:

  • StringConstants.continueButton is not defined in string_constants.dart. (link)

General comments:

  • There’s a lot of duplicated dialog code across multiple widgets—consider extracting common dialog layout and button styles into a reusable base widget to reduce boilerplate and keep the UI consistent.
  • The generateIdCard method in EmployeeIdController is quite long and mixes UI and rendering logic—splitting it into smaller private helper methods would improve readability and maintainability.
  • You’re creating nearly identical SnackBars in several places; abstracting snackBar construction into a shared utility would eliminate duplication and ensure a consistent look and feel.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- There’s a lot of duplicated dialog code across multiple widgets—consider extracting common dialog layout and button styles into a reusable base widget to reduce boilerplate and keep the UI consistent.
- The generateIdCard method in EmployeeIdController is quite long and mixes UI and rendering logic—splitting it into smaller private helper methods would improve readability and maintainability.
- You’re creating nearly identical SnackBars in several places; abstracting snackBar construction into a shared utility would eliminate duplication and ensure a consistent look and feel.

## Individual Comments

### Comment 1
<location> `lib/employee_id_generator/widgets/employee_details_form/employee_form_field.dart:122` </location>
<code_context>
+    switch (widget.validationType) {
+      case ValidationType.phone:
+        return [
+          FilteringTextInputFormatter.digitsOnly,
+          LengthLimitingTextInputFormatter(10),
+        ];
+      default:
</code_context>

<issue_to_address>
LengthLimitingTextInputFormatter(10) may restrict international phone numbers.

Consider increasing the digit limit or making it dynamic to support longer international phone numbers.

Suggested implementation:

```
      case ValidationType.phone:
        // Use a higher default limit for international numbers, or make it dynamic if desired
        final int maxPhoneLength = widget.maxPhoneLength ?? 15; // 15 is the ITU E.164 max length
        return [
          FilteringTextInputFormatter.digitsOnly,
          LengthLimitingTextInputFormatter(maxPhoneLength),
        ];

```

- You will need to add a `final int? maxPhoneLength;` property to your widget class and accept it in the constructor if you want to make the limit dynamic.
- If you do not want to make it dynamic, you can simply use the default value of 15 as shown.
</issue_to_address>

### Comment 2
<location> `lib/employee_id_generator/widgets/dialogs/image_source_dialog.dart:292` </location>
<code_context>
+                        size: 20,
+                      ),
+                      const SizedBox(width: 8),
+                      const Text(
+                        StringConstants.continueButton,
+                        style: TextStyle(
+                            fontSize: 16, fontWeight: FontWeight.w600),
</code_context>

<issue_to_address>
StringConstants.continueButton is not defined in string_constants.dart.

This reference will cause a runtime error. Please add the missing constant or update the reference.
</issue_to_address>

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

  • StringConstants.continueButton is not defined in string_constants.dart. (link)

its already present in main branch in StringConstants Class.

@Dhruv1797
Copy link
Contributor Author

@Vishveshwara @AsCress @mariobehling @Jhalakupadhyay The main code logic is in employee_id_controller.dart only. Please refer to this file for the code logic review; all rest of the code is just UI work.

@Dhruv1797
Copy link
Contributor Author

Here is the drive link for the updated apk file for this feature:
https://drive.google.com/file/d/1lZ4sOijxV0wpaK8hDVlx7FXXUm_7LgaJ/view?usp=sharing

@marcnause please review and test it.

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.

Not looking in the quality of the code, the UI and the use case is really good. But the rendered font is unreadable. Here is some resources I think you could apply to improve this feature: https://en.wikipedia.org/wiki/Font_rasterization

@hpdang
Copy link
Member

hpdang commented Jul 21, 2025

@Dhruv1797 how did you and Vish align on this? I believe he also implemented an employee ID card in the template feature. I don’t think we need separate “ID card” and “template” functionalities, these two can be combined into a single feature? #96

@Vishveshwara
Copy link
Contributor

@Dhruv1797 how did you and Vish align on this? I believe he also implemented an employee ID card in the template feature. I don’t think we need separate “ID card” and “template” functionalities, these two can be combined into a single feature? #96

Yes this PR is not necessary now.

@hpdang
Copy link
Member

hpdang commented Jul 23, 2025

implemented in #96

@hpdang hpdang closed this Jul 23, 2025
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.

Employee ID Card Generator Feature
4 participants