Game Prize and Logout

This commit is contained in:
efrilm
2025-09-18 10:39:54 +07:00
parent 006486bc2a
commit 3c596461c6
31 changed files with 4189 additions and 677 deletions
@@ -20,6 +20,7 @@ class PrizeHistory {
final int value;
final Color color;
final IconData icon;
final String? gamePrizeId; // Added for API integration
PrizeHistory({
required this.prize,
@@ -27,5 +28,73 @@ class PrizeHistory {
required this.value,
required this.color,
required this.icon,
this.gamePrizeId,
});
// CopyWith method for updating properties
PrizeHistory copyWith({
String? prize,
DateTime? dateTime,
int? value,
Color? color,
IconData? icon,
String? gamePrizeId,
}) {
return PrizeHistory(
prize: prize ?? this.prize,
dateTime: dateTime ?? this.dateTime,
value: value ?? this.value,
color: color ?? this.color,
icon: icon ?? this.icon,
gamePrizeId: gamePrizeId ?? this.gamePrizeId,
);
}
// Convert to Map for storage/API calls
Map<String, dynamic> toMap() {
return {
'prize': prize,
'dateTime': dateTime.toIso8601String(),
'value': value,
'gamePrizeId': gamePrizeId,
};
}
// Create from Map for loading from storage/API
factory PrizeHistory.fromMap(
Map<String, dynamic> map, {
required Color color,
required IconData icon,
}) {
return PrizeHistory(
prize: map['prize'] ?? '',
dateTime: DateTime.tryParse(map['dateTime'] ?? '') ?? DateTime.now(),
value: map['value'] ?? 0,
color: color,
icon: icon,
gamePrizeId: map['gamePrizeId'],
);
}
// Format date for display
String get formattedDate {
return '${dateTime.day.toString().padLeft(2, '0')}/${dateTime.month.toString().padLeft(2, '0')}/${dateTime.year} ${dateTime.hour.toString().padLeft(2, '0')}:${dateTime.minute.toString().padLeft(2, '0')}';
}
// Get prize category based on value
String get prizeCategory {
if (value >= 1000000) return 'Jackpot';
if (value >= 100000) return 'Big Prize';
if (value >= 10000) return 'Medium Prize';
if (value >= 1000) return 'Small Prize';
return 'Token/Spin';
}
// Get prize category color
Color get categoryColor {
if (value >= 1000000) return const Color(0xFFFFD700); // Gold
if (value >= 100000) return const Color(0xFFC0C0C0); // Silver
if (value >= 10000) return const Color(0xFFCD7F32); // Bronze
return color; // Default color
}
}
File diff suppressed because it is too large Load Diff