Refactor loading animation in LoadingComponent to use SingleChildScrollView for better layout handling

This commit is contained in:
Vaibhav Surve 2025-05-09 10:49:34 +05:30
parent fb2823c340
commit eeddee5168
2 changed files with 83 additions and 77 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

@ -72,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,
), ),
), ),
), ),