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
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

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