Files
worker/lib/core/constants/app_constants.dart
Phuoc Nguyen 628c81ce13 runable
2025-10-17 17:22:28 +07:00

522 lines
14 KiB
Dart

/// Application-level constants and configurations
///
/// This file contains app metadata, loyalty tier definitions, pagination settings,
/// and other application-wide configuration values.
library;
// ============================================================================
// Loyalty Member Tiers
// ============================================================================
/// Membership tier levels in the loyalty program
///
/// Ordered from lowest to highest:
/// - [MemberTier.gold]: Entry level (0-999 points)
/// - [MemberTier.platinum]: Mid level (1000-4999 points)
/// - [MemberTier.diamond]: Premium level (5000+ points)
enum MemberTier {
/// Gold tier - Entry level membership
/// Requirements: 0-999 points
/// Benefits: 1x points multiplier, basic discounts
gold,
/// Platinum tier - Mid level membership
/// Requirements: 1000-4999 points
/// Benefits: 1.5x points multiplier, priority support, special offers
platinum,
/// Diamond tier - Premium membership
/// Requirements: 5000+ points
/// Benefits: 2x points multiplier, exclusive rewards, VIP support, early access
diamond,
}
/// Extension methods for MemberTier enum
extension MemberTierExtension on MemberTier {
/// Get display name for the tier
String get displayName {
switch (this) {
case MemberTier.gold:
return 'Gold';
case MemberTier.platinum:
return 'Platinum';
case MemberTier.diamond:
return 'Diamond';
}
}
/// Get Vietnamese display name
String get displayNameVi {
switch (this) {
case MemberTier.gold:
return 'Vàng';
case MemberTier.platinum:
return 'Bạc';
case MemberTier.diamond:
return 'Kim Cương';
}
}
/// Get points multiplier for earning rewards
double get pointsMultiplier {
switch (this) {
case MemberTier.gold:
return 1.0;
case MemberTier.platinum:
return 1.5;
case MemberTier.diamond:
return 2.0;
}
}
/// Get minimum points required for this tier
int get minPoints {
switch (this) {
case MemberTier.gold:
return 0;
case MemberTier.platinum:
return 1000;
case MemberTier.diamond:
return 5000;
}
}
/// Get maximum points for this tier (null for diamond = unlimited)
int? get maxPoints {
switch (this) {
case MemberTier.gold:
return 999;
case MemberTier.platinum:
return 4999;
case MemberTier.diamond:
return null; // Unlimited
}
}
/// Get next tier (null if already at highest tier)
MemberTier? get nextTier {
switch (this) {
case MemberTier.gold:
return MemberTier.platinum;
case MemberTier.platinum:
return MemberTier.diamond;
case MemberTier.diamond:
return null; // Already at top
}
}
/// Get tier from points value
static MemberTier fromPoints(int points) {
if (points >= MemberTier.diamond.minPoints) {
return MemberTier.diamond;
} else if (points >= MemberTier.platinum.minPoints) {
return MemberTier.platinum;
} else {
return MemberTier.gold;
}
}
}
// ============================================================================
// User Types
// ============================================================================
/// Types of users in the Worker app
enum UserType {
/// Contractor - Construction project managers (Thầu thợ)
contractor,
/// Architect - Design professionals (Kiến trúc sư)
architect,
/// Distributor - Product resellers (Đại lý phân phối)
distributor,
/// Broker - Real estate and construction brokers (Môi giới)
broker,
}
/// Extension methods for UserType enum
extension UserTypeExtension on UserType {
/// Get display name
String get displayName {
switch (this) {
case UserType.contractor:
return 'Contractor';
case UserType.architect:
return 'Architect';
case UserType.distributor:
return 'Distributor';
case UserType.broker:
return 'Broker';
}
}
/// Get Vietnamese display name
String get displayNameVi {
switch (this) {
case UserType.contractor:
return 'Thầu thợ';
case UserType.architect:
return 'Kiến trúc sư';
case UserType.distributor:
return 'Đại lý phân phối';
case UserType.broker:
return 'Môi giới';
}
}
}
// ============================================================================
// Order Status
// ============================================================================
/// Order lifecycle status
enum OrderStatus {
/// Order placed, awaiting processing
pending,
/// Order is being prepared
processing,
/// Order is out for delivery
shipping,
/// Order delivered successfully
completed,
/// Order cancelled by user or system
cancelled,
}
/// Extension methods for OrderStatus enum
extension OrderStatusExtension on OrderStatus {
String get displayName {
switch (this) {
case OrderStatus.pending:
return 'Pending';
case OrderStatus.processing:
return 'Processing';
case OrderStatus.shipping:
return 'Shipping';
case OrderStatus.completed:
return 'Completed';
case OrderStatus.cancelled:
return 'Cancelled';
}
}
String get displayNameVi {
switch (this) {
case OrderStatus.pending:
return 'Chờ xử lý';
case OrderStatus.processing:
return 'Đang xử lý';
case OrderStatus.shipping:
return 'Đang giao';
case OrderStatus.completed:
return 'Hoàn thành';
case OrderStatus.cancelled:
return 'Đã hủy';
}
}
}
// ============================================================================
// Project Status
// ============================================================================
/// Construction project lifecycle status
enum ProjectStatus {
/// Project in planning phase
planning,
/// Project actively in progress
inProgress,
/// Project completed
completed,
/// Project on hold
onHold,
/// Project cancelled
cancelled,
}
extension ProjectStatusExtension on ProjectStatus {
String get displayName {
switch (this) {
case ProjectStatus.planning:
return 'Planning';
case ProjectStatus.inProgress:
return 'In Progress';
case ProjectStatus.completed:
return 'Completed';
case ProjectStatus.onHold:
return 'On Hold';
case ProjectStatus.cancelled:
return 'Cancelled';
}
}
String get displayNameVi {
switch (this) {
case ProjectStatus.planning:
return 'Lên kế hoạch';
case ProjectStatus.inProgress:
return 'Đang thực hiện';
case ProjectStatus.completed:
return 'Hoàn thành';
case ProjectStatus.onHold:
return 'Tạm dừng';
case ProjectStatus.cancelled:
return 'Đã hủy';
}
}
}
// ============================================================================
// Project Types
// ============================================================================
/// Types of construction projects
enum ProjectType {
/// Residential construction
residential,
/// Commercial construction
commercial,
/// Industrial construction
industrial,
}
extension ProjectTypeExtension on ProjectType {
String get displayName {
switch (this) {
case ProjectType.residential:
return 'Residential';
case ProjectType.commercial:
return 'Commercial';
case ProjectType.industrial:
return 'Industrial';
}
}
String get displayNameVi {
switch (this) {
case ProjectType.residential:
return 'Dân dụng';
case ProjectType.commercial:
return 'Thương mại';
case ProjectType.industrial:
return 'Công nghiệp';
}
}
}
// ============================================================================
// App Metadata
// ============================================================================
/// Application constants
class AppConstants {
// Private constructor to prevent instantiation
AppConstants._();
/// Application name
static const String appName = 'Worker';
/// Full application name
static const String appFullName = 'Worker - EuroTile & Vasta Stone';
/// Application version
static const String appVersion = '1.0.0';
/// Build number
static const int buildNumber = 1;
/// Company name
static const String companyName = 'EuroTile & Vasta Stone';
/// Support email
static const String supportEmail = 'support@worker.example.com';
/// Support phone number (Vietnamese format)
static const String supportPhone = '1900 xxxx';
/// Website URL
static const String websiteUrl = 'https://worker.example.com';
// ============================================================================
// Pagination Settings
// ============================================================================
/// Default page size for paginated lists
static const int defaultPageSize = 20;
/// Products page size
static const int productsPageSize = 20;
/// Orders page size
static const int ordersPageSize = 10;
/// Projects page size
static const int projectsPageSize = 15;
/// Notifications page size
static const int notificationsPageSize = 25;
/// Points history page size
static const int pointsHistoryPageSize = 20;
/// Maximum items to load at once
static const int maxPageSize = 100;
// ============================================================================
// Cache Settings
// ============================================================================
/// Cache duration for products (in hours)
static const int productsCacheDuration = 24;
/// Cache duration for user profile (in hours)
static const int profileCacheDuration = 1;
/// Cache duration for categories (in hours)
static const int categoriesCacheDuration = 48;
/// Maximum cache size (in MB)
static const int maxCacheSize = 100;
// ============================================================================
// OTP Settings
// ============================================================================
/// OTP code length (6 digits)
static const int otpLength = 6;
/// OTP resend cooldown (in seconds)
static const int otpResendCooldown = 60;
/// OTP validity duration (in minutes)
static const int otpValidityMinutes = 5;
// ============================================================================
// Referral Settings
// ============================================================================
/// Points earned per successful referral
static const int pointsPerReferral = 100;
/// Points earned by the referred user on signup
static const int welcomeBonusPoints = 50;
// ============================================================================
// Order Settings
// ============================================================================
/// Minimum order amount (in VND)
static const double minOrderAmount = 100000; // 100,000 VND
/// Free shipping threshold (in VND)
static const double freeShippingThreshold = 1000000; // 1,000,000 VND
/// Standard shipping fee (in VND)
static const double standardShippingFee = 30000; // 30,000 VND
/// Maximum items per order
static const int maxItemsPerOrder = 50;
// ============================================================================
// Image Settings
// ============================================================================
/// Maximum avatar size (in MB)
static const int maxAvatarSize = 5;
/// Maximum product image size (in MB)
static const int maxProductImageSize = 3;
/// Supported image formats
static const List<String> supportedImageFormats = ['jpg', 'jpeg', 'png', 'webp'];
/// Image quality for compression (0-100)
static const int imageQuality = 85;
// ============================================================================
// Search Settings
// ============================================================================
/// Minimum search query length
static const int minSearchLength = 2;
/// Search debounce delay (in milliseconds)
static const int searchDebounceMs = 500;
/// Maximum search results
static const int maxSearchResults = 50;
// ============================================================================
// Date & Time Settings
// ============================================================================
/// Default date format (Vietnamese: dd/MM/yyyy)
static const String dateFormat = 'dd/MM/yyyy';
/// Date time format
static const String dateTimeFormat = 'dd/MM/yyyy HH:mm';
/// Time format (24-hour)
static const String timeFormat = 'HH:mm';
/// Full date time format
static const String fullDateTimeFormat = 'EEEE, dd MMMM yyyy HH:mm';
// ============================================================================
// Validation Settings
// ============================================================================
/// Minimum password length
static const int minPasswordLength = 8;
/// Maximum password length
static const int maxPasswordLength = 50;
/// Minimum name length
static const int minNameLength = 2;
/// Maximum name length
static const int maxNameLength = 100;
/// Vietnamese phone number regex pattern
/// Matches: 0912345678, +84912345678, 84912345678
static const String phoneRegexPattern = r'^(0|\+84|84)[3|5|7|8|9][0-9]{8}$';
/// Email regex pattern
static const String emailRegexPattern = r'^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$';
// ============================================================================
// Feature Flags
// ============================================================================
/// Enable dark mode
static const bool enableDarkMode = true;
/// Enable biometric authentication
static const bool enableBiometric = true;
/// Enable push notifications
static const bool enablePushNotifications = true;
/// Enable offline mode
static const bool enableOfflineMode = true;
/// Enable analytics
static const bool enableAnalytics = true;
/// Enable crash reporting
static const bool enableCrashReporting = true;
}