added condition for no services
This commit is contained in:
parent
b2205c18f4
commit
c96aa42e81
@ -84,20 +84,38 @@ class _DailyTaskPlanningScreenState extends State<DailyTaskPlanningScreen>
|
||||
MySpacing.height(flexSpacing),
|
||||
Padding(
|
||||
padding: MySpacing.x(10),
|
||||
child: ServiceSelector(
|
||||
controller: serviceController,
|
||||
height: 40,
|
||||
onSelectionChanged: (service) async {
|
||||
final projectId = widget.projectId;
|
||||
if (projectId.isNotEmpty) {
|
||||
await dailyTaskPlanningController
|
||||
.fetchTaskData(
|
||||
projectId,
|
||||
serviceId: service?.id,
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
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,
|
||||
height: 40,
|
||||
onSelectionChanged: (service) async {
|
||||
final projectId = widget.projectId;
|
||||
if (projectId.isNotEmpty) {
|
||||
await dailyTaskPlanningController
|
||||
.fetchTaskData(
|
||||
projectId,
|
||||
serviceId: service?.id,
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
}),
|
||||
),
|
||||
MySpacing.height(flexSpacing),
|
||||
Padding(
|
||||
@ -126,12 +144,11 @@ class _DailyTaskPlanningScreenState extends State<DailyTaskPlanningScreen>
|
||||
return SkeletonLoaders.dailyProgressPlanningSkeletonCollapsedOnly();
|
||||
}
|
||||
|
||||
// Check 1: If no daily tasks are fetched at all
|
||||
if (dailyTasks.isEmpty) {
|
||||
return Center(
|
||||
child: MyText.bodySmall(
|
||||
"No Progress Report Found",
|
||||
fontWeight: 600,
|
||||
),
|
||||
return const _EmptyDataCard(
|
||||
title: "No Daily Tasks Found",
|
||||
subtitle: "No progress reports are planned for the selected filter.",
|
||||
);
|
||||
}
|
||||
|
||||
@ -164,11 +181,10 @@ class _DailyTaskPlanningScreenState extends State<DailyTaskPlanningScreen>
|
||||
.toList();
|
||||
|
||||
if (buildings.isEmpty) {
|
||||
return Center(
|
||||
child: MyText.bodySmall(
|
||||
"No Progress Report Found",
|
||||
fontWeight: 600,
|
||||
),
|
||||
return const _EmptyDataCard(
|
||||
title: "No Progress Report Found",
|
||||
subtitle:
|
||||
"No work is planned or completed for the selected service/project.",
|
||||
);
|
||||
}
|
||||
|
||||
@ -206,7 +222,7 @@ class _DailyTaskPlanningScreenState extends State<DailyTaskPlanningScreen>
|
||||
projectId,
|
||||
serviceController.selectedService?.id,
|
||||
);
|
||||
setMainState(() {});
|
||||
setMainState(() {});
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -247,11 +263,11 @@ class _DailyTaskPlanningScreenState extends State<DailyTaskPlanningScreen>
|
||||
.dailyProgressPlanningInfraSkeleton(),
|
||||
)
|
||||
else if (!buildingLoaded || building.floors.isEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: MyText.bodySmall(
|
||||
"No Progress Report Found for this Project",
|
||||
fontWeight: 600,
|
||||
const Padding(
|
||||
padding: EdgeInsets.all(16.0),
|
||||
child: _EmptyDataMessage(
|
||||
message:
|
||||
"No floors or work data found for this building.",
|
||||
),
|
||||
)
|
||||
else
|
||||
@ -473,7 +489,7 @@ class _DailyTaskPlanningScreenState extends State<DailyTaskPlanningScreen>
|
||||
),
|
||||
],
|
||||
),
|
||||
MySpacing.height(6),
|
||||
MySpacing.height(4),
|
||||
Row(
|
||||
children: [
|
||||
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,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user