fixed add members

This commit is contained in:
Deep Koluguri 2025-11-06 08:49:56 -05:00
parent ede5b15ade
commit 8d4fbfed00
2 changed files with 78 additions and 108 deletions

View File

@ -97,9 +97,9 @@ class _GroupDetailsPageState extends State<GroupDetailsPage> with SingleTickerPr
icon: Icon(Icons.more_vert, size: 24.w, color: Colors.grey.shade700), icon: Icon(Icons.more_vert, size: 24.w, color: Colors.grey.shade700),
tooltip: 'More Options', tooltip: 'More Options',
onSelected: (value) { onSelected: (value) {
if (value == 'select' && widget.group.isForming) { if (value == 'select') {
_showMemberSelectionDialog(context); _showMemberSelectionDialog(context);
} else if (value == 'add_user' && widget.group.isForming) { } else if (value == 'add_user') {
_showAddUserDialog(context); _showAddUserDialog(context);
} else if (value == 'add_past_draw') { } else if (value == 'add_past_draw') {
_showAddPastDrawDialog(context); _showAddPastDrawDialog(context);
@ -107,9 +107,14 @@ class _GroupDetailsPageState extends State<GroupDetailsPage> with SingleTickerPr
_showAddPastPaymentsDialog(context); _showAddPastPaymentsDialog(context);
} }
}, },
itemBuilder: (context) => [ itemBuilder: (context) {
// Add members options (only for forming groups) final currentMemberCount = widget.group.currentMemberCount;
if (widget.group.isForming) ...[ final maxMembers = widget.group.maxMembers;
final canAddMembers = currentMemberCount < maxMembers;
return [
// Add members options (if not full)
if (canAddMembers) ...[
PopupMenuItem( PopupMenuItem(
value: 'select', value: 'select',
child: Row( child: Row(
@ -153,7 +158,8 @@ class _GroupDetailsPageState extends State<GroupDetailsPage> with SingleTickerPr
], ],
), ),
), ),
], ];
},
), ),
], ],
bottom: PreferredSize( bottom: PreferredSize(

View File

@ -332,50 +332,28 @@ class ManagerDashboard extends StatelessWidget {
Widget _buildMobileStatsGrid() { Widget _buildMobileStatsGrid() {
return Obx(() { return Obx(() {
final groups = ChitGroupService.to.chitGroups; final groups = ChitGroupService.to.chitGroups;
final activeGroups = groups.where((g) => g.isActive).length;
final formingGroups = groups.where((g) => g.isForming).length;
final totalMembers = groups.fold<int>(0, (sum, group) => sum + (group.members?.length ?? 0)); final totalMembers = groups.fold<int>(0, (sum, group) => sum + (group.members?.length ?? 0));
return Column( return Row(
children: [ children: [
Row( Expanded(
children: [ child: InteractiveStatsCard(
Expanded(child: InteractiveStatsCard( title: 'Total Chitfunds',
title: 'Active Chitfunds', value: groups.length.toString(),
value: activeGroups.toString(), icon: Icons.account_balance_wallet,
icon: Icons.group, color: Colors.green.shade600,
color: Colors.blue.shade600,
onTap: () => _navigateToGroups(), onTap: () => _navigateToGroups(),
)),
SizedBox(width: 12.w),
Expanded(child: InteractiveStatsCard(
title: 'Forming Chitfunds',
value: formingGroups.toString(),
icon: Icons.group_add,
color: Colors.orange.shade600,
onTap: () => _navigateToGroups(),
)),
],
), ),
SizedBox(height: 12.h), ),
Row( SizedBox(width: 12.w),
children: [ Expanded(
Expanded(child: InteractiveStatsCard( child: InteractiveStatsCard(
title: 'Total Members', title: 'Total Members',
value: totalMembers.toString(), value: totalMembers.toString(),
icon: Icons.people, icon: Icons.people,
color: Colors.green.shade600, color: Colors.blue.shade600,
onTap: () => _navigateToMembers(), onTap: () => _navigateToMembers(),
)), ),
SizedBox(width: 12.w),
Expanded(child: InteractiveStatsCard(
title: 'Total Chitfunds',
value: groups.length.toString(),
icon: Icons.dashboard,
color: Colors.purple.shade600,
onTap: () => _navigateToGroups(),
)),
],
), ),
], ],
); );
@ -385,43 +363,29 @@ class ManagerDashboard extends StatelessWidget {
Widget _buildDesktopStatsGrid() { Widget _buildDesktopStatsGrid() {
return Obx(() { return Obx(() {
final groups = ChitGroupService.to.chitGroups; final groups = ChitGroupService.to.chitGroups;
final activeGroups = groups.where((g) => g.isActive).length;
final formingGroups = groups.where((g) => g.isForming).length;
final totalMembers = groups.fold<int>(0, (sum, group) => sum + (group.members?.length ?? 0)); final totalMembers = groups.fold<int>(0, (sum, group) => sum + (group.members?.length ?? 0));
return Row( return Row(
children: [ children: [
Expanded(child: InteractiveStatsCard( Expanded(
title: 'Active Groups', child: InteractiveStatsCard(
value: activeGroups.toString(), title: 'Total Chitfunds',
icon: Icons.group, value: groups.length.toString(),
color: Colors.blue.shade600, icon: Icons.account_balance_wallet,
color: Colors.green.shade600,
onTap: () => _navigateToGroups(), onTap: () => _navigateToGroups(),
)), ),
),
SizedBox(width: 16.w), SizedBox(width: 16.w),
Expanded(child: InteractiveStatsCard( Expanded(
title: 'Forming Groups', child: InteractiveStatsCard(
value: formingGroups.toString(),
icon: Icons.group_add,
color: Colors.orange.shade600,
onTap: () => _navigateToGroups(),
)),
SizedBox(width: 16.w),
Expanded(child: InteractiveStatsCard(
title: 'Total Members', title: 'Total Members',
value: totalMembers.toString(), value: totalMembers.toString(),
icon: Icons.people, icon: Icons.people,
color: Colors.green.shade600, color: Colors.blue.shade600,
onTap: () => _navigateToMembers(), onTap: () => _navigateToMembers(),
)), ),
SizedBox(width: 16.w), ),
Expanded(child: InteractiveStatsCard(
title: 'Total Groups',
value: groups.length.toString(),
icon: Icons.dashboard,
color: Colors.purple.shade600,
onTap: () => _navigateToGroups(),
)),
], ],
); );
}); });