From 703fd1f461b89f145dbb73ab17d38701138c5979 Mon Sep 17 00:00:00 2001 From: Deep Koluguri Date: Wed, 5 Nov 2025 23:50:06 -0500 Subject: [PATCH] import button --- .../interfaces/manager/chit_groups_page.dart | 98 +++++++++++++++---- .../manager/import_existing_group_dialog.dart | 1 - 2 files changed, 81 insertions(+), 18 deletions(-) diff --git a/luckychit/lib/interfaces/manager/chit_groups_page.dart b/luckychit/lib/interfaces/manager/chit_groups_page.dart index 87e756c..1eff8e3 100644 --- a/luckychit/lib/interfaces/manager/chit_groups_page.dart +++ b/luckychit/lib/interfaces/manager/chit_groups_page.dart @@ -4,6 +4,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; import '../../core/services/chit_group_service.dart'; import '../../core/models/chit_group.dart'; import 'create_group_dialog.dart'; +import 'import_existing_group_dialog.dart'; import 'member_selection_dialog.dart'; import 'group_details_page.dart'; import 'combined_draw_dialog.dart'; @@ -27,9 +28,37 @@ class ChitGroupsPage extends StatelessWidget { foregroundColor: Colors.white, elevation: 2, actions: [ - IconButton( + PopupMenuButton( icon: Icon(Icons.add, size: 24.w), - onPressed: () => _showCreateGroupDialog(context), + onSelected: (value) { + if (value == 'create') { + _showCreateGroupDialog(context); + } else if (value == 'import') { + _showImportGroupDialog(context); + } + }, + itemBuilder: (context) => [ + PopupMenuItem( + value: 'create', + child: Row( + children: [ + Icon(Icons.add_circle, color: Colors.green.shade600, size: 20.w), + SizedBox(width: 12.w), + const Text('Create New Group'), + ], + ), + ), + PopupMenuItem( + value: 'import', + child: Row( + children: [ + Icon(Icons.upload, color: Colors.blue.shade600, size: 20.w), + SizedBox(width: 12.w), + const Text('Import Existing Group'), + ], + ), + ), + ], ), ], ), @@ -63,7 +92,7 @@ class ChitGroupsPage extends StatelessWidget { ), SizedBox(height: 12.h), Text( - 'Create your first chit group to get started', + 'Create a new chit group or import an existing one', style: TextStyle( fontSize: 16.sp, color: Colors.grey.shade500, @@ -71,21 +100,43 @@ class ChitGroupsPage extends StatelessWidget { textAlign: TextAlign.center, ), SizedBox(height: 32.h), - ElevatedButton.icon( - onPressed: () => _showCreateGroupDialog(context), - icon: Icon(Icons.add, size: 20.w), - label: Text( - 'Create Group', - style: TextStyle(fontSize: 16.sp, fontWeight: FontWeight.w500), - ), - style: ElevatedButton.styleFrom( - backgroundColor: Colors.green.shade600, - foregroundColor: Colors.white, - padding: EdgeInsets.symmetric(horizontal: 24.w, vertical: 16.h), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(12.r), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + ElevatedButton.icon( + onPressed: () => _showCreateGroupDialog(context), + icon: Icon(Icons.add, size: 20.w), + label: Text( + 'Create New', + style: TextStyle(fontSize: 16.sp, fontWeight: FontWeight.w500), + ), + style: ElevatedButton.styleFrom( + backgroundColor: Colors.green.shade600, + foregroundColor: Colors.white, + padding: EdgeInsets.symmetric(horizontal: 24.w, vertical: 16.h), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12.r), + ), + ), ), - ), + SizedBox(width: 16.w), + OutlinedButton.icon( + onPressed: () => _showImportGroupDialog(context), + icon: Icon(Icons.upload, size: 20.w), + label: Text( + 'Import Existing', + style: TextStyle(fontSize: 16.sp, fontWeight: FontWeight.w500), + ), + style: OutlinedButton.styleFrom( + foregroundColor: Colors.blue.shade600, + side: BorderSide(color: Colors.blue.shade600, width: 2), + padding: EdgeInsets.symmetric(horizontal: 24.w, vertical: 16.h), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12.r), + ), + ), + ), + ], ), ], ), @@ -395,6 +446,19 @@ class ChitGroupsPage extends StatelessWidget { ); } + void _showImportGroupDialog(BuildContext context) { + showDialog( + context: context, + barrierDismissible: false, + builder: (context) => const ImportExistingGroupDialog(), + ).then((result) { + if (result == true) { + // Reload groups after successful import + ChitGroupService.to.loadManagerChitGroups(); + } + }); + } + void _showAddMemberDialog(BuildContext context, ChitGroup group) { showDialog( context: context, diff --git a/luckychit/lib/interfaces/manager/import_existing_group_dialog.dart b/luckychit/lib/interfaces/manager/import_existing_group_dialog.dart index a1f94b5..64de9c0 100644 --- a/luckychit/lib/interfaces/manager/import_existing_group_dialog.dart +++ b/luckychit/lib/interfaces/manager/import_existing_group_dialog.dart @@ -25,7 +25,6 @@ class _ImportExistingGroupDialogState extends State { DateTime? _selectedStartDate; bool _isLoading = false; - int _step = 1; // Multi-step wizard @override void initState() {