From 3bd25c11724437593c0f7e13c305d3ae7799f010 Mon Sep 17 00:00:00 2001 From: Vaibhav Surve Date: Tue, 3 Jun 2025 17:26:43 +0530 Subject: [PATCH] fix: Add percent indicator for visual progress representation in daily task planning --- lib/view/taskPlaning/daily_task_planing.dart | 74 +++++++++++++++----- pubspec.yaml | 1 + 2 files changed, 57 insertions(+), 18 deletions(-) diff --git a/lib/view/taskPlaning/daily_task_planing.dart b/lib/view/taskPlaning/daily_task_planing.dart index d9afd23..110a363 100644 --- a/lib/view/taskPlaning/daily_task_planing.dart +++ b/lib/view/taskPlaning/daily_task_planing.dart @@ -13,6 +13,7 @@ import 'package:marco/controller/permission_controller.dart'; import 'package:marco/model/dailyTaskPlaning/daily_task_planing_filter.dart'; import 'package:marco/controller/task_planing/daily_task_planing_controller.dart'; import 'package:marco/model/dailyTaskPlaning/assign_task_bottom_sheet .dart'; +import 'package:percent_indicator/percent_indicator.dart'; class DailyTaskPlaningScreen extends StatefulWidget { DailyTaskPlaningScreen({super.key}); @@ -287,7 +288,15 @@ class _DailyTaskPlaningScreenState extends State "${buildingKey}_${floor.floorName}_${area.areaName}"; final isExpanded = floorExpansionState[floorWorkAreaKey] ?? false; - + final totalPlanned = area.workItems + .map((wi) => wi.workItem.plannedWork ?? 0) + .fold(0, (prev, curr) => prev + curr); + final totalCompleted = area.workItems + .map((wi) => wi.workItem.completedWork ?? 0) + .fold(0, (prev, curr) => prev + curr); + final totalProgress = totalPlanned == 0 + ? 0.0 + : (totalCompleted / totalPlanned).clamp(0.0, 1.0); return ExpansionTile( onExpansionChanged: (expanded) { setMainState(() { @@ -303,25 +312,54 @@ class _DailyTaskPlaningScreenState extends State ), tilePadding: const EdgeInsets.symmetric( horizontal: 16, vertical: 0), - title: Wrap( - spacing: 16, - crossAxisAlignment: WrapCrossAlignment.center, + title: Row( + crossAxisAlignment: CrossAxisAlignment.center, children: [ - MyText.titleSmall( - "Floor: ${floor.floorName}", - fontWeight: 600, - color: Colors.teal, - maxLines: null, - overflow: TextOverflow.visible, - softWrap: true, + Expanded( + flex: 3, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + MyText.titleSmall( + "Floor: ${floor.floorName}", + fontWeight: 600, + color: Colors.teal, + maxLines: null, + overflow: TextOverflow.visible, + softWrap: true, + ), + MySpacing.height(4), + MyText.titleSmall( + "Work Area: ${area.areaName}", + fontWeight: 600, + color: Colors.blueGrey, + maxLines: null, + overflow: TextOverflow.visible, + softWrap: true, + ), + ], + ), ), - MyText.titleSmall( - "Work Area: ${area.areaName}", - fontWeight: 600, - color: Colors.blueGrey, - maxLines: null, - overflow: TextOverflow.visible, - softWrap: true, + MySpacing.width(12), + CircularPercentIndicator( + radius: 20.0, + lineWidth: 4.0, + animation: true, + percent: totalProgress, + center: Text( + "${(totalProgress * 100).toStringAsFixed(0)}%", + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 10.0, + ), + ), + circularStrokeCap: CircularStrokeCap.round, + progressColor: totalProgress >= 1.0 + ? Colors.green + : (totalProgress >= 0.5 + ? Colors.amber + : Colors.red), + backgroundColor: Colors.grey[300]!, ), ], ), diff --git a/pubspec.yaml b/pubspec.yaml index b2e3adf..91df0dd 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -67,6 +67,7 @@ dependencies: flutter_image_compress: ^2.1.0 path_provider: ^2.1.2 path: ^1.9.0 + percent_indicator: ^4.2.2 dev_dependencies: flutter_test: sdk: flutter