-
Notifications
You must be signed in to change notification settings - Fork 96
Add receipt customization feature with multiple templates and drag-and-drop component editor #230
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
base: master
Are you sure you want to change the base?
Conversation
Co-authored-by: evan361425 <14554683+evan361425@users.noreply.github.com>
Co-authored-by: evan361425 <14554683+evan361425@users.noreply.github.com>
Co-authored-by: evan361425 <14554683+evan361425@users.noreply.github.com>
|
@copilot Save templates by storage (sembast) and allow multiple templates and use the one that have enabled. If there is any template enabled, while other template enabling it will show alert dialog tells that it will disable all the other templates. Same as order attribute default option. |
- Add receiptTemplates store to Stores enum - Create ReceiptTemplate model with ModelStorage - Create ReceiptTemplates repository similar to OrderAttributes - Replace ReceiptSetting with template-based system - Add isDefault property to templates (one template enabled at a time) - Show confirmation dialog when enabling template (disables others) - Update UI to manage multiple templates - Create ReceiptTemplateModal for creating/editing templates - Create ReceiptTemplateComponentEditorPage for editing components - Add routes for template management - Update localization strings - Initialize ReceiptTemplates in main.dart - Remove old ReceiptSetting from settings provider Co-authored-by: evan361425 <14554683+evan361425@users.noreply.github.com>
Implemented in commit 2d94784. Changes:
Architecture:
On first run, creates "Default Template" with original layout. Receipts use |
Overview
This PR implements a comprehensive receipt customization system that allows users to create and manage multiple receipt templates with customizable components. Users can create multiple templates, enable one at a time, and configure each template's components through an intuitive drag-and-drop interface.
Features
Multiple Template Management
Component Types (7 types)
User Interface
Technical Implementation
Data Models:
ReceiptComponent(lib/models/receipt_component.dart): Abstract base class with type-safe implementationsReceiptTemplate(lib/models/repository/receipt_template.dart): Model extendingModelwithModelStorageReceiptTemplateObject(lib/models/objects/receipt_template_object.dart): Data object for serializationcopyWithmethodsRepository Pattern (
lib/models/repository/receipt_templates.dart):Repository<ReceiptTemplate>withRepositoryStoragedefaultTemplategetter returns currently enabled templateclearDefault()method for switching templatesReceipt Rendering (
lib/ui/printer/widgets/printer_receipt_view.dart):ReceiptTemplates.instance.currentComponentsfor dynamic renderingEditor UI:
ReceiptEditorPage: Lists all templates with create/edit actionsReceiptTemplateModal: Create/edit template name and default statusReceiptTemplateComponentEditorPage: Edit components within a specific templateReorderableListViewfor native Flutter drag-and-dropLocalization
Added localization keys for:
Both English and Chinese translations are complete.
Code Quality
Breaking Changes
None. The implementation is fully backwards compatible. On first run, creates a "Default Template" with the original hardcoded layout. If customization is not configured, the system uses the default layout.
Testing
Manual Testing Required
make build-l10nmake formatmake lintmake testTest Scenarios
Screenshots
Screenshots to be added after
make build-l10nis run and the feature is testedImplementation Notes
The feature uses a clean architecture with separation of concerns:
ReceiptTemplateextendsModelwithModelStoragemixinReceiptTemplatesmanages multiple templates following Repository patternThe system follows the same pattern as OrderAttribute/OrderAttributeOption for consistency:
Future Enhancements
Potential future additions could include:
Related Issues
Closes #[issue-number] - Allow user to customize receipts to print
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.