updated draw screen

This commit is contained in:
Deep Koluguri 2025-11-06 11:38:32 -05:00
parent e187618437
commit 5ad7d62386
2 changed files with 297 additions and 157 deletions

View File

@ -4,7 +4,6 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
import '../../core/services/chit_group_service.dart'; import '../../core/services/chit_group_service.dart';
import '../../core/services/api_service.dart'; import '../../core/services/api_service.dart';
import '../../core/models/chit_group.dart'; import '../../core/models/chit_group.dart';
import '../../core/models/group_member.dart';
import '../../core/utils/snackbar_util.dart'; import '../../core/utils/snackbar_util.dart';
class AddPastDrawDialog extends StatefulWidget { class AddPastDrawDialog extends StatefulWidget {
@ -27,7 +26,6 @@ class _AddPastDrawDialogState extends State<AddPastDrawDialog> {
final _apiService = ApiService(); final _apiService = ApiService();
String? _selectedMemberId; String? _selectedMemberId;
String? _selectedMemberName;
bool _isLoading = false; bool _isLoading = false;
int _selectedMonth = 1; int _selectedMonth = 1;
int _selectedYear = DateTime.now().year; int _selectedYear = DateTime.now().year;
@ -105,15 +103,26 @@ class _AddPastDrawDialogState extends State<AddPastDrawDialog> {
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20.r)), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20.r)),
child: Container( child: Container(
width: 500.w, width: 500.w,
padding: EdgeInsets.all(24.w), constraints: BoxConstraints(
child: Form( maxHeight: MediaQuery.of(context).size.height * 0.85,
key: _formKey, ),
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
// Header // Fixed Header
Row( Container(
padding: EdgeInsets.all(24.w),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(20.r),
topRight: Radius.circular(20.r),
),
border: Border(
bottom: BorderSide(color: Colors.grey.shade200),
),
),
child: Row(
children: [ children: [
Icon(Icons.history, color: Colors.blue.shade600, size: 28.w), Icon(Icons.history, color: Colors.blue.shade600, size: 28.w),
SizedBox(width: 12.w), SizedBox(width: 12.w),
@ -132,8 +141,17 @@ class _AddPastDrawDialogState extends State<AddPastDrawDialog> {
), ),
], ],
), ),
SizedBox(height: 24.h), ),
// Scrollable Content
Flexible(
child: SingleChildScrollView(
padding: EdgeInsets.all(24.w),
child: Form(
key: _formKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Month Info // Month Info
Container( Container(
padding: EdgeInsets.all(16.w), padding: EdgeInsets.all(16.w),
@ -186,6 +204,12 @@ class _AddPastDrawDialogState extends State<AddPastDrawDialog> {
borderRadius: BorderRadius.circular(12.r), borderRadius: BorderRadius.circular(12.r),
border: Border.all(color: Colors.orange.shade200), border: Border.all(color: Colors.orange.shade200),
), ),
child: Row(
children: [
Icon(Icons.warning_amber_rounded,
color: Colors.orange.shade700, size: 20.w),
SizedBox(width: 8.w),
Expanded(
child: Text( child: Text(
'Please add members to the group first', 'Please add members to the group first',
style: TextStyle( style: TextStyle(
@ -193,55 +217,89 @@ class _AddPastDrawDialogState extends State<AddPastDrawDialog> {
fontSize: 14.sp, fontSize: 14.sp,
), ),
), ),
),
],
),
); );
} }
return Container( return Container(
constraints: BoxConstraints(
maxHeight: 300.h, // Limit height for scrolling
),
decoration: BoxDecoration( decoration: BoxDecoration(
border: Border.all(color: Colors.grey.shade300), border: Border.all(color: Colors.grey.shade300),
borderRadius: BorderRadius.circular(12.r), borderRadius: BorderRadius.circular(12.r),
), ),
child: Column( child: ListView.builder(
children: members.map((member) { shrinkWrap: true,
final isSelected = member.id == _selectedMemberId; itemCount: members.length,
itemBuilder: (context, index) {
final member = members[index];
final isSelected = member.userId == _selectedMemberId;
final isLast = index == members.length - 1;
return InkWell( return InkWell(
onTap: () { onTap: () {
setState(() { setState(() {
_selectedMemberId = member.userId; _selectedMemberId = member.userId;
_selectedMemberName = member.user?.fullName ?? 'Unknown';
}); });
}, },
borderRadius: BorderRadius.vertical(
top: index == 0 ? Radius.circular(12.r) : Radius.zero,
bottom: isLast ? Radius.circular(12.r) : Radius.zero,
),
child: Container( child: Container(
padding: EdgeInsets.all(12.w), padding: EdgeInsets.symmetric(
horizontal: 12.w,
vertical: 14.h,
),
decoration: BoxDecoration( decoration: BoxDecoration(
color: isSelected ? Colors.green.shade50 : null, color: isSelected ? Colors.green.shade50 : null,
border: Border( border: !isLast ? Border(
bottom: BorderSide(color: Colors.grey.shade200), bottom: BorderSide(color: Colors.grey.shade200),
), ) : null,
), ),
child: Row( child: Row(
children: [ children: [
Icon( Icon(
isSelected ? Icons.radio_button_checked : Icons.radio_button_unchecked, isSelected ? Icons.radio_button_checked : Icons.radio_button_unchecked,
color: isSelected ? Colors.green.shade600 : Colors.grey.shade400, color: isSelected ? Colors.green.shade600 : Colors.grey.shade400,
size: 24.w,
), ),
SizedBox(width: 12.w), SizedBox(width: 12.w),
Expanded( Expanded(
child: Text( child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
member.user?.fullName ?? 'Unknown', member.user?.fullName ?? 'Unknown',
style: TextStyle( style: TextStyle(
fontSize: 16.sp, fontSize: 16.sp,
fontWeight: isSelected ? FontWeight.w600 : FontWeight.normal, fontWeight: isSelected ? FontWeight.w600 : FontWeight.normal,
), ),
), ),
if (member.user?.mobileNumber != null) ...[
SizedBox(height: 2.h),
Text(
member.user!.mobileNumber,
style: TextStyle(
fontSize: 13.sp,
color: Colors.grey.shade600,
),
),
],
],
),
), ),
if (isSelected) if (isSelected)
Icon(Icons.check_circle, color: Colors.green.shade600), Icon(Icons.check_circle,
color: Colors.green.shade600, size: 20.w),
], ],
), ),
), ),
); );
}).toList(), },
), ),
); );
}), }),
@ -262,7 +320,10 @@ class _AddPastDrawDialogState extends State<AddPastDrawDialog> {
decoration: InputDecoration( decoration: InputDecoration(
hintText: 'Prize amount won', hintText: 'Prize amount won',
prefixText: '', prefixText: '',
border: OutlineInputBorder(borderRadius: BorderRadius.circular(12.r)), prefixIcon: Icon(Icons.currency_rupee),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(12.r),
),
filled: true, filled: true,
fillColor: Colors.grey.shade50, fillColor: Colors.grey.shade50,
), ),
@ -272,10 +333,26 @@ class _AddPastDrawDialogState extends State<AddPastDrawDialog> {
return null; return null;
}, },
), ),
SizedBox(height: 24.h), ],
),
),
),
),
// Actions // Fixed Footer with Actions
Row( Container(
padding: EdgeInsets.all(24.w),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(20.r),
bottomRight: Radius.circular(20.r),
),
border: Border(
top: BorderSide(color: Colors.grey.shade200),
),
),
child: Row(
children: [ children: [
Expanded( Expanded(
child: OutlinedButton( child: OutlinedButton(
@ -303,6 +380,7 @@ class _AddPastDrawDialogState extends State<AddPastDrawDialog> {
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12.r), borderRadius: BorderRadius.circular(12.r),
), ),
elevation: 2,
), ),
child: _isLoading child: _isLoading
? SizedBox( ? SizedBox(
@ -321,8 +399,8 @@ class _AddPastDrawDialogState extends State<AddPastDrawDialog> {
), ),
], ],
), ),
],
), ),
],
), ),
), ),
); );

