adjusted slot machine

This commit is contained in:
Deep Koluguri 2025-11-06 19:06:54 -05:00
parent e6a59cef21
commit 9c4f353abd
2 changed files with 103 additions and 13 deletions

View File

@ -803,7 +803,94 @@ class _GroupDetailsPageState extends State<GroupDetailsPage> with SingleTickerPr
); );
} }
return RefreshIndicator( // Show draws with a header and conduct draw button
return Column(
children: [
// Header with Conduct Draw button or status message
Container(
padding: EdgeInsets.all(16.w),
decoration: BoxDecoration(
color: Colors.white,
border: Border(
bottom: BorderSide(color: Colors.grey.shade200, width: 1),
),
),
child: Row(
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Monthly Draws (${draws.length})',
style: TextStyle(
fontSize: 16.sp,
fontWeight: FontWeight.w600,
color: Colors.grey.shade800,
),
),
if (!widget.group.isActive) ...[
SizedBox(height: 4.h),
Text(
'Group must be "Active" to conduct draws',
style: TextStyle(
fontSize: 12.sp,
color: Colors.orange.shade700,
fontStyle: FontStyle.italic,
),
),
],
],
),
),
if (widget.group.isActive)
ElevatedButton.icon(
onPressed: () => _conductDraw(context),
icon: Icon(Icons.casino, size: 18.w),
label: Text(
'Conduct Draw',
style: TextStyle(fontSize: 14.sp),
),
style: ElevatedButton.styleFrom(
backgroundColor: Colors.purple.shade600,
foregroundColor: Colors.white,
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 10.h),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.r),
),
),
)
else
OutlinedButton.icon(
onPressed: () {
Get.snackbar(
'Group Not Active',
'Please start the chitfund group first to conduct draws.',
backgroundColor: Colors.orange,
colorText: Colors.white,
duration: const Duration(seconds: 3),
);
},
icon: Icon(Icons.info_outline, size: 18.w),
label: Text(
'Start Group',
style: TextStyle(fontSize: 14.sp),
),
style: OutlinedButton.styleFrom(
foregroundColor: Colors.orange.shade700,
side: BorderSide(color: Colors.orange.shade700),
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 10.h),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.r),
),
),
),
],
),
),
// Draws list
Expanded(
child: RefreshIndicator(
onRefresh: () => _service.loadGroupMonthlyDraws(widget.group.id), onRefresh: () => _service.loadGroupMonthlyDraws(widget.group.id),
child: ListView.builder( child: ListView.builder(
padding: EdgeInsets.all(16.w), padding: EdgeInsets.all(16.w),
@ -813,6 +900,9 @@ class _GroupDetailsPageState extends State<GroupDetailsPage> with SingleTickerPr
return _buildDrawCard(draw); return _buildDrawCard(draw);
}, },
), ),
),
),
],
); );
}); });
} }

View File

@ -410,7 +410,7 @@ class _SlotMachineDrawAnimationState extends State<SlotMachineDrawAnimation>
super.initState(); super.initState();
_slotController = AnimationController( _slotController = AnimationController(
duration: const Duration(milliseconds: 300), duration: const Duration(milliseconds: 400),
vsync: this, vsync: this,
); );
@ -481,7 +481,7 @@ class _SlotMachineDrawAnimationState extends State<SlotMachineDrawAnimation>
final totalSpins = 25 + (widget.members.length * 2); final totalSpins = 25 + (widget.members.length * 2);
int currentSpin = 0; int currentSpin = 0;
_slotTimer = Timer.periodic(const Duration(milliseconds: 150), (timer) { _slotTimer = Timer.periodic(const Duration(milliseconds: 250), (timer) {
if (currentSpin >= totalSpins) { if (currentSpin >= totalSpins) {
timer.cancel(); timer.cancel();
_completeAnimation(); _completeAnimation();
@ -506,7 +506,7 @@ class _SlotMachineDrawAnimationState extends State<SlotMachineDrawAnimation>
// Slow down in the last 30% of spins // Slow down in the last 30% of spins
timer.cancel(); timer.cancel();
_slotTimer = Timer.periodic( _slotTimer = Timer.periodic(
Duration(milliseconds: 200 + (currentSpin * 10)), Duration(milliseconds: 350 + (currentSpin * 15)),
(newTimer) { (newTimer) {
if (currentSpin >= totalSpins) { if (currentSpin >= totalSpins) {
newTimer.cancel(); newTimer.cancel();