feat: draw detail page

This commit is contained in:
efrilm
2025-08-29 15:40:45 +07:00
parent 8951ca44eb
commit c36a4059e1
4 changed files with 1270 additions and 306 deletions
+223 -204
View File
@@ -2,6 +2,7 @@ import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart';
import '../../../common/theme/theme.dart';
import '../../router/app_router.gr.dart';
// Models (simplified)
class DrawEvent {
@@ -220,242 +221,260 @@ class _DrawPageState extends State<DrawPage> {
_isUserEntered(draw.id);
final timeRemaining = _getTimeRemaining(draw.drawDate);
return Container(
margin: EdgeInsets.only(bottom: 16),
decoration: BoxDecoration(
color: AppColor.surface,
borderRadius: BorderRadius.circular(12),
boxShadow: [
BoxShadow(
color: AppColor.black.withOpacity(0.08),
blurRadius: 12,
offset: Offset(0, 4),
),
],
),
child: Column(
children: [
// Header with gradient background
Container(
height: 160,
width: double.infinity,
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [draw.primaryColor, draw.primaryColor.withOpacity(0.8)],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
borderRadius: BorderRadius.vertical(top: Radius.circular(12)),
return GestureDetector(
onTap: () => context.router.push(DrawDetailRoute(drawEvent: draw)),
child: Container(
margin: EdgeInsets.only(bottom: 16),
decoration: BoxDecoration(
color: AppColor.surface,
borderRadius: BorderRadius.circular(12),
boxShadow: [
BoxShadow(
color: AppColor.black.withOpacity(0.08),
blurRadius: 12,
offset: Offset(0, 4),
),
child: Stack(
children: [
// Background pattern (coins and gold bar)
Positioned(
right: 20,
top: 20,
child: Opacity(
opacity: 0.3,
child: Column(
children: [
Row(
children: [
_buildCoin(),
SizedBox(width: 8),
_buildCoin(),
],
),
SizedBox(height: 8),
_buildGoldBar(),
],
],
),
child: Column(
children: [
// Header with gradient background
Container(
height: 160,
width: double.infinity,
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
draw.primaryColor,
draw.primaryColor.withOpacity(0.8),
],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
borderRadius: BorderRadius.vertical(top: Radius.circular(12)),
),
child: Stack(
children: [
// Background pattern (coins and gold bar)
Positioned(
right: 20,
top: 20,
child: Opacity(
opacity: 0.3,
child: Column(
children: [
Row(
children: [
_buildCoin(),
SizedBox(width: 8),
_buildCoin(),
],
),
SizedBox(height: 8),
_buildGoldBar(),
],
),
),
),
),
// Content
Padding(
padding: EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (draw.isActive)
Container(
padding: EdgeInsets.symmetric(
horizontal: 8,
vertical: 4,
),
decoration: BoxDecoration(
color: AppColor.success,
borderRadius: BorderRadius.circular(4),
),
child: Text(
"AKTIF",
style: AppStyle.xs.copyWith(
color: AppColor.textWhite,
fontWeight: FontWeight.bold,
// Content
Padding(
padding: EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (draw.isActive)
Container(
padding: EdgeInsets.symmetric(
horizontal: 8,
vertical: 4,
),
decoration: BoxDecoration(
color: AppColor.success,
borderRadius: BorderRadius.circular(4),
),
child: Text(
"AKTIF",
style: AppStyle.xs.copyWith(
color: AppColor.textWhite,
fontWeight: FontWeight.bold,
),
),
),
SizedBox(height: 8),
Text(
"MAKAN\nDAPAT",
style: AppStyle.h5.copyWith(
color: AppColor.textWhite,
fontWeight: FontWeight.bold,
height: 0.9,
),
),
SizedBox(height: 8),
Text(
"MAKAN\nDAPAT",
style: AppStyle.h5.copyWith(
color: AppColor.textWhite,
fontWeight: FontWeight.bold,
height: 0.9,
SizedBox(height: 4),
Text(
draw.description,
style: AppStyle.sm.copyWith(
color: AppColor.textWhite,
),
),
),
SizedBox(height: 4),
Text(
draw.description,
style: AppStyle.sm.copyWith(color: AppColor.textWhite),
),
],
],
),
),
),
],
],
),
),
),
// Card content
Padding(
padding: EdgeInsets.all(16),
child: Column(
children: [
// Prize info
Row(
children: [
Text(draw.icon, style: AppStyle.h5),
SizedBox(width: 8),
Text(
draw.prize,
style: AppStyle.lg.copyWith(
fontWeight: FontWeight.bold,
color: AppColor.textPrimary,
),
),
],
),
SizedBox(height: 16),
// Stats row
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
children: [
Text(
"-",
style: AppStyle.h5.copyWith(
fontWeight: FontWeight.bold,
color: AppColor.textPrimary,
),
),
Text(
"Peserta",
style: AppStyle.sm.copyWith(
color: AppColor.textSecondary,
),
),
],
),
Column(
children: [
Text(
"${draw.hadiah}",
style: AppStyle.h5.copyWith(
fontWeight: FontWeight.bold,
color: AppColor.textPrimary,
),
),
Text(
"Hadiah",
style: AppStyle.sm.copyWith(
color: AppColor.textSecondary,
),
),
],
),
Column(
children: [
Text(
"0",
style: AppStyle.h5.copyWith(
fontWeight: FontWeight.bold,
color: AppColor.error,
),
),
Text(
"Voucher Anda",
style: AppStyle.sm.copyWith(
color: AppColor.textSecondary,
),
),
],
),
],
),
SizedBox(height: 16),
// Timer
if (draw.isActive)
// Card content
Padding(
padding: EdgeInsets.all(16),
child: Column(
children: [
// Prize info
Row(
children: [
Icon(Icons.access_time, color: AppColor.error, size: 16),
SizedBox(width: 4),
Text(draw.icon, style: AppStyle.h5),
SizedBox(width: 8),
Text(
"Berakhir dalam:",
style: AppStyle.md.copyWith(
draw.prize,
style: AppStyle.lg.copyWith(
fontWeight: FontWeight.bold,
color: AppColor.textPrimary,
),
),
Spacer(),
Text(
timeRemaining,
style: AppStyle.lg.copyWith(
fontWeight: FontWeight.bold,
color: AppColor.error,
),
),
],
),
SizedBox(height: 12),
SizedBox(height: 16),
// Spending requirement
GestureDetector(
onTap: () => _showSpendingInfo(draw),
child: Container(
padding: EdgeInsets.symmetric(vertical: 12, horizontal: 16),
decoration: BoxDecoration(
color: AppColor.backgroundLight,
borderRadius: BorderRadius.circular(8),
border: Border.all(color: AppColor.borderLight, width: 1),
),
child: Row(
children: [
Expanded(
child: Text(
"Belanja min. Rp ${_formatCurrency(draw.minSpending)} untuk berpartisipasi",
// Stats row
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
children: [
Text(
"-",
style: AppStyle.h5.copyWith(
fontWeight: FontWeight.bold,
color: AppColor.textPrimary,
),
),
Text(
"Peserta",
style: AppStyle.sm.copyWith(
color: AppColor.textSecondary,
),
),
),
],
),
Column(
children: [
Text(
"${draw.hadiah}",
style: AppStyle.h5.copyWith(
fontWeight: FontWeight.bold,
color: AppColor.textPrimary,
),
),
Text(
"Hadiah",
style: AppStyle.sm.copyWith(
color: AppColor.textSecondary,
),
),
],
),
Column(
children: [
Text(
"0",
style: AppStyle.h5.copyWith(
fontWeight: FontWeight.bold,
color: AppColor.error,
),
),
Text(
"Voucher Anda",
style: AppStyle.sm.copyWith(
color: AppColor.textSecondary,
),
),
],
),
],
),
SizedBox(height: 16),
// Timer
if (draw.isActive)
Row(
children: [
Icon(
Icons.chevron_right,
color: AppColor.textSecondary,
Icons.access_time,
color: AppColor.error,
size: 16,
),
SizedBox(width: 4),
Text(
"Berakhir dalam:",
style: AppStyle.md.copyWith(
color: AppColor.textPrimary,
),
),
Spacer(),
Text(
timeRemaining,
style: AppStyle.lg.copyWith(
fontWeight: FontWeight.bold,
color: AppColor.error,
),
),
],
),
SizedBox(height: 12),
// Spending requirement
GestureDetector(
onTap: () => _showSpendingInfo(draw),
child: Container(
padding: EdgeInsets.symmetric(
vertical: 12,
horizontal: 16,
),
decoration: BoxDecoration(
color: AppColor.backgroundLight,
borderRadius: BorderRadius.circular(8),
border: Border.all(
color: AppColor.borderLight,
width: 1,
),
),
child: Row(
children: [
Expanded(
child: Text(
"Belanja min. Rp ${_formatCurrency(draw.minSpending)} untuk berpartisipasi",
style: AppStyle.sm.copyWith(
color: AppColor.textSecondary,
),
),
),
Icon(
Icons.chevron_right,
color: AppColor.textSecondary,
size: 16,
),
],
),
),
),
),
],
],
),
),
),
],
],
),
),
);
}