Feature_Report_Action #48

Merged
vaibhav.surve merged 19 commits from Feature_Report_Action into main 2025-06-23 07:32:30 +00:00
2 changed files with 200 additions and 221 deletions
Showing only changes of commit c215c4c943 - Show all commits

View File

@ -7,7 +7,7 @@ import 'package:marco/helpers/widgets/my_snackbar.dart';
final Logger log = Logger(); final Logger log = Logger();
void showManageTaskBottomSheet({ void showCreateTaskBottomSheet({
required String workArea, required String workArea,
required String activity, required String activity,
required String completedWork, required String completedWork,
@ -33,15 +33,15 @@ void showManageTaskBottomSheet({
final horizontalPadding = final horizontalPadding =
isLarge ? constraints.maxWidth * 0.2 : 16.0; isLarge ? constraints.maxWidth * 0.2 : 16.0;
return SafeArea( return // Inside showManageTaskBottomSheet...
SafeArea(
child: Material(
color: Colors.white,
borderRadius: const BorderRadius.vertical(top: Radius.circular(20)),
child: Container( child: Container(
constraints: const BoxConstraints(maxHeight: 760), constraints: const BoxConstraints(maxHeight: 760),
padding: EdgeInsets.fromLTRB( padding: EdgeInsets.fromLTRB(horizontalPadding, 12, horizontalPadding, 24),
horizontalPadding, 12, horizontalPadding, 24),
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
),
child: SingleChildScrollView( child: SingleChildScrollView(
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
@ -57,91 +57,49 @@ void showManageTaskBottomSheet({
), ),
), ),
), ),
Row( Center(
mainAxisAlignment: MainAxisAlignment.center, child: MyText.titleLarge(
children: [
const SizedBox(width: 8),
MyText.titleMedium(
"Create Task", "Create Task",
fontWeight: 700, fontWeight: 700,
), ),
],
), ),
const SizedBox(height: 20),
_infoCardSection([
_infoRowWithIcon(Icons.workspaces, "Selected Work Area", workArea),
_infoRowWithIcon(Icons.list_alt, "Selected Activity", activity),
_infoRowWithIcon(Icons.check_circle_outline, "Completed Work", completedWork),
]),
const SizedBox(height: 16), const SizedBox(height: 16),
_infoRowWithIcon( _sectionTitle(Icons.edit_calendar, "Planned Work"),
Icons.workspaces, "Selected Work Area", workArea),
_infoRowWithIcon(
Icons.list_alt, "Selected Activity", activity),
const SizedBox(height: 12),
_infoRowWithIcon(Icons.check_circle_outline,
"Completed Work", completedWork),
const SizedBox(height: 12),
Row(
children: [
Icon(Icons.edit_calendar,
color: Colors.grey[700], size: 18),
const SizedBox(width: 8),
MyText.bodyMedium("Planned Work", fontWeight: 600),
],
),
const SizedBox(height: 6), const SizedBox(height: 6),
TextField( _customTextField(
controller: plannedTaskController, controller: plannedTaskController,
hint: "Enter planned work",
keyboardType: TextInputType.number, keyboardType: TextInputType.number,
decoration: InputDecoration(
hintText: "Enter planned work",
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(8)),
contentPadding: const EdgeInsets.symmetric(
horizontal: 12, vertical: 10),
),
), ),
const SizedBox(height: 16), const SizedBox(height: 16),
Row( _sectionTitle(Icons.description_outlined, "Comment"),
children: [
Icon(Icons.description_outlined,
color: Colors.grey[700], size: 18),
const SizedBox(width: 8),
MyText.bodyMedium("Comment", fontWeight: 600),
],
),
const SizedBox(height: 6), const SizedBox(height: 6),
TextField( _customTextField(
controller: descriptionController, controller: descriptionController,
hint: "Enter task description",
maxLines: 3, maxLines: 3,
decoration: InputDecoration(
hintText: "Enter task description",
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(8)),
contentPadding: const EdgeInsets.symmetric(
horizontal: 12, vertical: 10),
),
),
const SizedBox(height: 24),
Row(
children: [
Icon(Icons.category_outlined,
color: Colors.grey[700], size: 18),
const SizedBox(width: 8),
MyText.bodyMedium("Selected Work Category",
fontWeight: 600),
],
), ),
const SizedBox(height: 16),
_sectionTitle(Icons.category_outlined, "Selected Work Category"),
const SizedBox(height: 6), const SizedBox(height: 6),
Obx(() { Obx(() {
final categoryMap = controller.categoryIdNameMap; final categoryMap = controller.categoryIdNameMap;
final String selectedName = final String selectedName =
controller.selectedCategoryId.value != null controller.selectedCategoryId.value != null
? (categoryMap[ ? (categoryMap[controller.selectedCategoryId.value!] ?? 'Select Category')
controller.selectedCategoryId.value!] ??
'Select Category')
: 'Select Category'; : 'Select Category';
return Container( return Container(
width: double.infinity, width: double.infinity,
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 14),
horizontal: 12, vertical: 14),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.grey.shade100,
border: Border.all(color: Colors.grey.shade300), border: Border.all(color: Colors.grey.shade300),
borderRadius: BorderRadius.circular(8), borderRadius: BorderRadius.circular(8),
), ),
@ -164,8 +122,7 @@ void showManageTaskBottomSheet({
children: [ children: [
Text( Text(
selectedName, selectedName,
style: const TextStyle( style: const TextStyle(fontSize: 14, color: Colors.black87),
fontSize: 14, color: Colors.black87),
), ),
const Icon(Icons.arrow_drop_down), const Icon(Icons.arrow_drop_down),
], ],
@ -177,45 +134,23 @@ void showManageTaskBottomSheet({
Row( Row(
children: [ children: [
Expanded( Expanded(
child: OutlinedButton( child: OutlinedButton.icon(
onPressed: () { onPressed: () => Get.back(),
Get.back(); icon: const Icon(Icons.close, size: 18),
}, label: MyText.bodyMedium("Cancel", fontWeight: 600),
style: OutlinedButton.styleFrom( style: OutlinedButton.styleFrom(
side: const BorderSide(color: Colors.grey), side: const BorderSide(color: Colors.grey),
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
borderRadius: BorderRadius.circular(10)),
),
child: MyText.bodyMedium(
"Cancel",
fontWeight: 600,
color: Colors.black,
), ),
), ),
), ),
const SizedBox(width: 12), const SizedBox(width: 12),
Expanded( Expanded(
child: ElevatedButton( child: ElevatedButton.icon(
onPressed: () async { onPressed: () async {
final plannedValue = int.tryParse( final plannedValue = int.tryParse(plannedTaskController.text.trim()) ?? 0;
plannedTaskController.text.trim()) ?? final comment = descriptionController.text.trim();
0; final selectedCategoryId = controller.selectedCategoryId.value;
final comment =
descriptionController.text.trim();
final assignmentDate = DateTime.now();
// 🪵 Log the task creation input values
log.i({
"message": "Creating task with data",
"parentTaskId": parentTaskId,
"plannedTask": plannedValue,
"comment": comment,
"workAreaId": workAreaId,
"activityId": activityId,
});
final selectedCategoryId =
controller.selectedCategoryId.value;
if (selectedCategoryId == null) { if (selectedCategoryId == null) {
showAppSnackbar( showAppSnackbar(
title: "error", title: "error",
@ -231,24 +166,26 @@ void showManageTaskBottomSheet({
comment: comment, comment: comment,
workAreaId: workAreaId, workAreaId: workAreaId,
activityId: activityId, activityId: activityId,
categoryId: categoryId: selectedCategoryId,
selectedCategoryId,
); );
if (success) { if (success) {
Get.back(); Get.back();
Future.delayed(const Duration(milliseconds: 300), () {
onSubmit(); onSubmit();
showAppSnackbar(
title: "Success",
message: "Task created successfully!",
type: SnackbarType.success,
);
});
} }
}, },
icon: const Icon(Icons.check, size: 18),
label: MyText.bodyMedium("Submit", color: Colors.white, fontWeight: 600),
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
backgroundColor: Colors.blueAccent, backgroundColor: Colors.blueAccent,
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
borderRadius: BorderRadius.circular(10)),
),
child: MyText.bodyMedium(
"Submit",
fontWeight: 600,
color: Colors.white,
), ),
), ),
), ),
@ -258,6 +195,7 @@ void showManageTaskBottomSheet({
), ),
), ),
), ),
),
); );
}, },
); );
@ -266,6 +204,47 @@ void showManageTaskBottomSheet({
isScrollControlled: true, isScrollControlled: true,
); );
} }
Widget _sectionTitle(IconData icon, String title) {
return Row(
children: [
Icon(icon, color: Colors.grey[700], size: 18),
const SizedBox(width: 8),
MyText.bodyMedium(title, fontWeight: 600),
],
);
}
Widget _customTextField({
required TextEditingController controller,
required String hint,
int maxLines = 1,
TextInputType keyboardType = TextInputType.text,
}) {
return TextField(
controller: controller,
maxLines: maxLines,
keyboardType: keyboardType,
decoration: InputDecoration(
hintText: hint,
filled: true,
fillColor: Colors.grey.shade100,
border: OutlineInputBorder(borderRadius: BorderRadius.circular(8)),
contentPadding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
),
);
}
Widget _infoCardSection(List<Widget> children) {
return Container(
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: Colors.grey.shade100,
borderRadius: BorderRadius.circular(12),
border: Border.all(color: Colors.grey.shade300),
),
child: Column(children: children),
);
}
Widget _infoRowWithIcon(IconData icon, String title, String value) { Widget _infoRowWithIcon(IconData icon, String title, String value) {
return Padding( return Padding(

View File

@ -473,7 +473,7 @@ class _ReportActionBottomSheetState extends State<ReportActionBottomSheet>
if (shouldShowAddTaskSheet) { if (shouldShowAddTaskSheet) {
await Future.delayed( await Future.delayed(
Duration(milliseconds: 100)); Duration(milliseconds: 100));
showManageTaskBottomSheet( showCreateTaskBottomSheet(
workArea: widget.taskData['location'] ?? '', workArea: widget.taskData['location'] ?? '',
activity: widget.taskData['activity'] ?? '', activity: widget.taskData['activity'] ?? '',
completedWork: completedWork: