added condition for no services

This commit is contained in:
Vaibhav Surve 2025-12-08 11:37:16 +05:30
parent b2205c18f4
commit c96aa42e81

View File

@ -84,7 +84,24 @@ class _DailyTaskPlanningScreenState extends State<DailyTaskPlanningScreen>
MySpacing.height(flexSpacing), MySpacing.height(flexSpacing),
Padding( Padding(
padding: MySpacing.x(10), padding: MySpacing.x(10),
child: ServiceSelector( child: Obx(() {
// 1. Check if services are loading or empty
if (serviceController.isLoadingServices.value) {
return ServiceSelector(
controller: serviceController,
height: 40,
onSelectionChanged: (service) async {
// Empty handler when loading
},
);
}
if (serviceController.services.isEmpty) {
return const _EmptyServiceWidget();
}
// 2. Display ServiceSelector if services are available
return ServiceSelector(
controller: serviceController, controller: serviceController,
height: 40, height: 40,
onSelectionChanged: (service) async { onSelectionChanged: (service) async {
@ -97,7 +114,8 @@ class _DailyTaskPlanningScreenState extends State<DailyTaskPlanningScreen>
); );
} }
}, },
), );
}),
), ),
MySpacing.height(flexSpacing), MySpacing.height(flexSpacing),
Padding( Padding(
@ -126,12 +144,11 @@ class _DailyTaskPlanningScreenState extends State<DailyTaskPlanningScreen>
return SkeletonLoaders.dailyProgressPlanningSkeletonCollapsedOnly(); return SkeletonLoaders.dailyProgressPlanningSkeletonCollapsedOnly();
} }
// Check 1: If no daily tasks are fetched at all
if (dailyTasks.isEmpty) { if (dailyTasks.isEmpty) {
return Center( return const _EmptyDataCard(
child: MyText.bodySmall( title: "No Daily Tasks Found",
"No Progress Report Found", subtitle: "No progress reports are planned for the selected filter.",
fontWeight: 600,
),
); );
} }
@ -164,11 +181,10 @@ class _DailyTaskPlanningScreenState extends State<DailyTaskPlanningScreen>
.toList(); .toList();
if (buildings.isEmpty) { if (buildings.isEmpty) {
return Center( return const _EmptyDataCard(
child: MyText.bodySmall( title: "No Progress Report Found",
"No Progress Report Found", subtitle:
fontWeight: 600, "No work is planned or completed for the selected service/project.",
),
); );
} }
@ -247,11 +263,11 @@ class _DailyTaskPlanningScreenState extends State<DailyTaskPlanningScreen>
.dailyProgressPlanningInfraSkeleton(), .dailyProgressPlanningInfraSkeleton(),
) )
else if (!buildingLoaded || building.floors.isEmpty) else if (!buildingLoaded || building.floors.isEmpty)
Padding( const Padding(
padding: const EdgeInsets.all(16.0), padding: EdgeInsets.all(16.0),
child: MyText.bodySmall( child: _EmptyDataMessage(
"No Progress Report Found for this Project", message:
fontWeight: 600, "No floors or work data found for this building.",
), ),
) )
else else
@ -473,7 +489,7 @@ class _DailyTaskPlanningScreenState extends State<DailyTaskPlanningScreen>
), ),
], ],
), ),
MySpacing.height(6), MySpacing.height(4),
Row( Row(
children: [ children: [
MyText.bodySmall( MyText.bodySmall(
@ -538,3 +554,80 @@ class _DailyTaskPlanningScreenState extends State<DailyTaskPlanningScreen>
}); });
} }
} }
// =====================================================================
// NEW EMPTY DATA WIDGETS
// =====================================================================
class _EmptyDataMessage extends StatelessWidget {
final String message;
const _EmptyDataMessage({required this.message});
@override
Widget build(BuildContext context) {
return Center(
child: MyText.bodySmall(
message,
fontWeight: 600,
color: Colors.grey.shade500,
textAlign: TextAlign.center,
),
);
}
}
class _EmptyServiceWidget extends StatelessWidget {
const _EmptyServiceWidget({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0),
child: Center(
child: MyText.bodyMedium(
'No services found for this project.',
fontWeight: 700,
color: Colors.grey.shade600,
),
),
);
}
}
class _EmptyDataCard extends StatelessWidget {
final String title;
final String subtitle;
const _EmptyDataCard({required this.title, required this.subtitle});
@override
Widget build(BuildContext context) {
return MyCard.bordered(
paddingAll: 16,
borderRadiusAll: 10,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.task_alt_outlined,
size: 48,
color: Colors.grey.shade400,
),
MySpacing.height(12),
MyText.titleMedium(
title,
fontWeight: 700,
color: Colors.grey.shade700,
textAlign: TextAlign.center,
),
MySpacing.height(4),
MyText.bodySmall(
subtitle,
color: Colors.grey.shade500,
textAlign: TextAlign.center,
),
],
),
);
}
}