From 37c3b54237df14327b8e34ea64b6436f1caf8dff Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Thu, 24 Jul 2025 14:15:10 +0300 Subject: [PATCH] improvements --- .../components/assistant_employee_card.dart | 2 +- ...total_working_time_detail_bottomsheet.dart | 95 +++++++++++++++++++ 2 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 lib/views/widgets/total_working_time_detail_bottomsheet.dart diff --git a/lib/modules/cm_module/views/forms/maintenance_request/components/assistant_employee_card.dart b/lib/modules/cm_module/views/forms/maintenance_request/components/assistant_employee_card.dart index 09a02718..5558287c 100644 --- a/lib/modules/cm_module/views/forms/maintenance_request/components/assistant_employee_card.dart +++ b/lib/modules/cm_module/views/forms/maintenance_request/components/assistant_employee_card.dart @@ -69,7 +69,7 @@ class _AssistantEmployeeCardState extends State { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ context.translation.assistantEmployee.bodyText(context).custom(color: AppColor.black20), - Icon(isExpanded ? Icons.arrow_drop_up_outlined : Icons.arrow_drop_down), + Icon(isExpanded ? Icons.keyboard_arrow_up_rounded : Icons.keyboard_arrow_down_rounded), ], ), ).onPress(() { diff --git a/lib/views/widgets/total_working_time_detail_bottomsheet.dart b/lib/views/widgets/total_working_time_detail_bottomsheet.dart new file mode 100644 index 00000000..f89c68b9 --- /dev/null +++ b/lib/views/widgets/total_working_time_detail_bottomsheet.dart @@ -0,0 +1,95 @@ +import 'package:flutter/material.dart'; +import 'package:test_sa/extensions/context_extension.dart'; +import 'package:test_sa/extensions/int_extensions.dart'; +import 'package:test_sa/extensions/string_extensions.dart'; +import 'package:test_sa/extensions/text_extensions.dart'; +import 'package:test_sa/extensions/widget_extensions.dart'; +import 'package:test_sa/models/new_models/work_order_detail_model.dart'; +import 'package:test_sa/modules/cm_module/utilities/service_request_utils.dart'; +import 'package:test_sa/new_views/app_style/app_color.dart'; + +class TotalWorkingTimeDetailBottomSheet extends StatelessWidget { + final List activityMaintenanceTimers; + + const TotalWorkingTimeDetailBottomSheet({Key? key, this.activityMaintenanceTimers = const []}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Container( + height: MediaQuery.of(context).size.height * 0.5, + padding: const EdgeInsets.all(16), + child: Column( + children: [ + Container( + width: 40.toScreenWidth, + height: 5.toScreenHeight, + decoration: BoxDecoration(color: AppColor.neutral40, borderRadius: BorderRadius.circular(30)), + ), + 8.height, + Align( + alignment: AlignmentDirectional.centerStart, + child: Text( + "Total Working Time", + style: AppTextStyles.heading3.copyWith(fontWeight: FontWeight.w600, color: context.isDark ? AppColor.neutral30 : AppColor.neutral50), + ), + ), + ListView.separated( + itemCount: activityMaintenanceTimers.length, + separatorBuilder: (cxt, index) => const Divider().defaultStyle(context), + padding: const EdgeInsets.only(top: 16, bottom: 16), + itemBuilder: (cxt, index) { + int totalWorkingHours = DateTime.parse(activityMaintenanceTimers[index].endTime!).difference(DateTime.parse(activityMaintenanceTimers[index].startTime!)).inSeconds; + return Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + RichText( + text: TextSpan( + text: "From: ", + style: Theme.of(context).textTheme.bodySmall?.copyWith(color: context.isDark ? null : AppColor.neutral20, fontWeight: FontWeight.w500), + children: [TextSpan(text: activityMaintenanceTimers[index].startTime!.toServiceRequestDetailsFormat, style: Theme.of(context).textTheme.bodySmall)])), + 4.height, + RichText( + text: TextSpan( + text: "To: ", + style: Theme.of(context).textTheme.bodySmall?.copyWith(color: context.isDark ? null : AppColor.neutral20, fontWeight: FontWeight.w500), + children: [TextSpan(text: activityMaintenanceTimers[index].endTime!.toServiceRequestDetailsFormat, style: Theme.of(context).textTheme.bodySmall)])), + 4.height, + RichText( + text: TextSpan( + text: "Duration: ", + style: Theme.of(context).textTheme.bodySmall?.copyWith(color: context.isDark ? null : AppColor.neutral20, fontWeight: FontWeight.w500), + children: [TextSpan(text: " ${ServiceRequestUtils.formatTimerDuration(totalWorkingHours.round())}", style: Theme.of(context).textTheme.bodySmall)])), + ], + ); + }).expanded, + ], + ), + ); + } +} + +class TimerModel { + int? id; + String? startTime; + String? endTime; + dynamic workingHours; + + TimerModel({this.id, this.startTime, this.endTime, this.workingHours}); + + TimerModel.fromJson(Map json) { + id = json['id']; + startTime = json['startTime']; + endTime = json['endTime']; + workingHours = json['workingHours']; + } + + Map toJson() { + final Map data = {}; + data['id'] = id; + data['startTime'] = startTime; + data['endTime'] = endTime; + data['workingHours'] = workingHours; + return data; + } +}