import button

This commit is contained in:
Deep Koluguri 2025-11-05 23:50:06 -05:00
parent 9e9aaf7a07
commit 703fd1f461
2 changed files with 81 additions and 18 deletions

View File

@ -4,6 +4,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
import '../../core/services/chit_group_service.dart'; import '../../core/services/chit_group_service.dart';
import '../../core/models/chit_group.dart'; import '../../core/models/chit_group.dart';
import 'create_group_dialog.dart'; import 'create_group_dialog.dart';
import 'import_existing_group_dialog.dart';
import 'member_selection_dialog.dart'; import 'member_selection_dialog.dart';
import 'group_details_page.dart'; import 'group_details_page.dart';
import 'combined_draw_dialog.dart'; import 'combined_draw_dialog.dart';
@ -27,9 +28,37 @@ class ChitGroupsPage extends StatelessWidget {
foregroundColor: Colors.white, foregroundColor: Colors.white,
elevation: 2, elevation: 2,
actions: [ actions: [
IconButton( PopupMenuButton<String>(
icon: Icon(Icons.add, size: 24.w), 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), SizedBox(height: 12.h),
Text( Text(
'Create your first chit group to get started', 'Create a new chit group or import an existing one',
style: TextStyle( style: TextStyle(
fontSize: 16.sp, fontSize: 16.sp,
color: Colors.grey.shade500, color: Colors.grey.shade500,
@ -71,11 +100,14 @@ class ChitGroupsPage extends StatelessWidget {
textAlign: TextAlign.center, textAlign: TextAlign.center,
), ),
SizedBox(height: 32.h), SizedBox(height: 32.h),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton.icon( ElevatedButton.icon(
onPressed: () => _showCreateGroupDialog(context), onPressed: () => _showCreateGroupDialog(context),
icon: Icon(Icons.add, size: 20.w), icon: Icon(Icons.add, size: 20.w),
label: Text( label: Text(
'Create Group', 'Create New',
style: TextStyle(fontSize: 16.sp, fontWeight: FontWeight.w500), style: TextStyle(fontSize: 16.sp, fontWeight: FontWeight.w500),
), ),
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
@ -87,6 +119,25 @@ class ChitGroupsPage extends StatelessWidget {
), ),
), ),
), ),
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) { void _showAddMemberDialog(BuildContext context, ChitGroup group) {
showDialog( showDialog(
context: context, context: context,

View File

@ -25,7 +25,6 @@ class _ImportExistingGroupDialogState extends State<ImportExistingGroupDialog> {
DateTime? _selectedStartDate; DateTime? _selectedStartDate;
bool _isLoading = false; bool _isLoading = false;
int _step = 1; // Multi-step wizard
@override @override
void initState() { void initState() {