From c96aa42e8176431408f4f145011626fd552635f8 Mon Sep 17 00:00:00 2001 From: Vaibhav Surve Date: Mon, 8 Dec 2025 11:37:16 +0530 Subject: [PATCH] added condition for no services --- .../taskPlanning/daily_task_planning.dart | 155 ++++++++++++++---- 1 file changed, 124 insertions(+), 31 deletions(-) diff --git a/lib/view/taskPlanning/daily_task_planning.dart b/lib/view/taskPlanning/daily_task_planning.dart index 4660537..8ab34e7 100644 --- a/lib/view/taskPlanning/daily_task_planning.dart +++ b/lib/view/taskPlanning/daily_task_planning.dart @@ -84,20 +84,38 @@ class _DailyTaskPlanningScreenState extends State 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 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 .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 projectId, serviceController.selectedService?.id, ); - setMainState(() {}); + setMainState(() {}); } } }, @@ -247,11 +263,11 @@ class _DailyTaskPlanningScreenState extends State .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 ), ], ), - MySpacing.height(6), + MySpacing.height(4), Row( children: [ MyText.bodySmall( @@ -538,3 +554,80 @@ class _DailyTaskPlanningScreenState extends State }); } } + +// ===================================================================== +// 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, + ), + ], + ), + ); + } +}