From 16e2f5a4f3c8e2c3f5b107353c22e58f84d4876f Mon Sep 17 00:00:00 2001 From: Vaibhav Surve Date: Fri, 10 Oct 2025 19:52:12 +0530 Subject: [PATCH] enhanced desabled cards --- lib/view/directory/directory_view.dart | 513 ++++++++++++------------- 1 file changed, 239 insertions(+), 274 deletions(-) diff --git a/lib/view/directory/directory_view.dart b/lib/view/directory/directory_view.dart index 344e551..7817c3a 100644 --- a/lib/view/directory/directory_view.dart +++ b/lib/view/directory/directory_view.dart @@ -19,7 +19,6 @@ import 'package:marco/controller/permission_controller.dart'; import 'package:marco/helpers/utils/permission_constants.dart'; import 'package:marco/helpers/widgets/my_confirmation_dialog.dart'; - class DirectoryView extends StatefulWidget { @override State createState() => _DirectoryViewState(); @@ -452,84 +451,137 @@ class _DirectoryViewState extends State { .map((tag) => tag.name) .toList(); - return Opacity( - opacity: isDeleted ? 0.5 : 1.0, - child: Stack( - children: [ - Card( - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(5), - ), - elevation: 3, - shadowColor: - Colors.grey.withOpacity(0.3), - color: Colors.white, - child: InkWell( - borderRadius: - BorderRadius.circular(5), - onTap: isDeleted - ? null - : () => Get.to(() => - ContactDetailScreen( - contact: contact)), - child: Padding( - padding: const EdgeInsets.all(12), - child: Row( + return Card( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(5), + ), + elevation: 3, + shadowColor: Colors.grey.withOpacity(0.3), + color: Colors.white, + child: InkWell( + borderRadius: BorderRadius.circular(5), + onTap: isDeleted + ? null + : () => Get.to(() => + ContactDetailScreen( + contact: contact)), + child: Padding( + padding: const EdgeInsets.all(12), + child: Row( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + // Avatar + Avatar( + firstName: firstName, + lastName: lastName, + size: 40, + backgroundColor: isDeleted + ? Colors.grey.shade400 + : null, + ), + MySpacing.width(12), + // Contact Info + Expanded( + child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - // Avatar - Avatar( - firstName: firstName, - lastName: lastName, - size: 40, - backgroundColor: isDeleted - ? Colors.grey.shade400 - : null, + MyText.titleSmall( + contact.name, + fontWeight: 600, + overflow: + TextOverflow.ellipsis, + color: isDeleted + ? Colors.grey + : Colors.black87, ), - MySpacing.width(12), - // Contact Info - Expanded( - child: Column( - crossAxisAlignment: - CrossAxisAlignment - .start, - children: [ - MyText.titleSmall( - contact.name, - fontWeight: 600, - overflow: TextOverflow - .ellipsis, - color: isDeleted - ? Colors.grey - : Colors.black87, + MyText.bodySmall( + contact.organization, + color: isDeleted + ? Colors.grey + : Colors.grey[700], + overflow: + TextOverflow.ellipsis, + ), + MySpacing.height(6), + if (contact + .contactEmails.isNotEmpty) + Padding( + padding: + const EdgeInsets.only( + bottom: 4), + child: GestureDetector( + onTap: isDeleted + ? null + : () => LauncherUtils + .launchEmail(contact + .contactEmails + .first + .emailAddress), + onLongPress: isDeleted + ? null + : () => LauncherUtils + .copyToClipboard( + contact + .contactEmails + .first + .emailAddress, + typeLabel: + 'Email', + ), + child: Row( + children: [ + Icon( + Icons + .email_outlined, + 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, + ), + ), + ], ), - MyText.bodySmall( - contact.organization, - color: isDeleted - ? Colors.grey - : Colors.grey[700], - overflow: TextOverflow - .ellipsis, - ), - MySpacing.height(6), - if (contact.contactEmails - .isNotEmpty) - Padding( - padding: - const EdgeInsets - .only( - bottom: 4), + ), + ), + if (contact + .contactPhones.isNotEmpty) + Padding( + padding: + const EdgeInsets.only( + bottom: 8, top: 4), + child: Row( + children: [ + Expanded( child: GestureDetector( onTap: isDeleted ? null : () => LauncherUtils - .launchEmail(contact - .contactEmails + .launchPhone(contact + .contactPhones .first - .emailAddress), + .phoneNumber), onLongPress: isDeleted ? null @@ -537,17 +589,17 @@ class _DirectoryViewState extends State { LauncherUtils .copyToClipboard( contact - .contactEmails + .contactPhones .first - .emailAddress, + .phoneNumber, typeLabel: - 'Email', + 'Phone', ), child: Row( children: [ Icon( Icons - .email_outlined, + .phone_outlined, size: 16, color: isDeleted ? Colors @@ -560,9 +612,9 @@ class _DirectoryViewState extends State { child: MyText .labelSmall( contact - .contactEmails + .contactPhones .first - .emailAddress, + .phoneNumber, overflow: TextOverflow .ellipsis, @@ -580,213 +632,126 @@ class _DirectoryViewState extends State { ), ), ), - 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 - ? 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 - .first - .phoneNumber), - child: FaIcon( - FontAwesomeIcons - .whatsapp, - color: isDeleted - ? Colors - .grey - : Colors - .green, - size: 25), - ), - ], - ), + MySpacing.width(8), + GestureDetector( + onTap: isDeleted + ? null + : () => LauncherUtils + .launchWhatsApp(contact + .contactPhones + .first + .phoneNumber), + child: FaIcon( + FontAwesomeIcons + .whatsapp, + color: isDeleted + ? Colors.grey + : Colors + .green, + size: 25), ), - if (tags.isNotEmpty) - Padding( - padding: - const EdgeInsets - .only(top: 0), - child: Wrap( - spacing: 6, - runSpacing: 2, - children: tags - .map( - (tag) => Chip( - label: Text( - tag), - backgroundColor: Colors - .indigo - .shade50, - labelStyle: TextStyle( - color: isDeleted - ? Colors - .grey - : Colors - .indigo, - fontSize: - 12), - visualDensity: - VisualDensity - .compact, - shape: - RoundedRectangleBorder( - borderRadius: - BorderRadius.circular( - 5), - ), - ), - ) - .toList(), - ), - ), - ], + ], + ), ), - ), - // Actions Column (Arrow + Icons) - Column( - children: [ - // Direct action icon - if (!isDeleted) - IconButton( - icon: const Icon( - Icons.delete, - color: Colors - .redAccent, - size: 20), - onPressed: () async { - await Get.dialog( - ConfirmDialog( - 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); - }, + if (tags.isNotEmpty) + Padding( + padding: + const EdgeInsets.only( + top: 0), + child: Wrap( + spacing: 6, + runSpacing: 2, + children: tags + .map( + (tag) => Chip( + label: Text(tag), + backgroundColor: + Colors.indigo + .shade50, + labelStyle: TextStyle( + color: isDeleted + ? Colors + .grey + : Colors + .indigo, + fontSize: 12), + visualDensity: + VisualDensity + .compact, + shape: + RoundedRectangleBorder( + borderRadius: + BorderRadius + .circular( + 5), + ), ), - barrierDismissible: - false, - ); - }, - ) - else - IconButton( - icon: const Icon( - Icons.restore, - color: Colors.green, - size: 20), - onPressed: () async { - await Get.dialog( - ConfirmDialog( - title: - "Restore Contact", - message: - "Are you sure you want to restore this contact?", - confirmText: - "Restore", - confirmColor: - Colors.green, - icon: - Icons.restore, - onConfirm: - () async { - await controller - .restoreContact( - contact - .id); - }, - ), - barrierDismissible: - false, - ); - }, - ), - const SizedBox(height: 4), - Icon( - Icons.arrow_forward_ios, - color: Colors.grey, - size: 20, - ) - ], - ), + ) + .toList(), + ), + ), ], ), ), - ), + // Actions Column (Arrow + Icons) + Column( + children: [ + IconButton( + icon: Icon( + isDeleted + ? Icons.restore + : Icons.delete, + color: isDeleted + ? Colors.green + : Colors.redAccent, + size: 20, + ), + onPressed: () async { + await Get.dialog( + ConfirmDialog( + title: isDeleted + ? "Restore Contact" + : "Delete Contact", + message: isDeleted + ? "Are you sure you want to restore this contact?" + : "Are you sure you want to delete this contact?", + confirmText: isDeleted + ? "Restore" + : "Delete", + confirmColor: isDeleted + ? Colors.green + : Colors.redAccent, + icon: isDeleted + ? Icons.restore + : Icons + .delete_forever, + onConfirm: () async { + if (isDeleted) { + await controller + .restoreContact( + contact.id); + } else { + await controller + .deleteContact( + contact.id); + } + }, + ), + barrierDismissible: false, + ); + }, + ), + const SizedBox(height: 4), + Icon( + Icons.arrow_forward_ios, + color: Colors.grey, + size: 20, + ) + ], + ), + ], ), - ], + ), ), ); }));