diff --git a/lib/helpers/widgets/my_loading_component.dart b/lib/helpers/widgets/my_loading_component.dart index 4ddaca7..f556cef 100644 --- a/lib/helpers/widgets/my_loading_component.dart +++ b/lib/helpers/widgets/my_loading_component.dart @@ -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, + ), + ], + ), ); } } diff --git a/lib/view/dashboard/add_employee_screen.dart b/lib/view/dashboard/add_employee_screen.dart index e0829f4..d02dba8 100644 --- a/lib/view/dashboard/add_employee_screen.dart +++ b/lib/view/dashboard/add_employee_screen.dart @@ -24,12 +24,12 @@ class AddEmployeeScreen extends StatefulWidget { } class _AddEmployeeScreenState extends State with UIMixin { - AddEmployeeController controller = Get.put(AddEmployeeController()); + final AddEmployeeController controller = Get.put(AddEmployeeController()); @override Widget build(BuildContext context) { return Layout( - child: GetBuilder( + child: GetBuilder( init: controller, tag: 'add_employee_controller', builder: (controller) { @@ -73,8 +73,7 @@ class _AddEmployeeScreenState extends State 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 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 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 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 with UIMixin { return DropdownMenuItem( 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 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), diff --git a/lib/view/dashboard/employee_screen.dart b/lib/view/dashboard/employee_screen.dart index ae083ae..5e64bbb 100644 --- a/lib/view/dashboard/employee_screen.dart +++ b/lib/view/dashboard/employee_screen.dart @@ -41,9 +41,11 @@ class _EmployeeScreenState extends State with UIMixin { @override Widget build(BuildContext context) { return Layout( - child: Stack( - children: [ - GetBuilder( + child: Obx(() { + return LoadingComponent( + isLoading: employeesScreenController.isLoading.value, + loadingText: 'Loading Employees...', + child: GetBuilder( init: employeesScreenController, builder: (controller) { return Column( @@ -70,64 +72,68 @@ class _EmployeeScreenState extends State 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( - 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> items = [ - PopupMenuItem( - value: '', - child: MyText.bodySmall('All Employees', - fontWeight: 600), + child: PopupMenuButton( + 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> items = [ + PopupMenuItem( + value: '', + child: MyText.bodySmall('All Employees', + fontWeight: 600), + ), + ]; + + items.addAll( + employeesScreenController.projects + .map>((project) { + return PopupMenuItem( + 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>((project) { - return PopupMenuItem( - 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 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 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 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();