89 lines
2.8 KiB
Dart
89 lines
2.8 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
|
|
import '../services/apiService.dart';
|
|
import 'custom_popup.dart';
|
|
|
|
class UserActionsMenu extends StatelessWidget {
|
|
final ApiService apiService = ApiService();
|
|
final Map<String, dynamic> user;
|
|
final Future<Map<String, dynamic>> Function(int userId) getUserDetails;
|
|
|
|
UserActionsMenu({
|
|
super.key,
|
|
required this.user,
|
|
required this.getUserDetails,
|
|
});
|
|
|
|
int getUserId(dynamic value) {
|
|
if (value is String) return int.parse(value);
|
|
return value;
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return PopupMenuButton<int>(
|
|
color: Colors.white,
|
|
padding: EdgeInsets.zero,
|
|
offset: Offset(0, 30),
|
|
icon: Icon(
|
|
Icons.more_vert,
|
|
color: Color(0xFF475569),
|
|
size: 14,
|
|
),
|
|
itemBuilder: (context) => [
|
|
CustomPopupMenuEntry(
|
|
child: Container(
|
|
padding: EdgeInsets.symmetric(horizontal: 8, vertical: 8),
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
GestureDetector(
|
|
child: Tooltip(
|
|
message: 'View Details',
|
|
child: Icon(Icons.remove_red_eye,
|
|
color: Color(0xFF475569), size: 18)
|
|
),
|
|
// child: Icon(Icons.remove_red_eye,
|
|
// color: Color(0xFF475569), size: 18,),
|
|
onTap: () async {
|
|
Navigator.pop(context); // Close the menu
|
|
final userId = getUserId(user['user_id']);
|
|
final usersData = await getUserDetails(userId);
|
|
context.go("/CreateUserDetails", extra: {
|
|
"selectedUser": usersData,
|
|
"isViewMode": true,
|
|
});
|
|
},
|
|
),
|
|
SizedBox(width: 8),
|
|
GestureDetector(
|
|
child: Tooltip(
|
|
message: 'Edit Details',
|
|
child: Image.asset(
|
|
'assets/images/IconsImg/edit.png',
|
|
width: 20,
|
|
height: 15,
|
|
),
|
|
),
|
|
onTap: () async {
|
|
Navigator.pop(context); // Close the menu
|
|
final userId = getUserId(user['user_id']);
|
|
final usersData = await getUserDetails(userId);
|
|
context.go("/CreateUserDetails", extra: {
|
|
"selectedUser": usersData,
|
|
"isViewMode": false,
|
|
});
|
|
},
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|