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/model/dailyTaskPlaning/daily_task_planing_filter.dart';
|
||||||
import 'package:marco/controller/task_planing/daily_task_planing_controller.dart';
|
import 'package:marco/controller/task_planing/daily_task_planing_controller.dart';
|
||||||
import 'package:marco/model/dailyTaskPlaning/assign_task_bottom_sheet .dart';
|
import 'package:marco/model/dailyTaskPlaning/assign_task_bottom_sheet .dart';
|
||||||
|
import 'package:percent_indicator/percent_indicator.dart';
|
||||||
|
|
||||||
class DailyTaskPlaningScreen extends StatefulWidget {
|
class DailyTaskPlaningScreen extends StatefulWidget {
|
||||||
DailyTaskPlaningScreen({super.key});
|
DailyTaskPlaningScreen({super.key});
|
||||||
@ -287,7 +288,15 @@ class _DailyTaskPlaningScreenState extends State<DailyTaskPlaningScreen>
|
|||||||
"${buildingKey}_${floor.floorName}_${area.areaName}";
|
"${buildingKey}_${floor.floorName}_${area.areaName}";
|
||||||
final isExpanded =
|
final isExpanded =
|
||||||
floorExpansionState[floorWorkAreaKey] ?? false;
|
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(
|
return ExpansionTile(
|
||||||
onExpansionChanged: (expanded) {
|
onExpansionChanged: (expanded) {
|
||||||
setMainState(() {
|
setMainState(() {
|
||||||
@ -303,25 +312,54 @@ class _DailyTaskPlaningScreenState extends State<DailyTaskPlaningScreen>
|
|||||||
),
|
),
|
||||||
tilePadding: const EdgeInsets.symmetric(
|
tilePadding: const EdgeInsets.symmetric(
|
||||||
horizontal: 16, vertical: 0),
|
horizontal: 16, vertical: 0),
|
||||||
title: Wrap(
|
title: Row(
|
||||||
spacing: 16,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
crossAxisAlignment: WrapCrossAlignment.center,
|
|
||||||
children: [
|
children: [
|
||||||
MyText.titleSmall(
|
Expanded(
|
||||||
"Floor: ${floor.floorName}",
|
flex: 3,
|
||||||
fontWeight: 600,
|
child: Column(
|
||||||
color: Colors.teal,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
maxLines: null,
|
children: [
|
||||||
overflow: TextOverflow.visible,
|
MyText.titleSmall(
|
||||||
softWrap: true,
|
"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(
|
MySpacing.width(12),
|
||||||
"Work Area: ${area.areaName}",
|
CircularPercentIndicator(
|
||||||
fontWeight: 600,
|
radius: 20.0,
|
||||||
color: Colors.blueGrey,
|
lineWidth: 4.0,
|
||||||
maxLines: null,
|
animation: true,
|
||||||
overflow: TextOverflow.visible,
|
percent: totalProgress,
|
||||||
softWrap: true,
|
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
|
flutter_image_compress: ^2.1.0
|
||||||
path_provider: ^2.1.2
|
path_provider: ^2.1.2
|
||||||
path: ^1.9.0
|
path: ^1.9.0
|
||||||
|
percent_indicator: ^4.2.2
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
Loading…
x
Reference in New Issue
Block a user