Task Request Design complete

design_3.0_task_module_new
WaseemAbbasi22 8 months ago
parent eb978af46f
commit 15e62bb004

@ -553,6 +553,8 @@
"task": "مهمة",
"taskType": "نوع المهمة",
"createTaskRequest": "إنشاء طلب مهمة",
"taskRequest": "طلب مهمة"
"taskRequest": "طلب مهمة",
"completedActions": "الإجراءات المكتملة",
"impactStatus": "حالة التأثير"
}

@ -556,5 +556,7 @@
"task": "Task",
"taskType": "Task Type",
"createTaskRequest": "Create Task Request",
"taskRequest": "Task Request"
"taskRequest": "Task Request",
"completedActions": "Completed Actions",
"impactStatus": "Impact Status"
}

@ -1,4 +1,3 @@
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
@ -45,10 +44,23 @@ class _TaskRequestFormState extends State<TaskRequestForm> {
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
List<File> _files = [];
bool installationTye = false;
List<Lookup> completedActions = [
Lookup(value: 0, name: 'Physical Check'),
Lookup(value: 1, name: 'Software Update'),
Lookup(value: 0, name: 'Hardware Update'),
];
List<Lookup> impactStatus = [
Lookup(value: 0, name: 'Impacted'),
Lookup(value: 1, name: 'Not Impacted'),
];
Lookup selectedValue = Lookup(value: 0, name: 'Impacted');
@override
void initState() {
_formModel.fromDetails(widget.model);
_files = widget.model.receiverAttachments?.map((e) => File(e.attachmentName!)).toList() ?? [];
_files = widget.model.receiverAttachments?.map((e) => File(e.attachmentName!)).toList() ?? [];
super.initState();
}
@ -57,6 +69,7 @@ class _TaskRequestFormState extends State<TaskRequestForm> {
_requestedQuantityController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
@ -81,64 +94,73 @@ class _TaskRequestFormState extends State<TaskRequestForm> {
children: [
_timerWidget(context, 0, true),
12.height,
ADatePicker(
label: context.translation.installationDate,
hideShadow: true,
backgroundColor: AppColor.neutral90,
date: DateTime.now(),
formatDateWithTime: false,
onDatePicker: (selectedDate) {
// Handle the selected date and time here.
DateTime selectedDateTime = DateTime(
selectedDate.year,
selectedDate.month,
selectedDate.day,
);
},
),
12.height,
//TODO replace with provided lookup..
SingleItemDropDownMenu<Lookup, LastSituationProvider>(
context: context,
height: 56.toScreenHeight,
title: context.translation.serialNo,
showShadow: false,
backgroundColor: AppColor.neutral90,
showAsBottomSheet: true,
initialValue: null,
onSelect: (status) {
if (status != null) {
setState(() {});
}
},
),
12.height,
//TODO replace with provided lookup..
SingleItemDropDownMenu<Department, NullableLoadingProvider>(
context: context,
title: context.translation.department,
initialValue: Department(),
enabled: true,
backgroundColor: AppColor.neutral90,
showShadow: false,
staticData: [],
showAsBottomSheet: true,
onSelect: (value) {
},
),
installationTye
? Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ADatePicker(
label: context.translation.installationDate,
hideShadow: true,
backgroundColor: AppColor.neutral90,
date: DateTime.now(),
formatDateWithTime: false,
onDatePicker: (selectedDate) {
// Handle the selected date and time here.
DateTime selectedDateTime = DateTime(
selectedDate.year,
selectedDate.month,
selectedDate.day,
);
},
),
12.height,
//TODO replace with provided lookup..
SingleItemDropDownMenu<Lookup, LastSituationProvider>(
context: context,
height: 56.toScreenHeight,
title: context.translation.serialNo,
showShadow: false,
backgroundColor: AppColor.neutral90,
showAsBottomSheet: true,
initialValue: null,
onSelect: (status) {
if (status != null) {
setState(() {});
}
},
),
12.height,
//TODO replace with provided lookup..
SingleItemDropDownMenu<Department, NullableLoadingProvider>(
context: context,
title: context.translation.department,
initialValue: Department(),
enabled: true,
backgroundColor: AppColor.neutral90,
showShadow: false,
staticData: [],
showAsBottomSheet: true,
onSelect: (value) {},
),
],
)
: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
context.translation.completedActions.bodyText(context).custom(color: AppColor.white936),
completedActionWidget(),
16.height,
context.translation.impactStatus.bodyText(context).custom(color: AppColor.white936),
impactStatusWidget(),
]),
12.height,
AppTextFormField(
initialValue: _formModel.receiverComment ?? "",
initialValue: _formModel.receiverComment ?? "",
labelText: context.translation.technicalComment,
textInputType: TextInputType.multiline,
backgroundColor: AppColor.neutral90,
showShadow: false,
alignLabelWithHint: true,
onSaved: (value) {
_formModel.receiverComment = value;
_formModel.receiverComment = value;
},
),
20.height,
@ -160,7 +182,7 @@ class _TaskRequestFormState extends State<TaskRequestForm> {
child: AppFilledButton(
buttonColor: AppColor.green70,
label: context.translation.markAsCompleted,
onPressed: (){},
onPressed: () {},
// buttonColor: AppColor.primary10,
),
),
@ -181,6 +203,66 @@ class _TaskRequestFormState extends State<TaskRequestForm> {
// notifyListeners();
}
Widget completedActionWidget() {
return Column(
children: completedActions.asMap().entries.map((entry) {
int index = entry.key;
Lookup action = entry.value;
return Row(
children: [
Checkbox(
value: action.value == 1,
activeColor: AppColor.blueStatus(context),
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
onChanged: (value) {
setState(() {
completedActions[index] = Lookup(value: value! ? 1 : 0, name: action.name);
});
},
),
action.name!
.bodyText(context)
.custom(
color: context.isDark ? AppColor.primary50 : AppColor.neutral50,
)
.expanded,
],
);
}).toList(),
);
}
Widget impactStatusWidget() {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, // Aligns to the start
children: impactStatus.map((item) {
return Row(
mainAxisSize: MainAxisSize.min,
children: [
Radio<Lookup>(
value: item,
groupValue: selectedValue,
activeColor: AppColor.blueStatus(context),
visualDensity: VisualDensity.compact,
// Removes extra spacing
onChanged: (value) {
selectedValue = value!;
setState(() {});
},
),
Text(
item.name!,
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
color: context.isDark ? AppColor.primary50 : AppColor.neutral50,
),
),
16.width, // Adds spacing between items
],
);
}).toList(),
);
}
Widget _timerWidget(BuildContext context, double totalWorkingHours, bool isTimerEnable) {
return Column(
mainAxisSize: MainAxisSize.min,
@ -218,7 +300,6 @@ class _TaskRequestFormState extends State<TaskRequestForm> {
],
);
}
}
class AssistantEmployeeCard extends StatefulWidget {
@ -281,142 +362,141 @@ class _AssistantEmployeeCardState extends State<AssistantEmployeeCard> {
}),
isExpanded
? Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
ServiceReportAssistantEmployeeMenu(
title: context.translation.select,
backgroundColor: AppColor.neutral100,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
ServiceReportAssistantEmployeeMenu(
title: context.translation.select,
backgroundColor: AppColor.neutral100,
initialValue: null,
assetId: 23,
//TODO add check...
// enable: !isCurrentUserIsAssistantEmp,
onSelect: (employee) {
if (employee == null) {
requestDetailProvider.activityMaintenanceHelperModel?.assistantEmployees = [];
} else {
requestDetailProvider.activityMaintenanceHelperModel?.assistantEmployees = [employee.copyWith(id: 0)];
requestDetailProvider.activityMaintenanceHelperModel?.modelAssistantEmployees?.user = AssignedEmployee(userId: employee.user?.id, userName: employee.user?.name);
}
},
),
12.height,
Row(
mainAxisSize: MainAxisSize.min,
children: [
ADatePicker(
label: context.translation.startTime,
hideShadow: true,
backgroundColor: AppColor.neutral100,
date: requestDetailProvider.activityMaintenanceHelperModel?.modelAssistantEmployees?.startDate,
formatDateWithTime: true,
onDatePicker: (selectedDate) {
showTimePicker(
context: context,
initialTime: TimeOfDay.now(),
).then((selectedTime) {
// Handle the selected date and time here.
if (selectedTime != null) {
DateTime selectedDateTime = DateTime(
selectedDate.year,
selectedDate.month,
selectedDate.day,
selectedTime.hour,
selectedTime.minute,
);
requestDetailProvider.activityMaintenanceHelperModel?.modelAssistantEmployees?.startDate = selectedDateTime;
requestDetailProvider.updateActivityMaintenanceHelperModel(requestDetailProvider.activityMaintenanceHelperModel);
ServiceRequestUtils.calculateAndAssignWorkingHours(
startTime: requestDetailProvider.activityMaintenanceHelperModel?.modelAssistantEmployees?.startDate,
endTime: requestDetailProvider.activityMaintenanceHelperModel?.modelAssistantEmployees?.startDate,
workingHoursController: _workingHoursController,
updateModel: (hours) {
requestDetailProvider.activityMaintenanceHelperModel!.modelAssistantEmployees!.workingHours = hours;
});
}
});
},
).expanded,
8.width,
ADatePicker(
label: context.translation.endTime,
hideShadow: true,
backgroundColor: AppColor.neutral100,
date: requestDetailProvider.activityMaintenanceHelperModel?.modelAssistantEmployees?.endDate,
formatDateWithTime: true,
onDatePicker: (selectedDate) {
showTimePicker(
context: context,
initialTime: TimeOfDay.now(),
).then((selectedTime) {
// Handle the selected date and time here.
if (selectedTime != null) {
DateTime selectedDateTime = DateTime(
selectedDate.year,
selectedDate.month,
selectedDate.day,
selectedTime.hour,
selectedTime.minute,
);
//TODO need to replace with model attributes..
// if (requestDetailProvider.activityMaintenanceHelperModel?.modelAssistantEmployees?.startDate != null &&
// selectedDateTime.isBefore(requestDetailProvider.activityMaintenanceHelperModel!.modelAssistantEmployees!.startDate!)) {
// "End Date time must be greater then start date".showToast;
// return;
// }
// requestDetailProvider.activityMaintenanceHelperModel?.modelAssistantEmployees?.endDate = selectedDateTime;
// requestDetailProvider.updateActivityMaintenanceHelperModel(requestDetailProvider.activityMaintenanceHelperModel);
// ServiceRequestUtils.calculateAndAssignWorkingHours(
// startTime: requestDetailProvider.activityMaintenanceHelperModel?.modelAssistantEmployees?.startDate,
// endTime: requestDetailProvider.activityMaintenanceHelperModel?.modelAssistantEmployees?.endDate,
// workingHoursController: _workingHoursController,
// updateModel: (hours) {
// requestDetailProvider.activityMaintenanceHelperModel!.modelAssistantEmployees!.workingHours = hours;
// });
initialValue: null,
assetId: 23,
//TODO add check...
// enable: !isCurrentUserIsAssistantEmp,
onSelect: (employee) {
if (employee == null) {
requestDetailProvider.activityMaintenanceHelperModel?.assistantEmployees = [];
} else {
requestDetailProvider.activityMaintenanceHelperModel?.assistantEmployees = [employee.copyWith(id: 0)];
requestDetailProvider.activityMaintenanceHelperModel?.modelAssistantEmployees?.user = AssignedEmployee(userId: employee.user?.id, userName: employee.user?.name);
}
});
},
).expanded,
],
),
12.height,
AppTextFormField(
labelText: context.translation.workingHours,
backgroundColor: AppColor.neutral80,
controller: _workingHoursController,
suffixIcon: "clock".toSvgAsset(width: 20, color: context.isDark ? AppColor.neutral10 : null).paddingOnly(end: 16),
initialValue: requestDetailProvider.activityMaintenanceHelperModel?.modelAssistantEmployees?.workingHours != null
? requestDetailProvider.activityMaintenanceHelperModel!.modelAssistantEmployees!.workingHours.toString()
: '',
textAlign: TextAlign.center,
labelStyle: AppTextStyles.textFieldLabelStyle,
enable: false,
showShadow: false,
style: Theme.of(context).textTheme.titleMedium,
),
12.height,
AppTextFormField(
initialValue: requestDetailProvider.activityMaintenanceHelperModel?.modelAssistantEmployees?.technicalComment,
labelText: context.translation.technicalComment,
backgroundColor: AppColor.neutral100,
showShadow: false,
labelStyle: AppTextStyles.textFieldLabelStyle,
alignLabelWithHint: true,
textInputType: TextInputType.multiline,
onChange: (value) {
requestDetailProvider.activityMaintenanceHelperModel?.modelAssistantEmployees?.technicalComment = value;
},
onSaved: (value) {
requestDetailProvider.activityMaintenanceHelperModel?.modelAssistantEmployees?.technicalComment = value;
},
),
16.height,
],
)
},
),
12.height,
Row(
mainAxisSize: MainAxisSize.min,
children: [
ADatePicker(
label: context.translation.startTime,
hideShadow: true,
backgroundColor: AppColor.neutral100,
date: requestDetailProvider.activityMaintenanceHelperModel?.modelAssistantEmployees?.startDate,
formatDateWithTime: true,
onDatePicker: (selectedDate) {
showTimePicker(
context: context,
initialTime: TimeOfDay.now(),
).then((selectedTime) {
// Handle the selected date and time here.
if (selectedTime != null) {
DateTime selectedDateTime = DateTime(
selectedDate.year,
selectedDate.month,
selectedDate.day,
selectedTime.hour,
selectedTime.minute,
);
requestDetailProvider.activityMaintenanceHelperModel?.modelAssistantEmployees?.startDate = selectedDateTime;
requestDetailProvider.updateActivityMaintenanceHelperModel(requestDetailProvider.activityMaintenanceHelperModel);
ServiceRequestUtils.calculateAndAssignWorkingHours(
startTime: requestDetailProvider.activityMaintenanceHelperModel?.modelAssistantEmployees?.startDate,
endTime: requestDetailProvider.activityMaintenanceHelperModel?.modelAssistantEmployees?.startDate,
workingHoursController: _workingHoursController,
updateModel: (hours) {
requestDetailProvider.activityMaintenanceHelperModel!.modelAssistantEmployees!.workingHours = hours;
});
}
});
},
).expanded,
8.width,
ADatePicker(
label: context.translation.endTime,
hideShadow: true,
backgroundColor: AppColor.neutral100,
date: requestDetailProvider.activityMaintenanceHelperModel?.modelAssistantEmployees?.endDate,
formatDateWithTime: true,
onDatePicker: (selectedDate) {
showTimePicker(
context: context,
initialTime: TimeOfDay.now(),
).then((selectedTime) {
// Handle the selected date and time here.
if (selectedTime != null) {
DateTime selectedDateTime = DateTime(
selectedDate.year,
selectedDate.month,
selectedDate.day,
selectedTime.hour,
selectedTime.minute,
);
//TODO need to replace with model attributes..
// if (requestDetailProvider.activityMaintenanceHelperModel?.modelAssistantEmployees?.startDate != null &&
// selectedDateTime.isBefore(requestDetailProvider.activityMaintenanceHelperModel!.modelAssistantEmployees!.startDate!)) {
// "End Date time must be greater then start date".showToast;
// return;
// }
// requestDetailProvider.activityMaintenanceHelperModel?.modelAssistantEmployees?.endDate = selectedDateTime;
// requestDetailProvider.updateActivityMaintenanceHelperModel(requestDetailProvider.activityMaintenanceHelperModel);
// ServiceRequestUtils.calculateAndAssignWorkingHours(
// startTime: requestDetailProvider.activityMaintenanceHelperModel?.modelAssistantEmployees?.startDate,
// endTime: requestDetailProvider.activityMaintenanceHelperModel?.modelAssistantEmployees?.endDate,
// workingHoursController: _workingHoursController,
// updateModel: (hours) {
// requestDetailProvider.activityMaintenanceHelperModel!.modelAssistantEmployees!.workingHours = hours;
// });
}
});
},
).expanded,
],
),
12.height,
AppTextFormField(
labelText: context.translation.workingHours,
backgroundColor: AppColor.neutral80,
controller: _workingHoursController,
suffixIcon: "clock".toSvgAsset(width: 20, color: context.isDark ? AppColor.neutral10 : null).paddingOnly(end: 16),
initialValue: requestDetailProvider.activityMaintenanceHelperModel?.modelAssistantEmployees?.workingHours != null
? requestDetailProvider.activityMaintenanceHelperModel!.modelAssistantEmployees!.workingHours.toString()
: '',
textAlign: TextAlign.center,
labelStyle: AppTextStyles.textFieldLabelStyle,
enable: false,
showShadow: false,
style: Theme.of(context).textTheme.titleMedium,
),
12.height,
AppTextFormField(
initialValue: requestDetailProvider.activityMaintenanceHelperModel?.modelAssistantEmployees?.technicalComment,
labelText: context.translation.technicalComment,
backgroundColor: AppColor.neutral100,
showShadow: false,
labelStyle: AppTextStyles.textFieldLabelStyle,
alignLabelWithHint: true,
textInputType: TextInputType.multiline,
onChange: (value) {
requestDetailProvider.activityMaintenanceHelperModel?.modelAssistantEmployees?.technicalComment = value;
},
onSaved: (value) {
requestDetailProvider.activityMaintenanceHelperModel?.modelAssistantEmployees?.technicalComment = value;
},
),
16.height,
],
)
: const SizedBox(),
],
);
});
}
}

Loading…
Cancel
Save