enhanced desabled cards

This commit is contained in:
Vaibhav Surve 2025-10-10 19:52:12 +05:30
parent cd92d4d309
commit 16e2f5a4f3

View File

@ -19,7 +19,6 @@ import 'package:marco/controller/permission_controller.dart';
import 'package:marco/helpers/utils/permission_constants.dart'; import 'package:marco/helpers/utils/permission_constants.dart';
import 'package:marco/helpers/widgets/my_confirmation_dialog.dart'; import 'package:marco/helpers/widgets/my_confirmation_dialog.dart';
class DirectoryView extends StatefulWidget { class DirectoryView extends StatefulWidget {
@override @override
State<DirectoryView> createState() => _DirectoryViewState(); State<DirectoryView> createState() => _DirectoryViewState();
@ -452,22 +451,15 @@ class _DirectoryViewState extends State<DirectoryView> {
.map((tag) => tag.name) .map((tag) => tag.name)
.toList(); .toList();
return Opacity( return Card(
opacity: isDeleted ? 0.5 : 1.0,
child: Stack(
children: [
Card(
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: borderRadius: BorderRadius.circular(5),
BorderRadius.circular(5),
), ),
elevation: 3, elevation: 3,
shadowColor: shadowColor: Colors.grey.withOpacity(0.3),
Colors.grey.withOpacity(0.3),
color: Colors.white, color: Colors.white,
child: InkWell( child: InkWell(
borderRadius: borderRadius: BorderRadius.circular(5),
BorderRadius.circular(5),
onTap: isDeleted onTap: isDeleted
? null ? null
: () => Get.to(() => : () => Get.to(() =>
@ -493,14 +485,13 @@ class _DirectoryViewState extends State<DirectoryView> {
Expanded( Expanded(
child: Column( child: Column(
crossAxisAlignment: crossAxisAlignment:
CrossAxisAlignment CrossAxisAlignment.start,
.start,
children: [ children: [
MyText.titleSmall( MyText.titleSmall(
contact.name, contact.name,
fontWeight: 600, fontWeight: 600,
overflow: TextOverflow overflow:
.ellipsis, TextOverflow.ellipsis,
color: isDeleted color: isDeleted
? Colors.grey ? Colors.grey
: Colors.black87, : Colors.black87,
@ -510,19 +501,17 @@ class _DirectoryViewState extends State<DirectoryView> {
color: isDeleted color: isDeleted
? Colors.grey ? Colors.grey
: Colors.grey[700], : Colors.grey[700],
overflow: TextOverflow overflow:
.ellipsis, TextOverflow.ellipsis,
), ),
MySpacing.height(6), MySpacing.height(6),
if (contact.contactEmails if (contact
.isNotEmpty) .contactEmails.isNotEmpty)
Padding( Padding(
padding: padding:
const EdgeInsets const EdgeInsets.only(
.only(
bottom: 4), bottom: 4),
child: child: GestureDetector(
GestureDetector(
onTap: isDeleted onTap: isDeleted
? null ? null
: () => LauncherUtils : () => LauncherUtils
@ -530,11 +519,9 @@ class _DirectoryViewState extends State<DirectoryView> {
.contactEmails .contactEmails
.first .first
.emailAddress), .emailAddress),
onLongPress: onLongPress: isDeleted
isDeleted
? null ? null
: () => : () => LauncherUtils
LauncherUtils
.copyToClipboard( .copyToClipboard(
contact contact
.contactEmails .contactEmails
@ -549,6 +536,71 @@ class _DirectoryViewState extends State<DirectoryView> {
Icons Icons
.email_outlined, .email_outlined,
size: 16, size: 16,
color: isDeleted
? Colors.grey
: Colors
.indigo),
MySpacing.width(4),
Expanded(
child: MyText
.labelSmall(
contact
.contactEmails
.first
.emailAddress,
overflow:
TextOverflow
.ellipsis,
color: isDeleted
? Colors.grey
: Colors
.indigo,
decoration:
TextDecoration
.underline,
),
),
],
),
),
),
if (contact
.contactPhones.isNotEmpty)
Padding(
padding:
const EdgeInsets.only(
bottom: 8, top: 4),
child: Row(
children: [
Expanded(
child:
GestureDetector(
onTap: isDeleted
? null
: () => LauncherUtils
.launchPhone(contact
.contactPhones
.first
.phoneNumber),
onLongPress:
isDeleted
? null
: () =>
LauncherUtils
.copyToClipboard(
contact
.contactPhones
.first
.phoneNumber,
typeLabel:
'Phone',
),
child: Row(
children: [
Icon(
Icons
.phone_outlined,
size: 16,
color: isDeleted color: isDeleted
? Colors ? Colors
.grey .grey
@ -560,9 +612,9 @@ class _DirectoryViewState extends State<DirectoryView> {
child: MyText child: MyText
.labelSmall( .labelSmall(
contact contact
.contactEmails .contactPhones
.first .first
.emailAddress, .phoneNumber,
overflow: overflow:
TextOverflow TextOverflow
.ellipsis, .ellipsis,
@ -580,72 +632,12 @@ class _DirectoryViewState extends State<DirectoryView> {
), ),
), ),
), ),
if (contact.contactPhones MySpacing.width(8),
.isNotEmpty)
Padding(
padding:
const EdgeInsets
.only(
bottom: 8,
top: 4),
child: Row(
children: [
Expanded(
child:
GestureDetector( GestureDetector(
onTap: isDeleted onTap: isDeleted
? null ? null
: () => LauncherUtils.launchPhone(contact : () => LauncherUtils
.contactPhones .launchWhatsApp(contact
.first
.phoneNumber),
onLongPress:
isDeleted
? null
: () =>
LauncherUtils.copyToClipboard(
contact.contactPhones.first.phoneNumber,
typeLabel: 'Phone',
),
child: Row(
children: [
Icon(
Icons
.phone_outlined,
size:
16,
color: isDeleted
? Colors.grey
: Colors.indigo),
MySpacing
.width(
4),
Expanded(
child: MyText
.labelSmall(
contact
.contactPhones
.first
.phoneNumber,
overflow:
TextOverflow.ellipsis,
color: isDeleted
? Colors.grey
: Colors.indigo,
decoration:
TextDecoration.underline,
),
),
],
),
),
),
MySpacing.width(
8),
GestureDetector(
onTap: isDeleted
? null
: () => LauncherUtils.launchWhatsApp(contact
.contactPhones .contactPhones
.first .first
.phoneNumber), .phoneNumber),
@ -653,8 +645,7 @@ class _DirectoryViewState extends State<DirectoryView> {
FontAwesomeIcons FontAwesomeIcons
.whatsapp, .whatsapp,
color: isDeleted color: isDeleted
? Colors ? Colors.grey
.grey
: Colors : Colors
.green, .green,
size: 25), size: 25),
@ -665,18 +656,17 @@ class _DirectoryViewState extends State<DirectoryView> {
if (tags.isNotEmpty) if (tags.isNotEmpty)
Padding( Padding(
padding: padding:
const EdgeInsets const EdgeInsets.only(
.only(top: 0), top: 0),
child: Wrap( child: Wrap(
spacing: 6, spacing: 6,
runSpacing: 2, runSpacing: 2,
children: tags children: tags
.map( .map(
(tag) => Chip( (tag) => Chip(
label: Text( label: Text(tag),
tag), backgroundColor:
backgroundColor: Colors Colors.indigo
.indigo
.shade50, .shade50,
labelStyle: TextStyle( labelStyle: TextStyle(
color: isDeleted color: isDeleted
@ -684,15 +674,15 @@ class _DirectoryViewState extends State<DirectoryView> {
.grey .grey
: Colors : Colors
.indigo, .indigo,
fontSize: fontSize: 12),
12),
visualDensity: visualDensity:
VisualDensity VisualDensity
.compact, .compact,
shape: shape:
RoundedRectangleBorder( RoundedRectangleBorder(
borderRadius: borderRadius:
BorderRadius.circular( BorderRadius
.circular(
5), 5),
), ),
), ),
@ -706,70 +696,48 @@ class _DirectoryViewState extends State<DirectoryView> {
// Actions Column (Arrow + Icons) // Actions Column (Arrow + Icons)
Column( Column(
children: [ children: [
// Direct action icon
if (!isDeleted)
IconButton( IconButton(
icon: const Icon( icon: Icon(
Icons.delete, isDeleted
color: Colors ? Icons.restore
.redAccent, : Icons.delete,
size: 20), color: isDeleted
onPressed: () async { ? Colors.green
await Get.dialog( : Colors.redAccent,
ConfirmDialog( size: 20,
title:
"Delete Contact",
message:
"Are you sure you want to delete this contact?",
confirmText:
"Delete",
confirmColor:
Colors
.redAccent,
icon: Icons
.delete_forever,
onConfirm:
() async {
await controller
.deleteContact(
contact
.id);
},
), ),
barrierDismissible:
false,
);
},
)
else
IconButton(
icon: const Icon(
Icons.restore,
color: Colors.green,
size: 20),
onPressed: () async { onPressed: () async {
await Get.dialog( await Get.dialog(
ConfirmDialog( ConfirmDialog(
title: title: isDeleted
"Restore Contact", ? "Restore Contact"
message: : "Delete Contact",
"Are you sure you want to restore this contact?", message: isDeleted
confirmText: ? "Are you sure you want to restore this contact?"
"Restore", : "Are you sure you want to delete this contact?",
confirmColor: confirmText: isDeleted
Colors.green, ? "Restore"
icon: : "Delete",
Icons.restore, confirmColor: isDeleted
onConfirm: ? Colors.green
() async { : Colors.redAccent,
icon: isDeleted
? Icons.restore
: Icons
.delete_forever,
onConfirm: () async {
if (isDeleted) {
await controller await controller
.restoreContact( .restoreContact(
contact contact.id);
.id); } else {
await controller
.deleteContact(
contact.id);
}
}, },
), ),
barrierDismissible: barrierDismissible: false,
false,
); );
}, },
), ),
@ -785,9 +753,6 @@ class _DirectoryViewState extends State<DirectoryView> {
), ),
), ),
), ),
),
],
),
); );
})); }));
}), }),