|
|
|
|
@ -1,3 +1,4 @@
|
|
|
|
|
import 'package:flutter/gestures.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
import 'package:test_sa/controllers/api_routes/urls.dart';
|
|
|
|
|
@ -8,12 +9,15 @@ import 'package:test_sa/extensions/text_extensions.dart';
|
|
|
|
|
import 'package:test_sa/extensions/widget_extensions.dart';
|
|
|
|
|
import 'package:test_sa/models/all_requests_and_count_model.dart';
|
|
|
|
|
import 'package:test_sa/models/new_models/task_request/task_request_model.dart';
|
|
|
|
|
import 'package:test_sa/modules/cm_module/utilities/service_request_utils.dart';
|
|
|
|
|
import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart';
|
|
|
|
|
import 'package:test_sa/new_views/common_widgets/default_app_bar.dart';
|
|
|
|
|
import 'package:test_sa/new_views/common_widgets/working_time_tile.dart';
|
|
|
|
|
import 'package:test_sa/providers/task_request_provider/task_request_provider.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/images/files_list.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/loaders/app_loading.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/requests/request_status.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/total_working_time_detail_bottomsheet.dart';
|
|
|
|
|
|
|
|
|
|
import '../../../../controllers/providers/api/user_provider.dart';
|
|
|
|
|
import '../../../../models/enums/user_types.dart';
|
|
|
|
|
@ -61,7 +65,6 @@ class _TaskRequestDetailsViewState extends State<TaskRequestDetailsView> {
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
userProvider ??= Provider.of<UserProvider>(context, listen: false);
|
|
|
|
|
return Scaffold(
|
|
|
|
|
// appBar: DefaultAppBar(title:taskProvider?.taskRequestModel?.taskType?.id==7?'Recall and Alert Details': context.translation.taskRequest),
|
|
|
|
|
appBar: DefaultAppBar(title: context.translation.taskRequest),
|
|
|
|
|
body: Consumer<TaskRequestProvider>(builder: (context, taskProvider, child) {
|
|
|
|
|
TaskData? taskModel = taskProvider.taskRequestModel;
|
|
|
|
|
@ -122,6 +125,7 @@ class _TaskRequestDetailsViewState extends State<TaskRequestDetailsView> {
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
showWorkingTime(taskModel?.taskJobActivityEngineerTimers ?? []),
|
|
|
|
|
if ((taskProvider.taskRequestModel?.taskJobContactPersons ?? []).isNotEmpty) ...[contactInfoCard(context, taskProvider.taskRequestModel!)],
|
|
|
|
|
if (taskProvider.taskRequestModel?.callComment != null) ...[
|
|
|
|
|
const Divider().defaultStyle(context),
|
|
|
|
|
@ -167,6 +171,55 @@ class _TaskRequestDetailsViewState extends State<TaskRequestDetailsView> {
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget showWorkingTime(List<TaskJobActivityEngineerTimer> timer) {
|
|
|
|
|
if (context.userProvider.user!.type == UsersTypes.normal_user) return const SizedBox();
|
|
|
|
|
|
|
|
|
|
double totalWorkingHours = timer.fold<double>(0.0, (sum, item) {
|
|
|
|
|
if (item.startDate == null || item.endDate == null) return sum;
|
|
|
|
|
try {
|
|
|
|
|
final start = DateTime.parse(item.startDate!);
|
|
|
|
|
final end = DateTime.parse(item.endDate!);
|
|
|
|
|
|
|
|
|
|
final diffInHours = end.difference(start).inSeconds / 3600.0; // convert to hours
|
|
|
|
|
|
|
|
|
|
return sum + diffInHours;
|
|
|
|
|
} catch (_) {
|
|
|
|
|
return sum;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
String totalHourString = (totalWorkingHours > 0.0) ? ServiceRequestUtils.formatTotalWorkingHours(totalWorkingHours) : totalWorkingHours.toString();
|
|
|
|
|
|
|
|
|
|
return RichText(
|
|
|
|
|
text: TextSpan(
|
|
|
|
|
text: "${context.translation.totalWorkingTime}: ",
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 14.toScreenWidth, fontWeight: FontWeight.w500, fontStyle: FontStyle.normal, decoration: TextDecoration.none, color: context.isDark ? AppColor.neutral10 : AppColor.neutral20),
|
|
|
|
|
children: [
|
|
|
|
|
TextSpan(text: "$totalHourString ", style: AppTextStyles.bodyText),
|
|
|
|
|
const WidgetSpan(
|
|
|
|
|
child: Icon(Icons.info_outline_rounded, color: AppColor.primary10, size: 14),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
).onPress(() => showModalBottomSheet(
|
|
|
|
|
context: context,
|
|
|
|
|
isDismissible: true,
|
|
|
|
|
shape: const RoundedRectangleBorder(
|
|
|
|
|
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
|
|
|
|
|
),
|
|
|
|
|
clipBehavior: Clip.antiAliasWithSaveLayer,
|
|
|
|
|
builder: (BuildContext context) => TotalWorkingTimeDetailBottomSheet(
|
|
|
|
|
timerList: timer.map((e) {
|
|
|
|
|
return TimerHistoryModel(
|
|
|
|
|
id: e.id,
|
|
|
|
|
startTime: e.startDate,
|
|
|
|
|
endTime: e.endDate,
|
|
|
|
|
workingHours: e.totalWorkingHour,
|
|
|
|
|
);
|
|
|
|
|
}).toList()),
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget contactInfoCard(BuildContext context, TaskData? taskModel) {
|
|
|
|
|
return Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
@ -270,6 +323,16 @@ class _TaskRequestDetailsViewState extends State<TaskRequestDetailsView> {
|
|
|
|
|
'${context.translation.assetNo}: ${taskModel.asset?.assetNumber ?? "-"}'.bodyText(context),
|
|
|
|
|
'${context.translation.manufacture}: ${taskModel.asset?.manufacturer ?? "-"}'.bodyText(context),
|
|
|
|
|
'${context.translation.model}: ${taskModel.asset?.model ?? "-"}'.bodyText(context),
|
|
|
|
|
'${context.translation.serialNo}: ${taskModel.asset?.serialNo ?? "-"}'.bodyText(context),
|
|
|
|
|
'${context.translation.assetType}: ${taskModel.asset?.assetTypeName ?? "-"}'.bodyText(context),
|
|
|
|
|
'${context.translation.site}: ${taskModel.asset?.siteName ?? "-"}'.bodyText(context),
|
|
|
|
|
'${context.translation.building}: ${taskModel.asset?.buildingName ?? "-"}'.bodyText(context),
|
|
|
|
|
'${context.translation.floor}: ${taskModel.asset?.floorName ?? "-"}'.bodyText(context),
|
|
|
|
|
'${context.translation.department}: ${taskModel.asset?.departmentName ?? "-"}'.bodyText(context),
|
|
|
|
|
'${context.translation.room}: ${taskModel.asset?.roomName ?? "-"}'.bodyText(context),
|
|
|
|
|
'${context.translation.supplier}: ${taskModel.asset?.supplierName ?? "-"}'.bodyText(context),
|
|
|
|
|
'PO Number: ${taskModel.asset?.poNumber ?? "-"}'.bodyText(context),
|
|
|
|
|
'${context.translation.installationDate}: ${taskModel.asset?.installationDate?.toAssetDetailsFormat ?? "-"}'.bodyText(context),
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
: const SizedBox();
|
|
|
|
|
|