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/widgets/my_confirmation_dialog.dart';
class DirectoryView extends StatefulWidget {
@override
State<DirectoryView> createState() => _DirectoryViewState();
@ -452,22 +451,15 @@ class _DirectoryViewState extends State<DirectoryView> {
.map((tag) => tag.name)
.toList();
return Opacity(
opacity: isDeleted ? 0.5 : 1.0,
child: Stack(
children: [
Card(
return Card(
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(5),
borderRadius: BorderRadius.circular(5),
),
elevation: 3,
shadowColor:
Colors.grey.withOpacity(0.3),
shadowColor: Colors.grey.withOpacity(0.3),
color: Colors.white,
child: InkWell(
borderRadius:
BorderRadius.circular(5),
borderRadius: BorderRadius.circular(5),
onTap: isDeleted
? null
: () => Get.to(() =>
@ -493,14 +485,13 @@ class _DirectoryViewState extends State<DirectoryView> {
Expanded(
child: Column(
crossAxisAlignment:
CrossAxisAlignment
.start,
CrossAxisAlignment.start,
children: [
MyText.titleSmall(
contact.name,
fontWeight: 600,
overflow: TextOverflow
.ellipsis,
overflow:
TextOverflow.ellipsis,
color: isDeleted
? Colors.grey
: Colors.black87,
@ -510,19 +501,17 @@ class _DirectoryViewState extends State<DirectoryView> {
color: isDeleted
? Colors.grey
: Colors.grey[700],
overflow: TextOverflow
.ellipsis,
overflow:
TextOverflow.ellipsis,
),
MySpacing.height(6),
if (contact.contactEmails
.isNotEmpty)
if (contact
.contactEmails.isNotEmpty)
Padding(
padding:
const EdgeInsets
.only(
const EdgeInsets.only(
bottom: 4),
child:
GestureDetector(
child: GestureDetector(
onTap: isDeleted
? null
: () => LauncherUtils
@ -530,11 +519,9 @@ class _DirectoryViewState extends State<DirectoryView> {
.contactEmails
.first
.emailAddress),
onLongPress:
isDeleted
onLongPress: isDeleted
? null
: () =>
LauncherUtils
: () => LauncherUtils
.copyToClipboard(
contact
.contactEmails
@ -549,6 +536,71 @@ class _DirectoryViewState extends State<DirectoryView> {
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,
),
),
],
),
),
),
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
@ -560,9 +612,9 @@ class _DirectoryViewState extends State<DirectoryView> {
child: MyText
.labelSmall(
contact
.contactEmails
.contactPhones
.first
.emailAddress,
.phoneNumber,
overflow:
TextOverflow
.ellipsis,
@ -580,72 +632,12 @@ class _DirectoryViewState extends State<DirectoryView> {
),
),
),
if (contact.contactPhones
.isNotEmpty)
Padding(
padding:
const EdgeInsets
.only(
bottom: 8,
top: 4),
child: Row(
children: [
Expanded(
child:
MySpacing.width(8),
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
: () => LauncherUtils
.launchWhatsApp(contact
.contactPhones
.first
.phoneNumber),
@ -653,8 +645,7 @@ class _DirectoryViewState extends State<DirectoryView> {
FontAwesomeIcons
.whatsapp,
color: isDeleted
? Colors
.grey
? Colors.grey
: Colors
.green,
size: 25),
@ -665,18 +656,17 @@ class _DirectoryViewState extends State<DirectoryView> {
if (tags.isNotEmpty)
Padding(
padding:
const EdgeInsets
.only(top: 0),
const EdgeInsets.only(
top: 0),
child: Wrap(
spacing: 6,
runSpacing: 2,
children: tags
.map(
(tag) => Chip(
label: Text(
tag),
backgroundColor: Colors
.indigo
label: Text(tag),
backgroundColor:
Colors.indigo
.shade50,
labelStyle: TextStyle(
color: isDeleted
@ -684,15 +674,15 @@ class _DirectoryViewState extends State<DirectoryView> {
.grey
: Colors
.indigo,
fontSize:
12),
fontSize: 12),
visualDensity:
VisualDensity
.compact,
shape:
RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(
BorderRadius
.circular(
5),
),
),
@ -706,70 +696,48 @@ class _DirectoryViewState extends State<DirectoryView> {
// 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);
},
icon: Icon(
isDeleted
? Icons.restore
: Icons.delete,
color: isDeleted
? Colors.green
: Colors.redAccent,
size: 20,
),
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 {
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);
contact.id);
} else {
await controller
.deleteContact(
contact.id);
}
},
),
barrierDismissible:
false,
barrierDismissible: false,
);
},
),
@ -785,9 +753,6 @@ class _DirectoryViewState extends State<DirectoryView> {
),
),
),
),
],
),
);
}));
}),