From eeddee51684fd081a99f8388e44753948ac78edb Mon Sep 17 00:00:00 2001 From: Vaibhav Surve Date: Fri, 9 May 2025 10:49:34 +0530 Subject: [PATCH] Refactor loading animation in LoadingComponent to use SingleChildScrollView for better layout handling --- lib/helpers/widgets/my_loading_component.dart | 44 +++---- lib/view/dashboard/employee_screen.dart | 116 +++++++++--------- 2 files changed, 83 insertions(+), 77 deletions(-) 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/employee_screen.dart b/lib/view/dashboard/employee_screen.dart index ef6b319..5e64bbb 100644 --- a/lib/view/dashboard/employee_screen.dart +++ b/lib/view/dashboard/employee_screen.dart @@ -72,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, ), ), ),