View File

@ -793,13 +793,55 @@ class _GroupDetailsPageState extends State<GroupDetailsPage> with SingleTickerPr
return const Center(child: CircularProgressIndicator()); return const Center(child: CircularProgressIndicator());
} }
// Auto-generate sample data if empty // Show empty state if no data from backend
if (financialData.isEmpty) { if (financialData.isEmpty) {
WidgetsBinding.instance.addPostFrameCallback((_) { return Center(
final sampleData = _service.generateSampleFinancialData(widget.group); child: Padding(
_service.financialData.value = sampleData; padding: EdgeInsets.all(32.w),
}); child: Column(
return const Center(child: CircularProgressIndicator()); mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.table_chart_outlined,
size: 64.w,
color: Colors.grey.shade400,
),
SizedBox(height: 16.h),
Text(
'No Financial Data Available',
style: TextStyle(
fontSize: 18.sp,
fontWeight: FontWeight.w600,
color: Colors.grey.shade700,
),
),
SizedBox(height: 8.h),
Text(
'Financial data will appear here once\nthe group becomes active',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 14.sp,
color: Colors.grey.shade600,
),
),
SizedBox(height: 24.h),
ElevatedButton.icon(
onPressed: () => _service.loadGroupFinancialData(widget.group.id),
icon: const Icon(Icons.refresh),
label: const Text('Refresh Data'),
style: ElevatedButton.styleFrom(
backgroundColor: Colors.blue.shade600,
foregroundColor: Colors.white,
padding: EdgeInsets.symmetric(
horizontal: 24.w,
vertical: 12.h,
),
),
),
],
),
),
);
} }
return RefreshIndicator( return RefreshIndicator(
@ -2285,7 +2327,27 @@ class _GroupDetailsPageState extends State<GroupDetailsPage> with SingleTickerPr
final nextMonthName = _getMonthName(nextMonth); final nextMonthName = _getMonthName(nextMonth);
final nextMonthNumber = currentMonthNumber + 1; final nextMonthNumber = currentMonthNumber + 1;
// Note: Bid amounts are now hardcoded to match the image data // Get current month draw data
final currentDraw = _service.monthlyDraws.firstWhereOrNull(
(draw) => draw.month == currentMonth && draw.year == currentYear,
);
// Get financial data for current month
final financialData = _service.financialData;
final currentMonthFinancial = financialData.firstWhereOrNull(
(entry) => entry.monthYear == '$currentMonth/$currentYear',
);
// Determine bid/prize amounts - use actual data or fallback to group values
final currentBidAmount = currentMonthFinancial?.bidAmount ?? currentDraw?.prizeAmount ?? group.totalValue;
final currentPrizeAmount = currentDraw?.prizeAmount ?? currentBidAmount;
// For next month, estimate based on pattern or use group total value
final nextMonthFinancial = financialData.firstWhereOrNull(
(entry) => entry.monthYear == '$nextMonth/$nextYear',
);
final nextBidAmount = nextMonthFinancial?.bidAmount ?? group.totalValue;
final nextPrizePool = nextMonthFinancial?.bidAmount ?? group.totalValue;
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
@ -2355,7 +2417,7 @@ class _GroupDetailsPageState extends State<GroupDetailsPage> with SingleTickerPr
crossAxisAlignment: CrossAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.end,
children: [ children: [
Text( Text(
_formatIndianCurrency(190900), // September 2025 bid amount from the image _formatIndianCurrency(currentBidAmount),
style: TextStyle( style: TextStyle(
fontSize: 20.sp, fontSize: 20.sp,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
@ -2415,7 +2477,7 @@ class _GroupDetailsPageState extends State<GroupDetailsPage> with SingleTickerPr
crossAxisAlignment: CrossAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.end,
children: [ children: [
Text( Text(
_formatIndianCurrency(190900), // September 2025 prize amount from the image _formatIndianCurrency(currentPrizeAmount),
style: TextStyle( style: TextStyle(
fontSize: 16.sp, fontSize: 16.sp,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
@ -2494,7 +2556,7 @@ class _GroupDetailsPageState extends State<GroupDetailsPage> with SingleTickerPr
crossAxisAlignment: CrossAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.end,
children: [ children: [
Text( Text(
_formatIndianCurrency(193500), // October 2025 expected bid amount _formatIndianCurrency(nextBidAmount),
style: TextStyle( style: TextStyle(
fontSize: 20.sp, fontSize: 20.sp,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
@ -2554,7 +2616,7 @@ class _GroupDetailsPageState extends State<GroupDetailsPage> with SingleTickerPr
crossAxisAlignment: CrossAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.end,
children: [ children: [
Text( Text(
_formatIndianCurrency(193500), // October 2025 prize pool amount _formatIndianCurrency(nextPrizePool),
style: TextStyle( style: TextStyle(
fontSize: 16.sp, fontSize: 16.sp,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,