feat(directory): refactor DirectoryView layout for improved structure and readability
This commit is contained in:
parent
43aeec4c6f
commit
5fb18a13d2
@ -27,14 +27,28 @@ class DirectoryView extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Column(
|
return Scaffold(
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
floatingActionButton: FloatingActionButton(
|
||||||
|
backgroundColor: Colors.red,
|
||||||
|
onPressed: () async {
|
||||||
|
final result = await Get.bottomSheet(
|
||||||
|
AddContactBottomSheet(),
|
||||||
|
isScrollControlled: true,
|
||||||
|
backgroundColor: Colors.transparent,
|
||||||
|
);
|
||||||
|
if (result == true) {
|
||||||
|
controller.fetchContacts();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: const Icon(Icons.add, color: Colors.white),
|
||||||
|
),
|
||||||
|
body: Column(
|
||||||
children: [
|
children: [
|
||||||
// Search + Filter + Toggle
|
|
||||||
Padding(
|
Padding(
|
||||||
padding: MySpacing.xy(8, 8),
|
padding: MySpacing.xy(8, 8),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
// Search Field
|
|
||||||
Expanded(
|
Expanded(
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
height: 35,
|
height: 35,
|
||||||
@ -70,17 +84,13 @@ class DirectoryView extends StatelessWidget {
|
|||||||
child: InkWell(
|
child: InkWell(
|
||||||
borderRadius: BorderRadius.circular(24),
|
borderRadius: BorderRadius.circular(24),
|
||||||
onTap: _refreshDirectory,
|
onTap: _refreshDirectory,
|
||||||
child: MouseRegion(
|
|
||||||
cursor: SystemMouseCursors.click,
|
|
||||||
child: const Padding(
|
child: const Padding(
|
||||||
padding: EdgeInsets.all(0),
|
padding: EdgeInsets.all(0),
|
||||||
child: Icon(Icons.refresh, color: Colors.green, size: 28),
|
child: Icon(Icons.refresh, color: Colors.green, size: 28),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
MySpacing.width(8),
|
MySpacing.width(8),
|
||||||
// Filter Icon with red dot
|
|
||||||
Obx(() {
|
Obx(() {
|
||||||
final isFilterActive = controller.hasActiveFilters();
|
final isFilterActive = controller.hasActiveFilters();
|
||||||
return Stack(
|
return Stack(
|
||||||
@ -96,16 +106,15 @@ class DirectoryView extends StatelessWidget {
|
|||||||
child: IconButton(
|
child: IconButton(
|
||||||
icon: Icon(Icons.filter_alt_outlined,
|
icon: Icon(Icons.filter_alt_outlined,
|
||||||
size: 20,
|
size: 20,
|
||||||
color: isFilterActive
|
color:
|
||||||
? Colors.indigo
|
isFilterActive ? Colors.indigo : Colors.black87),
|
||||||
: Colors.black87),
|
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
showModalBottomSheet(
|
showModalBottomSheet(
|
||||||
context: context,
|
context: context,
|
||||||
isScrollControlled: true,
|
isScrollControlled: true,
|
||||||
shape: const RoundedRectangleBorder(
|
shape: const RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.vertical(
|
borderRadius:
|
||||||
top: Radius.circular(20)),
|
BorderRadius.vertical(top: Radius.circular(20)),
|
||||||
),
|
),
|
||||||
builder: (_) => const DirectoryFilterBottomSheet(),
|
builder: (_) => const DirectoryFilterBottomSheet(),
|
||||||
);
|
);
|
||||||
@ -129,7 +138,6 @@ class DirectoryView extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
MySpacing.width(10),
|
MySpacing.width(10),
|
||||||
// 3-dot Popup with toggle
|
|
||||||
Container(
|
Container(
|
||||||
height: 35,
|
height: 35,
|
||||||
width: 35,
|
width: 35,
|
||||||
@ -152,8 +160,7 @@ class DirectoryView extends StatelessWidget {
|
|||||||
child: Obx(() => Row(
|
child: Obx(() => Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
MyText.bodySmall('Show Inactive',
|
MyText.bodySmall('Show Inactive', fontWeight: 600),
|
||||||
fontWeight: 600),
|
|
||||||
Switch.adaptive(
|
Switch.adaptive(
|
||||||
value: !controller.isActive.value,
|
value: !controller.isActive.value,
|
||||||
activeColor: Colors.indigo,
|
activeColor: Colors.indigo,
|
||||||
@ -172,8 +179,6 @@ class DirectoryView extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
// Contact List
|
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Obx(() {
|
child: Obx(() {
|
||||||
if (controller.isLoading.value) {
|
if (controller.isLoading.value) {
|
||||||
@ -209,7 +214,8 @@ class DirectoryView extends StatelessWidget {
|
|||||||
: '-';
|
: '-';
|
||||||
final nameParts = contact.name.trim().split(" ");
|
final nameParts = contact.name.trim().split(" ");
|
||||||
final firstName = nameParts.first;
|
final firstName = nameParts.first;
|
||||||
final lastName = nameParts.length > 1 ? nameParts.last : "";
|
final lastName =
|
||||||
|
nameParts.length > 1 ? nameParts.last : "";
|
||||||
final tags = contact.tags.map((tag) => tag.name).toList();
|
final tags = contact.tags.map((tag) => tag.name).toList();
|
||||||
|
|
||||||
return InkWell(
|
return InkWell(
|
||||||
@ -217,13 +223,14 @@ class DirectoryView extends StatelessWidget {
|
|||||||
Get.to(() => ContactDetailScreen(contact: contact));
|
Get.to(() => ContactDetailScreen(contact: contact));
|
||||||
},
|
},
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.fromLTRB(12, 10, 12, 0),
|
||||||
horizontal: 12.0, vertical: 10),
|
|
||||||
child: Row(
|
child: Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Avatar(
|
Avatar(
|
||||||
firstName: firstName, lastName: lastName, size: 45),
|
firstName: firstName,
|
||||||
|
lastName: lastName,
|
||||||
|
size: 45),
|
||||||
MySpacing.width(12),
|
MySpacing.width(12),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Column(
|
child: Column(
|
||||||
@ -241,8 +248,8 @@ class DirectoryView extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
...contact.contactEmails.map((e) =>
|
...contact.contactEmails.map((e) =>
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () => LauncherUtils.launchEmail(
|
onTap: () => LauncherUtils
|
||||||
e.emailAddress),
|
.launchEmail(e.emailAddress),
|
||||||
onLongPress: () =>
|
onLongPress: () =>
|
||||||
LauncherUtils.copyToClipboard(
|
LauncherUtils.copyToClipboard(
|
||||||
e.emailAddress,
|
e.emailAddress,
|
||||||
@ -266,8 +273,8 @@ class DirectoryView extends StatelessWidget {
|
|||||||
overflow:
|
overflow:
|
||||||
TextOverflow.ellipsis,
|
TextOverflow.ellipsis,
|
||||||
color: Colors.indigo,
|
color: Colors.indigo,
|
||||||
decoration:
|
decoration: TextDecoration
|
||||||
TextDecoration.underline,
|
.underline,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -276,8 +283,8 @@ class DirectoryView extends StatelessWidget {
|
|||||||
)),
|
)),
|
||||||
...contact.contactPhones.map((p) =>
|
...contact.contactPhones.map((p) =>
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () => LauncherUtils.launchPhone(
|
onTap: () => LauncherUtils
|
||||||
p.phoneNumber),
|
.launchPhone(p.phoneNumber),
|
||||||
onLongPress: () =>
|
onLongPress: () =>
|
||||||
LauncherUtils.copyToClipboard(
|
LauncherUtils.copyToClipboard(
|
||||||
p.phoneNumber,
|
p.phoneNumber,
|
||||||
@ -301,8 +308,8 @@ class DirectoryView extends StatelessWidget {
|
|||||||
overflow:
|
overflow:
|
||||||
TextOverflow.ellipsis,
|
TextOverflow.ellipsis,
|
||||||
color: Colors.indigo,
|
color: Colors.indigo,
|
||||||
decoration:
|
decoration: TextDecoration
|
||||||
TextDecoration.underline,
|
.underline,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -344,29 +351,8 @@ class DirectoryView extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
|
|
||||||
// Floating action button (moved here so it doesn't appear in NotesView)
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(right: 16.0, bottom: 16.0),
|
|
||||||
child: Align(
|
|
||||||
alignment: Alignment.bottomRight,
|
|
||||||
child: FloatingActionButton(
|
|
||||||
backgroundColor: Colors.red,
|
|
||||||
onPressed: () async {
|
|
||||||
final result = await Get.bottomSheet(
|
|
||||||
AddContactBottomSheet(),
|
|
||||||
isScrollControlled: true,
|
|
||||||
backgroundColor: Colors.transparent,
|
|
||||||
);
|
|
||||||
if (result == true) {
|
|
||||||
controller.fetchContacts();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: const Icon(Icons.add, color: Colors.white),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user