refactor(directory): simplify floating action button and enhance menu structure
This commit is contained in:
parent
9c28dc05dd
commit
219815dd27
@ -25,7 +25,6 @@ class DirectoryView extends StatefulWidget {
|
|||||||
class _DirectoryViewState extends State<DirectoryView> {
|
class _DirectoryViewState extends State<DirectoryView> {
|
||||||
final DirectoryController controller = Get.find();
|
final DirectoryController controller = Get.find();
|
||||||
final TextEditingController searchController = TextEditingController();
|
final TextEditingController searchController = TextEditingController();
|
||||||
bool isFabExpanded = false;
|
|
||||||
final PermissionController permissionController =
|
final PermissionController permissionController =
|
||||||
Get.put(PermissionController());
|
Get.put(PermissionController());
|
||||||
|
|
||||||
@ -148,57 +147,11 @@ class _DirectoryViewState extends State<DirectoryView> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: Colors.white,
|
backgroundColor: Colors.white,
|
||||||
floatingActionButton: Column(
|
floatingActionButton: FloatingActionButton(
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
if (isFabExpanded) ...[
|
|
||||||
Obx(() {
|
|
||||||
if (permissionController
|
|
||||||
.hasPermission(Permissions.directoryAdmin) ||
|
|
||||||
permissionController
|
|
||||||
.hasPermission(Permissions.directoryManager)) {
|
|
||||||
return Padding(
|
|
||||||
padding: const EdgeInsets.only(bottom: 8),
|
|
||||||
child: FloatingActionButton.extended(
|
|
||||||
heroTag: 'manageBuckets',
|
|
||||||
backgroundColor: Colors.grey[850],
|
|
||||||
icon: const Icon(Icons.folder_open_outlined,
|
|
||||||
color: Colors.white),
|
|
||||||
label: const Text("Manage Buckets",
|
|
||||||
style: TextStyle(color: Colors.white)),
|
|
||||||
onPressed: () {
|
|
||||||
setState(() => isFabExpanded = false);
|
|
||||||
_handleManageBuckets();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return const SizedBox.shrink();
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(bottom: 8),
|
|
||||||
child: FloatingActionButton.extended(
|
|
||||||
heroTag: 'createContact',
|
heroTag: 'createContact',
|
||||||
backgroundColor: Colors.indigo,
|
|
||||||
icon: const Icon(Icons.person_add_alt_1, color: Colors.white),
|
|
||||||
label: const Text("Create Contact",
|
|
||||||
style: TextStyle(color: Colors.white)),
|
|
||||||
onPressed: () {
|
|
||||||
setState(() => isFabExpanded = false);
|
|
||||||
_handleCreateContact();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
FloatingActionButton(
|
|
||||||
heroTag: 'toggleFab',
|
|
||||||
backgroundColor: Colors.red,
|
backgroundColor: Colors.red,
|
||||||
onPressed: () => setState(() => isFabExpanded = !isFabExpanded),
|
onPressed: _handleCreateContact,
|
||||||
child: Icon(isFabExpanded ? Icons.close : Icons.add,
|
child: const Icon(Icons.person_add_alt_1, color: Colors.white),
|
||||||
color: Colors.white),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
body: Column(
|
body: Column(
|
||||||
children: [
|
children: [
|
||||||
@ -312,15 +265,73 @@ class _DirectoryViewState extends State<DirectoryView> {
|
|||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(10),
|
borderRadius: BorderRadius.circular(10),
|
||||||
),
|
),
|
||||||
itemBuilder: (context) => [
|
itemBuilder: (context) {
|
||||||
|
List<PopupMenuEntry<int>> menuItems = [];
|
||||||
|
|
||||||
|
// Section: Actions
|
||||||
|
if (permissionController
|
||||||
|
.hasPermission(Permissions.directoryAdmin) ||
|
||||||
|
permissionController
|
||||||
|
.hasPermission(Permissions.directoryManager)) {
|
||||||
|
menuItems.add(
|
||||||
|
const PopupMenuItem<int>(
|
||||||
|
enabled: false,
|
||||||
|
height: 30,
|
||||||
|
child: Text(
|
||||||
|
"Actions",
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: Colors.grey),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
menuItems.add(
|
||||||
|
PopupMenuItem<int>(
|
||||||
|
value: 1,
|
||||||
|
child: Row(
|
||||||
|
children: const [
|
||||||
|
Icon(Icons.label_outline,
|
||||||
|
size: 20, color: Colors.black87),
|
||||||
|
SizedBox(width: 10),
|
||||||
|
Expanded(child: Text("Manage Buckets")),
|
||||||
|
Icon(Icons.chevron_right,
|
||||||
|
size: 20, color: Colors.red),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
onTap: () {
|
||||||
|
Future.delayed(Duration.zero, () {
|
||||||
|
_handleManageBuckets();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Section: Preferences
|
||||||
|
menuItems.add(
|
||||||
|
const PopupMenuItem<int>(
|
||||||
|
enabled: false,
|
||||||
|
height: 30,
|
||||||
|
child: Text(
|
||||||
|
"Preferences",
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: Colors.grey),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
menuItems.add(
|
||||||
PopupMenuItem<int>(
|
PopupMenuItem<int>(
|
||||||
value: 0,
|
value: 0,
|
||||||
enabled: false,
|
enabled: false,
|
||||||
child: Obx(() => Row(
|
child: Obx(() => Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
children: [
|
||||||
MyText.bodySmall('Show Inactive',
|
const Icon(Icons.visibility_off_outlined,
|
||||||
fontWeight: 600),
|
size: 20, color: Colors.black87),
|
||||||
|
const SizedBox(width: 10),
|
||||||
|
const Expanded(child: Text('Show Inactive')),
|
||||||
Switch.adaptive(
|
Switch.adaptive(
|
||||||
value: !controller.isActive.value,
|
value: !controller.isActive.value,
|
||||||
activeColor: Colors.indigo,
|
activeColor: Colors.indigo,
|
||||||
@ -333,7 +344,10 @@ class _DirectoryViewState extends State<DirectoryView> {
|
|||||||
],
|
],
|
||||||
)),
|
)),
|
||||||
),
|
),
|
||||||
],
|
);
|
||||||
|
|
||||||
|
return menuItems;
|
||||||
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user