3.8 KiB
3.8 KiB
Price Policy Feature Implementation
✅ Files Created
Domain Layer
lib/features/price_policy/domain/entities/price_document.dartlib/features/price_policy/domain/entities/price_document.freezed.dart
Presentation Layer
lib/features/price_policy/presentation/providers/price_documents_provider.dartlib/features/price_policy/presentation/providers/price_documents_provider.g.dartlib/features/price_policy/presentation/pages/price_policy_page.dartlib/features/price_policy/presentation/widgets/document_card.dart
Exports
lib/features/price_policy/price_policy.dart(barrel export)
Router
- Updated
lib/core/router/app_router.dart
🔧 Fixes Applied
1. Removed Unused Import
File: price_policy_page.dart
- ❌ Removed:
import 'package:intl/intl.dart';(unused)
2. Fixed Provider Pattern
File: price_documents_provider.dart
- ❌ Before: Used class-based
NotifierProviderpattern - ✅ After: Used functional
@riverpodprovider pattern - This matches the pattern used by simple providers in the project (like
gifts_provider.dart)
// ✅ Correct pattern
@riverpod
List<PriceDocument> priceDocuments(PriceDocumentsRef ref) {
return _mockDocuments;
}
@riverpod
List<PriceDocument> filteredPriceDocuments(
FilteredPriceDocumentsRef ref,
DocumentCategory category,
) {
final allDocs = ref.watch(priceDocumentsProvider);
return allDocs.where((doc) => doc.category == category).toList();
}
3. Fixed Hash Code Generation
File: price_documents_provider.g.dart
- ❌ Before: Used
_SystemHash(undefined) - ✅ After: Used
Object.hash(built-in Dart)
4. Added Barrel Export
File: price_policy.dart
- Created centralized export file for cleaner imports
5. Updated Router Import
File: app_router.dart
- ❌ Before:
import 'package:worker/features/price_policy/presentation/pages/price_policy_page.dart'; - ✅ After:
import 'package:worker/features/price_policy/price_policy.dart';
🎨 Features Implemented
Page Structure
- AppBar: Standard black text, white background, info button
- Tabs: 2 tabs (Chính sách giá / Bảng giá)
- Document Cards: Responsive layout with icon, info, and download button
Documents Included
Tab 1: Chính sách giá (4 PDF documents)
- Chính sách giá Eurotile T10/2025
- Chính sách giá Vasta Stone T10/2025
- Chính sách chiết khấu đại lý 2025
- Điều kiện thanh toán & giao hàng
Tab 2: Bảng giá (5 Excel documents)
- Bảng giá Gạch Granite Eurotile 2025
- Bảng giá Gạch Ceramic Eurotile 2025
- Bảng giá Đá tự nhiên Vasta Stone 2025
- Bảng giá Phụ kiện & Vật liệu 2025
- Bảng giá Gạch Outdoor & Chống trơn 2025
🚀 Usage
Navigation
// Push to price policy page
context.push(RouteNames.pricePolicy);
// or
context.push('/price-policy');
Import
import 'package:worker/features/price_policy/price_policy.dart';
✅ Testing Checklist
- Domain entity created with Freezed
- Providers created with Riverpod
- Page UI matches HTML reference
- Tabs work correctly
- Document cards display properly
- Download button shows SnackBar
- Info dialog displays
- Pull-to-refresh works
- Empty state handling
- Responsive layout (mobile/desktop)
- Route added to router
- All imports resolved
- No build errors
📝 Next Steps (Optional)
Backend Integration
- Create API endpoints for document list
- Implement actual file download
- Add document upload for admin
Enhanced Features
- Add search functionality
- Add date range filter
- Add document preview
- Add offline caching with Hive
- Add download progress indicator
- Add file sharing functionality
🎯 Reference
Based on HTML design: html/chinh-sach-gia.html