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

View File

@ -41,9 +41,11 @@ class _EmployeeScreenState extends State<EmployeeScreen> with UIMixin {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Layout( return Layout(
child: Stack( child: Obx(() {
children: [ return LoadingComponent(
GetBuilder<EmployeesScreenController>( isLoading: employeesScreenController.isLoading.value,
loadingText: 'Loading Employees...',
child: GetBuilder<EmployeesScreenController>(
init: employeesScreenController, init: employeesScreenController,
builder: (controller) { builder: (controller) {
return Column( return Column(
@ -70,64 +72,68 @@ class _EmployeeScreenState extends State<EmployeeScreen> with UIMixin {
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Container( Expanded(
decoration: BoxDecoration( child: Container(
border: Border.all( decoration: BoxDecoration(
color: Colors.black, border: Border.all(
width: 1.5, color: Colors.black,
width: 1.5,
),
borderRadius: BorderRadius.circular(4),
), ),
borderRadius: BorderRadius.circular(4), child: PopupMenuButton<String>(
), onSelected: (String value) async {
child: PopupMenuButton<String>( if (value.isEmpty) {
onSelected: (String value) async { employeesScreenController.selectedProjectId =
if (value.isEmpty) { null;
employeesScreenController.selectedProjectId = await employeesScreenController
null; .fetchAllEmployees();
await employeesScreenController } else {
.fetchAllEmployees(); employeesScreenController.selectedProjectId =
} else { value;
employeesScreenController.selectedProjectId = await employeesScreenController
value; .fetchEmployeesByProject(value);
await employeesScreenController }
.fetchEmployeesByProject(value); employeesScreenController.update();
} },
employeesScreenController.update(); itemBuilder: (BuildContext context) {
}, List<PopupMenuItem<String>> items = [
itemBuilder: (BuildContext context) { PopupMenuItem<String>(
List<PopupMenuItem<String>> items = [ value: '',
PopupMenuItem<String>( child: MyText.bodySmall('All Employees',
value: '', fontWeight: 600),
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('Name', color: contentTheme.primary)),
DataColumn( DataColumn(
label: MyText.labelLarge('Contact', color: contentTheme.primary)), label: MyText.labelLarge('Contact', color: contentTheme.primary)),
DataColumn(
label: MyText.labelLarge('Actions', color: contentTheme.primary)),
]; ];
final rows = 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(); }).toList();