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
|
||||
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: [
|
||||
// Search + Filter + Toggle
|
||||
Padding(
|
||||
padding: MySpacing.xy(8, 8),
|
||||
child: Row(
|
||||
children: [
|
||||
// Search Field
|
||||
Expanded(
|
||||
child: SizedBox(
|
||||
height: 35,
|
||||
@ -70,17 +84,13 @@ class DirectoryView extends StatelessWidget {
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(24),
|
||||
onTap: _refreshDirectory,
|
||||
child: MouseRegion(
|
||||
cursor: SystemMouseCursors.click,
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.all(0),
|
||||
child: Icon(Icons.refresh, color: Colors.green, size: 28),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
MySpacing.width(8),
|
||||
// Filter Icon with red dot
|
||||
Obx(() {
|
||||
final isFilterActive = controller.hasActiveFilters();
|
||||
return Stack(
|
||||
@ -96,16 +106,15 @@ class DirectoryView extends StatelessWidget {
|
||||
child: IconButton(
|
||||
icon: Icon(Icons.filter_alt_outlined,
|
||||
size: 20,
|
||||
color: isFilterActive
|
||||
? Colors.indigo
|
||||
: Colors.black87),
|
||||
color:
|
||||
isFilterActive ? Colors.indigo : Colors.black87),
|
||||
onPressed: () {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.vertical(
|
||||
top: Radius.circular(20)),
|
||||
borderRadius:
|
||||
BorderRadius.vertical(top: Radius.circular(20)),
|
||||
),
|
||||
builder: (_) => const DirectoryFilterBottomSheet(),
|
||||
);
|
||||
@ -129,7 +138,6 @@ class DirectoryView extends StatelessWidget {
|
||||
);
|
||||
}),
|
||||
MySpacing.width(10),
|
||||
// 3-dot Popup with toggle
|
||||
Container(
|
||||
height: 35,
|
||||
width: 35,
|
||||
@ -152,8 +160,7 @@ class DirectoryView extends StatelessWidget {
|
||||
child: Obx(() => Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
MyText.bodySmall('Show Inactive',
|
||||
fontWeight: 600),
|
||||
MyText.bodySmall('Show Inactive', fontWeight: 600),
|
||||
Switch.adaptive(
|
||||
value: !controller.isActive.value,
|
||||
activeColor: Colors.indigo,
|
||||
@ -172,8 +179,6 @@ class DirectoryView extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// Contact List
|
||||
Expanded(
|
||||
child: Obx(() {
|
||||
if (controller.isLoading.value) {
|
||||
@ -209,7 +214,8 @@ class DirectoryView extends StatelessWidget {
|
||||
: '-';
|
||||
final nameParts = contact.name.trim().split(" ");
|
||||
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();
|
||||
|
||||
return InkWell(
|
||||
@ -217,13 +223,14 @@ class DirectoryView extends StatelessWidget {
|
||||
Get.to(() => ContactDetailScreen(contact: contact));
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12.0, vertical: 10),
|
||||
padding: const EdgeInsets.fromLTRB(12, 10, 12, 0),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Avatar(
|
||||
firstName: firstName, lastName: lastName, size: 45),
|
||||
firstName: firstName,
|
||||
lastName: lastName,
|
||||
size: 45),
|
||||
MySpacing.width(12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
@ -241,8 +248,8 @@ class DirectoryView extends StatelessWidget {
|
||||
children: [
|
||||
...contact.contactEmails.map((e) =>
|
||||
GestureDetector(
|
||||
onTap: () => LauncherUtils.launchEmail(
|
||||
e.emailAddress),
|
||||
onTap: () => LauncherUtils
|
||||
.launchEmail(e.emailAddress),
|
||||
onLongPress: () =>
|
||||
LauncherUtils.copyToClipboard(
|
||||
e.emailAddress,
|
||||
@ -266,8 +273,8 @@ class DirectoryView extends StatelessWidget {
|
||||
overflow:
|
||||
TextOverflow.ellipsis,
|
||||
color: Colors.indigo,
|
||||
decoration:
|
||||
TextDecoration.underline,
|
||||
decoration: TextDecoration
|
||||
.underline,
|
||||
),
|
||||
),
|
||||
],
|
||||
@ -276,8 +283,8 @@ class DirectoryView extends StatelessWidget {
|
||||
)),
|
||||
...contact.contactPhones.map((p) =>
|
||||
GestureDetector(
|
||||
onTap: () => LauncherUtils.launchPhone(
|
||||
p.phoneNumber),
|
||||
onTap: () => LauncherUtils
|
||||
.launchPhone(p.phoneNumber),
|
||||
onLongPress: () =>
|
||||
LauncherUtils.copyToClipboard(
|
||||
p.phoneNumber,
|
||||
@ -301,8 +308,8 @@ class DirectoryView extends StatelessWidget {
|
||||
overflow:
|
||||
TextOverflow.ellipsis,
|
||||
color: Colors.indigo,
|
||||
decoration:
|
||||
TextDecoration.underline,
|
||||
decoration: TextDecoration
|
||||
.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