enhanced desabled cards
This commit is contained in:
parent
cd92d4d309
commit
16e2f5a4f3
@ -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,84 +451,137 @@ 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,
|
shape: RoundedRectangleBorder(
|
||||||
child: Stack(
|
borderRadius: BorderRadius.circular(5),
|
||||||
children: [
|
),
|
||||||
Card(
|
elevation: 3,
|
||||||
shape: RoundedRectangleBorder(
|
shadowColor: Colors.grey.withOpacity(0.3),
|
||||||
borderRadius:
|
color: Colors.white,
|
||||||
BorderRadius.circular(5),
|
child: InkWell(
|
||||||
),
|
borderRadius: BorderRadius.circular(5),
|
||||||
elevation: 3,
|
onTap: isDeleted
|
||||||
shadowColor:
|
? null
|
||||||
Colors.grey.withOpacity(0.3),
|
: () => Get.to(() =>
|
||||||
color: Colors.white,
|
ContactDetailScreen(
|
||||||
child: InkWell(
|
contact: contact)),
|
||||||
borderRadius:
|
child: Padding(
|
||||||
BorderRadius.circular(5),
|
padding: const EdgeInsets.all(12),
|
||||||
onTap: isDeleted
|
child: Row(
|
||||||
? null
|
crossAxisAlignment:
|
||||||
: () => Get.to(() =>
|
CrossAxisAlignment.start,
|
||||||
ContactDetailScreen(
|
children: [
|
||||||
contact: contact)),
|
// Avatar
|
||||||
child: Padding(
|
Avatar(
|
||||||
padding: const EdgeInsets.all(12),
|
firstName: firstName,
|
||||||
child: Row(
|
lastName: lastName,
|
||||||
|
size: 40,
|
||||||
|
backgroundColor: isDeleted
|
||||||
|
? Colors.grey.shade400
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
MySpacing.width(12),
|
||||||
|
// Contact Info
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
crossAxisAlignment:
|
crossAxisAlignment:
|
||||||
CrossAxisAlignment.start,
|
CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
// Avatar
|
MyText.titleSmall(
|
||||||
Avatar(
|
contact.name,
|
||||||
firstName: firstName,
|
fontWeight: 600,
|
||||||
lastName: lastName,
|
overflow:
|
||||||
size: 40,
|
TextOverflow.ellipsis,
|
||||||
backgroundColor: isDeleted
|
color: isDeleted
|
||||||
? Colors.grey.shade400
|
? Colors.grey
|
||||||
: null,
|
: Colors.black87,
|
||||||
),
|
),
|
||||||
MySpacing.width(12),
|
MyText.bodySmall(
|
||||||
// Contact Info
|
contact.organization,
|
||||||
Expanded(
|
color: isDeleted
|
||||||
child: Column(
|
? Colors.grey
|
||||||
crossAxisAlignment:
|
: Colors.grey[700],
|
||||||
CrossAxisAlignment
|
overflow:
|
||||||
.start,
|
TextOverflow.ellipsis,
|
||||||
children: [
|
),
|
||||||
MyText.titleSmall(
|
MySpacing.height(6),
|
||||||
contact.name,
|
if (contact
|
||||||
fontWeight: 600,
|
.contactEmails.isNotEmpty)
|
||||||
overflow: TextOverflow
|
Padding(
|
||||||
.ellipsis,
|
padding:
|
||||||
color: isDeleted
|
const EdgeInsets.only(
|
||||||
? Colors.grey
|
bottom: 4),
|
||||||
: Colors.black87,
|
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
|
if (contact
|
||||||
? Colors.grey
|
.contactPhones.isNotEmpty)
|
||||||
: Colors.grey[700],
|
Padding(
|
||||||
overflow: TextOverflow
|
padding:
|
||||||
.ellipsis,
|
const EdgeInsets.only(
|
||||||
),
|
bottom: 8, top: 4),
|
||||||
MySpacing.height(6),
|
child: Row(
|
||||||
if (contact.contactEmails
|
children: [
|
||||||
.isNotEmpty)
|
Expanded(
|
||||||
Padding(
|
|
||||||
padding:
|
|
||||||
const EdgeInsets
|
|
||||||
.only(
|
|
||||||
bottom: 4),
|
|
||||||
child:
|
child:
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: isDeleted
|
onTap: isDeleted
|
||||||
? null
|
? null
|
||||||
: () => LauncherUtils
|
: () => LauncherUtils
|
||||||
.launchEmail(contact
|
.launchPhone(contact
|
||||||
.contactEmails
|
.contactPhones
|
||||||
.first
|
.first
|
||||||
.emailAddress),
|
.phoneNumber),
|
||||||
onLongPress:
|
onLongPress:
|
||||||
isDeleted
|
isDeleted
|
||||||
? null
|
? null
|
||||||
@ -537,17 +589,17 @@ class _DirectoryViewState extends State<DirectoryView> {
|
|||||||
LauncherUtils
|
LauncherUtils
|
||||||
.copyToClipboard(
|
.copyToClipboard(
|
||||||
contact
|
contact
|
||||||
.contactEmails
|
.contactPhones
|
||||||
.first
|
.first
|
||||||
.emailAddress,
|
.phoneNumber,
|
||||||
typeLabel:
|
typeLabel:
|
||||||
'Email',
|
'Phone',
|
||||||
),
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Icon(
|
Icon(
|
||||||
Icons
|
Icons
|
||||||
.email_outlined,
|
.phone_outlined,
|
||||||
size: 16,
|
size: 16,
|
||||||
color: isDeleted
|
color: isDeleted
|
||||||
? Colors
|
? Colors
|
||||||
@ -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,213 +632,126 @@ class _DirectoryViewState extends State<DirectoryView> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (contact.contactPhones
|
MySpacing.width(8),
|
||||||
.isNotEmpty)
|
GestureDetector(
|
||||||
Padding(
|
onTap: isDeleted
|
||||||
padding:
|
? null
|
||||||
const EdgeInsets
|
: () => LauncherUtils
|
||||||
.only(
|
.launchWhatsApp(contact
|
||||||
bottom: 8,
|
.contactPhones
|
||||||
top: 4),
|
.first
|
||||||
child: Row(
|
.phoneNumber),
|
||||||
children: [
|
child: FaIcon(
|
||||||
Expanded(
|
FontAwesomeIcons
|
||||||
child:
|
.whatsapp,
|
||||||
GestureDetector(
|
color: isDeleted
|
||||||
onTap: isDeleted
|
? Colors.grey
|
||||||
? null
|
: Colors
|
||||||
: () => LauncherUtils.launchPhone(contact
|
.green,
|
||||||
.contactPhones
|
size: 25),
|
||||||
.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),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
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(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
if (tags.isNotEmpty)
|
||||||
// Actions Column (Arrow + Icons)
|
Padding(
|
||||||
Column(
|
padding:
|
||||||
children: [
|
const EdgeInsets.only(
|
||||||
// Direct action icon
|
top: 0),
|
||||||
if (!isDeleted)
|
child: Wrap(
|
||||||
IconButton(
|
spacing: 6,
|
||||||
icon: const Icon(
|
runSpacing: 2,
|
||||||
Icons.delete,
|
children: tags
|
||||||
color: Colors
|
.map(
|
||||||
.redAccent,
|
(tag) => Chip(
|
||||||
size: 20),
|
label: Text(tag),
|
||||||
onPressed: () async {
|
backgroundColor:
|
||||||
await Get.dialog(
|
Colors.indigo
|
||||||
ConfirmDialog(
|
.shade50,
|
||||||
title:
|
labelStyle: TextStyle(
|
||||||
"Delete Contact",
|
color: isDeleted
|
||||||
message:
|
? Colors
|
||||||
"Are you sure you want to delete this contact?",
|
.grey
|
||||||
confirmText:
|
: Colors
|
||||||
"Delete",
|
.indigo,
|
||||||
confirmColor:
|
fontSize: 12),
|
||||||
Colors
|
visualDensity:
|
||||||
.redAccent,
|
VisualDensity
|
||||||
icon: Icons
|
.compact,
|
||||||
.delete_forever,
|
shape:
|
||||||
onConfirm:
|
RoundedRectangleBorder(
|
||||||
() async {
|
borderRadius:
|
||||||
await controller
|
BorderRadius
|
||||||
.deleteContact(
|
.circular(
|
||||||
contact
|
5),
|
||||||
.id);
|
),
|
||||||
},
|
|
||||||
),
|
),
|
||||||
barrierDismissible:
|
)
|
||||||
false,
|
.toList(),
|
||||||
);
|
),
|
||||||
},
|
),
|
||||||
)
|
|
||||||
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,
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
// 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,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}));
|
}));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user