Merge pull request 'Vaibhav_Task-#200' (#17) from Vaibhav_Task-#200 into main

Reviewed-on: #17
This commit is contained in:
vaibhav.surve 2025-05-09 06:04:01 +00:00
commit 82dcf0c8fe
3 changed files with 102 additions and 139 deletions

View File

@ -78,28 +78,30 @@ class _LoadingAnimation extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
Image.asset(
Images.loadingLogo,
height: imageSize,
width: imageSize,
fit: BoxFit.contain,
),
const SizedBox(height: 8),
Text(
loadingText,
style: _textStyle,
textAlign: TextAlign.center,
),
const SizedBox(height: 4),
if (showDots)
LoadingAnimationWidget.waveDots(
color: const Color(0xFFEF0000),
size: 50,
return SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Image.asset(
Images.loadingLogo,
height: imageSize,
width: imageSize,
fit: BoxFit.contain,
),
],
const SizedBox(height: 8),
Text(
loadingText,
style: _textStyle,
textAlign: TextAlign.center,
),
const SizedBox(height: 4),
if (showDots)
LoadingAnimationWidget.waveDots(
color: const Color(0xFFEF0000),
size: 50,
),
],
),
);
}
}

View File

@ -24,12 +24,12 @@ class AddEmployeeScreen extends StatefulWidget {
}
class _AddEmployeeScreenState extends State<AddEmployeeScreen> with UIMixin {
AddEmployeeController controller = Get.put(AddEmployeeController());
final AddEmployeeController controller = Get.put(AddEmployeeController());
@override
Widget build(BuildContext context) {
return Layout(
child: GetBuilder(
child: GetBuilder<AddEmployeeController>(
init: controller,
tag: 'add_employee_controller',
builder: (controller) {
@ -73,8 +73,7 @@ class _AddEmployeeScreenState extends State<AddEmployeeScreen> with UIMixin {
Widget detail() {
return Form(
key: controller
.basicValidator.formKey, // Ensure the key is correctly assigned
key: controller.basicValidator.formKey,
child: MyCard.bordered(
borderRadiusAll: 4,
border: Border.all(color: Colors.grey.withOpacity(0.2)),
@ -97,10 +96,8 @@ class _AddEmployeeScreenState extends State<AddEmployeeScreen> with UIMixin {
MyText.labelMedium("First Name"),
MySpacing.height(8),
TextFormField(
validator:
controller.basicValidator.getValidation('first_name'),
controller:
controller.basicValidator.getController('first_name'),
validator: controller.basicValidator.getValidation('first_name'),
controller: controller.basicValidator.getController('first_name'),
keyboardType: TextInputType.name,
decoration: InputDecoration(
hintText: "eg: Jhon",
@ -117,10 +114,8 @@ class _AddEmployeeScreenState extends State<AddEmployeeScreen> with UIMixin {
MyText.labelMedium("Last Name"),
MySpacing.height(8),
TextFormField(
validator:
controller.basicValidator.getValidation('last_name'),
controller:
controller.basicValidator.getController('last_name'),
validator: controller.basicValidator.getValidation('last_name'),
controller: controller.basicValidator.getController('last_name'),
keyboardType: TextInputType.name,
decoration: InputDecoration(
hintText: "eg: Doe",
@ -137,10 +132,8 @@ class _AddEmployeeScreenState extends State<AddEmployeeScreen> with UIMixin {
MyText.labelMedium("Phone Number"),
MySpacing.height(8),
TextFormField(
validator:
controller.basicValidator.getValidation('phone_number'),
controller:
controller.basicValidator.getController('phone_number'),
validator: controller.basicValidator.getValidation('phone_number'),
controller: controller.basicValidator.getController('phone_number'),
keyboardType: TextInputType.phone,
decoration: InputDecoration(
hintText: "eg: +91 9876543210",
@ -171,8 +164,7 @@ class _AddEmployeeScreenState extends State<AddEmployeeScreen> with UIMixin {
return DropdownMenuItem<Gender>(
value: gender,
child: MyText.labelMedium(
gender.name[0].toUpperCase() +
gender.name.substring(1),
gender.name[0].toUpperCase() + gender.name.substring(1),
),
);
}).toList(),
@ -235,11 +227,10 @@ class _AddEmployeeScreenState extends State<AddEmployeeScreen> with UIMixin {
children: [
MyButton.text(
onPressed: () {
Get.toNamed('/dashboard/employees');
Get.back();
},
padding: MySpacing.xy(20, 16),
splashColor:
contentTheme.secondary.withValues(alpha: 0.1),
splashColor: contentTheme.secondary.withValues(alpha: 0.1),
child: MyText.bodySmall('Cancel'),
),
MySpacing.width(12),

View File

@ -41,9 +41,11 @@ class _EmployeeScreenState extends State<EmployeeScreen> with UIMixin {
@override
Widget build(BuildContext context) {
return Layout(
child: Stack(
children: [
GetBuilder<EmployeesScreenController>(
child: Obx(() {
return LoadingComponent(
isLoading: employeesScreenController.isLoading.value,
loadingText: 'Loading Employees...',
child: GetBuilder<EmployeesScreenController>(
init: employeesScreenController,
builder: (controller) {
return Column(
@ -70,64 +72,68 @@ class _EmployeeScreenState extends State<EmployeeScreen> with UIMixin {
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
decoration: BoxDecoration(
border: Border.all(
color: Colors.black,
width: 1.5,
Expanded(
child: Container(
decoration: BoxDecoration(
border: Border.all(
color: Colors.black,
width: 1.5,
),
borderRadius: BorderRadius.circular(4),
),
borderRadius: BorderRadius.circular(4),
),
child: PopupMenuButton<String>(
onSelected: (String value) async {
if (value.isEmpty) {
employeesScreenController.selectedProjectId =
null;
await employeesScreenController
.fetchAllEmployees();
} else {
employeesScreenController.selectedProjectId =
value;
await employeesScreenController
.fetchEmployeesByProject(value);
}
employeesScreenController.update();
},
itemBuilder: (BuildContext context) {
List<PopupMenuItem<String>> items = [
PopupMenuItem<String>(
value: '',
child: MyText.bodySmall('All Employees',
fontWeight: 600),
child: PopupMenuButton<String>(
onSelected: (String value) async {
if (value.isEmpty) {
employeesScreenController.selectedProjectId =
null;
await employeesScreenController
.fetchAllEmployees();
} else {
employeesScreenController.selectedProjectId =
value;
await employeesScreenController
.fetchEmployeesByProject(value);
}
employeesScreenController.update();
},
itemBuilder: (BuildContext context) {
List<PopupMenuItem<String>> items = [
PopupMenuItem<String>(
value: '',
child: MyText.bodySmall('All Employees',
fontWeight: 600),
),
];
items.addAll(
employeesScreenController.projects
.map<PopupMenuItem<String>>((project) {
return PopupMenuItem<String>(
value: project.id,
child: MyText.bodySmall(project.name),
);
}).toList(),
);
return items;
},
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 12.0, vertical: 8.0),
child: Text(
employeesScreenController.selectedProjectId ==
null
? 'All Employees'
: employeesScreenController.projects
.firstWhere((project) =>
project.id ==
employeesScreenController
.selectedProjectId)
.name,
overflow: TextOverflow
.ellipsis,
style: TextStyle(fontWeight: FontWeight.w600),
),
];
items.addAll(
employeesScreenController.projects
.map<PopupMenuItem<String>>((project) {
return PopupMenuItem<String>(
value: project.id,
child: MyText.bodySmall(project.name),
);
}).toList(),
);
return items;
},
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 12.0, vertical: 8.0),
child: MyText.bodySmall(
employeesScreenController.selectedProjectId ==
null
? 'All Employees'
: employeesScreenController.projects
.firstWhere((project) =>
project.id ==
employeesScreenController
.selectedProjectId)
.name,
fontWeight: 600,
),
),
),
@ -155,22 +161,8 @@ class _EmployeeScreenState extends State<EmployeeScreen> with UIMixin {
);
},
),
Obx(() {
return employeesScreenController.isLoading.value
? Container(
color: Colors.black.withOpacity(0.05),
child: const Center(
child: LoadingComponent(
isLoading: true,
loadingText: 'Loading Employees...',
child: SizedBox.shrink(),
),
),
)
: const SizedBox.shrink();
}),
],
),
);
}),
);
}
@ -186,8 +178,6 @@ class _EmployeeScreenState extends State<EmployeeScreen> with UIMixin {
DataColumn(label: MyText.labelLarge('Name', color: contentTheme.primary)),
DataColumn(
label: MyText.labelLarge('Contact', color: contentTheme.primary)),
DataColumn(
label: MyText.labelLarge('Actions', color: contentTheme.primary)),
];
final rows =
@ -217,26 +207,6 @@ class _EmployeeScreenState extends State<EmployeeScreen> with UIMixin {
],
),
),
DataCell(
Row(
children: [
IconButton(
icon: const Icon(Icons.visibility),
tooltip: 'View',
onPressed: () {
// View employee action
},
),
IconButton(
icon: const Icon(Icons.edit),
tooltip: 'Edit',
onPressed: () {
// Edit employee action
},
),
],
),
),
],
);
}).toList();