Add Comment Task feature with controller and UI integration #20
@ -16,7 +16,7 @@ import 'package:marco/view/dashboard/add_employee_screen.dart';
|
|||||||
import 'package:marco/view/dashboard/employee_screen.dart';
|
import 'package:marco/view/dashboard/employee_screen.dart';
|
||||||
import 'package:marco/view/dashboard/daily_task_screen.dart';
|
import 'package:marco/view/dashboard/daily_task_screen.dart';
|
||||||
import 'package:marco/view/taskPlaning/report_task_screen.dart';
|
import 'package:marco/view/taskPlaning/report_task_screen.dart';
|
||||||
|
import 'package:marco/view/taskPlaning/comment_task_screen.dart';
|
||||||
|
|
||||||
class AuthMiddleware extends GetMiddleware {
|
class AuthMiddleware extends GetMiddleware {
|
||||||
@override
|
@override
|
||||||
@ -59,7 +59,10 @@ getPageRoute() {
|
|||||||
name: '/daily-task/report-task',
|
name: '/daily-task/report-task',
|
||||||
page: () => ReportTaskScreen(),
|
page: () => ReportTaskScreen(),
|
||||||
middlewares: [AuthMiddleware()]),
|
middlewares: [AuthMiddleware()]),
|
||||||
|
GetPage(
|
||||||
|
name: '/daily-task/comment-task',
|
||||||
|
page: () => CommentTaskScreen(),
|
||||||
|
middlewares: [AuthMiddleware()]),
|
||||||
// Authentication
|
// Authentication
|
||||||
GetPage(name: '/auth/login', page: () => LoginScreen()),
|
GetPage(name: '/auth/login', page: () => LoginScreen()),
|
||||||
GetPage(
|
GetPage(
|
||||||
|
|||||||
@ -244,15 +244,17 @@ class _DailyTaskScreenState extends State<DailyTaskScreen> with UIMixin {
|
|||||||
].where((e) => e != null && e.isNotEmpty).join(' > ');
|
].where((e) => e != null && e.isNotEmpty).join(' > ');
|
||||||
|
|
||||||
return DataRow(cells: [
|
return DataRow(cells: [
|
||||||
DataCell(Column(
|
DataCell(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
MyText.bodyMedium(workItem?.activityMaster?.activityName ?? 'N/A'),
|
children: [
|
||||||
const SizedBox(height: 2),
|
MyText.bodyMedium(workItem?.activityMaster?.activityName ?? 'N/A', fontWeight: 600),
|
||||||
MyText.bodySmall(location),
|
SizedBox(height: 2),
|
||||||
],
|
MyText.bodySmall(location, color: Colors.grey),
|
||||||
)),
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
DataCell(
|
DataCell(
|
||||||
MyText.bodyMedium(
|
MyText.bodyMedium(
|
||||||
'${task.plannedTask ?? "NA"} / '
|
'${task.plannedTask ?? "NA"} / '
|
||||||
|
|||||||
259
lib/view/taskPlaning/comment_task_screen.dart
Normal file
259
lib/view/taskPlaning/comment_task_screen.dart
Normal file
@ -0,0 +1,259 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_lucide/flutter_lucide.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
import 'package:marco/controller/task_planing/report_task_controller.dart';
|
||||||
|
import 'package:marco/helpers/theme/app_theme.dart';
|
||||||
|
import 'package:marco/helpers/utils/mixins/ui_mixin.dart';
|
||||||
|
import 'package:marco/helpers/utils/my_shadow.dart';
|
||||||
|
import 'package:marco/helpers/widgets/my_breadcrumb.dart';
|
||||||
|
import 'package:marco/helpers/widgets/my_breadcrumb_item.dart';
|
||||||
|
import 'package:marco/helpers/widgets/my_button.dart';
|
||||||
|
import 'package:marco/helpers/widgets/my_card.dart';
|
||||||
|
import 'package:marco/helpers/widgets/my_flex.dart';
|
||||||
|
import 'package:marco/helpers/widgets/my_flex_item.dart';
|
||||||
|
import 'package:marco/helpers/widgets/my_spacing.dart';
|
||||||
|
import 'package:marco/helpers/widgets/my_text.dart';
|
||||||
|
import 'package:marco/helpers/widgets/my_text_style.dart';
|
||||||
|
import 'package:marco/view/layouts/layout.dart';
|
||||||
|
|
||||||
|
class CommentTaskScreen extends StatefulWidget {
|
||||||
|
const CommentTaskScreen({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<CommentTaskScreen> createState() => _CommentTaskScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _CommentTaskScreenState extends State<CommentTaskScreen> with UIMixin {
|
||||||
|
final ReportTaskController controller = Get.put(ReportTaskController());
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final taskData = Get.arguments as Map<String, dynamic>;
|
||||||
|
print("Task Data: $taskData");
|
||||||
|
controller.basicValidator.getController('assigned_date')?.text =
|
||||||
|
taskData['assignedOn'] ?? '';
|
||||||
|
controller.basicValidator.getController('assigned_by')?.text =
|
||||||
|
taskData['assignedBy'] ?? '';
|
||||||
|
controller.basicValidator.getController('work_area')?.text =
|
||||||
|
taskData['location'] ?? '';
|
||||||
|
controller.basicValidator.getController('activity')?.text =
|
||||||
|
taskData['activity'] ?? '';
|
||||||
|
controller.basicValidator.getController('team_size')?.text =
|
||||||
|
taskData['teamSize'].toString();
|
||||||
|
controller.basicValidator.getController('assigned')?.text =
|
||||||
|
taskData['assigned'] ?? '';
|
||||||
|
controller.basicValidator.getController('task_id')?.text =
|
||||||
|
taskData['taskId'] ?? '';
|
||||||
|
|
||||||
|
return Layout(
|
||||||
|
child: GetBuilder<ReportTaskController>(
|
||||||
|
init: controller,
|
||||||
|
tag: 'report_task_controller',
|
||||||
|
builder: (controller) {
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: MySpacing.x(flexSpacing),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
MyText.titleMedium("Report Task",
|
||||||
|
fontSize: 18, fontWeight: 600),
|
||||||
|
MyBreadcrumb(
|
||||||
|
children: [
|
||||||
|
MyBreadcrumbItem(name: 'Daily Task'),
|
||||||
|
MyBreadcrumbItem(name: 'Report Task'),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
MySpacing.height(flexSpacing),
|
||||||
|
Padding(
|
||||||
|
padding: MySpacing.x(flexSpacing / 2),
|
||||||
|
child: MyFlex(
|
||||||
|
children: [
|
||||||
|
MyFlexItem(sizes: "lg-8 md-12", child: detail()),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget detail() {
|
||||||
|
return Form(
|
||||||
|
key: controller.basicValidator.formKey,
|
||||||
|
child: MyCard.bordered(
|
||||||
|
borderRadiusAll: 4,
|
||||||
|
border: Border.all(color: Colors.grey.withOpacity(0.2)),
|
||||||
|
shadow: MyShadow(elevation: 1, position: MyShadowPosition.bottom),
|
||||||
|
paddingAll: 24,
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Icon(LucideIcons.server, size: 16),
|
||||||
|
MySpacing.width(12),
|
||||||
|
MyText.titleMedium("General", fontWeight: 600),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
MySpacing.height(24),
|
||||||
|
|
||||||
|
// Static fields
|
||||||
|
buildRow(
|
||||||
|
"Assigned Date",
|
||||||
|
controller.basicValidator
|
||||||
|
.getController('assigned_date')
|
||||||
|
?.text
|
||||||
|
.trim()),
|
||||||
|
buildRow(
|
||||||
|
"Assigned By",
|
||||||
|
controller.basicValidator
|
||||||
|
.getController('assigned_by')
|
||||||
|
?.text
|
||||||
|
.trim()),
|
||||||
|
buildRow(
|
||||||
|
"Work Area",
|
||||||
|
controller.basicValidator
|
||||||
|
.getController('work_area')
|
||||||
|
?.text
|
||||||
|
.trim()),
|
||||||
|
buildRow(
|
||||||
|
"Activity",
|
||||||
|
controller.basicValidator
|
||||||
|
.getController('activity')
|
||||||
|
?.text
|
||||||
|
.trim()),
|
||||||
|
buildRow(
|
||||||
|
"Team Size",
|
||||||
|
controller.basicValidator
|
||||||
|
.getController('team_size')
|
||||||
|
?.text
|
||||||
|
.trim()),
|
||||||
|
buildRow(
|
||||||
|
"Assigned",
|
||||||
|
controller.basicValidator
|
||||||
|
.getController('assigned')
|
||||||
|
?.text
|
||||||
|
.trim()),
|
||||||
|
|
||||||
|
// Input fields
|
||||||
|
MyText.labelMedium("Completed Work"),
|
||||||
|
MySpacing.height(8),
|
||||||
|
TextFormField(
|
||||||
|
validator:
|
||||||
|
controller.basicValidator.getValidation('completed_work'),
|
||||||
|
controller:
|
||||||
|
controller.basicValidator.getController('completed_work'),
|
||||||
|
keyboardType: TextInputType.number,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: "eg: 10",
|
||||||
|
hintStyle: MyTextStyle.bodySmall(xMuted: true),
|
||||||
|
border: outlineInputBorder,
|
||||||
|
enabledBorder: outlineInputBorder,
|
||||||
|
focusedBorder: focusedInputBorder,
|
||||||
|
contentPadding: MySpacing.all(16),
|
||||||
|
isCollapsed: true,
|
||||||
|
floatingLabelBehavior: FloatingLabelBehavior.never,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
MySpacing.height(24),
|
||||||
|
MyText.labelMedium("Comment"),
|
||||||
|
MySpacing.height(8),
|
||||||
|
TextFormField(
|
||||||
|
validator: controller.basicValidator.getValidation('comment'),
|
||||||
|
controller: controller.basicValidator.getController('comment'),
|
||||||
|
keyboardType: TextInputType.text,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: "eg: Work done successfully",
|
||||||
|
hintStyle: MyTextStyle.bodySmall(xMuted: true),
|
||||||
|
border: outlineInputBorder,
|
||||||
|
enabledBorder: outlineInputBorder,
|
||||||
|
focusedBorder: focusedInputBorder,
|
||||||
|
contentPadding: MySpacing.all(16),
|
||||||
|
isCollapsed: true,
|
||||||
|
floatingLabelBehavior: FloatingLabelBehavior.never,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
MySpacing.height(24),
|
||||||
|
|
||||||
|
// Buttons
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
MyButton.text(
|
||||||
|
onPressed: () => Get.back(),
|
||||||
|
padding: MySpacing.xy(20, 16),
|
||||||
|
splashColor: contentTheme.secondary.withValues(alpha: 0.1),
|
||||||
|
child: MyText.bodySmall('Cancel'),
|
||||||
|
),
|
||||||
|
MySpacing.width(12),
|
||||||
|
MyButton(
|
||||||
|
onPressed: () async {
|
||||||
|
if (controller.basicValidator.validateForm()) {
|
||||||
|
await controller.reportTask(
|
||||||
|
projectId: controller.basicValidator
|
||||||
|
.getController('task_id')
|
||||||
|
?.text ??
|
||||||
|
'', // Replace with actual ID
|
||||||
|
comment: controller.basicValidator
|
||||||
|
.getController('comment')
|
||||||
|
?.text ??
|
||||||
|
'',
|
||||||
|
completedTask: int.tryParse(controller.basicValidator
|
||||||
|
.getController('completed_work')
|
||||||
|
?.text ??
|
||||||
|
'') ??
|
||||||
|
0,
|
||||||
|
checklist: [],
|
||||||
|
reportedDate: DateTime.now(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
elevation: 0,
|
||||||
|
padding: MySpacing.xy(20, 16),
|
||||||
|
backgroundColor: contentTheme.primary,
|
||||||
|
borderRadiusAll: AppStyle.buttonRadius.medium,
|
||||||
|
child: MyText.bodySmall(
|
||||||
|
'Save',
|
||||||
|
color: contentTheme.onPrimary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
|
||||||
|
// Loading spinner
|
||||||
|
Obx(() {
|
||||||
|
return controller.isLoading.value
|
||||||
|
? Center(child: CircularProgressIndicator())
|
||||||
|
: SizedBox.shrink();
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget buildRow(String label, String? value) {
|
||||||
|
print("Label: $label, Value: $value");
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.only(bottom: 16),
|
||||||
|
child: Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
MyText.labelMedium("$label:"),
|
||||||
|
MySpacing.width(12),
|
||||||
|
Expanded(
|
||||||
|
child: MyText.bodyMedium(value?.isNotEmpty == true ? value! : "-"),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user