-
Notifications
You must be signed in to change notification settings - Fork 13
feat: added employee id card generator feature. #85
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
feat: added employee id card generator feature. #85
Conversation
Reviewer's GuideThis 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 transfersequenceDiagram
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
Class diagram for Employee ID Card Generator core typesclassDiagram
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
Class diagram for Employee ID Card Generator dialogsclassDiagram
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
}
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this 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>
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
lib/employee_id_generator/widgets/employee_details_form/employee_form_field.dart
Show resolved
Hide resolved
its already present in |
@Vishveshwara @AsCress @mariobehling @Jhalakupadhyay The main code logic is in |
Here is the drive link for the updated apk file for this feature: @marcnause please review and test it. |
There was a problem hiding this 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
@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. |
implemented in #96 |
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:
Checklist:
constants.dart
without hard coding any value.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:
Enhancements: