fix: Add percent indicator for visual progress representation in daily task planning
This commit is contained in:
parent
eabe48e572
commit
3bd25c1172
@ -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<DailyTaskPlaningScreen>
|
||||
"${buildingKey}_${floor.floorName}_${area.areaName}";
|
||||
final isExpanded =
|
||||
floorExpansionState[floorWorkAreaKey] ?? false;
|
||||
|
||||
final totalPlanned = area.workItems
|
||||
.map((wi) => wi.workItem.plannedWork ?? 0)
|
||||
.fold<int>(0, (prev, curr) => prev + curr);
|
||||
final totalCompleted = area.workItems
|
||||
.map((wi) => wi.workItem.completedWork ?? 0)
|
||||
.fold<int>(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<DailyTaskPlaningScreen>
|
||||
),
|
||||
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]!,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user