Feature_Report_Action #48
@ -35,168 +35,188 @@ void showCreateTaskBottomSheet({
|
|||||||
|
|
||||||
return // Inside showManageTaskBottomSheet...
|
return // Inside showManageTaskBottomSheet...
|
||||||
|
|
||||||
SafeArea(
|
SafeArea(
|
||||||
child: Material(
|
child: Material(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
borderRadius: const BorderRadius.vertical(top: Radius.circular(20)),
|
borderRadius:
|
||||||
child: Container(
|
const BorderRadius.vertical(top: Radius.circular(20)),
|
||||||
constraints: const BoxConstraints(maxHeight: 760),
|
child: Container(
|
||||||
padding: EdgeInsets.fromLTRB(horizontalPadding, 12, horizontalPadding, 24),
|
constraints: const BoxConstraints(maxHeight: 760),
|
||||||
child: SingleChildScrollView(
|
padding: EdgeInsets.fromLTRB(
|
||||||
child: Column(
|
horizontalPadding, 12, horizontalPadding, 24),
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
child: SingleChildScrollView(
|
||||||
children: [
|
child: Column(
|
||||||
Center(
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
child: Container(
|
children: [
|
||||||
width: 40,
|
Center(
|
||||||
height: 4,
|
child: Container(
|
||||||
margin: const EdgeInsets.only(bottom: 16),
|
width: 40,
|
||||||
decoration: BoxDecoration(
|
height: 4,
|
||||||
color: Colors.grey.shade400,
|
margin: const EdgeInsets.only(bottom: 16),
|
||||||
borderRadius: BorderRadius.circular(2),
|
decoration: BoxDecoration(
|
||||||
),
|
color: Colors.grey.shade400,
|
||||||
),
|
borderRadius: BorderRadius.circular(2),
|
||||||
),
|
),
|
||||||
Center(
|
),
|
||||||
child: MyText.titleLarge(
|
|
||||||
"Create Task",
|
|
||||||
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),
|
|
||||||
_sectionTitle(Icons.edit_calendar, "Planned Work"),
|
|
||||||
const SizedBox(height: 6),
|
|
||||||
_customTextField(
|
|
||||||
controller: plannedTaskController,
|
|
||||||
hint: "Enter planned work",
|
|
||||||
keyboardType: TextInputType.number,
|
|
||||||
),
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
_sectionTitle(Icons.description_outlined, "Comment"),
|
|
||||||
const SizedBox(height: 6),
|
|
||||||
_customTextField(
|
|
||||||
controller: descriptionController,
|
|
||||||
hint: "Enter task description",
|
|
||||||
maxLines: 3,
|
|
||||||
),
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
_sectionTitle(Icons.category_outlined, "Selected Work Category"),
|
|
||||||
const SizedBox(height: 6),
|
|
||||||
Obx(() {
|
|
||||||
final categoryMap = controller.categoryIdNameMap;
|
|
||||||
final String selectedName =
|
|
||||||
controller.selectedCategoryId.value != null
|
|
||||||
? (categoryMap[controller.selectedCategoryId.value!] ?? 'Select Category')
|
|
||||||
: 'Select Category';
|
|
||||||
|
|
||||||
return Container(
|
|
||||||
width: double.infinity,
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 14),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.grey.shade100,
|
|
||||||
border: Border.all(color: Colors.grey.shade300),
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
),
|
|
||||||
child: PopupMenuButton<String>(
|
|
||||||
padding: EdgeInsets.zero,
|
|
||||||
onSelected: (val) {
|
|
||||||
controller.selectCategory(val);
|
|
||||||
onCategoryChanged(val);
|
|
||||||
},
|
|
||||||
itemBuilder: (context) => categoryMap.entries
|
|
||||||
.map(
|
|
||||||
(entry) => PopupMenuItem<String>(
|
|
||||||
value: entry.key,
|
|
||||||
child: Text(entry.value),
|
|
||||||
),
|
),
|
||||||
)
|
Center(
|
||||||
.toList(),
|
child: MyText.titleLarge(
|
||||||
child: Row(
|
"Create Task",
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
fontWeight: 700,
|
||||||
children: [
|
),
|
||||||
Text(
|
),
|
||||||
selectedName,
|
const SizedBox(height: 20),
|
||||||
style: const TextStyle(fontSize: 14, color: Colors.black87),
|
_infoCardSection([
|
||||||
),
|
_infoRowWithIcon(
|
||||||
const Icon(Icons.arrow_drop_down),
|
Icons.workspaces, "Selected Work Area", workArea),
|
||||||
],
|
_infoRowWithIcon(
|
||||||
),
|
Icons.list_alt, "Selected Activity", activity),
|
||||||
),
|
_infoRowWithIcon(Icons.check_circle_outline,
|
||||||
);
|
"Completed Work", completedWork),
|
||||||
}),
|
]),
|
||||||
const SizedBox(height: 24),
|
const SizedBox(height: 16),
|
||||||
Row(
|
_sectionTitle(Icons.edit_calendar, "Planned Work"),
|
||||||
children: [
|
const SizedBox(height: 6),
|
||||||
Expanded(
|
_customTextField(
|
||||||
child: OutlinedButton.icon(
|
controller: plannedTaskController,
|
||||||
onPressed: () => Get.back(),
|
hint: "Enter planned work",
|
||||||
icon: const Icon(Icons.close, size: 18),
|
keyboardType: TextInputType.number,
|
||||||
label: MyText.bodyMedium("Cancel", fontWeight: 600),
|
),
|
||||||
style: OutlinedButton.styleFrom(
|
const SizedBox(height: 16),
|
||||||
side: const BorderSide(color: Colors.grey),
|
_sectionTitle(Icons.description_outlined, "Comment"),
|
||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
const SizedBox(height: 6),
|
||||||
),
|
_customTextField(
|
||||||
),
|
controller: descriptionController,
|
||||||
),
|
hint: "Enter task description",
|
||||||
const SizedBox(width: 12),
|
maxLines: 3,
|
||||||
Expanded(
|
),
|
||||||
child: ElevatedButton.icon(
|
const SizedBox(height: 16),
|
||||||
onPressed: () async {
|
_sectionTitle(
|
||||||
final plannedValue = int.tryParse(plannedTaskController.text.trim()) ?? 0;
|
Icons.category_outlined, "Selected Work Category"),
|
||||||
final comment = descriptionController.text.trim();
|
const SizedBox(height: 6),
|
||||||
final selectedCategoryId = controller.selectedCategoryId.value;
|
Obx(() {
|
||||||
if (selectedCategoryId == null) {
|
final categoryMap = controller.categoryIdNameMap;
|
||||||
showAppSnackbar(
|
final String selectedName =
|
||||||
title: "error",
|
controller.selectedCategoryId.value != null
|
||||||
message: "Please select a work category!",
|
? (categoryMap[controller
|
||||||
type: SnackbarType.error,
|
.selectedCategoryId.value!] ??
|
||||||
);
|
'Select Category')
|
||||||
return;
|
: 'Select Category';
|
||||||
}
|
|
||||||
|
|
||||||
final success = await controller.createTask(
|
return Container(
|
||||||
parentTaskId: parentTaskId,
|
width: double.infinity,
|
||||||
plannedTask: plannedValue,
|
padding: const EdgeInsets.symmetric(
|
||||||
comment: comment,
|
horizontal: 12, vertical: 14),
|
||||||
workAreaId: workAreaId,
|
decoration: BoxDecoration(
|
||||||
activityId: activityId,
|
color: Colors.grey.shade100,
|
||||||
categoryId: selectedCategoryId,
|
border: Border.all(color: Colors.grey.shade300),
|
||||||
);
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
),
|
||||||
if (success) {
|
child: PopupMenuButton<String>(
|
||||||
Get.back();
|
padding: EdgeInsets.zero,
|
||||||
Future.delayed(const Duration(milliseconds: 300), () {
|
onSelected: (val) {
|
||||||
onSubmit();
|
controller.selectCategory(val);
|
||||||
showAppSnackbar(
|
onCategoryChanged(val);
|
||||||
title: "Success",
|
},
|
||||||
message: "Task created successfully!",
|
itemBuilder: (context) => categoryMap.entries
|
||||||
type: SnackbarType.success,
|
.map(
|
||||||
|
(entry) => PopupMenuItem<String>(
|
||||||
|
value: entry.key,
|
||||||
|
child: Text(entry.value),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.toList(),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment:
|
||||||
|
MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
selectedName,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 14, color: Colors.black87),
|
||||||
|
),
|
||||||
|
const Icon(Icons.arrow_drop_down),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
});
|
}),
|
||||||
}
|
const SizedBox(height: 24),
|
||||||
},
|
Row(
|
||||||
icon: const Icon(Icons.check, size: 18),
|
children: [
|
||||||
label: MyText.bodyMedium("Submit", color: Colors.white, fontWeight: 600),
|
Expanded(
|
||||||
style: ElevatedButton.styleFrom(
|
child: OutlinedButton.icon(
|
||||||
backgroundColor: Colors.blueAccent,
|
onPressed: () => Get.back(),
|
||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
icon: const Icon(Icons.close, size: 18),
|
||||||
|
label: MyText.bodyMedium("Cancel",
|
||||||
|
fontWeight: 600),
|
||||||
|
style: OutlinedButton.styleFrom(
|
||||||
|
side: const BorderSide(color: Colors.grey),
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(10)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
Expanded(
|
||||||
|
child: ElevatedButton.icon(
|
||||||
|
onPressed: () async {
|
||||||
|
final plannedValue = int.tryParse(
|
||||||
|
plannedTaskController.text.trim()) ??
|
||||||
|
0;
|
||||||
|
final comment =
|
||||||
|
descriptionController.text.trim();
|
||||||
|
final selectedCategoryId =
|
||||||
|
controller.selectedCategoryId.value;
|
||||||
|
if (selectedCategoryId == null) {
|
||||||
|
showAppSnackbar(
|
||||||
|
title: "error",
|
||||||
|
message: "Please select a work category!",
|
||||||
|
type: SnackbarType.error,
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final success = await controller.createTask(
|
||||||
|
parentTaskId: parentTaskId,
|
||||||
|
plannedTask: plannedValue,
|
||||||
|
comment: comment,
|
||||||
|
workAreaId: workAreaId,
|
||||||
|
activityId: activityId,
|
||||||
|
categoryId: selectedCategoryId,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (success) {
|
||||||
|
Get.back();
|
||||||
|
Future.delayed(
|
||||||
|
const Duration(milliseconds: 300), () {
|
||||||
|
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(
|
||||||
|
backgroundColor: Colors.blueAccent,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(10)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
);
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@ -204,6 +224,7 @@ SafeArea(
|
|||||||
isScrollControlled: true,
|
isScrollControlled: true,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _sectionTitle(IconData icon, String title) {
|
Widget _sectionTitle(IconData icon, String title) {
|
||||||
return Row(
|
return Row(
|
||||||
children: [
|
children: [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user