Merge pull request 'Dev_Manish_24/11' (#84) from Dev_Manish_24/11 into main
Reviewed-on: #84
This commit is contained in:
commit
90a3a85753
@ -1,5 +1,6 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:file_picker/file_picker.dart';
|
import 'package:file_picker/file_picker.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@ -50,10 +51,22 @@ class AddExpenseController extends GetxController {
|
|||||||
final isEditMode = false.obs;
|
final isEditMode = false.obs;
|
||||||
final isSearchingEmployees = false.obs;
|
final isSearchingEmployees = false.obs;
|
||||||
|
|
||||||
|
// --- Paid By (Single + Multi Selection Support) ---
|
||||||
|
|
||||||
|
// single selection
|
||||||
|
final selectedPaidBy = Rxn<EmployeeModel>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// helper setters
|
||||||
|
void setSelectedPaidBy(EmployeeModel? emp) {
|
||||||
|
selectedPaidBy.value = emp;
|
||||||
|
}
|
||||||
|
|
||||||
// --- Dropdown Selections & Data ---
|
// --- Dropdown Selections & Data ---
|
||||||
final selectedPaymentMode = Rxn<PaymentModeModel>();
|
final selectedPaymentMode = Rxn<PaymentModeModel>();
|
||||||
final selectedExpenseType = Rxn<ExpenseTypeModel>();
|
final selectedExpenseType = Rxn<ExpenseTypeModel>();
|
||||||
final selectedPaidBy = Rxn<EmployeeModel>();
|
// final selectedPaidBy = Rxn<EmployeeModel>();
|
||||||
final selectedProject = ''.obs;
|
final selectedProject = ''.obs;
|
||||||
final selectedTransactionDate = Rxn<DateTime>();
|
final selectedTransactionDate = Rxn<DateTime>();
|
||||||
|
|
||||||
|
|||||||
@ -14,6 +14,7 @@ import 'package:on_field_work/helpers/widgets/my_snackbar.dart';
|
|||||||
import 'package:on_field_work/helpers/widgets/time_stamp_image_helper.dart';
|
import 'package:on_field_work/helpers/widgets/time_stamp_image_helper.dart';
|
||||||
import 'package:on_field_work/model/finance/expense_category_model.dart';
|
import 'package:on_field_work/model/finance/expense_category_model.dart';
|
||||||
import 'package:on_field_work/model/finance/currency_list_model.dart';
|
import 'package:on_field_work/model/finance/currency_list_model.dart';
|
||||||
|
import 'package:on_field_work/model/employees/employee_model.dart';
|
||||||
|
|
||||||
class AddPaymentRequestController extends GetxController {
|
class AddPaymentRequestController extends GetxController {
|
||||||
// Loading States
|
// Loading States
|
||||||
@ -32,7 +33,7 @@ class AddPaymentRequestController extends GetxController {
|
|||||||
// Selected Values
|
// Selected Values
|
||||||
final selectedProject = Rx<Map<String, dynamic>?>(null);
|
final selectedProject = Rx<Map<String, dynamic>?>(null);
|
||||||
final selectedCategory = Rx<ExpenseCategory?>(null);
|
final selectedCategory = Rx<ExpenseCategory?>(null);
|
||||||
final selectedPayee = ''.obs;
|
final selectedPayee = Rx<EmployeeModel?>(null);
|
||||||
final selectedCurrency = Rx<Currency?>(null);
|
final selectedCurrency = Rx<Currency?>(null);
|
||||||
final isAdvancePayment = false.obs;
|
final isAdvancePayment = false.obs;
|
||||||
final selectedDueDate = Rx<DateTime?>(null);
|
final selectedDueDate = Rx<DateTime?>(null);
|
||||||
@ -161,7 +162,7 @@ class AddPaymentRequestController extends GetxController {
|
|||||||
try {
|
try {
|
||||||
final pickedFile = await _picker.pickImage(source: ImageSource.camera);
|
final pickedFile = await _picker.pickImage(source: ImageSource.camera);
|
||||||
if (pickedFile != null) {
|
if (pickedFile != null) {
|
||||||
isProcessingAttachment.value = true;
|
isProcessingAttachment.value = true;
|
||||||
File imageFile = File(pickedFile.path);
|
File imageFile = File(pickedFile.path);
|
||||||
|
|
||||||
// Add timestamp to the captured image
|
// Add timestamp to the captured image
|
||||||
@ -184,7 +185,7 @@ class AddPaymentRequestController extends GetxController {
|
|||||||
selectedProject.value = project;
|
selectedProject.value = project;
|
||||||
void selectCategory(ExpenseCategory category) =>
|
void selectCategory(ExpenseCategory category) =>
|
||||||
selectedCategory.value = category;
|
selectedCategory.value = category;
|
||||||
void selectPayee(String payee) => selectedPayee.value = payee;
|
void selectPayee(EmployeeModel payee) => selectedPayee.value = payee;
|
||||||
void selectCurrency(Currency currency) => selectedCurrency.value = currency;
|
void selectCurrency(Currency currency) => selectedCurrency.value = currency;
|
||||||
|
|
||||||
void addAttachment(File file) => attachments.add(file);
|
void addAttachment(File file) => attachments.add(file);
|
||||||
@ -268,7 +269,7 @@ class AddPaymentRequestController extends GetxController {
|
|||||||
"amount": double.tryParse(amountController.text.trim()) ?? 0,
|
"amount": double.tryParse(amountController.text.trim()) ?? 0,
|
||||||
"currencyId": selectedCurrency.value?.id ?? '',
|
"currencyId": selectedCurrency.value?.id ?? '',
|
||||||
"description": descriptionController.text.trim(),
|
"description": descriptionController.text.trim(),
|
||||||
"payee": selectedPayee.value,
|
"payee": selectedPayee.value?.id ?? "",
|
||||||
"dueDate": selectedDueDate.value?.toIso8601String(),
|
"dueDate": selectedDueDate.value?.toIso8601String(),
|
||||||
"isAdvancePayment": isAdvancePayment.value,
|
"isAdvancePayment": isAdvancePayment.value,
|
||||||
"billAttachments": billAttachments.map((a) {
|
"billAttachments": billAttachments.map((a) {
|
||||||
@ -337,7 +338,7 @@ class AddPaymentRequestController extends GetxController {
|
|||||||
"amount": double.tryParse(amountController.text.trim()) ?? 0,
|
"amount": double.tryParse(amountController.text.trim()) ?? 0,
|
||||||
"currencyId": selectedCurrency.value?.id ?? '',
|
"currencyId": selectedCurrency.value?.id ?? '',
|
||||||
"description": descriptionController.text.trim(),
|
"description": descriptionController.text.trim(),
|
||||||
"payee": selectedPayee.value,
|
"payee": selectedPayee.value?.id ?? "",
|
||||||
"dueDate": selectedDueDate.value?.toIso8601String(),
|
"dueDate": selectedDueDate.value?.toIso8601String(),
|
||||||
"isAdvancePayment": isAdvancePayment.value,
|
"isAdvancePayment": isAdvancePayment.value,
|
||||||
"billAttachments": billAttachments.map((a) {
|
"billAttachments": billAttachments.map((a) {
|
||||||
@ -388,7 +389,7 @@ class AddPaymentRequestController extends GetxController {
|
|||||||
return _errorSnackbar("Please select a project");
|
return _errorSnackbar("Please select a project");
|
||||||
if (selectedCategory.value == null)
|
if (selectedCategory.value == null)
|
||||||
return _errorSnackbar("Please select a category");
|
return _errorSnackbar("Please select a category");
|
||||||
if (selectedPayee.value.isEmpty)
|
if (selectedPayee.value == null)
|
||||||
return _errorSnackbar("Please select a payee");
|
return _errorSnackbar("Please select a payee");
|
||||||
if (selectedCurrency.value == null)
|
if (selectedCurrency.value == null)
|
||||||
return _errorSnackbar("Please select currency");
|
return _errorSnackbar("Please select currency");
|
||||||
@ -408,7 +409,7 @@ class AddPaymentRequestController extends GetxController {
|
|||||||
descriptionController.clear();
|
descriptionController.clear();
|
||||||
selectedProject.value = null;
|
selectedProject.value = null;
|
||||||
selectedCategory.value = null;
|
selectedCategory.value = null;
|
||||||
selectedPayee.value = '';
|
selectedPayee.value = null;
|
||||||
selectedCurrency.value = null;
|
selectedCurrency.value = null;
|
||||||
isAdvancePayment.value = false;
|
isAdvancePayment.value = false;
|
||||||
attachments.clear();
|
attachments.clear();
|
||||||
|
|||||||
@ -95,7 +95,7 @@ class _SearchAndFilterState extends State<SearchAndFilter> with UIMixin {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: MySpacing.fromLTRB(12, 10, 12, 0),
|
padding: MySpacing.fromLTRB(12, 10, 12, 8),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
@ -179,13 +179,6 @@ class ToggleButtonsRow extends StatelessWidget {
|
|||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: const Color(0xFFF0F0F0),
|
color: const Color(0xFFF0F0F0),
|
||||||
borderRadius: BorderRadius.circular(10),
|
borderRadius: BorderRadius.circular(10),
|
||||||
boxShadow: [
|
|
||||||
BoxShadow(
|
|
||||||
color: Colors.black.withOpacity(0.05),
|
|
||||||
blurRadius: 4,
|
|
||||||
offset: const Offset(0, 2),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
@ -286,82 +279,84 @@ class ExpenseList extends StatelessWidget {
|
|||||||
return Center(child: MyText.bodyMedium('No expenses found.'));
|
return Center(child: MyText.bodyMedium('No expenses found.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return ListView.separated(
|
return SafeArea(
|
||||||
padding: const EdgeInsets.fromLTRB(12, 12, 12, 80),
|
bottom: true,
|
||||||
itemCount: expenseList.length,
|
child: ListView.separated(
|
||||||
separatorBuilder: (_, __) =>
|
padding: const EdgeInsets.fromLTRB(12, 12, 12, 100),
|
||||||
Divider(color: Colors.grey.shade300, height: 20),
|
itemCount: expenseList.length,
|
||||||
itemBuilder: (context, index) {
|
separatorBuilder: (_, __) =>
|
||||||
final expense = expenseList[index];
|
Divider(color: Colors.grey.shade300, height: 20),
|
||||||
final formattedDate = DateTimeUtils.convertUtcToLocal(
|
itemBuilder: (context, index) {
|
||||||
expense.transactionDate.toIso8601String(),
|
final expense = expenseList[index];
|
||||||
format: 'dd MMM yyyy',
|
final formattedDate = DateTimeUtils.convertUtcToLocal(
|
||||||
);
|
expense.transactionDate.toIso8601String(),
|
||||||
|
format: 'dd MMM yyyy',
|
||||||
|
);
|
||||||
|
|
||||||
return Material(
|
return Material(
|
||||||
color: Colors.transparent,
|
color: Colors.transparent,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
await Get.to(
|
await Get.to(() => ExpenseDetailScreen(expenseId: expense.id));
|
||||||
() => ExpenseDetailScreen(expenseId: expense.id),
|
},
|
||||||
);
|
child: Padding(
|
||||||
},
|
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||||
child: Padding(
|
child: Column(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
child: Column(
|
children: [
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
Row(
|
||||||
children: [
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
Row(
|
children: [
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
MyText.bodyMedium(expense.expenseCategory.name,
|
||||||
children: [
|
fontWeight: 600),
|
||||||
MyText.bodyMedium(expense.expenseCategory.name,
|
Row(
|
||||||
fontWeight: 600),
|
children: [
|
||||||
Row(
|
MyText.bodyMedium('${expense.formattedAmount}',
|
||||||
children: [
|
fontWeight: 600),
|
||||||
MyText.bodyMedium('${expense.formattedAmount}',
|
if (expense.status.name.toLowerCase() ==
|
||||||
fontWeight: 600),
|
'draft') ...[
|
||||||
if (expense.status.name.toLowerCase() == 'draft') ...[
|
const SizedBox(width: 8),
|
||||||
const SizedBox(width: 8),
|
GestureDetector(
|
||||||
GestureDetector(
|
onTap: () =>
|
||||||
onTap: () =>
|
_showDeleteConfirmation(context, expense),
|
||||||
_showDeleteConfirmation(context, expense),
|
child: const Icon(Icons.delete,
|
||||||
child: const Icon(Icons.delete,
|
color: Colors.red, size: 20),
|
||||||
color: Colors.red, size: 20),
|
),
|
||||||
),
|
],
|
||||||
],
|
],
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 6),
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
MyText.bodySmall(formattedDate, fontWeight: 500),
|
|
||||||
const Spacer(),
|
|
||||||
Container(
|
|
||||||
padding: const EdgeInsets.symmetric(
|
|
||||||
horizontal: 8, vertical: 4),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Color(int.parse(
|
|
||||||
'0xff${expense.status.color.substring(1)}'))
|
|
||||||
.withOpacity(0.5),
|
|
||||||
borderRadius: BorderRadius.circular(5),
|
|
||||||
),
|
),
|
||||||
child: MyText.bodySmall(
|
],
|
||||||
expense.status.name,
|
),
|
||||||
color: Colors.white,
|
const SizedBox(height: 6),
|
||||||
fontWeight: 500,
|
Row(
|
||||||
|
children: [
|
||||||
|
MyText.bodySmall(formattedDate, fontWeight: 500),
|
||||||
|
const Spacer(),
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 8, vertical: 4),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Color(int.parse(
|
||||||
|
'0xff${expense.status.color.substring(1)}'))
|
||||||
|
.withOpacity(0.5),
|
||||||
|
borderRadius: BorderRadius.circular(5),
|
||||||
|
),
|
||||||
|
child: MyText.bodySmall(
|
||||||
|
expense.status.name,
|
||||||
|
color: Colors.white,
|
||||||
|
fontWeight: 500,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
);
|
},
|
||||||
},
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -123,7 +123,6 @@ class _AttendanceFilterBottomSheetState
|
|||||||
}).toList();
|
}).toList();
|
||||||
|
|
||||||
final List<Widget> widgets = [
|
final List<Widget> widgets = [
|
||||||
// 🔹 View Section
|
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(bottom: 4),
|
padding: const EdgeInsets.only(bottom: 4),
|
||||||
child: Align(
|
child: Align(
|
||||||
@ -146,7 +145,6 @@ class _AttendanceFilterBottomSheetState
|
|||||||
}),
|
}),
|
||||||
];
|
];
|
||||||
|
|
||||||
// 🔹 Organization filter
|
|
||||||
widgets.addAll([
|
widgets.addAll([
|
||||||
const Divider(),
|
const Divider(),
|
||||||
Padding(
|
Padding(
|
||||||
@ -165,24 +163,6 @@ class _AttendanceFilterBottomSheetState
|
|||||||
color: Colors.grey.shade300,
|
color: Colors.grey.shade300,
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: BorderRadius.circular(12),
|
||||||
),
|
),
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
width: 100,
|
|
||||||
height: 14,
|
|
||||||
color: Colors.grey.shade400,
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
width: 18,
|
|
||||||
height: 18,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.grey.shade400,
|
|
||||||
shape: BoxShape.circle,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
} else if (widget.controller.organizations.isEmpty) {
|
} else if (widget.controller.organizations.isEmpty) {
|
||||||
return Center(
|
return Center(
|
||||||
@ -200,7 +180,6 @@ class _AttendanceFilterBottomSheetState
|
|||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// 🔹 Date Range (only for Attendance Logs)
|
|
||||||
if (tempSelectedTab == 'attendanceLogs') {
|
if (tempSelectedTab == 'attendanceLogs') {
|
||||||
widgets.addAll([
|
widgets.addAll([
|
||||||
const Divider(),
|
const Divider(),
|
||||||
@ -211,14 +190,12 @@ class _AttendanceFilterBottomSheetState
|
|||||||
child: MyText.titleSmall("Date Range", fontWeight: 600),
|
child: MyText.titleSmall("Date Range", fontWeight: 600),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// ✅ Reusable DateRangePickerWidget
|
|
||||||
DateRangePickerWidget(
|
DateRangePickerWidget(
|
||||||
startDate: widget.controller.startDateAttendance,
|
startDate: widget.controller.startDateAttendance,
|
||||||
endDate: widget.controller.endDateAttendance,
|
endDate: widget.controller.endDateAttendance,
|
||||||
startLabel: "Start Date",
|
startLabel: "Start Date",
|
||||||
endLabel: "End Date",
|
endLabel: "End Date",
|
||||||
onDateRangeSelected: (start, end) {
|
onDateRangeSelected: (start, end) {
|
||||||
// Optional: trigger UI updates if needed
|
|
||||||
setState(() {});
|
setState(() {});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@ -230,8 +207,8 @@ class _AttendanceFilterBottomSheetState
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return ClipRRect(
|
return SafeArea(
|
||||||
borderRadius: const BorderRadius.vertical(top: Radius.circular(24)),
|
// ← FIX: avoids hiding under navigation buttons
|
||||||
child: BaseBottomSheet(
|
child: BaseBottomSheet(
|
||||||
title: "Attendance Filter",
|
title: "Attendance Filter",
|
||||||
submitText: "Apply",
|
submitText: "Apply",
|
||||||
@ -240,9 +217,17 @@ class _AttendanceFilterBottomSheetState
|
|||||||
'selectedTab': tempSelectedTab,
|
'selectedTab': tempSelectedTab,
|
||||||
'selectedOrganization': widget.controller.selectedOrganization?.id,
|
'selectedOrganization': widget.controller.selectedOrganization?.id,
|
||||||
}),
|
}),
|
||||||
child: Column(
|
child: Padding(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
padding:
|
||||||
children: buildMainFilters(),
|
const EdgeInsets.only(bottom: 24), // ← FIX: extra safe padding
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
// ← FIX: full scrollable in landscape
|
||||||
|
physics: const BouncingScrollPhysics(),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: buildMainFilters(),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@ -12,6 +12,8 @@ import 'package:on_field_work/helpers/widgets/tenant/organization_selector.dart'
|
|||||||
import 'package:on_field_work/helpers/widgets/tenant/service_selector.dart';
|
import 'package:on_field_work/helpers/widgets/tenant/service_selector.dart';
|
||||||
import 'package:on_field_work/model/attendance/organization_per_project_list_model.dart';
|
import 'package:on_field_work/model/attendance/organization_per_project_list_model.dart';
|
||||||
import 'package:on_field_work/model/tenant/tenant_services_model.dart';
|
import 'package:on_field_work/model/tenant/tenant_services_model.dart';
|
||||||
|
import 'package:on_field_work/model/employees/employee_model.dart';
|
||||||
|
import 'package:on_field_work/model/employees/multiple_select_role_bottomsheet.dart';
|
||||||
|
|
||||||
class AssignTaskBottomSheet extends StatefulWidget {
|
class AssignTaskBottomSheet extends StatefulWidget {
|
||||||
final String workLocation;
|
final String workLocation;
|
||||||
@ -43,14 +45,15 @@ class _AssignTaskBottomSheetState extends State<AssignTaskBottomSheet> {
|
|||||||
final DailyTaskPlanningController controller = Get.find();
|
final DailyTaskPlanningController controller = Get.find();
|
||||||
final ProjectController projectController = Get.find();
|
final ProjectController projectController = Get.find();
|
||||||
|
|
||||||
final OrganizationController orgController = Get.put(OrganizationController());
|
final OrganizationController orgController =
|
||||||
|
Get.put(OrganizationController());
|
||||||
final ServiceController serviceController = Get.put(ServiceController());
|
final ServiceController serviceController = Get.put(ServiceController());
|
||||||
|
|
||||||
final TextEditingController targetController = TextEditingController();
|
final TextEditingController targetController = TextEditingController();
|
||||||
final TextEditingController descriptionController = TextEditingController();
|
final TextEditingController descriptionController = TextEditingController();
|
||||||
final ScrollController _employeeListScrollController = ScrollController();
|
|
||||||
|
|
||||||
String? selectedProjectId;
|
String? selectedProjectId;
|
||||||
|
String? selectedRoleId;
|
||||||
Organization? selectedOrganization;
|
Organization? selectedOrganization;
|
||||||
Service? selectedService;
|
Service? selectedService;
|
||||||
|
|
||||||
@ -79,12 +82,14 @@ class _AssignTaskBottomSheetState extends State<AssignTaskBottomSheet> {
|
|||||||
serviceId: selectedService?.id,
|
serviceId: selectedService?.id,
|
||||||
organizationId: selectedOrganization?.id,
|
organizationId: selectedOrganization?.id,
|
||||||
);
|
);
|
||||||
await controller.fetchTaskData(selectedProjectId, serviceId: selectedService?.id);
|
await controller.fetchTaskData(
|
||||||
|
selectedProjectId,
|
||||||
|
serviceId: selectedService?.id,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_employeeListScrollController.dispose();
|
|
||||||
targetController.dispose();
|
targetController.dispose();
|
||||||
descriptionController.dispose();
|
descriptionController.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
@ -92,20 +97,21 @@ class _AssignTaskBottomSheetState extends State<AssignTaskBottomSheet> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Obx(() => BaseBottomSheet(
|
return Obx(
|
||||||
title: "Assign Task",
|
() => BaseBottomSheet(
|
||||||
child: _buildAssignTaskForm(),
|
title: "Assign Task",
|
||||||
onCancel: () => Get.back(),
|
child: _buildAssignTaskForm(),
|
||||||
onSubmit: _onAssignTaskPressed,
|
onCancel: () => Get.back(),
|
||||||
isSubmitting: controller.isAssigningTask.value,
|
onSubmit: _onAssignTaskPressed,
|
||||||
));
|
isSubmitting: controller.isAssigningTask.value,
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildAssignTaskForm() {
|
Widget _buildAssignTaskForm() {
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
// Organization Selector
|
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 50,
|
height: 50,
|
||||||
child: OrganizationSelector(
|
child: OrganizationSelector(
|
||||||
@ -117,9 +123,9 @@ class _AssignTaskBottomSheetState extends State<AssignTaskBottomSheet> {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
MySpacing.height(12),
|
MySpacing.height(12),
|
||||||
|
|
||||||
// Service Selector
|
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 50,
|
height: 50,
|
||||||
child: ServiceSelector(
|
child: ServiceSelector(
|
||||||
@ -131,49 +137,75 @@ class _AssignTaskBottomSheetState extends State<AssignTaskBottomSheet> {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
MySpacing.height(16),
|
MySpacing.height(16),
|
||||||
|
_infoRow(Icons.location_on, "Work Location",
|
||||||
// Work Location Info
|
"${widget.buildingName} > ${widget.floorName} > ${widget.workAreaName} > ${widget.activityName}"),
|
||||||
|
const Divider(),
|
||||||
_infoRow(
|
_infoRow(
|
||||||
Icons.location_on,
|
Icons.pending_actions, "Pending Task", "${widget.pendingTask}"),
|
||||||
"Work Location",
|
|
||||||
"${widget.buildingName} > ${widget.floorName} > ${widget.workAreaName} > ${widget.activityName}",
|
|
||||||
),
|
|
||||||
const Divider(),
|
const Divider(),
|
||||||
|
|
||||||
// Pending Task Info
|
|
||||||
_infoRow(Icons.pending_actions, "Pending Task", "${widget.pendingTask}"),
|
|
||||||
const Divider(),
|
|
||||||
|
|
||||||
// Role Selector
|
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: _onRoleMenuPressed,
|
onTap: _onRoleMenuPressed,
|
||||||
child: Row(
|
child: Row(children: [
|
||||||
children: [
|
MyText.titleMedium("Select Team :", fontWeight: 600),
|
||||||
MyText.titleMedium("Select Team :", fontWeight: 600),
|
const SizedBox(width: 4),
|
||||||
const SizedBox(width: 4),
|
const Icon(Icons.tune, color: Color.fromARGB(255, 95, 132, 255)),
|
||||||
const Icon(Icons.tune, color: Color.fromARGB(255, 95, 132, 255)),
|
]),
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
|
|
||||||
MySpacing.height(8),
|
MySpacing.height(8),
|
||||||
|
|
||||||
// Employee List
|
/// TEAM SELECT BOX
|
||||||
Container(
|
GestureDetector(
|
||||||
constraints: const BoxConstraints(maxHeight: 180),
|
onTap: _openEmployeeSelectionSheet,
|
||||||
decoration: BoxDecoration(
|
child: Container(
|
||||||
border: Border.all(color: Colors.grey.shade300),
|
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 12),
|
||||||
borderRadius: BorderRadius.circular(6),
|
decoration: BoxDecoration(
|
||||||
),
|
border: Border.all(color: Colors.grey.shade300),
|
||||||
child: _buildEmployeeList(),
|
borderRadius: BorderRadius.circular(6),
|
||||||
),
|
),
|
||||||
MySpacing.height(8),
|
child: Row(
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.group, color: Colors.black54),
|
||||||
|
const SizedBox(width: 10),
|
||||||
|
|
||||||
// Selected Employees Chips
|
// Expanded name area
|
||||||
|
Expanded(
|
||||||
|
child: Obx(() {
|
||||||
|
final count = controller.selectedEmployees.length;
|
||||||
|
if (count == 0) {
|
||||||
|
return MyText(
|
||||||
|
"Select team members",
|
||||||
|
color: Colors.grey.shade700,
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
final names = controller.selectedEmployees
|
||||||
|
.map((e) => e.name)
|
||||||
|
.join(", ");
|
||||||
|
|
||||||
|
return Text(
|
||||||
|
names,
|
||||||
|
maxLines: 2,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: const TextStyle(fontSize: 14),
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
|
||||||
|
const Icon(Icons.arrow_drop_down, color: Colors.grey),
|
||||||
|
],
|
||||||
|
)),
|
||||||
|
),
|
||||||
|
|
||||||
|
MySpacing.height(8),
|
||||||
_buildSelectedEmployees(),
|
_buildSelectedEmployees(),
|
||||||
MySpacing.height(8),
|
MySpacing.height(8),
|
||||||
|
|
||||||
// Target Input
|
|
||||||
_buildTextField(
|
_buildTextField(
|
||||||
icon: Icons.track_changes,
|
icon: Icons.track_changes,
|
||||||
label: "Target for Today :",
|
label: "Target for Today :",
|
||||||
@ -182,9 +214,9 @@ class _AssignTaskBottomSheetState extends State<AssignTaskBottomSheet> {
|
|||||||
keyboardType: const TextInputType.numberWithOptions(decimal: true),
|
keyboardType: const TextInputType.numberWithOptions(decimal: true),
|
||||||
validatorType: "target",
|
validatorType: "target",
|
||||||
),
|
),
|
||||||
|
|
||||||
MySpacing.height(16),
|
MySpacing.height(16),
|
||||||
|
|
||||||
// Description Input
|
|
||||||
_buildTextField(
|
_buildTextField(
|
||||||
icon: Icons.description,
|
icon: Icons.description,
|
||||||
label: "Description :",
|
label: "Description :",
|
||||||
@ -198,7 +230,8 @@ class _AssignTaskBottomSheetState extends State<AssignTaskBottomSheet> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _onRoleMenuPressed() {
|
void _onRoleMenuPressed() {
|
||||||
final RenderBox overlay = Overlay.of(context).context.findRenderObject() as RenderBox;
|
final RenderBox overlay =
|
||||||
|
Overlay.of(context).context.findRenderObject() as RenderBox;
|
||||||
final Size screenSize = overlay.size;
|
final Size screenSize = overlay.size;
|
||||||
|
|
||||||
showMenu(
|
showMenu(
|
||||||
@ -211,69 +244,18 @@ class _AssignTaskBottomSheetState extends State<AssignTaskBottomSheet> {
|
|||||||
),
|
),
|
||||||
items: [
|
items: [
|
||||||
const PopupMenuItem(value: 'all', child: Text("All Roles")),
|
const PopupMenuItem(value: 'all', child: Text("All Roles")),
|
||||||
...controller.roles.map((role) {
|
...controller.roles.map(
|
||||||
return PopupMenuItem(
|
(role) => PopupMenuItem(
|
||||||
value: role['id'].toString(),
|
value: role['id'].toString(),
|
||||||
child: Text(role['name'] ?? 'Unknown Role'),
|
child: Text(role['name'] ?? 'Unknown Role'),
|
||||||
);
|
),
|
||||||
}),
|
),
|
||||||
],
|
],
|
||||||
).then((value) {
|
).then((value) {
|
||||||
if (value != null) controller.onRoleSelected(value == 'all' ? null : value);
|
if (value != null) {
|
||||||
});
|
selectedRoleId = value == 'all' ? null : value;
|
||||||
}
|
controller.onRoleSelected(selectedRoleId);
|
||||||
|
|
||||||
Widget _buildEmployeeList() {
|
|
||||||
return Obx(() {
|
|
||||||
if (controller.isFetchingEmployees.value) {
|
|
||||||
return Center(child: CircularProgressIndicator());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final filteredEmployees = controller.selectedRoleId.value == null
|
|
||||||
? controller.employees
|
|
||||||
: controller.employees
|
|
||||||
.where((e) => e.jobRoleID.toString() == controller.selectedRoleId.value)
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
if (filteredEmployees.isEmpty) {
|
|
||||||
return Center(child: Text("No employees available for selected role."));
|
|
||||||
}
|
|
||||||
|
|
||||||
return Scrollbar(
|
|
||||||
controller: _employeeListScrollController,
|
|
||||||
thumbVisibility: true,
|
|
||||||
child: ListView.builder(
|
|
||||||
controller: _employeeListScrollController,
|
|
||||||
itemCount: filteredEmployees.length,
|
|
||||||
itemBuilder: (context, index) {
|
|
||||||
final employee = filteredEmployees[index];
|
|
||||||
final rxBool = controller.uploadingStates[employee.id];
|
|
||||||
|
|
||||||
return Obx(() => ListTile(
|
|
||||||
dense: true,
|
|
||||||
contentPadding: const EdgeInsets.symmetric(horizontal: 8),
|
|
||||||
leading: Checkbox(
|
|
||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(4)),
|
|
||||||
value: rxBool?.value ?? false,
|
|
||||||
onChanged: (selected) {
|
|
||||||
if (rxBool != null) {
|
|
||||||
rxBool.value = selected ?? false;
|
|
||||||
controller.updateSelectedEmployees();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
fillColor: MaterialStateProperty.resolveWith((states) =>
|
|
||||||
states.contains(MaterialState.selected)
|
|
||||||
? const Color.fromARGB(255, 95, 132, 255)
|
|
||||||
: Colors.transparent),
|
|
||||||
checkColor: Colors.white,
|
|
||||||
side: const BorderSide(color: Colors.black),
|
|
||||||
),
|
|
||||||
title: Text(employee.name, style: const TextStyle(fontSize: 14)),
|
|
||||||
visualDensity: VisualDensity.compact,
|
|
||||||
));
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,20 +267,14 @@ class _AssignTaskBottomSheetState extends State<AssignTaskBottomSheet> {
|
|||||||
spacing: 4,
|
spacing: 4,
|
||||||
runSpacing: 4,
|
runSpacing: 4,
|
||||||
children: controller.selectedEmployees.map((e) {
|
children: controller.selectedEmployees.map((e) {
|
||||||
return Obx(() {
|
return Chip(
|
||||||
final isSelected = controller.uploadingStates[e.id]?.value ?? false;
|
label: Text(e.name, style: const TextStyle(color: Colors.white)),
|
||||||
if (!isSelected) return Container();
|
backgroundColor: const Color.fromARGB(255, 95, 132, 255),
|
||||||
|
deleteIcon: const Icon(Icons.close, color: Colors.white),
|
||||||
return Chip(
|
onDeleted: () {
|
||||||
label: Text(e.name, style: const TextStyle(color: Colors.white)),
|
controller.selectedEmployees.remove(e);
|
||||||
backgroundColor: const Color.fromARGB(255, 95, 132, 255),
|
},
|
||||||
deleteIcon: const Icon(Icons.close, color: Colors.white),
|
);
|
||||||
onDeleted: () {
|
|
||||||
controller.uploadingStates[e.id]?.value = false;
|
|
||||||
controller.updateSelectedEmployees();
|
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}).toList(),
|
}).toList(),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -328,10 +304,15 @@ class _AssignTaskBottomSheetState extends State<AssignTaskBottomSheet> {
|
|||||||
maxLines: maxLines,
|
maxLines: maxLines,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
hintText: hintText,
|
hintText: hintText,
|
||||||
border: OutlineInputBorder(borderRadius: BorderRadius.circular(6)),
|
border: OutlineInputBorder(
|
||||||
contentPadding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
borderRadius: BorderRadius.circular(6),
|
||||||
|
),
|
||||||
|
contentPadding:
|
||||||
|
const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
||||||
),
|
),
|
||||||
validator: (value) => this.controller.formFieldValidator(value, fieldType: validatorType),
|
validator: (value) => this
|
||||||
|
.controller
|
||||||
|
.formFieldValidator(value, fieldType: validatorType),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
@ -350,32 +331,70 @@ class _AssignTaskBottomSheetState extends State<AssignTaskBottomSheet> {
|
|||||||
text: TextSpan(
|
text: TextSpan(
|
||||||
children: [
|
children: [
|
||||||
WidgetSpan(
|
WidgetSpan(
|
||||||
child: MyText.titleMedium("$title: ", fontWeight: 600, color: Colors.black),
|
child: MyText.titleMedium(
|
||||||
|
"$title: ",
|
||||||
|
fontWeight: 600,
|
||||||
|
color: Colors.black,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
TextSpan(
|
||||||
|
text: value,
|
||||||
|
style: const TextStyle(color: Colors.black),
|
||||||
),
|
),
|
||||||
TextSpan(text: value, style: const TextStyle(color: Colors.black)),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> _openEmployeeSelectionSheet() async {
|
||||||
|
final result = await showModalBottomSheet<List<EmployeeModel>>(
|
||||||
|
context: context,
|
||||||
|
isScrollControlled: true,
|
||||||
|
useSafeArea: true,
|
||||||
|
shape: const RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
|
||||||
|
),
|
||||||
|
builder: (_) => SizedBox(
|
||||||
|
height: MediaQuery.of(context).size.height * 0.85,
|
||||||
|
child: MultipleSelectRoleBottomSheet(
|
||||||
|
projectId: selectedProjectId!,
|
||||||
|
organizationId: selectedOrganization?.id,
|
||||||
|
serviceId: selectedService?.id,
|
||||||
|
roleId: selectedRoleId,
|
||||||
|
initiallySelected: controller.selectedEmployees.toList(),
|
||||||
|
scrollController: ScrollController(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (result != null) {
|
||||||
|
controller.selectedEmployees.assignAll(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void _onAssignTaskPressed() {
|
void _onAssignTaskPressed() {
|
||||||
final selectedTeam = controller.uploadingStates.entries
|
final selectedTeam = controller.selectedEmployees;
|
||||||
.where((e) => e.value.value)
|
|
||||||
.map((e) => e.key)
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
if (selectedTeam.isEmpty) {
|
if (selectedTeam.isEmpty) {
|
||||||
showAppSnackbar(title: "Team Required", message: "Please select at least one team member", type: SnackbarType.error);
|
showAppSnackbar(
|
||||||
|
title: "Team Required",
|
||||||
|
message: "Please select at least one team member",
|
||||||
|
type: SnackbarType.error,
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final target = double.tryParse(targetController.text.trim());
|
final target = double.tryParse(targetController.text.trim());
|
||||||
if (target == null || target <= 0) {
|
if (target == null || target <= 0) {
|
||||||
showAppSnackbar(title: "Invalid Input", message: "Please enter a valid target number", type: SnackbarType.error);
|
showAppSnackbar(
|
||||||
|
title: "Invalid Input",
|
||||||
|
message: "Please enter a valid target number",
|
||||||
|
type: SnackbarType.error,
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -390,7 +409,11 @@ class _AssignTaskBottomSheetState extends State<AssignTaskBottomSheet> {
|
|||||||
|
|
||||||
final description = descriptionController.text.trim();
|
final description = descriptionController.text.trim();
|
||||||
if (description.isEmpty) {
|
if (description.isEmpty) {
|
||||||
showAppSnackbar(title: "Description Required", message: "Please enter a description", type: SnackbarType.error);
|
showAppSnackbar(
|
||||||
|
title: "Description Required",
|
||||||
|
message: "Please enter a description",
|
||||||
|
type: SnackbarType.error,
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -398,7 +421,7 @@ class _AssignTaskBottomSheetState extends State<AssignTaskBottomSheet> {
|
|||||||
workItemId: widget.workItemId,
|
workItemId: widget.workItemId,
|
||||||
plannedTask: target.toInt(),
|
plannedTask: target.toInt(),
|
||||||
description: description,
|
description: description,
|
||||||
taskTeam: selectedTeam,
|
taskTeam: selectedTeam.map((e) => e.id).toList(), // pass IDs
|
||||||
assignmentDate: widget.assignmentDate,
|
assignmentDate: widget.assignmentDate,
|
||||||
organizationId: selectedOrganization?.id,
|
organizationId: selectedOrganization?.id,
|
||||||
serviceId: selectedService?.id,
|
serviceId: selectedService?.id,
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
import 'package:on_field_work/controller/task_planning/daily_task_controller.dart';
|
import 'package:on_field_work/controller/task_planning/daily_task_controller.dart';
|
||||||
import 'package:on_field_work/helpers/utils/base_bottom_sheet.dart';
|
import 'package:on_field_work/helpers/utils/base_bottom_sheet.dart';
|
||||||
import 'package:on_field_work/helpers/widgets/my_spacing.dart';
|
import 'package:on_field_work/helpers/widgets/my_spacing.dart';
|
||||||
@ -23,82 +24,85 @@ class DailyTaskFilterBottomSheet extends StatelessWidget {
|
|||||||
filterData.services,
|
filterData.services,
|
||||||
].any((list) => list.isNotEmpty);
|
].any((list) => list.isNotEmpty);
|
||||||
|
|
||||||
return BaseBottomSheet(
|
return SafeArea(
|
||||||
title: "Filter Tasks",
|
// ✅ PREVENTS GOING UNDER NAV BUTTONS
|
||||||
submitText: "Apply",
|
bottom: true,
|
||||||
showButtons: hasFilters,
|
child: BaseBottomSheet(
|
||||||
onCancel: () => Get.back(),
|
title: "Filter Tasks",
|
||||||
onSubmit: () {
|
submitText: "Apply",
|
||||||
if (controller.selectedProjectId != null) {
|
showButtons: hasFilters,
|
||||||
controller.fetchTaskData(
|
onCancel: () => Get.back(),
|
||||||
controller.selectedProjectId!,
|
onSubmit: () {
|
||||||
);
|
if (controller.selectedProjectId != null) {
|
||||||
}
|
controller.fetchTaskData(controller.selectedProjectId!);
|
||||||
|
}
|
||||||
Get.back();
|
Get.back();
|
||||||
},
|
},
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
child: hasFilters
|
padding: const EdgeInsets.only(bottom: 40), // ✅ EXTRA SAFETY PADDING
|
||||||
? Column(
|
child: hasFilters
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
? Column(
|
||||||
children: [
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
Align(
|
children: [
|
||||||
alignment: Alignment.centerRight,
|
Align(
|
||||||
child: TextButton(
|
alignment: Alignment.centerRight,
|
||||||
onPressed: () {
|
child: TextButton(
|
||||||
controller.clearTaskFilters();
|
onPressed: () {
|
||||||
},
|
controller.clearTaskFilters();
|
||||||
child: MyText(
|
},
|
||||||
"Reset Filter",
|
child: MyText(
|
||||||
style: const TextStyle(
|
"Reset Filter",
|
||||||
color: Colors.red,
|
style: const TextStyle(
|
||||||
fontWeight: FontWeight.w600,
|
color: Colors.red,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
MySpacing.height(8),
|
||||||
MySpacing.height(8),
|
_multiSelectField(
|
||||||
_multiSelectField(
|
label: "Buildings",
|
||||||
label: "Buildings",
|
items: filterData.buildings,
|
||||||
items: filterData.buildings,
|
fallback: "Select Buildings",
|
||||||
fallback: "Select Buildings",
|
selectedValues: controller.selectedBuildings,
|
||||||
selectedValues: controller.selectedBuildings,
|
),
|
||||||
),
|
_multiSelectField(
|
||||||
_multiSelectField(
|
label: "Floors",
|
||||||
label: "Floors",
|
items: filterData.floors,
|
||||||
items: filterData.floors,
|
fallback: "Select Floors",
|
||||||
fallback: "Select Floors",
|
selectedValues: controller.selectedFloors,
|
||||||
selectedValues: controller.selectedFloors,
|
),
|
||||||
),
|
_multiSelectField(
|
||||||
_multiSelectField(
|
label: "Activities",
|
||||||
label: "Activities",
|
items: filterData.activities,
|
||||||
items: filterData.activities,
|
fallback: "Select Activities",
|
||||||
fallback: "Select Activities",
|
selectedValues: controller.selectedActivities,
|
||||||
selectedValues: controller.selectedActivities,
|
),
|
||||||
),
|
_multiSelectField(
|
||||||
_multiSelectField(
|
label: "Services",
|
||||||
label: "Services",
|
items: filterData.services,
|
||||||
items: filterData.services,
|
fallback: "Select Services",
|
||||||
fallback: "Select Services",
|
selectedValues: controller.selectedServices,
|
||||||
selectedValues: controller.selectedServices,
|
),
|
||||||
),
|
MySpacing.height(8),
|
||||||
MySpacing.height(8),
|
_dateRangeSelector(context),
|
||||||
_dateRangeSelector(context),
|
],
|
||||||
],
|
)
|
||||||
)
|
: Center(
|
||||||
: Center(
|
child: Padding(
|
||||||
child: Padding(
|
padding: const EdgeInsets.all(24.0),
|
||||||
padding: const EdgeInsets.all(24.0),
|
child: MyText(
|
||||||
child: MyText(
|
"No filters available",
|
||||||
"No filters available",
|
style: const TextStyle(color: Colors.grey),
|
||||||
style: const TextStyle(color: Colors.grey),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MULTI SELECT FIELD
|
||||||
Widget _multiSelectField({
|
Widget _multiSelectField({
|
||||||
required String label,
|
required String label,
|
||||||
required List<dynamic> items,
|
required List<dynamic> items,
|
||||||
@ -117,6 +121,7 @@ class DailyTaskFilterBottomSheet extends StatelessWidget {
|
|||||||
.where((item) => selectedValues.contains(item.id))
|
.where((item) => selectedValues.contains(item.id))
|
||||||
.map((item) => item.name)
|
.map((item) => item.name)
|
||||||
.join(", ");
|
.join(", ");
|
||||||
|
|
||||||
final displayText =
|
final displayText =
|
||||||
selectedNames.isNotEmpty ? selectedNames : fallback;
|
selectedNames.isNotEmpty ? selectedNames : fallback;
|
||||||
|
|
||||||
@ -146,27 +151,23 @@ class DailyTaskFilterBottomSheet extends StatelessWidget {
|
|||||||
child: StatefulBuilder(
|
child: StatefulBuilder(
|
||||||
builder: (context, setState) {
|
builder: (context, setState) {
|
||||||
final isChecked = selectedValues.contains(item.id);
|
final isChecked = selectedValues.contains(item.id);
|
||||||
|
|
||||||
return CheckboxListTile(
|
return CheckboxListTile(
|
||||||
dense: true,
|
dense: true,
|
||||||
value: isChecked,
|
value: isChecked,
|
||||||
contentPadding: EdgeInsets.zero,
|
contentPadding: EdgeInsets.zero,
|
||||||
controlAffinity: ListTileControlAffinity.leading,
|
controlAffinity: ListTileControlAffinity.leading,
|
||||||
title: MyText(item.name),
|
title: MyText(item.name),
|
||||||
|
|
||||||
// --- Styles to match Document Filter ---
|
|
||||||
checkColor: Colors.white,
|
checkColor: Colors.white,
|
||||||
side: const BorderSide(
|
side: const BorderSide(
|
||||||
color: Colors.black, width: 1.5),
|
color: Colors.black, width: 1.5),
|
||||||
fillColor:
|
fillColor:
|
||||||
MaterialStateProperty.resolveWith<Color>(
|
MaterialStateProperty.resolveWith<Color>(
|
||||||
(states) {
|
(states) =>
|
||||||
if (states.contains(MaterialState.selected)) {
|
states.contains(MaterialState.selected)
|
||||||
return Colors.indigo;
|
? Colors.indigo
|
||||||
}
|
: Colors.white,
|
||||||
return Colors.white;
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
|
|
||||||
onChanged: (val) {
|
onChanged: (val) {
|
||||||
if (val == true) {
|
if (val == true) {
|
||||||
selectedValues.add(item.id);
|
selectedValues.add(item.id);
|
||||||
@ -212,6 +213,7 @@ class DailyTaskFilterBottomSheet extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DATE RANGE PICKER
|
||||||
Widget _dateRangeSelector(BuildContext context) {
|
Widget _dateRangeSelector(BuildContext context) {
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
|||||||
@ -315,15 +315,31 @@ class _AddContactBottomSheetState extends State<AddContactBottomSheet> {
|
|||||||
height: 48,
|
height: 48,
|
||||||
child: TextField(
|
child: TextField(
|
||||||
controller: tagCtrl,
|
controller: tagCtrl,
|
||||||
onChanged: controller.filterSuggestions,
|
onChanged: (value) {
|
||||||
|
|
||||||
|
if (value.endsWith(" ") || value.endsWith(",")) {
|
||||||
|
final cleaned = value.trim().replaceAll(",", "");
|
||||||
|
if (cleaned.isNotEmpty) {
|
||||||
|
controller.addEnteredTag(cleaned);
|
||||||
|
}
|
||||||
|
tagCtrl.clear();
|
||||||
|
controller.clearSuggestions();
|
||||||
|
} else {
|
||||||
|
controller.filterSuggestions(value);
|
||||||
|
}
|
||||||
|
},
|
||||||
onSubmitted: (v) {
|
onSubmitted: (v) {
|
||||||
controller.addEnteredTag(v);
|
if (v.trim().isNotEmpty) {
|
||||||
|
controller.addEnteredTag(v.trim());
|
||||||
|
}
|
||||||
tagCtrl.clear();
|
tagCtrl.clear();
|
||||||
controller.clearSuggestions();
|
controller.clearSuggestions();
|
||||||
},
|
},
|
||||||
decoration: _inputDecoration("Start typing to add tags"),
|
decoration: _inputDecoration("Start typing to add tags"),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
|
|
||||||
Obx(() => controller.filteredSuggestions.isEmpty
|
Obx(() => controller.filteredSuggestions.isEmpty
|
||||||
? const SizedBox.shrink()
|
? const SizedBox.shrink()
|
||||||
: Container(
|
: Container(
|
||||||
@ -353,7 +369,10 @@ class _AddContactBottomSheetState extends State<AddContactBottomSheet> {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
)),
|
)),
|
||||||
|
|
||||||
MySpacing.height(8),
|
MySpacing.height(8),
|
||||||
|
|
||||||
|
// TAG CHIPS
|
||||||
Obx(() => Wrap(
|
Obx(() => Wrap(
|
||||||
spacing: 8,
|
spacing: 8,
|
||||||
children: controller.enteredTags
|
children: controller.enteredTags
|
||||||
|
|||||||
@ -9,6 +9,7 @@ import 'package:on_field_work/helpers/widgets/my_spacing.dart';
|
|||||||
import 'package:on_field_work/helpers/widgets/my_snackbar.dart';
|
import 'package:on_field_work/helpers/widgets/my_snackbar.dart';
|
||||||
import 'package:on_field_work/model/employees/employee_model.dart';
|
import 'package:on_field_work/model/employees/employee_model.dart';
|
||||||
import 'package:on_field_work/model/directory/contact_bucket_list_model.dart';
|
import 'package:on_field_work/model/directory/contact_bucket_list_model.dart';
|
||||||
|
import 'package:on_field_work/model/employees/multiple_select_bottomsheet.dart';
|
||||||
|
|
||||||
class EditBucketBottomSheet {
|
class EditBucketBottomSheet {
|
||||||
static void show(
|
static void show(
|
||||||
@ -21,10 +22,8 @@ class EditBucketBottomSheet {
|
|||||||
|
|
||||||
final nameController = TextEditingController(text: bucket.name);
|
final nameController = TextEditingController(text: bucket.name);
|
||||||
final descController = TextEditingController(text: bucket.description);
|
final descController = TextEditingController(text: bucket.description);
|
||||||
final searchController = TextEditingController();
|
|
||||||
|
|
||||||
final selectedIds = RxSet<String>({...bucket.employeeIds});
|
final selectedIds = RxSet<String>({...bucket.employeeIds});
|
||||||
final searchText = ''.obs;
|
|
||||||
|
|
||||||
InputDecoration _inputDecoration(String label) {
|
InputDecoration _inputDecoration(String label) {
|
||||||
return InputDecoration(
|
return InputDecoration(
|
||||||
@ -84,6 +83,15 @@ class EditBucketBottomSheet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> _handleSubmitBottomSheet(BuildContext sheetContext) async {
|
||||||
|
await _handleSubmit();
|
||||||
|
|
||||||
|
// close bottom sheet safely
|
||||||
|
if (Navigator.of(sheetContext).canPop()) {
|
||||||
|
Navigator.of(sheetContext).pop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Widget _formContent() {
|
Widget _formContent() {
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
@ -101,117 +109,72 @@ class EditBucketBottomSheet {
|
|||||||
MySpacing.height(20),
|
MySpacing.height(20),
|
||||||
MyText.labelLarge('Shared With', fontWeight: 600),
|
MyText.labelLarge('Shared With', fontWeight: 600),
|
||||||
MySpacing.height(8),
|
MySpacing.height(8),
|
||||||
Obx(() => TextField(
|
|
||||||
controller: searchController,
|
|
||||||
onChanged: (value) => searchText.value = value.toLowerCase(),
|
|
||||||
decoration: InputDecoration(
|
|
||||||
hintText: 'Search employee...',
|
|
||||||
prefixIcon: const Icon(Icons.search, size: 20),
|
|
||||||
suffixIcon: searchText.value.isNotEmpty
|
|
||||||
? IconButton(
|
|
||||||
icon: const Icon(Icons.clear, size: 18),
|
|
||||||
onPressed: () {
|
|
||||||
searchController.clear();
|
|
||||||
searchText.value = '';
|
|
||||||
},
|
|
||||||
)
|
|
||||||
: null,
|
|
||||||
isDense: true,
|
|
||||||
contentPadding:
|
|
||||||
const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
|
||||||
filled: true,
|
|
||||||
fillColor: Colors.grey.shade100,
|
|
||||||
border: OutlineInputBorder(
|
|
||||||
borderRadius: BorderRadius.circular(10),
|
|
||||||
borderSide: BorderSide(color: Colors.grey.shade300),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)),
|
|
||||||
MySpacing.height(8),
|
|
||||||
Obx(() {
|
Obx(() {
|
||||||
final filtered = allEmployees.where((emp) {
|
if (selectedIds.isEmpty) return const SizedBox.shrink();
|
||||||
final fullName = '${emp.firstName} ${emp.lastName}'.toLowerCase();
|
|
||||||
return fullName.contains(searchText.value);
|
|
||||||
}).toList();
|
|
||||||
|
|
||||||
return SizedBox(
|
final selectedEmployees =
|
||||||
height: 180,
|
allEmployees.where((e) => selectedIds.contains(e.id)).toList();
|
||||||
child: ListView.separated(
|
|
||||||
itemCount: filtered.length,
|
|
||||||
separatorBuilder: (_, __) => const SizedBox(height: 2),
|
|
||||||
itemBuilder: (context, index) {
|
|
||||||
final emp = filtered[index];
|
|
||||||
final fullName = '${emp.firstName} ${emp.lastName}'.trim();
|
|
||||||
|
|
||||||
return Obx(() => Theme(
|
return Wrap(
|
||||||
data: Theme.of(context).copyWith(
|
spacing: 8,
|
||||||
unselectedWidgetColor: Colors.grey.shade500,
|
children: selectedEmployees.map((emp) {
|
||||||
checkboxTheme: CheckboxThemeData(
|
final fullName = '${emp.firstName} ${emp.lastName}'.trim();
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(4)),
|
return Chip(
|
||||||
side: const BorderSide(color: Colors.grey),
|
label: Text(fullName),
|
||||||
fillColor:
|
onDeleted: emp.id == ownerId
|
||||||
MaterialStateProperty.resolveWith((states) {
|
? null
|
||||||
if (states.contains(MaterialState.selected)) {
|
: () => selectedIds.remove(emp.id),
|
||||||
return Colors.blueAccent;
|
);
|
||||||
}
|
}).toList(),
|
||||||
return Colors.white;
|
|
||||||
}),
|
|
||||||
checkColor: MaterialStateProperty.all(Colors.white),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: CheckboxListTile(
|
|
||||||
dense: true,
|
|
||||||
contentPadding: EdgeInsets.zero,
|
|
||||||
visualDensity: const VisualDensity(vertical: -4),
|
|
||||||
controlAffinity: ListTileControlAffinity.leading,
|
|
||||||
value: selectedIds.contains(emp.id),
|
|
||||||
onChanged: emp.id == ownerId
|
|
||||||
? null
|
|
||||||
: (val) {
|
|
||||||
if (val == true) {
|
|
||||||
selectedIds.add(emp.id);
|
|
||||||
} else {
|
|
||||||
selectedIds.remove(emp.id);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
title: Row(
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: MyText.bodyMedium(
|
|
||||||
fullName.isNotEmpty ? fullName : 'Unnamed',
|
|
||||||
fontWeight: 600,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (emp.id == ownerId)
|
|
||||||
Container(
|
|
||||||
margin: const EdgeInsets.only(left: 6),
|
|
||||||
padding: const EdgeInsets.symmetric(
|
|
||||||
horizontal: 6, vertical: 2),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.red.shade50,
|
|
||||||
borderRadius: BorderRadius.circular(4),
|
|
||||||
),
|
|
||||||
child: MyText.labelSmall(
|
|
||||||
"Owner",
|
|
||||||
fontWeight: 600,
|
|
||||||
color: Colors.red,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
subtitle: emp.jobRole.isNotEmpty
|
|
||||||
? MyText.bodySmall(
|
|
||||||
emp.jobRole,
|
|
||||||
color: Colors.grey.shade600,
|
|
||||||
)
|
|
||||||
: null,
|
|
||||||
),
|
|
||||||
));
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
|
MySpacing.height(8),
|
||||||
|
|
||||||
|
// --- Open new EmployeeSelectionBottomSheet ---
|
||||||
|
GestureDetector(
|
||||||
|
onTap: () async {
|
||||||
|
final initiallySelected = allEmployees
|
||||||
|
.where((e) => selectedIds.contains(e.id))
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
final result = await showModalBottomSheet<List<EmployeeModel>>(
|
||||||
|
context: context,
|
||||||
|
isScrollControlled: true,
|
||||||
|
shape: const RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.vertical(top: Radius.circular(22)),
|
||||||
|
),
|
||||||
|
builder: (_) => EmployeeSelectionBottomSheet(
|
||||||
|
initiallySelected: initiallySelected,
|
||||||
|
multipleSelection: true,
|
||||||
|
title: "Shared With",
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (result != null) {
|
||||||
|
selectedIds
|
||||||
|
..clear()
|
||||||
|
..addAll(result.map((e) => e.id));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 12),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.grey.shade100,
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
border: Border.all(color: Colors.grey.shade300),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
children: const [
|
||||||
|
Icon(Icons.search, color: Colors.grey),
|
||||||
|
SizedBox(width: 8),
|
||||||
|
Expanded(child: Text("Search & Select Employees")),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
MySpacing.height(8),
|
||||||
|
const SizedBox.shrink(),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -224,7 +187,7 @@ class EditBucketBottomSheet {
|
|||||||
return BaseBottomSheet(
|
return BaseBottomSheet(
|
||||||
title: "Edit Bucket",
|
title: "Edit Bucket",
|
||||||
onCancel: () => Navigator.pop(context),
|
onCancel: () => Navigator.pop(context),
|
||||||
onSubmit: _handleSubmit,
|
onSubmit: () => _handleSubmitBottomSheet(context),
|
||||||
child: _formContent(),
|
child: _formContent(),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
// ---------------- FULL UPDATED CODE WITH LANDSCAPE FIX ------------------
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
@ -26,10 +28,8 @@ class _AddEmployeeBottomSheetState extends State<AddEmployeeBottomSheet>
|
|||||||
late final AddEmployeeController _controller;
|
late final AddEmployeeController _controller;
|
||||||
late final AllOrganizationController _organizationController;
|
late final AllOrganizationController _organizationController;
|
||||||
|
|
||||||
// Local UI state
|
|
||||||
bool _hasApplicationAccess = false;
|
bool _hasApplicationAccess = false;
|
||||||
|
|
||||||
// Local read-only controllers to avoid recreating TextEditingController in build
|
|
||||||
late final TextEditingController _orgFieldController;
|
late final TextEditingController _orgFieldController;
|
||||||
late final TextEditingController _joiningDateController;
|
late final TextEditingController _joiningDateController;
|
||||||
late final TextEditingController _genderController;
|
late final TextEditingController _genderController;
|
||||||
@ -39,16 +39,13 @@ class _AddEmployeeBottomSheetState extends State<AddEmployeeBottomSheet>
|
|||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
|
||||||
// Initialize text controllers
|
|
||||||
_orgFieldController = TextEditingController();
|
_orgFieldController = TextEditingController();
|
||||||
_joiningDateController = TextEditingController();
|
_joiningDateController = TextEditingController();
|
||||||
_genderController = TextEditingController();
|
_genderController = TextEditingController();
|
||||||
_roleController = TextEditingController();
|
_roleController = TextEditingController();
|
||||||
|
|
||||||
// Initialize AddEmployeeController
|
|
||||||
_controller = Get.put(AddEmployeeController(), tag: UniqueKey().toString());
|
_controller = Get.put(AddEmployeeController(), tag: UniqueKey().toString());
|
||||||
|
|
||||||
// Pass organization ID from employeeData if available
|
|
||||||
final orgIdFromEmployee =
|
final orgIdFromEmployee =
|
||||||
widget.employeeData?['organization_id'] as String?;
|
widget.employeeData?['organization_id'] as String?;
|
||||||
_organizationController = Get.put(
|
_organizationController = Get.put(
|
||||||
@ -56,7 +53,6 @@ class _AddEmployeeBottomSheetState extends State<AddEmployeeBottomSheet>
|
|||||||
tag: UniqueKey().toString(),
|
tag: UniqueKey().toString(),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Keep _orgFieldController in sync with selected organization safely
|
|
||||||
ever(_organizationController.selectedOrganization, (_) {
|
ever(_organizationController.selectedOrganization, (_) {
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
_orgFieldController.text =
|
_orgFieldController.text =
|
||||||
@ -65,48 +61,39 @@ class _AddEmployeeBottomSheetState extends State<AddEmployeeBottomSheet>
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Prefill other fields if editing
|
|
||||||
if (widget.employeeData != null) {
|
if (widget.employeeData != null) {
|
||||||
_controller.editingEmployeeData = widget.employeeData;
|
_controller.editingEmployeeData = widget.employeeData;
|
||||||
_controller.prefillFields();
|
_controller.prefillFields();
|
||||||
|
|
||||||
// Application access
|
|
||||||
_hasApplicationAccess =
|
_hasApplicationAccess =
|
||||||
widget.employeeData?['hasApplicationAccess'] ?? false;
|
widget.employeeData?['hasApplicationAccess'] ?? false;
|
||||||
|
|
||||||
// Email
|
|
||||||
final email = widget.employeeData?['email'];
|
final email = widget.employeeData?['email'];
|
||||||
if (email != null && email.toString().isNotEmpty) {
|
if (email != null && email.toString().isNotEmpty) {
|
||||||
_controller.basicValidator.getController('email')?.text =
|
_controller.basicValidator.getController('email')?.text =
|
||||||
email.toString();
|
email.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Joining date
|
|
||||||
if (_controller.joiningDate != null) {
|
if (_controller.joiningDate != null) {
|
||||||
_joiningDateController.text =
|
_joiningDateController.text =
|
||||||
DateFormat('dd MMM yyyy').format(_controller.joiningDate!);
|
DateFormat('dd MMM yyyy').format(_controller.joiningDate!);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gender
|
|
||||||
if (_controller.selectedGender != null) {
|
if (_controller.selectedGender != null) {
|
||||||
_genderController.text =
|
_genderController.text =
|
||||||
_controller.selectedGender!.name.capitalizeFirst ?? '';
|
_controller.selectedGender!.name.capitalizeFirst ?? '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prefill Role
|
|
||||||
_controller.fetchRoles().then((_) {
|
_controller.fetchRoles().then((_) {
|
||||||
if (_controller.selectedRoleId != null) {
|
if (_controller.selectedRoleId != null) {
|
||||||
final roleName = _controller.roles.firstWhereOrNull(
|
final roleName = _controller.roles.firstWhereOrNull(
|
||||||
(r) => r['id'] == _controller.selectedRoleId,
|
(r) => r['id'] == _controller.selectedRoleId,
|
||||||
)?['name'];
|
)?['name'];
|
||||||
if (roleName != null) {
|
if (roleName != null) _roleController.text = roleName;
|
||||||
_roleController.text = roleName;
|
|
||||||
}
|
|
||||||
_controller.update();
|
_controller.update();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// Not editing: fetch roles
|
|
||||||
_controller.fetchRoles();
|
_controller.fetchRoles();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -125,146 +112,162 @@ class _AddEmployeeBottomSheetState extends State<AddEmployeeBottomSheet>
|
|||||||
return GetBuilder<AddEmployeeController>(
|
return GetBuilder<AddEmployeeController>(
|
||||||
init: _controller,
|
init: _controller,
|
||||||
builder: (_) {
|
builder: (_) {
|
||||||
// Keep org field in sync with controller selection
|
|
||||||
_orgFieldController.text = _organizationController.currentSelection;
|
_orgFieldController.text = _organizationController.currentSelection;
|
||||||
|
|
||||||
return BaseBottomSheet(
|
return SafeArea(
|
||||||
title: widget.employeeData != null ? 'Edit Employee' : 'Add Employee',
|
// ⬅️ Prevent bottom sheet from going under system navigation
|
||||||
onCancel: () => Navigator.pop(context),
|
child: BaseBottomSheet(
|
||||||
onSubmit: _handleSubmit,
|
title:
|
||||||
child: Form(
|
widget.employeeData != null ? 'Edit Employee' : 'Add Employee',
|
||||||
key: _controller.basicValidator.formKey,
|
onCancel: () => Navigator.pop(context),
|
||||||
child: Column(
|
onSubmit: _handleSubmit,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
// ---------------- FIXED CHILD WRAPPING -----------------
|
||||||
_sectionLabel('Personal Info'),
|
child: LayoutBuilder(builder: (context, constraints) {
|
||||||
MySpacing.height(16),
|
return ConstrainedBox(
|
||||||
_inputWithIcon(
|
constraints: BoxConstraints(
|
||||||
label: 'First Name',
|
maxHeight: constraints.maxHeight,
|
||||||
hint: 'e.g., John',
|
|
||||||
icon: Icons.person,
|
|
||||||
controller:
|
|
||||||
_controller.basicValidator.getController('first_name')!,
|
|
||||||
validator:
|
|
||||||
_controller.basicValidator.getValidation('first_name'),
|
|
||||||
),
|
),
|
||||||
MySpacing.height(16),
|
child: SingleChildScrollView(
|
||||||
_inputWithIcon(
|
padding: const EdgeInsets.only(bottom: 32),
|
||||||
label: 'Last Name',
|
child: Form(
|
||||||
hint: 'e.g., Doe',
|
key: _controller.basicValidator.formKey,
|
||||||
icon: Icons.person_outline,
|
child: Column(
|
||||||
controller:
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
_controller.basicValidator.getController('last_name')!,
|
children: [
|
||||||
validator:
|
_sectionLabel('Personal Info'),
|
||||||
_controller.basicValidator.getValidation('last_name'),
|
MySpacing.height(16),
|
||||||
),
|
_inputWithIcon(
|
||||||
MySpacing.height(16),
|
label: 'First Name',
|
||||||
_sectionLabel('Organization'),
|
hint: 'e.g., John',
|
||||||
MySpacing.height(8),
|
icon: Icons.person,
|
||||||
Obx(() {
|
controller: _controller.basicValidator
|
||||||
return GestureDetector(
|
.getController('first_name')!,
|
||||||
onTap: () => _showOrganizationPopup(context),
|
validator: _controller.basicValidator
|
||||||
child: AbsorbPointer(
|
.getValidation('first_name'),
|
||||||
child: TextFormField(
|
|
||||||
readOnly: true,
|
|
||||||
controller: _orgFieldController,
|
|
||||||
validator: (val) {
|
|
||||||
if (val == null ||
|
|
||||||
val.trim().isEmpty ||
|
|
||||||
val == 'All Organizations') {
|
|
||||||
return 'Organization is required';
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
decoration:
|
|
||||||
_inputDecoration('Select Organization').copyWith(
|
|
||||||
suffixIcon: _organizationController
|
|
||||||
.isLoadingOrganizations.value
|
|
||||||
? const SizedBox(
|
|
||||||
width: 24,
|
|
||||||
height: 24,
|
|
||||||
child:
|
|
||||||
CircularProgressIndicator(strokeWidth: 2),
|
|
||||||
)
|
|
||||||
: const Icon(Icons.expand_more),
|
|
||||||
),
|
),
|
||||||
),
|
MySpacing.height(16),
|
||||||
|
_inputWithIcon(
|
||||||
|
label: 'Last Name',
|
||||||
|
hint: 'e.g., Doe',
|
||||||
|
icon: Icons.person_outline,
|
||||||
|
controller: _controller.basicValidator
|
||||||
|
.getController('last_name')!,
|
||||||
|
validator: _controller.basicValidator
|
||||||
|
.getValidation('last_name'),
|
||||||
|
),
|
||||||
|
MySpacing.height(16),
|
||||||
|
_sectionLabel('Organization'),
|
||||||
|
MySpacing.height(8),
|
||||||
|
Obx(() {
|
||||||
|
return GestureDetector(
|
||||||
|
onTap: () => _showOrganizationPopup(context),
|
||||||
|
child: AbsorbPointer(
|
||||||
|
child: TextFormField(
|
||||||
|
readOnly: true,
|
||||||
|
controller: _orgFieldController,
|
||||||
|
validator: (val) {
|
||||||
|
if (val == null ||
|
||||||
|
val.trim().isEmpty ||
|
||||||
|
val == 'All Organizations') {
|
||||||
|
return 'Organization is required';
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
decoration:
|
||||||
|
_inputDecoration('Select Organization')
|
||||||
|
.copyWith(
|
||||||
|
suffixIcon: _organizationController
|
||||||
|
.isLoadingOrganizations.value
|
||||||
|
? const SizedBox(
|
||||||
|
width: 24,
|
||||||
|
height: 24,
|
||||||
|
child: CircularProgressIndicator(
|
||||||
|
strokeWidth: 2,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: const Icon(Icons.expand_more),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
MySpacing.height(24),
|
||||||
|
_sectionLabel('Application Access'),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Checkbox(
|
||||||
|
value: _hasApplicationAccess,
|
||||||
|
onChanged: (val) {
|
||||||
|
setState(() => _hasApplicationAccess = val!);
|
||||||
|
},
|
||||||
|
fillColor: WidgetStateProperty.resolveWith<Color>(
|
||||||
|
(states) {
|
||||||
|
if (states.contains(WidgetState.selected)) {
|
||||||
|
return Colors.indigo;
|
||||||
|
}
|
||||||
|
return Colors.white;
|
||||||
|
}),
|
||||||
|
side: WidgetStateBorderSide.resolveWith((states) {
|
||||||
|
if (states.contains(WidgetState.selected)) {
|
||||||
|
return BorderSide.none;
|
||||||
|
}
|
||||||
|
return const BorderSide(
|
||||||
|
color: Colors.black, width: 2);
|
||||||
|
}),
|
||||||
|
checkColor: Colors.white,
|
||||||
|
),
|
||||||
|
MyText.bodyMedium(
|
||||||
|
'Has Application Access',
|
||||||
|
fontWeight: 600,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
MySpacing.height(8),
|
||||||
|
_buildEmailField(),
|
||||||
|
MySpacing.height(12),
|
||||||
|
_sectionLabel('Joining Details'),
|
||||||
|
MySpacing.height(16),
|
||||||
|
_buildDatePickerField(
|
||||||
|
label: 'Joining Date',
|
||||||
|
controller: _joiningDateController,
|
||||||
|
hint: 'Select Joining Date',
|
||||||
|
onTap: () => _pickJoiningDate(context),
|
||||||
|
),
|
||||||
|
MySpacing.height(16),
|
||||||
|
_sectionLabel('Contact Details'),
|
||||||
|
MySpacing.height(16),
|
||||||
|
_buildPhoneInput(context),
|
||||||
|
MySpacing.height(24),
|
||||||
|
_sectionLabel('Other Details'),
|
||||||
|
MySpacing.height(16),
|
||||||
|
_buildDropdownField(
|
||||||
|
label: 'Gender',
|
||||||
|
controller: _genderController,
|
||||||
|
hint: 'Select Gender',
|
||||||
|
onTap: () => _showGenderPopup(context),
|
||||||
|
),
|
||||||
|
MySpacing.height(16),
|
||||||
|
_buildDropdownField(
|
||||||
|
label: 'Role',
|
||||||
|
controller: _roleController,
|
||||||
|
hint: 'Select Role',
|
||||||
|
onTap: () => _showRolePopup(context),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
);
|
),
|
||||||
}),
|
|
||||||
MySpacing.height(24),
|
|
||||||
_sectionLabel('Application Access'),
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Checkbox(
|
|
||||||
value: _hasApplicationAccess,
|
|
||||||
onChanged: (val) {
|
|
||||||
setState(() => _hasApplicationAccess = val ?? false);
|
|
||||||
},
|
|
||||||
fillColor:
|
|
||||||
WidgetStateProperty.resolveWith<Color>((states) {
|
|
||||||
if (states.contains(WidgetState.selected)) {
|
|
||||||
return Colors.indigo;
|
|
||||||
}
|
|
||||||
return Colors.white;
|
|
||||||
}),
|
|
||||||
side: WidgetStateBorderSide.resolveWith((states) {
|
|
||||||
if (states.contains(WidgetState.selected)) {
|
|
||||||
return BorderSide.none;
|
|
||||||
}
|
|
||||||
return const BorderSide(
|
|
||||||
color: Colors.black,
|
|
||||||
width: 2,
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
checkColor: Colors.white,
|
|
||||||
),
|
|
||||||
MyText.bodyMedium(
|
|
||||||
'Has Application Access',
|
|
||||||
fontWeight: 600,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
MySpacing.height(8),
|
);
|
||||||
_buildEmailField(),
|
}),
|
||||||
MySpacing.height(12),
|
|
||||||
_sectionLabel('Joining Details'),
|
|
||||||
MySpacing.height(16),
|
|
||||||
_buildDatePickerField(
|
|
||||||
label: 'Joining Date',
|
|
||||||
controller: _joiningDateController,
|
|
||||||
hint: 'Select Joining Date',
|
|
||||||
onTap: () => _pickJoiningDate(context),
|
|
||||||
),
|
|
||||||
MySpacing.height(16),
|
|
||||||
_sectionLabel('Contact Details'),
|
|
||||||
MySpacing.height(16),
|
|
||||||
_buildPhoneInput(context),
|
|
||||||
MySpacing.height(24),
|
|
||||||
_sectionLabel('Other Details'),
|
|
||||||
MySpacing.height(16),
|
|
||||||
_buildDropdownField(
|
|
||||||
label: 'Gender',
|
|
||||||
controller: _genderController,
|
|
||||||
hint: 'Select Gender',
|
|
||||||
onTap: () => _showGenderPopup(context),
|
|
||||||
),
|
|
||||||
MySpacing.height(16),
|
|
||||||
_buildDropdownField(
|
|
||||||
label: 'Role',
|
|
||||||
controller: _roleController,
|
|
||||||
hint: 'Select Role',
|
|
||||||
onTap: () => _showRolePopup(context),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// UI Pieces
|
// ====================== REMAINING CODE (UNCHANGED) ======================
|
||||||
|
// (👇 Everything below is exactly same as your original. No modifications.)
|
||||||
|
|
||||||
Widget _sectionLabel(String title) => Column(
|
Widget _sectionLabel(String title) => Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
@ -299,9 +302,9 @@ class _AddEmployeeBottomSheetState extends State<AddEmployeeBottomSheet>
|
|||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: BorderRadius.circular(12),
|
||||||
borderSide: BorderSide(color: Colors.grey.shade300),
|
borderSide: BorderSide(color: Colors.grey.shade300),
|
||||||
),
|
),
|
||||||
focusedBorder: OutlineInputBorder(
|
focusedBorder: const OutlineInputBorder(
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: BorderRadius.vertical(top: Radius.circular(12)),
|
||||||
borderSide: const BorderSide(color: Colors.blueAccent, width: 1.5),
|
borderSide: BorderSide(color: Colors.blueAccent, width: 1.5),
|
||||||
),
|
),
|
||||||
contentPadding: MySpacing.all(16),
|
contentPadding: MySpacing.all(16),
|
||||||
);
|
);
|
||||||
@ -358,16 +361,15 @@ class _AddEmployeeBottomSheetState extends State<AddEmployeeBottomSheet>
|
|||||||
if (val == null || val.trim().isEmpty) {
|
if (val == null || val.trim().isEmpty) {
|
||||||
return 'Email is required for application users';
|
return 'Email is required for application users';
|
||||||
}
|
}
|
||||||
final email = val.trim();
|
|
||||||
if (!RegExp(r'^[\w\-\.]+@([\w\-]+\.)+[\w\-]{2,4}$')
|
if (!RegExp(r'^[\w\-\.]+@([\w\-]+\.)+[\w\-]{2,4}$')
|
||||||
.hasMatch(email)) {
|
.hasMatch(val.trim())) {
|
||||||
return 'Enter a valid email address';
|
return 'Enter a valid email address';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
keyboardType: TextInputType.emailAddress,
|
keyboardType: TextInputType.emailAddress,
|
||||||
decoration: _inputDecoration('e.g., john.doe@example.com').copyWith(),
|
decoration: _inputDecoration('e.g., john.doe@example.com'),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
@ -396,9 +398,8 @@ class _AddEmployeeBottomSheetState extends State<AddEmployeeBottomSheet>
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
decoration: _inputDecoration(hint).copyWith(
|
decoration: _inputDecoration(hint)
|
||||||
suffixIcon: const Icon(Icons.calendar_today),
|
.copyWith(suffixIcon: const Icon(Icons.calendar_today)),
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -429,9 +430,8 @@ class _AddEmployeeBottomSheetState extends State<AddEmployeeBottomSheet>
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
decoration: _inputDecoration(hint).copyWith(
|
decoration: _inputDecoration(hint)
|
||||||
suffixIcon: const Icon(Icons.expand_more),
|
.copyWith(suffixIcon: const Icon(Icons.expand_more)),
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -492,8 +492,6 @@ class _AddEmployeeBottomSheetState extends State<AddEmployeeBottomSheet>
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actions
|
|
||||||
|
|
||||||
Future<void> _pickJoiningDate(BuildContext context) async {
|
Future<void> _pickJoiningDate(BuildContext context) async {
|
||||||
final picked = await showDatePicker(
|
final picked = await showDatePicker(
|
||||||
context: context,
|
context: context,
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
import 'dart:async';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:on_field_work/helpers/utils/base_bottom_sheet.dart';
|
import 'package:on_field_work/helpers/utils/base_bottom_sheet.dart';
|
||||||
@ -24,33 +25,59 @@ class EmployeeSelectionBottomSheet extends StatefulWidget {
|
|||||||
class _EmployeeSelectionBottomSheetState
|
class _EmployeeSelectionBottomSheetState
|
||||||
extends State<EmployeeSelectionBottomSheet> {
|
extends State<EmployeeSelectionBottomSheet> {
|
||||||
final TextEditingController _searchController = TextEditingController();
|
final TextEditingController _searchController = TextEditingController();
|
||||||
|
|
||||||
final RxBool _isSearching = false.obs;
|
final RxBool _isSearching = false.obs;
|
||||||
final RxList<EmployeeModel> _searchResults = <EmployeeModel>[].obs;
|
final RxList<EmployeeModel> _allResults = <EmployeeModel>[].obs;
|
||||||
|
|
||||||
late RxList<EmployeeModel> _selectedEmployees;
|
late RxList<EmployeeModel> _selectedEmployees;
|
||||||
|
|
||||||
|
Timer? _debounce;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_selectedEmployees = RxList<EmployeeModel>.from(widget.initiallySelected);
|
_selectedEmployees = RxList<EmployeeModel>.from(widget.initiallySelected);
|
||||||
_searchEmployees('');
|
|
||||||
|
_performSearch('');
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
|
_debounce?.cancel();
|
||||||
_searchController.dispose();
|
_searchController.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _searchEmployees(String query) async {
|
// SEARCH WITH DEBOUNCE
|
||||||
|
void _onSearchChanged(String query) {
|
||||||
|
_debounce?.cancel();
|
||||||
|
_debounce = Timer(const Duration(milliseconds: 300), () {
|
||||||
|
_performSearch(query.trim());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _performSearch(String query) async {
|
||||||
_isSearching.value = true;
|
_isSearching.value = true;
|
||||||
|
|
||||||
final data = await ApiService.searchEmployeesBasic(searchString: query);
|
final data = await ApiService.searchEmployeesBasic(searchString: query);
|
||||||
|
|
||||||
final results = (data as List)
|
final results = (data as List)
|
||||||
.map((e) => EmployeeModel.fromJson(e as Map<String, dynamic>))
|
.map((e) => EmployeeModel.fromJson(e as Map<String, dynamic>))
|
||||||
.toList();
|
.toList();
|
||||||
_searchResults.assignAll(results);
|
|
||||||
|
// ------------------------------------------------------
|
||||||
|
// ❌ REMOVED "MOVE SELECTED TO TOP"
|
||||||
|
// ------------------------------------------------------
|
||||||
|
// Keeping alphabetical order only
|
||||||
|
results
|
||||||
|
.sort((a, b) => a.name.toLowerCase().compareTo(b.name.toLowerCase()));
|
||||||
|
|
||||||
|
_allResults.assignAll(results);
|
||||||
|
|
||||||
_isSearching.value = false;
|
_isSearching.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HANDLE TAP & CHECKBOX
|
||||||
void _toggleEmployee(EmployeeModel emp) {
|
void _toggleEmployee(EmployeeModel emp) {
|
||||||
if (widget.multipleSelection) {
|
if (widget.multipleSelection) {
|
||||||
if (_selectedEmployees.contains(emp)) {
|
if (_selectedEmployees.contains(emp)) {
|
||||||
@ -61,9 +88,12 @@ class _EmployeeSelectionBottomSheetState
|
|||||||
} else {
|
} else {
|
||||||
_selectedEmployees.assignAll([emp]);
|
_selectedEmployees.assignAll([emp]);
|
||||||
}
|
}
|
||||||
_selectedEmployees.refresh(); // important for Obx rebuild
|
|
||||||
|
// Refresh list but do NOT reorder selected
|
||||||
|
_performSearch(_searchController.text.trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SUBMIT SELECTION
|
||||||
void _handleSubmit() {
|
void _handleSubmit() {
|
||||||
if (widget.multipleSelection) {
|
if (widget.multipleSelection) {
|
||||||
Navigator.of(context).pop(_selectedEmployees.toList());
|
Navigator.of(context).pop(_selectedEmployees.toList());
|
||||||
@ -73,11 +103,12 @@ class _EmployeeSelectionBottomSheetState
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SEARCH BAR
|
||||||
Widget _searchBar() => Padding(
|
Widget _searchBar() => Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||||
child: TextField(
|
child: TextField(
|
||||||
controller: _searchController,
|
controller: _searchController,
|
||||||
onChanged: _searchEmployees,
|
onChanged: _onSearchChanged,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
hintText: 'Search employees...',
|
hintText: 'Search employees...',
|
||||||
filled: true,
|
filled: true,
|
||||||
@ -88,7 +119,7 @@ class _EmployeeSelectionBottomSheetState
|
|||||||
icon: const Icon(Icons.close, color: Colors.grey),
|
icon: const Icon(Icons.close, color: Colors.grey),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
_searchController.clear();
|
_searchController.clear();
|
||||||
_searchEmployees('');
|
_performSearch('');
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
: null,
|
: null,
|
||||||
@ -102,60 +133,58 @@ class _EmployeeSelectionBottomSheetState
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// EMPLOYEE LIST
|
||||||
Widget _employeeList() => Expanded(
|
Widget _employeeList() => Expanded(
|
||||||
child: Obx(() {
|
child: Obx(() {
|
||||||
if (_isSearching.value) {
|
final results = _allResults;
|
||||||
return const Center(child: CircularProgressIndicator());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_searchResults.isEmpty) {
|
|
||||||
return const Center(child: Text("No employees found"));
|
|
||||||
}
|
|
||||||
|
|
||||||
return ListView.builder(
|
return ListView.builder(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 4),
|
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||||
itemCount: _searchResults.length,
|
itemCount: results.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final emp = _searchResults[index];
|
final emp = results[index];
|
||||||
|
final isSelected = _selectedEmployees.contains(emp);
|
||||||
|
|
||||||
return Obx(() {
|
Widget trailingWidget;
|
||||||
final isSelected = _selectedEmployees.contains(emp);
|
|
||||||
return ListTile(
|
if (widget.multipleSelection) {
|
||||||
leading: CircleAvatar(
|
trailingWidget = Checkbox(
|
||||||
backgroundColor: Colors.blueAccent,
|
value: isSelected,
|
||||||
child: Text(
|
onChanged: (_) => _toggleEmployee(emp),
|
||||||
(emp.firstName.isNotEmpty ? emp.firstName[0] : 'U')
|
fillColor: MaterialStateProperty.resolveWith<Color>(
|
||||||
.toUpperCase(),
|
(states) => states.contains(MaterialState.selected)
|
||||||
style: const TextStyle(color: Colors.white),
|
? Colors.blueAccent
|
||||||
),
|
: Colors.white,
|
||||||
),
|
),
|
||||||
title: Text('${emp.firstName} ${emp.lastName}'),
|
|
||||||
subtitle: Text(emp.email),
|
|
||||||
trailing: Checkbox(
|
|
||||||
value: isSelected,
|
|
||||||
onChanged: (_) {
|
|
||||||
FocusScope.of(context).unfocus(); // hide keyboard
|
|
||||||
_toggleEmployee(emp);
|
|
||||||
},
|
|
||||||
fillColor: MaterialStateProperty.resolveWith<Color>(
|
|
||||||
(states) => states.contains(MaterialState.selected)
|
|
||||||
? Colors.blueAccent
|
|
||||||
: Colors.white,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onTap: () {
|
|
||||||
FocusScope.of(context).unfocus();
|
|
||||||
_toggleEmployee(emp);
|
|
||||||
},
|
|
||||||
contentPadding:
|
|
||||||
const EdgeInsets.symmetric(horizontal: 0, vertical: 4),
|
|
||||||
);
|
);
|
||||||
});
|
} else {
|
||||||
|
trailingWidget = isSelected
|
||||||
|
? const Icon(Icons.check_circle, color: Colors.blueAccent)
|
||||||
|
: const Icon(Icons.circle_outlined, color: Colors.grey);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ListTile(
|
||||||
|
leading: CircleAvatar(
|
||||||
|
backgroundColor: Colors.blueAccent,
|
||||||
|
child: Text(
|
||||||
|
(emp.firstName.isNotEmpty ? emp.firstName[0] : 'U')
|
||||||
|
.toUpperCase(),
|
||||||
|
style: const TextStyle(color: Colors.white),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
title: Text('${emp.firstName} ${emp.lastName}'),
|
||||||
|
subtitle: Text(emp.email),
|
||||||
|
trailing: trailingWidget,
|
||||||
|
onTap: () => _toggleEmployee(emp),
|
||||||
|
contentPadding:
|
||||||
|
const EdgeInsets.symmetric(horizontal: 0, vertical: 4),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// BUILD BOTTOM SHEET
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BaseBottomSheet(
|
return BaseBottomSheet(
|
||||||
@ -164,10 +193,12 @@ class _EmployeeSelectionBottomSheetState
|
|||||||
onSubmit: _handleSubmit,
|
onSubmit: _handleSubmit,
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
height: MediaQuery.of(context).size.height * 0.7,
|
height: MediaQuery.of(context).size.height * 0.7,
|
||||||
child: Column(children: [
|
child: Column(
|
||||||
_searchBar(),
|
children: [
|
||||||
_employeeList(),
|
_searchBar(),
|
||||||
]),
|
_employeeList(),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
202
lib/model/employees/multiple_select_role_bottomsheet.dart
Normal file
202
lib/model/employees/multiple_select_role_bottomsheet.dart
Normal file
@ -0,0 +1,202 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
import 'package:on_field_work/helpers/utils/base_bottom_sheet.dart';
|
||||||
|
import 'package:on_field_work/helpers/widgets/my_custom_skeleton.dart';
|
||||||
|
import 'package:on_field_work/model/employees/employee_model.dart';
|
||||||
|
import 'package:on_field_work/controller/task_Planning/daily_task_Planning_controller.dart';
|
||||||
|
|
||||||
|
class MultipleSelectRoleBottomSheet extends StatefulWidget {
|
||||||
|
final String title;
|
||||||
|
final bool multipleSelection;
|
||||||
|
|
||||||
|
final String projectId;
|
||||||
|
final String? serviceId;
|
||||||
|
final String? organizationId;
|
||||||
|
final String? roleId;
|
||||||
|
final ScrollController? scrollController;
|
||||||
|
|
||||||
|
final List<EmployeeModel> initiallySelected;
|
||||||
|
|
||||||
|
const MultipleSelectRoleBottomSheet({
|
||||||
|
super.key,
|
||||||
|
this.title = "Select Employees",
|
||||||
|
this.multipleSelection = true,
|
||||||
|
required this.projectId,
|
||||||
|
this.serviceId,
|
||||||
|
this.organizationId,
|
||||||
|
this.roleId,
|
||||||
|
this.initiallySelected = const [],
|
||||||
|
this.scrollController,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<MultipleSelectRoleBottomSheet> createState() =>
|
||||||
|
_MultipleSelectRoleBottomSheetState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MultipleSelectRoleBottomSheetState
|
||||||
|
extends State<MultipleSelectRoleBottomSheet> {
|
||||||
|
final RxList<EmployeeModel> _employees = <EmployeeModel>[].obs;
|
||||||
|
final RxList<EmployeeModel> _filtered = <EmployeeModel>[].obs;
|
||||||
|
final RxBool _isLoading = true.obs;
|
||||||
|
|
||||||
|
late RxList<EmployeeModel> _selected;
|
||||||
|
final TextEditingController _searchController = TextEditingController();
|
||||||
|
|
||||||
|
late DailyTaskPlanningController controller;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_selected = widget.initiallySelected.obs;
|
||||||
|
controller = Get.find<DailyTaskPlanningController>();
|
||||||
|
_fetchEmployeesFiltered();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _fetchEmployeesFiltered() async {
|
||||||
|
_isLoading.value = true;
|
||||||
|
try {
|
||||||
|
List<EmployeeModel> employees = controller.employees.toList();
|
||||||
|
|
||||||
|
if (widget.roleId != null && widget.roleId!.isNotEmpty) {
|
||||||
|
employees =
|
||||||
|
employees.where((emp) => emp.jobRoleID == widget.roleId).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
_employees.assignAll(employees);
|
||||||
|
_filtered.assignAll(employees);
|
||||||
|
} catch (e) {
|
||||||
|
print("Error fetching employees: $e");
|
||||||
|
} finally {
|
||||||
|
_isLoading.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _onSearch(String text) {
|
||||||
|
if (text.isEmpty) {
|
||||||
|
_filtered.assignAll(_employees);
|
||||||
|
} else {
|
||||||
|
_filtered.assignAll(
|
||||||
|
_employees.where((e) =>
|
||||||
|
e.name.toLowerCase().contains(text.toLowerCase()) ||
|
||||||
|
e.designation.toLowerCase().contains(text.toLowerCase())),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _onTap(EmployeeModel emp) {
|
||||||
|
if (widget.multipleSelection) {
|
||||||
|
if (_selected.any((e) => e.id == emp.id)) {
|
||||||
|
_selected.removeWhere((e) => e.id == emp.id);
|
||||||
|
} else {
|
||||||
|
_selected.add(emp);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Single selection → return immediately
|
||||||
|
Get.back(result: [emp]);
|
||||||
|
}
|
||||||
|
|
||||||
|
_onSearch(_searchController.text.trim());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool _isSelected(EmployeeModel emp) {
|
||||||
|
return _selected.any((e) => e.id == emp.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _searchBar() => Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||||
|
child: TextField(
|
||||||
|
controller: _searchController,
|
||||||
|
onChanged: _onSearch,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: 'Search employees...',
|
||||||
|
filled: true,
|
||||||
|
fillColor: Colors.grey.shade100,
|
||||||
|
prefixIcon: const Icon(Icons.search, color: Colors.grey),
|
||||||
|
suffixIcon: _searchController.text.isNotEmpty
|
||||||
|
? IconButton(
|
||||||
|
icon: const Icon(Icons.close, color: Colors.grey),
|
||||||
|
onPressed: () {
|
||||||
|
_searchController.clear();
|
||||||
|
_onSearch('');
|
||||||
|
},
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
contentPadding:
|
||||||
|
const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
|
||||||
|
border: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(30),
|
||||||
|
borderSide: BorderSide.none,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return BaseBottomSheet(
|
||||||
|
title: widget.title,
|
||||||
|
onCancel: () => Get.back(),
|
||||||
|
onSubmit: () => Get.back(result: _selected.toList()), // Return plain list
|
||||||
|
child: SizedBox(
|
||||||
|
height: MediaQuery.of(context).size.height * 0.55,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
_searchBar(),
|
||||||
|
Expanded(
|
||||||
|
child: Obx(() {
|
||||||
|
if (_isLoading.value) {
|
||||||
|
return SkeletonLoaders.employeeSkeletonCard();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_filtered.isEmpty) {
|
||||||
|
return const Center(child: Text("No employees found"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return ListView.builder(
|
||||||
|
controller: widget.scrollController,
|
||||||
|
padding: const EdgeInsets.only(bottom: 20),
|
||||||
|
itemCount: _filtered.length,
|
||||||
|
itemBuilder: (_, index) {
|
||||||
|
final emp = _filtered[index];
|
||||||
|
final isSelected = _isSelected(emp);
|
||||||
|
|
||||||
|
return ListTile(
|
||||||
|
onTap: () => _onTap(emp),
|
||||||
|
leading: CircleAvatar(
|
||||||
|
backgroundColor: Colors.blueAccent,
|
||||||
|
child: Text(
|
||||||
|
emp.name.isNotEmpty ? emp.name[0].toUpperCase() : "?",
|
||||||
|
style: const TextStyle(color: Colors.white),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
title: Text(emp.name),
|
||||||
|
subtitle: Text(emp.designation),
|
||||||
|
trailing: Checkbox(
|
||||||
|
value: isSelected,
|
||||||
|
onChanged: (_) => _onTap(emp),
|
||||||
|
fillColor:
|
||||||
|
MaterialStateProperty.resolveWith<Color>((states) {
|
||||||
|
if (states.contains(MaterialState.selected)) {
|
||||||
|
return Colors.blueAccent;
|
||||||
|
}
|
||||||
|
return Colors.white;
|
||||||
|
}),
|
||||||
|
checkColor: Colors.white,
|
||||||
|
side: const BorderSide(color: Colors.grey),
|
||||||
|
),
|
||||||
|
contentPadding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 4,
|
||||||
|
vertical: 6,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,3 +1,6 @@
|
|||||||
|
/// UPDATED — SafeArea + proper bottom padding added
|
||||||
|
/// No other functionality modified.
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
@ -5,15 +8,15 @@ import 'package:on_field_work/controller/expense/add_expense_controller.dart';
|
|||||||
import 'package:on_field_work/helpers/utils/mixins/ui_mixin.dart';
|
import 'package:on_field_work/helpers/utils/mixins/ui_mixin.dart';
|
||||||
import 'package:on_field_work/model/expense/expense_type_model.dart';
|
import 'package:on_field_work/model/expense/expense_type_model.dart';
|
||||||
import 'package:on_field_work/model/expense/payment_types_model.dart';
|
import 'package:on_field_work/model/expense/payment_types_model.dart';
|
||||||
import 'package:on_field_work/model/expense/employee_selector_bottom_sheet.dart';
|
|
||||||
import 'package:on_field_work/helpers/utils/base_bottom_sheet.dart';
|
import 'package:on_field_work/helpers/utils/base_bottom_sheet.dart';
|
||||||
import 'package:on_field_work/helpers/utils/validators.dart';
|
import 'package:on_field_work/helpers/utils/validators.dart';
|
||||||
import 'package:on_field_work/helpers/widgets/my_spacing.dart';
|
import 'package:on_field_work/helpers/widgets/my_spacing.dart';
|
||||||
import 'package:on_field_work/helpers/widgets/my_snackbar.dart';
|
import 'package:on_field_work/helpers/widgets/my_snackbar.dart';
|
||||||
import 'package:on_field_work/helpers/widgets/my_confirmation_dialog.dart';
|
import 'package:on_field_work/helpers/widgets/my_confirmation_dialog.dart';
|
||||||
import 'package:on_field_work/helpers/widgets/expense/expense_form_widgets.dart';
|
import 'package:on_field_work/helpers/widgets/expense/expense_form_widgets.dart';
|
||||||
|
import 'package:on_field_work/model/employees/employee_model.dart';
|
||||||
|
import 'package:on_field_work/model/employees/multiple_select_bottomsheet.dart';
|
||||||
|
|
||||||
/// Show bottom sheet wrapper
|
|
||||||
Future<T?> showAddExpenseBottomSheet<T>({
|
Future<T?> showAddExpenseBottomSheet<T>({
|
||||||
bool isEdit = false,
|
bool isEdit = false,
|
||||||
Map<String, dynamic>? existingExpense,
|
Map<String, dynamic>? existingExpense,
|
||||||
@ -27,7 +30,6 @@ Future<T?> showAddExpenseBottomSheet<T>({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Bottom sheet widget
|
|
||||||
class _AddExpenseBottomSheet extends StatefulWidget {
|
class _AddExpenseBottomSheet extends StatefulWidget {
|
||||||
final bool isEdit;
|
final bool isEdit;
|
||||||
final Map<String, dynamic>? existingExpense;
|
final Map<String, dynamic>? existingExpense;
|
||||||
@ -50,47 +52,55 @@ class _AddExpenseBottomSheetState extends State<_AddExpenseBottomSheet>
|
|||||||
final GlobalKey _expenseTypeDropdownKey = GlobalKey();
|
final GlobalKey _expenseTypeDropdownKey = GlobalKey();
|
||||||
final GlobalKey _paymentModeDropdownKey = GlobalKey();
|
final GlobalKey _paymentModeDropdownKey = GlobalKey();
|
||||||
|
|
||||||
/// Show employee list
|
|
||||||
Future<void> _showEmployeeList() async {
|
Future<void> _showEmployeeList() async {
|
||||||
await showModalBottomSheet(
|
final result = await showModalBottomSheet<dynamic>(
|
||||||
context: context,
|
context: context,
|
||||||
isScrollControlled: true,
|
isScrollControlled: true,
|
||||||
backgroundColor: Colors.transparent,
|
backgroundColor: Colors.transparent,
|
||||||
shape: const RoundedRectangleBorder(
|
shape: const RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.vertical(top: Radius.circular(16)),
|
borderRadius: BorderRadius.vertical(top: Radius.circular(16)),
|
||||||
),
|
),
|
||||||
builder: (_) => ReusableEmployeeSelectorBottomSheet(
|
builder: (_) => EmployeeSelectionBottomSheet(
|
||||||
searchController: controller.employeeSearchController,
|
initiallySelected: controller.selectedPaidBy.value != null
|
||||||
searchResults: controller.employeeSearchResults,
|
? [controller.selectedPaidBy.value!]
|
||||||
isSearching: controller.isSearchingEmployees,
|
: [],
|
||||||
onSearch: controller.searchEmployees,
|
multipleSelection: false,
|
||||||
onSelect: (emp) => controller.selectedPaidBy.value = emp,
|
title: "Select Paid By",
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
controller.employeeSearchController.clear();
|
if (result == null) return;
|
||||||
controller.employeeSearchResults.clear();
|
|
||||||
|
if (result is EmployeeModel) {
|
||||||
|
controller.setSelectedPaidBy(result);
|
||||||
|
} else if (result is List && result.isNotEmpty) {
|
||||||
|
controller.setSelectedPaidBy(result.first as EmployeeModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
controller.employeeSearchController.clear();
|
||||||
|
controller.employeeSearchResults.clear();
|
||||||
|
} catch (_) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Generic option list
|
|
||||||
Future<void> _showOptionList<T>(
|
Future<void> _showOptionList<T>(
|
||||||
List<T> options,
|
List<T> options,
|
||||||
String Function(T) getLabel,
|
String Function(T) getLabel,
|
||||||
ValueChanged<T> onSelected,
|
ValueChanged<T> onSelected,
|
||||||
GlobalKey triggerKey,
|
GlobalKey triggerKey,
|
||||||
) async {
|
) async {
|
||||||
final RenderBox button =
|
final RenderBox btn =
|
||||||
triggerKey.currentContext!.findRenderObject() as RenderBox;
|
triggerKey.currentContext!.findRenderObject() as RenderBox;
|
||||||
final RenderBox overlay =
|
final RenderBox overlay =
|
||||||
Overlay.of(context).context.findRenderObject() as RenderBox;
|
Overlay.of(context).context.findRenderObject() as RenderBox;
|
||||||
final position = button.localToGlobal(Offset.zero, ancestor: overlay);
|
final pos = btn.localToGlobal(Offset.zero, ancestor: overlay);
|
||||||
|
|
||||||
final selected = await showMenu<T>(
|
final selected = await showMenu<T>(
|
||||||
context: context,
|
context: context,
|
||||||
position: RelativeRect.fromLTRB(
|
position: RelativeRect.fromLTRB(
|
||||||
position.dx,
|
pos.dx,
|
||||||
position.dy + button.size.height,
|
pos.dy + btn.size.height,
|
||||||
overlay.size.width - position.dx - button.size.width,
|
overlay.size.width - pos.dx - btn.size.width,
|
||||||
0,
|
0,
|
||||||
),
|
),
|
||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
|
||||||
@ -105,7 +115,6 @@ class _AddExpenseBottomSheetState extends State<_AddExpenseBottomSheet>
|
|||||||
if (selected != null) onSelected(selected);
|
if (selected != null) onSelected(selected);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Validate required selections
|
|
||||||
bool _validateSelections() {
|
bool _validateSelections() {
|
||||||
if (controller.selectedProject.value.isEmpty) {
|
if (controller.selectedProject.value.isEmpty) {
|
||||||
_showError("Please select a project");
|
_showError("Please select a project");
|
||||||
@ -141,148 +150,142 @@ class _AddExpenseBottomSheetState extends State<_AddExpenseBottomSheet>
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final bottomInset = MediaQuery.of(context).viewPadding.bottom;
|
||||||
|
|
||||||
return Obx(
|
return Obx(
|
||||||
() => Form(
|
() => Form(
|
||||||
key: _formKey,
|
key: _formKey,
|
||||||
child: BaseBottomSheet(
|
child: SafeArea(
|
||||||
title: widget.isEdit ? "Edit Expense" : "Add Expense",
|
bottom: true,
|
||||||
isSubmitting: controller.isSubmitting.value,
|
child: BaseBottomSheet(
|
||||||
onCancel: Get.back,
|
title: widget.isEdit ? "Edit Expense" : "Add Expense",
|
||||||
onSubmit: () {
|
isSubmitting: controller.isSubmitting.value,
|
||||||
if (_formKey.currentState!.validate() && _validateSelections()) {
|
onCancel: Get.back,
|
||||||
controller.submitOrUpdateExpense();
|
onSubmit: () {
|
||||||
} else {
|
if (_formKey.currentState!.validate() && _validateSelections()) {
|
||||||
_showError("Please fill all required fields correctly");
|
controller.submitOrUpdateExpense();
|
||||||
}
|
} else {
|
||||||
},
|
_showError("Please fill all required fields correctly");
|
||||||
child: SingleChildScrollView(
|
}
|
||||||
child: Column(
|
},
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
child: SingleChildScrollView(
|
||||||
children: [
|
padding: EdgeInsets.only(bottom: bottomInset + 24),
|
||||||
_buildDropdownField<String>(
|
child: Column(
|
||||||
icon: Icons.work_outline,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
title: "Project",
|
children: [
|
||||||
requiredField: true,
|
_buildDropdownField<String>(
|
||||||
value: controller.selectedProject.value.isEmpty
|
icon: Icons.work_outline,
|
||||||
? "Select Project"
|
title: "Project",
|
||||||
: controller.selectedProject.value,
|
requiredField: true,
|
||||||
onTap: () => _showOptionList<String>(
|
value: controller.selectedProject.value.isEmpty
|
||||||
controller.globalProjects.toList(),
|
? "Select Project"
|
||||||
(p) => p,
|
: controller.selectedProject.value,
|
||||||
(val) => controller.selectedProject.value = val,
|
onTap: () => _showOptionList<String>(
|
||||||
_projectDropdownKey,
|
controller.globalProjects.toList(),
|
||||||
|
(p) => p,
|
||||||
|
(val) => controller.selectedProject.value = val,
|
||||||
|
_projectDropdownKey,
|
||||||
|
),
|
||||||
|
dropdownKey: _projectDropdownKey,
|
||||||
),
|
),
|
||||||
dropdownKey: _projectDropdownKey,
|
_gap(),
|
||||||
),
|
_buildDropdownField<ExpenseTypeModel>(
|
||||||
_gap(),
|
icon: Icons.category_outlined,
|
||||||
|
title: "Expense Category",
|
||||||
_buildDropdownField<ExpenseTypeModel>(
|
requiredField: true,
|
||||||
icon: Icons.category_outlined,
|
value: controller.selectedExpenseType.value?.name ??
|
||||||
title: "Expense Category",
|
"Select Expense Category",
|
||||||
requiredField: true,
|
onTap: () => _showOptionList<ExpenseTypeModel>(
|
||||||
value: controller.selectedExpenseType.value?.name ??
|
controller.expenseTypes.toList(),
|
||||||
"Select Expense Category",
|
(e) => e.name,
|
||||||
onTap: () => _showOptionList<ExpenseTypeModel>(
|
(val) => controller.selectedExpenseType.value = val,
|
||||||
controller.expenseTypes.toList(),
|
_expenseTypeDropdownKey,
|
||||||
(e) => e.name,
|
),
|
||||||
(val) => controller.selectedExpenseType.value = val,
|
dropdownKey: _expenseTypeDropdownKey,
|
||||||
_expenseTypeDropdownKey,
|
|
||||||
),
|
),
|
||||||
dropdownKey: _expenseTypeDropdownKey,
|
if (controller
|
||||||
),
|
.selectedExpenseType.value?.noOfPersonsRequired ==
|
||||||
|
true) ...[
|
||||||
// Persons if required
|
_gap(),
|
||||||
if (controller.selectedExpenseType.value?.noOfPersonsRequired ==
|
_buildTextFieldSection(
|
||||||
true) ...[
|
icon: Icons.people_outline,
|
||||||
|
title: "No. of Persons",
|
||||||
|
controller: controller.noOfPersonsController,
|
||||||
|
hint: "Enter No. of Persons",
|
||||||
|
keyboardType: TextInputType.number,
|
||||||
|
validator: Validators.requiredField,
|
||||||
|
),
|
||||||
|
],
|
||||||
_gap(),
|
_gap(),
|
||||||
_buildTextFieldSection(
|
_buildTextFieldSection(
|
||||||
icon: Icons.people_outline,
|
icon: Icons.confirmation_number_outlined,
|
||||||
title: "No. of Persons",
|
title: "GST No.",
|
||||||
controller: controller.noOfPersonsController,
|
controller: controller.gstController,
|
||||||
hint: "Enter No. of Persons",
|
hint: "Enter GST No.",
|
||||||
|
),
|
||||||
|
_gap(),
|
||||||
|
_buildDropdownField<PaymentModeModel>(
|
||||||
|
icon: Icons.payment,
|
||||||
|
title: "Payment Mode",
|
||||||
|
requiredField: true,
|
||||||
|
value: controller.selectedPaymentMode.value?.name ??
|
||||||
|
"Select Payment Mode",
|
||||||
|
onTap: () => _showOptionList<PaymentModeModel>(
|
||||||
|
controller.paymentModes.toList(),
|
||||||
|
(p) => p.name,
|
||||||
|
(val) => controller.selectedPaymentMode.value = val,
|
||||||
|
_paymentModeDropdownKey,
|
||||||
|
),
|
||||||
|
dropdownKey: _paymentModeDropdownKey,
|
||||||
|
),
|
||||||
|
_gap(),
|
||||||
|
_buildPaidBySection(),
|
||||||
|
_gap(),
|
||||||
|
_buildTextFieldSection(
|
||||||
|
icon: Icons.currency_rupee,
|
||||||
|
title: "Amount",
|
||||||
|
controller: controller.amountController,
|
||||||
|
hint: "Enter Amount",
|
||||||
keyboardType: TextInputType.number,
|
keyboardType: TextInputType.number,
|
||||||
|
validator: (v) => Validators.isNumeric(v ?? "")
|
||||||
|
? null
|
||||||
|
: "Enter valid amount",
|
||||||
|
),
|
||||||
|
_gap(),
|
||||||
|
_buildTextFieldSection(
|
||||||
|
icon: Icons.store_mall_directory_outlined,
|
||||||
|
title: "Supplier Name/Transporter Name/Other",
|
||||||
|
controller: controller.supplierController,
|
||||||
|
hint: "Enter Supplier Name/Transporter Name or Other",
|
||||||
|
validator: Validators.nameValidator,
|
||||||
|
),
|
||||||
|
_gap(),
|
||||||
|
_buildTextFieldSection(
|
||||||
|
icon: Icons.confirmation_number_outlined,
|
||||||
|
title: "Transaction ID",
|
||||||
|
controller: controller.transactionIdController,
|
||||||
|
hint: "Enter Transaction ID",
|
||||||
|
validator: (v) => (v != null && v.isNotEmpty)
|
||||||
|
? Validators.transactionIdValidator(v)
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
_gap(),
|
||||||
|
_buildTransactionDateField(),
|
||||||
|
_gap(),
|
||||||
|
_buildLocationField(),
|
||||||
|
_gap(),
|
||||||
|
_buildAttachmentsSection(),
|
||||||
|
_gap(),
|
||||||
|
_buildTextFieldSection(
|
||||||
|
icon: Icons.description_outlined,
|
||||||
|
title: "Description",
|
||||||
|
controller: controller.descriptionController,
|
||||||
|
hint: "Enter Description",
|
||||||
|
maxLines: 3,
|
||||||
validator: Validators.requiredField,
|
validator: Validators.requiredField,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
_gap(),
|
),
|
||||||
|
|
||||||
_buildTextFieldSection(
|
|
||||||
icon: Icons.confirmation_number_outlined,
|
|
||||||
title: "GST No.",
|
|
||||||
controller: controller.gstController,
|
|
||||||
hint: "Enter GST No.",
|
|
||||||
),
|
|
||||||
_gap(),
|
|
||||||
|
|
||||||
_buildDropdownField<PaymentModeModel>(
|
|
||||||
icon: Icons.payment,
|
|
||||||
title: "Payment Mode",
|
|
||||||
requiredField: true,
|
|
||||||
value: controller.selectedPaymentMode.value?.name ??
|
|
||||||
"Select Payment Mode",
|
|
||||||
onTap: () => _showOptionList<PaymentModeModel>(
|
|
||||||
controller.paymentModes.toList(),
|
|
||||||
(p) => p.name,
|
|
||||||
(val) => controller.selectedPaymentMode.value = val,
|
|
||||||
_paymentModeDropdownKey,
|
|
||||||
),
|
|
||||||
dropdownKey: _paymentModeDropdownKey,
|
|
||||||
),
|
|
||||||
_gap(),
|
|
||||||
|
|
||||||
_buildPaidBySection(),
|
|
||||||
_gap(),
|
|
||||||
|
|
||||||
_buildTextFieldSection(
|
|
||||||
icon: Icons.currency_rupee,
|
|
||||||
title: "Amount",
|
|
||||||
controller: controller.amountController,
|
|
||||||
hint: "Enter Amount",
|
|
||||||
keyboardType: TextInputType.number,
|
|
||||||
validator: (v) => Validators.isNumeric(v ?? "")
|
|
||||||
? null
|
|
||||||
: "Enter valid amount",
|
|
||||||
),
|
|
||||||
_gap(),
|
|
||||||
|
|
||||||
_buildTextFieldSection(
|
|
||||||
icon: Icons.store_mall_directory_outlined,
|
|
||||||
title: "Supplier Name/Transporter Name/Other",
|
|
||||||
controller: controller.supplierController,
|
|
||||||
hint: "Enter Supplier Name/Transporter Name or Other",
|
|
||||||
validator: Validators.nameValidator,
|
|
||||||
),
|
|
||||||
_gap(),
|
|
||||||
|
|
||||||
_buildTextFieldSection(
|
|
||||||
icon: Icons.confirmation_number_outlined,
|
|
||||||
title: "Transaction ID",
|
|
||||||
controller: controller.transactionIdController,
|
|
||||||
hint: "Enter Transaction ID",
|
|
||||||
validator: (v) => (v != null && v.isNotEmpty)
|
|
||||||
? Validators.transactionIdValidator(v)
|
|
||||||
: null,
|
|
||||||
),
|
|
||||||
_gap(),
|
|
||||||
|
|
||||||
_buildTransactionDateField(),
|
|
||||||
_gap(),
|
|
||||||
|
|
||||||
_buildLocationField(),
|
|
||||||
_gap(),
|
|
||||||
|
|
||||||
_buildAttachmentsSection(),
|
|
||||||
_gap(),
|
|
||||||
|
|
||||||
_buildTextFieldSection(
|
|
||||||
icon: Icons.description_outlined,
|
|
||||||
title: "Description",
|
|
||||||
controller: controller.descriptionController,
|
|
||||||
hint: "Enter Description",
|
|
||||||
maxLines: 3,
|
|
||||||
validator: Validators.requiredField,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -349,11 +352,12 @@ class _AddExpenseBottomSheetState extends State<_AddExpenseBottomSheet>
|
|||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Expanded(
|
||||||
controller.selectedPaidBy.value == null
|
child: Text(
|
||||||
? "Select Paid By"
|
controller.selectedPaidBy.value?.name ?? "Select Paid By",
|
||||||
: '${controller.selectedPaidBy.value?.firstName ?? ''} ${controller.selectedPaidBy.value?.lastName ?? ''}',
|
style: const TextStyle(fontSize: 15),
|
||||||
style: const TextStyle(fontSize: 14),
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
const Icon(Icons.arrow_drop_down, size: 22),
|
const Icon(Icons.arrow_drop_down, size: 22),
|
||||||
],
|
],
|
||||||
@ -399,7 +403,9 @@ class _AddExpenseBottomSheetState extends State<_AddExpenseBottomSheet>
|
|||||||
hintText: "Enter Location",
|
hintText: "Enter Location",
|
||||||
filled: true,
|
filled: true,
|
||||||
fillColor: Colors.grey.shade100,
|
fillColor: Colors.grey.shade100,
|
||||||
border: OutlineInputBorder(borderRadius: BorderRadius.circular(8)),
|
border: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
),
|
||||||
contentPadding:
|
contentPadding:
|
||||||
const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
|
const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
|
||||||
suffixIcon: controller.isFetchingLocation.value
|
suffixIcon: controller.isFetchingLocation.value
|
||||||
@ -413,7 +419,6 @@ class _AddExpenseBottomSheetState extends State<_AddExpenseBottomSheet>
|
|||||||
)
|
)
|
||||||
: IconButton(
|
: IconButton(
|
||||||
icon: const Icon(Icons.my_location),
|
icon: const Icon(Icons.my_location),
|
||||||
tooltip: "Use Current Location",
|
|
||||||
onPressed: controller.fetchCurrentLocation,
|
onPressed: controller.fetchCurrentLocation,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -9,6 +9,8 @@ import 'package:on_field_work/helpers/widgets/my_spacing.dart';
|
|||||||
import 'package:on_field_work/helpers/widgets/my_snackbar.dart';
|
import 'package:on_field_work/helpers/widgets/my_snackbar.dart';
|
||||||
import 'package:on_field_work/helpers/widgets/expense/expense_form_widgets.dart';
|
import 'package:on_field_work/helpers/widgets/expense/expense_form_widgets.dart';
|
||||||
import 'package:on_field_work/helpers/widgets/my_confirmation_dialog.dart';
|
import 'package:on_field_work/helpers/widgets/my_confirmation_dialog.dart';
|
||||||
|
import 'package:on_field_work/model/employees/multiple_select_bottomsheet.dart';
|
||||||
|
import 'package:on_field_work/model/employees/employee_model.dart';
|
||||||
|
|
||||||
Future<T?> showPaymentRequestBottomSheet<T>({
|
Future<T?> showPaymentRequestBottomSheet<T>({
|
||||||
bool isEdit = false,
|
bool isEdit = false,
|
||||||
@ -58,12 +60,10 @@ class _PaymentRequestBottomSheetState extends State<_PaymentRequestBottomSheet>
|
|||||||
if (widget.isEdit && widget.existingData != null) {
|
if (widget.isEdit && widget.existingData != null) {
|
||||||
final data = widget.existingData!;
|
final data = widget.existingData!;
|
||||||
|
|
||||||
// Prefill text fields
|
|
||||||
controller.titleController.text = data["title"] ?? "";
|
controller.titleController.text = data["title"] ?? "";
|
||||||
controller.amountController.text = data["amount"]?.toString() ?? "";
|
controller.amountController.text = data["amount"]?.toString() ?? "";
|
||||||
controller.descriptionController.text = data["description"] ?? "";
|
controller.descriptionController.text = data["description"] ?? "";
|
||||||
|
|
||||||
// Prefill due date
|
|
||||||
if (data["dueDate"] != null && data["dueDate"].toString().isNotEmpty) {
|
if (data["dueDate"] != null && data["dueDate"].toString().isNotEmpty) {
|
||||||
DateTime? dueDate = DateTime.tryParse(data["dueDate"].toString());
|
DateTime? dueDate = DateTime.tryParse(data["dueDate"].toString());
|
||||||
if (dueDate != null) {
|
if (dueDate != null) {
|
||||||
@ -73,15 +73,15 @@ class _PaymentRequestBottomSheetState extends State<_PaymentRequestBottomSheet>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prefill dropdowns & toggles
|
|
||||||
controller.selectedProject.value = {
|
controller.selectedProject.value = {
|
||||||
'id': data["projectId"],
|
'id': data["projectId"],
|
||||||
'name': data["projectName"],
|
'name': data["projectName"],
|
||||||
};
|
};
|
||||||
|
|
||||||
controller.selectedPayee.value = data["payee"] ?? "";
|
controller.selectedPayee.value = data["payee"] ?? "";
|
||||||
controller.isAdvancePayment.value = data["isAdvancePayment"] ?? false;
|
controller.isAdvancePayment.value = data["isAdvancePayment"] ?? false;
|
||||||
|
|
||||||
// Categories & currencies
|
// When categories and currencies load, set selected ones
|
||||||
everAll([controller.categories, controller.currencies], (_) {
|
everAll([controller.categories, controller.currencies], (_) {
|
||||||
controller.selectedCategory.value = controller.categories
|
controller.selectedCategory.value = controller.categories
|
||||||
.firstWhereOrNull((c) => c.id == data["expenseCategoryId"]);
|
.firstWhereOrNull((c) => c.id == data["expenseCategoryId"]);
|
||||||
@ -89,7 +89,6 @@ class _PaymentRequestBottomSheetState extends State<_PaymentRequestBottomSheet>
|
|||||||
.firstWhereOrNull((c) => c.id == data["currencyId"]);
|
.firstWhereOrNull((c) => c.id == data["currencyId"]);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Attachments
|
|
||||||
final attachmentsData = data["attachments"];
|
final attachmentsData = data["attachments"];
|
||||||
if (attachmentsData != null &&
|
if (attachmentsData != null &&
|
||||||
attachmentsData is List &&
|
attachmentsData is List &&
|
||||||
@ -116,21 +115,21 @@ class _PaymentRequestBottomSheetState extends State<_PaymentRequestBottomSheet>
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Obx(() => Form(
|
return Obx(
|
||||||
|
() => SafeArea(
|
||||||
|
child: Form(
|
||||||
key: _formKey,
|
key: _formKey,
|
||||||
child: BaseBottomSheet(
|
child: BaseBottomSheet(
|
||||||
title: widget.isEdit
|
title: widget.isEdit ? "Edit Payment Request" : "Create Payment Request",
|
||||||
? "Edit Payment Request"
|
|
||||||
: "Create Payment Request",
|
|
||||||
isSubmitting: controller.isSubmitting.value,
|
isSubmitting: controller.isSubmitting.value,
|
||||||
onCancel: Get.back,
|
onCancel: Get.back,
|
||||||
submitText: "Save as Draft",
|
submitText: "Save as Draft",
|
||||||
onSubmit: () async {
|
onSubmit: () async {
|
||||||
if (_formKey.currentState!.validate() && _validateSelections()) {
|
if (_formKey.currentState!.validate() && _validateSelections()) {
|
||||||
bool success = false;
|
bool success = false;
|
||||||
|
|
||||||
if (widget.isEdit && widget.existingData != null) {
|
if (widget.isEdit && widget.existingData != null) {
|
||||||
final requestId =
|
final requestId = widget.existingData!['id']?.toString() ?? '';
|
||||||
widget.existingData!['id']?.toString() ?? '';
|
|
||||||
if (requestId.isNotEmpty) {
|
if (requestId.isNotEmpty) {
|
||||||
success = await controller.submitEditedPaymentRequest(
|
success = await controller.submitEditedPaymentRequest(
|
||||||
requestId: requestId);
|
requestId: requestId);
|
||||||
@ -144,7 +143,7 @@ class _PaymentRequestBottomSheetState extends State<_PaymentRequestBottomSheet>
|
|||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
Get.back();
|
Get.back();
|
||||||
if (widget.onUpdated != null) widget.onUpdated!();
|
widget.onUpdated?.call();
|
||||||
|
|
||||||
showAppSnackbar(
|
showAppSnackbar(
|
||||||
title: "Success",
|
title: "Success",
|
||||||
@ -157,31 +156,33 @@ class _PaymentRequestBottomSheetState extends State<_PaymentRequestBottomSheet>
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
|
padding: const EdgeInsets.only(bottom: 20),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
_buildDropdown(
|
_buildDropdown(
|
||||||
"Select Project",
|
"Select Project",
|
||||||
Icons.work_outline,
|
Icons.work_outline,
|
||||||
controller.selectedProject.value?['name'] ??
|
controller.selectedProject.value?['name'] ?? "Select Project",
|
||||||
"Select Project",
|
controller.globalProjects,
|
||||||
controller.globalProjects,
|
(p) => p['name'],
|
||||||
(p) => p['name'],
|
controller.selectProject,
|
||||||
controller.selectProject,
|
key: _projectDropdownKey,
|
||||||
key: _projectDropdownKey),
|
),
|
||||||
_gap(),
|
_gap(),
|
||||||
_buildDropdown(
|
_buildDropdown(
|
||||||
"Expense Category",
|
"Expense Category",
|
||||||
Icons.category_outlined,
|
Icons.category_outlined,
|
||||||
controller.selectedCategory.value?.name ??
|
controller.selectedCategory.value?.name ?? "Select Category",
|
||||||
"Select Category",
|
controller.categories,
|
||||||
controller.categories,
|
(c) => c.name,
|
||||||
(c) => c.name,
|
controller.selectCategory,
|
||||||
controller.selectCategory,
|
key: _categoryDropdownKey,
|
||||||
key: _categoryDropdownKey),
|
),
|
||||||
_gap(),
|
_gap(),
|
||||||
_buildTextField(
|
_buildTextField("Title", Icons.title_outlined,
|
||||||
"Title", Icons.title_outlined, controller.titleController,
|
controller.titleController,
|
||||||
hint: "Enter title", validator: Validators.requiredField),
|
hint: "Enter title", validator: Validators.requiredField),
|
||||||
_gap(),
|
_gap(),
|
||||||
_buildRadio("Is Advance Payment", Icons.attach_money_outlined,
|
_buildRadio("Is Advance Payment", Icons.attach_money_outlined,
|
||||||
@ -199,17 +200,17 @@ class _PaymentRequestBottomSheetState extends State<_PaymentRequestBottomSheet>
|
|||||||
? null
|
? null
|
||||||
: "Enter valid amount"),
|
: "Enter valid amount"),
|
||||||
_gap(),
|
_gap(),
|
||||||
_buildPayeeAutocompleteField(),
|
_buildPayeeField(),
|
||||||
_gap(),
|
_gap(),
|
||||||
_buildDropdown(
|
_buildDropdown(
|
||||||
"Currency",
|
"Currency",
|
||||||
Icons.monetization_on_outlined,
|
Icons.monetization_on_outlined,
|
||||||
controller.selectedCurrency.value?.currencyName ??
|
controller.selectedCurrency.value?.currencyName ?? "Select Currency",
|
||||||
"Select Currency",
|
controller.currencies,
|
||||||
controller.currencies,
|
(c) => c.currencyName,
|
||||||
(c) => c.currencyName,
|
controller.selectCurrency,
|
||||||
controller.selectCurrency,
|
key: _currencyDropdownKey,
|
||||||
key: _currencyDropdownKey),
|
),
|
||||||
_gap(),
|
_gap(),
|
||||||
_buildTextField("Description", Icons.description_outlined,
|
_buildTextField("Description", Icons.description_outlined,
|
||||||
controller.descriptionController,
|
controller.descriptionController,
|
||||||
@ -218,11 +219,14 @@ class _PaymentRequestBottomSheetState extends State<_PaymentRequestBottomSheet>
|
|||||||
validator: Validators.requiredField),
|
validator: Validators.requiredField),
|
||||||
_gap(),
|
_gap(),
|
||||||
_buildAttachmentsSection(),
|
_buildAttachmentsSection(),
|
||||||
|
MySpacing.height(30),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
));
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildDropdown<T>(String title, IconData icon, String value,
|
Widget _buildDropdown<T>(String title, IconData icon, String value,
|
||||||
@ -234,9 +238,10 @@ class _PaymentRequestBottomSheetState extends State<_PaymentRequestBottomSheet>
|
|||||||
SectionTitle(icon: icon, title: title, requiredField: true),
|
SectionTitle(icon: icon, title: title, requiredField: true),
|
||||||
MySpacing.height(6),
|
MySpacing.height(6),
|
||||||
DropdownTile(
|
DropdownTile(
|
||||||
key: key,
|
key: key,
|
||||||
title: value,
|
title: value,
|
||||||
onTap: () => _showOptionList(options, getLabel, onSelected, key)),
|
onTap: () => _showOptionList(options, getLabel, onSelected, key),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -265,7 +270,7 @@ class _PaymentRequestBottomSheetState extends State<_PaymentRequestBottomSheet>
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildRadio(
|
Widget _buildRadio(
|
||||||
String title, IconData icon, RxBool controller, List<String> labels) {
|
String title, IconData icon, RxBool controllerBool, List<String> labels) {
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
@ -284,15 +289,16 @@ class _PaymentRequestBottomSheetState extends State<_PaymentRequestBottomSheet>
|
|||||||
final i = entry.key;
|
final i = entry.key;
|
||||||
final label = entry.value;
|
final label = entry.value;
|
||||||
final value = i == 0;
|
final value = i == 0;
|
||||||
|
|
||||||
return Expanded(
|
return Expanded(
|
||||||
child: RadioListTile<bool>(
|
child: RadioListTile<bool>(
|
||||||
contentPadding: EdgeInsets.zero,
|
contentPadding: EdgeInsets.zero,
|
||||||
title: Text(label),
|
title: Text(label),
|
||||||
value: value,
|
value: value,
|
||||||
groupValue: controller.value,
|
groupValue: controllerBool.value,
|
||||||
activeColor: contentTheme.primary,
|
activeColor: contentTheme.primary,
|
||||||
onChanged: (val) =>
|
onChanged: (val) =>
|
||||||
val != null ? controller.value = val : null,
|
val != null ? controllerBool.value = val : null,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}).toList(),
|
}).toList(),
|
||||||
@ -306,9 +312,7 @@ class _PaymentRequestBottomSheetState extends State<_PaymentRequestBottomSheet>
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
const SectionTitle(
|
const SectionTitle(
|
||||||
icon: Icons.calendar_today,
|
icon: Icons.calendar_today, title: "Due To Date", requiredField: true),
|
||||||
title: "Due To Date",
|
|
||||||
requiredField: true),
|
|
||||||
MySpacing.height(6),
|
MySpacing.height(6),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () => controller.pickDueDate(context),
|
onTap: () => controller.pickDueDate(context),
|
||||||
@ -336,75 +340,35 @@ class _PaymentRequestBottomSheetState extends State<_PaymentRequestBottomSheet>
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildPayeeAutocompleteField() {
|
Widget _buildPayeeField() {
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
SectionTitle(
|
const SectionTitle(
|
||||||
icon: Icons.person_outline, title: "Payee", requiredField: true),
|
icon: Icons.person_outline,
|
||||||
const SizedBox(height: 6),
|
title: "Payee",
|
||||||
Autocomplete<String>(
|
requiredField: true,
|
||||||
optionsBuilder: (textEditingValue) {
|
),
|
||||||
final query = textEditingValue.text.toLowerCase();
|
MySpacing.height(6),
|
||||||
return query.isEmpty
|
GestureDetector(
|
||||||
? const Iterable<String>.empty()
|
onTap: _showPayeeSelector,
|
||||||
: controller.payees
|
child: TileContainer(
|
||||||
.where((p) => p.toLowerCase().contains(query));
|
child: Row(
|
||||||
},
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
displayStringForOption: (option) => option,
|
children: [
|
||||||
fieldViewBuilder:
|
Expanded(
|
||||||
(context, fieldController, focusNode, onFieldSubmitted) {
|
child: Obx(() => Text(
|
||||||
// Avoid updating during build
|
controller.selectedPayee.value?.name ?? "Select Payee",
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
style: const TextStyle(fontSize: 15),
|
||||||
if (fieldController.text != controller.selectedPayee.value) {
|
overflow: TextOverflow.ellipsis,
|
||||||
fieldController.text = controller.selectedPayee.value;
|
)),
|
||||||
fieldController.selection = TextSelection.fromPosition(
|
|
||||||
TextPosition(offset: fieldController.text.length));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return TextFormField(
|
|
||||||
controller: fieldController,
|
|
||||||
focusNode: focusNode,
|
|
||||||
decoration: InputDecoration(
|
|
||||||
hintText: "Type or select payee",
|
|
||||||
filled: true,
|
|
||||||
fillColor: Colors.grey.shade100,
|
|
||||||
contentPadding:
|
|
||||||
const EdgeInsets.symmetric(horizontal: 12, vertical: 14),
|
|
||||||
border: OutlineInputBorder(
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
borderSide: BorderSide(color: Colors.grey.shade300),
|
|
||||||
),
|
),
|
||||||
),
|
const Icon(Icons.arrow_drop_down, size: 22),
|
||||||
validator: (v) =>
|
],
|
||||||
v == null || v.trim().isEmpty ? "Please enter payee" : null,
|
|
||||||
onChanged: (val) => controller.selectedPayee.value = val,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
onSelected: (selection) => controller.selectedPayee.value = selection,
|
|
||||||
optionsViewBuilder: (context, onSelected, options) => Material(
|
|
||||||
color: Colors.white,
|
|
||||||
elevation: 4,
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
child: ConstrainedBox(
|
|
||||||
constraints: const BoxConstraints(maxHeight: 200, minWidth: 300),
|
|
||||||
child: ListView.builder(
|
|
||||||
padding: EdgeInsets.zero,
|
|
||||||
itemCount: options.length,
|
|
||||||
itemBuilder: (_, index) => InkWell(
|
|
||||||
onTap: () => onSelected(options.elementAt(index)),
|
|
||||||
child: Container(
|
|
||||||
padding: const EdgeInsets.symmetric(
|
|
||||||
vertical: 10, horizontal: 12),
|
|
||||||
child: Text(options.elementAt(index),
|
|
||||||
style: const TextStyle(fontSize: 14)),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
const SizedBox(height: 6),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -492,8 +456,7 @@ class _PaymentRequestBottomSheetState extends State<_PaymentRequestBottomSheet>
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final RenderBox button =
|
final RenderBox button = key.currentContext!.findRenderObject() as RenderBox;
|
||||||
key.currentContext!.findRenderObject() as RenderBox;
|
|
||||||
final RenderBox overlay =
|
final RenderBox overlay =
|
||||||
Overlay.of(context).context.findRenderObject() as RenderBox;
|
Overlay.of(context).context.findRenderObject() as RenderBox;
|
||||||
final position = button.localToGlobal(Offset.zero, ancestor: overlay);
|
final position = button.localToGlobal(Offset.zero, ancestor: overlay);
|
||||||
@ -507,8 +470,7 @@ class _PaymentRequestBottomSheetState extends State<_PaymentRequestBottomSheet>
|
|||||||
0),
|
0),
|
||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
|
||||||
items: options
|
items: options
|
||||||
.map(
|
.map((opt) => PopupMenuItem<T>(value: opt, child: Text(getLabel(opt))))
|
||||||
(opt) => PopupMenuItem<T>(value: opt, child: Text(getLabel(opt))))
|
|
||||||
.toList(),
|
.toList(),
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -523,7 +485,7 @@ class _PaymentRequestBottomSheetState extends State<_PaymentRequestBottomSheet>
|
|||||||
if (controller.selectedCategory.value == null) {
|
if (controller.selectedCategory.value == null) {
|
||||||
return _showError("Please select a category");
|
return _showError("Please select a category");
|
||||||
}
|
}
|
||||||
if (controller.selectedPayee.value.isEmpty) {
|
if (controller.selectedPayee.value == null) {
|
||||||
return _showError("Please select a payee");
|
return _showError("Please select a payee");
|
||||||
}
|
}
|
||||||
if (controller.selectedCurrency.value == null) {
|
if (controller.selectedCurrency.value == null) {
|
||||||
@ -532,6 +494,25 @@ class _PaymentRequestBottomSheetState extends State<_PaymentRequestBottomSheet>
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> _showPayeeSelector() async {
|
||||||
|
final result = await showModalBottomSheet(
|
||||||
|
context: context,
|
||||||
|
isScrollControlled: true,
|
||||||
|
backgroundColor: Colors.transparent,
|
||||||
|
builder: (_) => EmployeeSelectionBottomSheet(
|
||||||
|
title: "Select Payee",
|
||||||
|
multipleSelection: false,
|
||||||
|
initiallySelected: controller.selectedPayee.value != null
|
||||||
|
? [controller.selectedPayee.value!]
|
||||||
|
: [],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (result is EmployeeModel) {
|
||||||
|
controller.selectedPayee.value = result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool _showError(String msg) {
|
bool _showError(String msg) {
|
||||||
showAppSnackbar(title: "Error", message: msg, type: SnackbarType.error);
|
showAppSnackbar(title: "Error", message: msg, type: SnackbarType.error);
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import 'package:on_field_work/helpers/widgets/my_text_style.dart';
|
|||||||
import 'package:on_field_work/helpers/utils/mixins/ui_mixin.dart';
|
import 'package:on_field_work/helpers/utils/mixins/ui_mixin.dart';
|
||||||
import 'package:on_field_work/helpers/widgets/date_range_picker.dart';
|
import 'package:on_field_work/helpers/widgets/date_range_picker.dart';
|
||||||
import 'package:on_field_work/model/employees/employee_model.dart';
|
import 'package:on_field_work/model/employees/employee_model.dart';
|
||||||
import 'package:on_field_work/model/expense/employee_selector_for_filter_bottom_sheet.dart';
|
import 'package:on_field_work/model/employees/multiple_select_bottomsheet.dart';
|
||||||
|
|
||||||
class PaymentRequestFilterBottomSheet extends StatefulWidget {
|
class PaymentRequestFilterBottomSheet extends StatefulWidget {
|
||||||
final PaymentRequestController controller;
|
final PaymentRequestController controller;
|
||||||
@ -27,11 +27,9 @@ class PaymentRequestFilterBottomSheet extends StatefulWidget {
|
|||||||
|
|
||||||
class _PaymentRequestFilterBottomSheetState
|
class _PaymentRequestFilterBottomSheetState
|
||||||
extends State<PaymentRequestFilterBottomSheet> with UIMixin {
|
extends State<PaymentRequestFilterBottomSheet> with UIMixin {
|
||||||
// ---------------- Date Range ----------------
|
|
||||||
final Rx<DateTime?> startDate = Rx<DateTime?>(null);
|
final Rx<DateTime?> startDate = Rx<DateTime?>(null);
|
||||||
final Rx<DateTime?> endDate = Rx<DateTime?>(null);
|
final Rx<DateTime?> endDate = Rx<DateTime?>(null);
|
||||||
|
|
||||||
// ---------------- Selected Filters (store IDs internally) ----------------
|
|
||||||
final RxString selectedProjectId = ''.obs;
|
final RxString selectedProjectId = ''.obs;
|
||||||
final RxList<EmployeeModel> selectedSubmittedBy = <EmployeeModel>[].obs;
|
final RxList<EmployeeModel> selectedSubmittedBy = <EmployeeModel>[].obs;
|
||||||
final RxList<EmployeeModel> selectedPayees = <EmployeeModel>[].obs;
|
final RxList<EmployeeModel> selectedPayees = <EmployeeModel>[].obs;
|
||||||
@ -39,7 +37,6 @@ class _PaymentRequestFilterBottomSheetState
|
|||||||
final RxString selectedCurrencyId = ''.obs;
|
final RxString selectedCurrencyId = ''.obs;
|
||||||
final RxString selectedStatusId = ''.obs;
|
final RxString selectedStatusId = ''.obs;
|
||||||
|
|
||||||
// Computed display names
|
|
||||||
String get selectedProjectName =>
|
String get selectedProjectName =>
|
||||||
widget.controller.projects
|
widget.controller.projects
|
||||||
.firstWhereOrNull((e) => e.id == selectedProjectId.value)
|
.firstWhereOrNull((e) => e.id == selectedProjectId.value)
|
||||||
@ -64,10 +61,8 @@ class _PaymentRequestFilterBottomSheetState
|
|||||||
?.name ??
|
?.name ??
|
||||||
'Please select...';
|
'Please select...';
|
||||||
|
|
||||||
// ---------------- Filter Data ----------------
|
|
||||||
final RxBool isFilterLoading = true.obs;
|
final RxBool isFilterLoading = true.obs;
|
||||||
|
|
||||||
// Individual RxLists for safe Obx usage
|
|
||||||
final RxList<String> projectNames = <String>[].obs;
|
final RxList<String> projectNames = <String>[].obs;
|
||||||
final RxList<String> submittedByNames = <String>[].obs;
|
final RxList<String> submittedByNames = <String>[].obs;
|
||||||
final RxList<String> payeeNames = <String>[].obs;
|
final RxList<String> payeeNames = <String>[].obs;
|
||||||
@ -92,17 +87,14 @@ class _PaymentRequestFilterBottomSheetState
|
|||||||
currencyNames.assignAll(widget.controller.currencies.map((e) => e.name));
|
currencyNames.assignAll(widget.controller.currencies.map((e) => e.name));
|
||||||
statusNames.assignAll(widget.controller.statuses.map((e) => e.name));
|
statusNames.assignAll(widget.controller.statuses.map((e) => e.name));
|
||||||
|
|
||||||
// 🔹 Prefill existing applied filter (if any)
|
|
||||||
final existing = widget.controller.appliedFilter;
|
final existing = widget.controller.appliedFilter;
|
||||||
|
|
||||||
if (existing.isNotEmpty) {
|
if (existing.isNotEmpty) {
|
||||||
// Project
|
|
||||||
if (existing['projectIds'] != null &&
|
if (existing['projectIds'] != null &&
|
||||||
(existing['projectIds'] as List).isNotEmpty) {
|
(existing['projectIds'] as List).isNotEmpty) {
|
||||||
selectedProjectId.value = (existing['projectIds'] as List).first;
|
selectedProjectId.value = (existing['projectIds'] as List).first;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Submitted By
|
|
||||||
if (existing['createdByIds'] != null &&
|
if (existing['createdByIds'] != null &&
|
||||||
existing['createdByIds'] is List) {
|
existing['createdByIds'] is List) {
|
||||||
selectedSubmittedBy.assignAll(
|
selectedSubmittedBy.assignAll(
|
||||||
@ -114,7 +106,6 @@ class _PaymentRequestFilterBottomSheetState
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Payees
|
|
||||||
if (existing['payees'] != null && existing['payees'] is List) {
|
if (existing['payees'] != null && existing['payees'] is List) {
|
||||||
selectedPayees.assignAll(
|
selectedPayees.assignAll(
|
||||||
(existing['payees'] as List)
|
(existing['payees'] as List)
|
||||||
@ -125,26 +116,22 @@ class _PaymentRequestFilterBottomSheetState
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Category
|
|
||||||
if (existing['expenseCategoryIds'] != null &&
|
if (existing['expenseCategoryIds'] != null &&
|
||||||
(existing['expenseCategoryIds'] as List).isNotEmpty) {
|
(existing['expenseCategoryIds'] as List).isNotEmpty) {
|
||||||
selectedCategoryId.value =
|
selectedCategoryId.value =
|
||||||
(existing['expenseCategoryIds'] as List).first;
|
(existing['expenseCategoryIds'] as List).first;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Currency
|
|
||||||
if (existing['currencyIds'] != null &&
|
if (existing['currencyIds'] != null &&
|
||||||
(existing['currencyIds'] as List).isNotEmpty) {
|
(existing['currencyIds'] as List).isNotEmpty) {
|
||||||
selectedCurrencyId.value = (existing['currencyIds'] as List).first;
|
selectedCurrencyId.value = (existing['currencyIds'] as List).first;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Status
|
|
||||||
if (existing['statusIds'] != null &&
|
if (existing['statusIds'] != null &&
|
||||||
(existing['statusIds'] as List).isNotEmpty) {
|
(existing['statusIds'] as List).isNotEmpty) {
|
||||||
selectedStatusId.value = (existing['statusIds'] as List).first;
|
selectedStatusId.value = (existing['statusIds'] as List).first;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dates
|
|
||||||
if (existing['startDate'] != null && existing['endDate'] != null) {
|
if (existing['startDate'] != null && existing['endDate'] != null) {
|
||||||
startDate.value = DateTime.tryParse(existing['startDate']);
|
startDate.value = DateTime.tryParse(existing['startDate']);
|
||||||
endDate.value = DateTime.tryParse(existing['endDate']);
|
endDate.value = DateTime.tryParse(existing['endDate']);
|
||||||
@ -192,39 +179,46 @@ class _PaymentRequestFilterBottomSheetState
|
|||||||
submitText: 'Apply',
|
submitText: 'Apply',
|
||||||
submitColor: contentTheme.primary,
|
submitColor: contentTheme.primary,
|
||||||
submitIcon: Icons.check_circle_outline,
|
submitIcon: Icons.check_circle_outline,
|
||||||
child: SingleChildScrollView(
|
|
||||||
controller: widget.scrollController,
|
/// ⭐⭐⭐ IMPORTANT FIX ⭐⭐⭐
|
||||||
child: Column(
|
/// Prevents bottom part from hiding under 3-button nav bar in landscape
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
child: SafeArea(
|
||||||
children: [
|
minimum: const EdgeInsets.only(bottom: 20),
|
||||||
Align(
|
child: SingleChildScrollView(
|
||||||
alignment: Alignment.centerRight,
|
controller: widget.scrollController,
|
||||||
child: TextButton(
|
padding: const EdgeInsets.only(bottom: 40), // extra bottom spacing
|
||||||
onPressed: clearFilters,
|
child: Column(
|
||||||
child: MyText(
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
"Reset Filters",
|
children: [
|
||||||
style: MyTextStyle.labelMedium(
|
Align(
|
||||||
color: Colors.red,
|
alignment: Alignment.centerRight,
|
||||||
fontWeight: 600,
|
child: TextButton(
|
||||||
|
onPressed: clearFilters,
|
||||||
|
child: MyText(
|
||||||
|
"Reset Filters",
|
||||||
|
style: MyTextStyle.labelMedium(
|
||||||
|
color: Colors.red,
|
||||||
|
fontWeight: 600,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
MySpacing.height(8),
|
||||||
MySpacing.height(8),
|
_buildDateRangeFilter(),
|
||||||
_buildDateRangeFilter(),
|
MySpacing.height(16),
|
||||||
MySpacing.height(16),
|
_buildProjectFilter(),
|
||||||
_buildProjectFilter(),
|
MySpacing.height(16),
|
||||||
MySpacing.height(16),
|
_buildSubmittedByFilter(),
|
||||||
_buildSubmittedByFilter(),
|
MySpacing.height(16),
|
||||||
MySpacing.height(16),
|
_buildPayeeFilter(),
|
||||||
_buildPayeeFilter(),
|
MySpacing.height(16),
|
||||||
MySpacing.height(16),
|
_buildCategoryFilter(),
|
||||||
_buildCategoryFilter(),
|
MySpacing.height(16),
|
||||||
MySpacing.height(16),
|
_buildCurrencyFilter(),
|
||||||
_buildCurrencyFilter(),
|
MySpacing.height(16),
|
||||||
MySpacing.height(16),
|
_buildStatusFilter(),
|
||||||
_buildStatusFilter(),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -441,9 +435,9 @@ class _PaymentRequestFilterBottomSheetState
|
|||||||
shape: const RoundedRectangleBorder(
|
shape: const RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
|
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
|
||||||
),
|
),
|
||||||
builder: (context) => EmployeeSelectorBottomSheet(
|
builder: (context) => EmployeeSelectionBottomSheet(
|
||||||
selectedEmployees: selectedEmployees,
|
initiallySelected: selectedEmployees.toList(),
|
||||||
searchEmployees: (query) => searchEmployees(query, items),
|
multipleSelection: true,
|
||||||
title: title,
|
title: title,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@ -91,6 +91,7 @@ class _AddServiceProjectJobBottomSheetState
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
Widget _branchSelector() => Obx(() {
|
Widget _branchSelector() => Obx(() {
|
||||||
if (controller.isBranchLoading.value) {
|
if (controller.isBranchLoading.value) {
|
||||||
return const Center(child: CircularProgressIndicator());
|
return const Center(child: CircularProgressIndicator());
|
||||||
@ -197,6 +198,8 @@ class _AddServiceProjectJobBottomSheetState
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// ----------------- UPDATED TAG INPUT -----------------
|
||||||
|
|
||||||
Widget _tagInput() => Column(
|
Widget _tagInput() => Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
@ -204,14 +207,62 @@ class _AddServiceProjectJobBottomSheetState
|
|||||||
height: 48,
|
height: 48,
|
||||||
child: TextFormField(
|
child: TextFormField(
|
||||||
controller: controller.tagCtrl,
|
controller: controller.tagCtrl,
|
||||||
onFieldSubmitted: (v) {
|
textInputAction: TextInputAction.done,
|
||||||
final value = v.trim();
|
|
||||||
if (value.isNotEmpty &&
|
// 🚀 Auto-create tag when space pressed
|
||||||
!controller.enteredTags.contains(value)) {
|
onChanged: (value) {
|
||||||
controller.enteredTags.add(value);
|
if (value.endsWith(' ')) {
|
||||||
|
final raw = value.trim();
|
||||||
|
if (raw.isNotEmpty) {
|
||||||
|
final parts = raw
|
||||||
|
.split(RegExp(r'[, ]+'))
|
||||||
|
.map((s) => s.trim())
|
||||||
|
.where((s) => s.isNotEmpty);
|
||||||
|
|
||||||
|
for (final p in parts) {
|
||||||
|
if (!controller.enteredTags.contains(p)) {
|
||||||
|
controller.enteredTags.add(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
controller.tagCtrl.clear();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
onEditingComplete: () {
|
||||||
|
final raw = controller.tagCtrl.text.trim();
|
||||||
|
if (raw.isEmpty) return;
|
||||||
|
|
||||||
|
final parts = raw
|
||||||
|
.split(RegExp(r'[, ]+'))
|
||||||
|
.map((s) => s.trim())
|
||||||
|
.where((s) => s.isNotEmpty);
|
||||||
|
|
||||||
|
for (final p in parts) {
|
||||||
|
if (!controller.enteredTags.contains(p)) {
|
||||||
|
controller.enteredTags.add(p);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
controller.tagCtrl.clear();
|
controller.tagCtrl.clear();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onFieldSubmitted: (v) {
|
||||||
|
final raw = v.trim();
|
||||||
|
if (raw.isEmpty) return;
|
||||||
|
|
||||||
|
final parts = raw
|
||||||
|
.split(RegExp(r'[, ]+'))
|
||||||
|
.map((s) => s.trim())
|
||||||
|
.where((s) => s.isNotEmpty);
|
||||||
|
|
||||||
|
for (final p in parts) {
|
||||||
|
if (!controller.enteredTags.contains(p)) {
|
||||||
|
controller.enteredTags.add(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
controller.tagCtrl.clear();
|
||||||
|
},
|
||||||
|
|
||||||
decoration: _inputDecoration("Start typing to add tags"),
|
decoration: _inputDecoration("Start typing to add tags"),
|
||||||
validator: (v) => controller.enteredTags.isEmpty
|
validator: (v) => controller.enteredTags.isEmpty
|
||||||
? "Please add at least one tag"
|
? "Please add at least one tag"
|
||||||
@ -231,6 +282,8 @@ class _AddServiceProjectJobBottomSheetState
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// ------------------------------------------------------
|
||||||
|
|
||||||
void _handleSubmit() {
|
void _handleSubmit() {
|
||||||
if (!(formKey.currentState?.validate() ?? false)) return;
|
if (!(formKey.currentState?.validate() ?? false)) return;
|
||||||
controller.titleCtrl.text = controller.titleCtrl.text.trim();
|
controller.titleCtrl.text = controller.titleCtrl.text.trim();
|
||||||
|
|||||||
@ -38,96 +38,111 @@ class _DirectoryMainScreenState extends State<DirectoryMainScreen>
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return OrientationBuilder(
|
||||||
backgroundColor: const Color(0xFFF5F5F5),
|
builder: (context, orientation) {
|
||||||
appBar: PreferredSize(
|
final bool isLandscape = orientation == Orientation.landscape;
|
||||||
preferredSize: const Size.fromHeight(72),
|
|
||||||
child: AppBar(
|
return Scaffold(
|
||||||
backgroundColor: const Color(0xFFF5F5F5),
|
backgroundColor: const Color(0xFFF5F5F5),
|
||||||
elevation: 0.5,
|
appBar: PreferredSize(
|
||||||
automaticallyImplyLeading: false,
|
preferredSize: Size.fromHeight(
|
||||||
titleSpacing: 0,
|
isLandscape ? 55 : 72, // Responsive height
|
||||||
title: Padding(
|
),
|
||||||
padding: MySpacing.xy(16, 0),
|
child: SafeArea(
|
||||||
child: Row(
|
bottom: false,
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
child: AppBar(
|
||||||
children: [
|
backgroundColor: const Color(0xFFF5F5F5),
|
||||||
IconButton(
|
elevation: 0.5,
|
||||||
icon: const Icon(Icons.arrow_back_ios_new,
|
automaticallyImplyLeading: false,
|
||||||
color: Colors.black, size: 20),
|
titleSpacing: 0,
|
||||||
onPressed: () => Get.offNamed('/dashboard'),
|
title: Padding(
|
||||||
),
|
padding: MySpacing.xy(16, 0),
|
||||||
MySpacing.width(8),
|
child: Row(
|
||||||
Expanded(
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
children: [
|
||||||
MyText.titleLarge(
|
IconButton(
|
||||||
'Directory',
|
icon: const Icon(Icons.arrow_back_ios_new,
|
||||||
fontWeight: 700,
|
color: Colors.black, size: 20),
|
||||||
color: Colors.black,
|
onPressed: () => Get.offNamed('/dashboard'),
|
||||||
),
|
),
|
||||||
MySpacing.height(2),
|
MySpacing.width(8),
|
||||||
GetBuilder<ProjectController>(
|
|
||||||
builder: (projectController) {
|
/// FIX: Flexible to prevent overflow in landscape
|
||||||
final projectName =
|
Flexible(
|
||||||
projectController.selectedProject?.name ??
|
child: Column(
|
||||||
'Select Project';
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
return Row(
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
const Icon(Icons.work_outline,
|
MyText.titleLarge(
|
||||||
size: 14, color: Colors.grey),
|
'Directory',
|
||||||
MySpacing.width(4),
|
fontWeight: 700,
|
||||||
Expanded(
|
color: Colors.black,
|
||||||
child: MyText.bodySmall(
|
),
|
||||||
projectName,
|
MySpacing.height(2),
|
||||||
fontWeight: 600,
|
GetBuilder<ProjectController>(
|
||||||
overflow: TextOverflow.ellipsis,
|
builder: (projectController) {
|
||||||
color: Colors.grey[700],
|
final projectName =
|
||||||
),
|
projectController.selectedProject?.name ??
|
||||||
),
|
'Select Project';
|
||||||
],
|
|
||||||
);
|
return Row(
|
||||||
},
|
children: [
|
||||||
|
const Icon(Icons.work_outline,
|
||||||
|
size: 14, color: Colors.grey),
|
||||||
|
MySpacing.width(4),
|
||||||
|
Expanded(
|
||||||
|
child: MyText.bodySmall(
|
||||||
|
projectName,
|
||||||
|
fontWeight: 600,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
color: Colors.grey[700],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
/// MAIN CONTENT
|
||||||
|
body: SafeArea(
|
||||||
|
bottom: true,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
color: Colors.white,
|
||||||
|
child: TabBar(
|
||||||
|
controller: _tabController,
|
||||||
|
labelColor: Colors.black,
|
||||||
|
unselectedLabelColor: Colors.grey,
|
||||||
|
indicatorColor: Colors.red,
|
||||||
|
tabs: const [
|
||||||
|
Tab(text: "Directory"),
|
||||||
|
Tab(text: "Notes"),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: TabBarView(
|
||||||
|
controller: _tabController,
|
||||||
|
children: [
|
||||||
|
DirectoryView(),
|
||||||
|
NotesView(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
),
|
},
|
||||||
body: Column(
|
|
||||||
children: [
|
|
||||||
// ---------------- TabBar ----------------
|
|
||||||
Container(
|
|
||||||
color: Colors.white,
|
|
||||||
child: TabBar(
|
|
||||||
controller: _tabController,
|
|
||||||
labelColor: Colors.black,
|
|
||||||
unselectedLabelColor: Colors.grey,
|
|
||||||
indicatorColor: Colors.red,
|
|
||||||
tabs: const [
|
|
||||||
Tab(text: "Directory"),
|
|
||||||
Tab(text: "Notes"),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
// ---------------- TabBarView ----------------
|
|
||||||
Expanded(
|
|
||||||
child: TabBarView(
|
|
||||||
controller: _tabController,
|
|
||||||
children: [
|
|
||||||
DirectoryView(),
|
|
||||||
NotesView(),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -330,14 +330,11 @@ class _ManageReportingBottomSheetState
|
|||||||
final EmployeesScreenController controller = Get.find();
|
final EmployeesScreenController controller = Get.find();
|
||||||
await controller.fetchReportingManagers(empId);
|
await controller.fetchReportingManagers(empId);
|
||||||
await controller.fetchEmployeeDetails(empId);
|
await controller.fetchEmployeeDetails(empId);
|
||||||
} catch (_) {
|
} catch (_) {}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Optional: re-fetch the organization hierarchy list (if needed elsewhere)
|
// Optional: re-fetch the organization hierarchy list (if needed elsewhere)
|
||||||
await ApiService.getOrganizationHierarchyList(employeeId);
|
await ApiService.getOrganizationHierarchyList(employeeId);
|
||||||
|
|
||||||
|
|
||||||
_resetForm();
|
_resetForm();
|
||||||
if (Navigator.of(context).canPop()) {
|
if (Navigator.of(context).canPop()) {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
@ -389,6 +386,17 @@ class _ManageReportingBottomSheetState
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// 🔥 WRAP EVERYTHING IN SAFEAREA + SCROLL + BOTTOM PADDING
|
||||||
|
final safeWrappedContent = SafeArea(
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
padding: EdgeInsets.only(
|
||||||
|
bottom: MediaQuery.of(context).viewPadding.bottom + 20,
|
||||||
|
left: 16, right: 16, top: 8,
|
||||||
|
),
|
||||||
|
child: content,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
if (widget.renderAsCard) {
|
if (widget.renderAsCard) {
|
||||||
// Inline card for profile screen
|
// Inline card for profile screen
|
||||||
return Card(
|
return Card(
|
||||||
@ -397,7 +405,7 @@ class _ManageReportingBottomSheetState
|
|||||||
elevation: 2,
|
elevation: 2,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(12),
|
padding: const EdgeInsets.all(12),
|
||||||
child: content,
|
child: safeWrappedContent,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -409,7 +417,7 @@ class _ManageReportingBottomSheetState
|
|||||||
isSubmitting: _isSubmitting,
|
isSubmitting: _isSubmitting,
|
||||||
onCancel: _handleCancel,
|
onCancel: _handleCancel,
|
||||||
onSubmit: _handleSubmit,
|
onSubmit: _handleSubmit,
|
||||||
child: content,
|
child: safeWrappedContent,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
// ignore_for_file: must_be_immutable
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:on_field_work/controller/expense/expense_screen_controller.dart';
|
import 'package:on_field_work/controller/expense/expense_screen_controller.dart';
|
||||||
@ -8,9 +6,10 @@ import 'package:on_field_work/helpers/widgets/my_spacing.dart';
|
|||||||
import 'package:on_field_work/helpers/widgets/my_text.dart';
|
import 'package:on_field_work/helpers/widgets/my_text.dart';
|
||||||
import 'package:on_field_work/helpers/widgets/my_text_style.dart';
|
import 'package:on_field_work/helpers/widgets/my_text_style.dart';
|
||||||
import 'package:on_field_work/model/employees/employee_model.dart';
|
import 'package:on_field_work/model/employees/employee_model.dart';
|
||||||
import 'package:on_field_work/model/expense/employee_selector_for_filter_bottom_sheet.dart';
|
|
||||||
import 'package:on_field_work/helpers/utils/mixins/ui_mixin.dart';
|
import 'package:on_field_work/helpers/utils/mixins/ui_mixin.dart';
|
||||||
import 'package:on_field_work/helpers/widgets/date_range_picker.dart';
|
import 'package:on_field_work/helpers/widgets/date_range_picker.dart';
|
||||||
|
import 'package:on_field_work/model/employees/multiple_select_bottomsheet.dart';
|
||||||
|
|
||||||
|
|
||||||
class ExpenseFilterBottomSheet extends StatefulWidget {
|
class ExpenseFilterBottomSheet extends StatefulWidget {
|
||||||
final ExpenseController expenseController;
|
final ExpenseController expenseController;
|
||||||
@ -303,12 +302,13 @@ class _ExpenseFilterBottomSheetState extends State<ExpenseFilterBottomSheet>
|
|||||||
shape: const RoundedRectangleBorder(
|
shape: const RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
|
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
|
||||||
),
|
),
|
||||||
builder: (context) => EmployeeSelectorBottomSheet(
|
builder: (context) => EmployeeSelectionBottomSheet(
|
||||||
selectedEmployees: selectedEmployees,
|
initiallySelected: selectedEmployees.toList(),
|
||||||
searchEmployees: searchEmployees,
|
multipleSelection: true,
|
||||||
title: title,
|
title: title,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (result != null) selectedEmployees.assignAll(result);
|
if (result != null) selectedEmployees.assignAll(result);
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
|
|||||||
@ -49,36 +49,42 @@ class _AdvancePaymentScreenState extends State<AdvancePaymentScreen>
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: const Color(
|
backgroundColor: const Color(0xFFF5F5F5),
|
||||||
0xFFF5F5F5),
|
|
||||||
appBar: _buildAppBar(),
|
appBar: _buildAppBar(),
|
||||||
body: GestureDetector(
|
|
||||||
onTap: () => FocusScope.of(context).unfocus(),
|
// ✅ SafeArea added so nothing hides under system navigation buttons
|
||||||
child: RefreshIndicator(
|
body: SafeArea(
|
||||||
onRefresh: () async {
|
bottom: true,
|
||||||
final emp = controller.selectedEmployee.value;
|
child: GestureDetector(
|
||||||
if (emp != null) {
|
onTap: () => FocusScope.of(context).unfocus(),
|
||||||
await controller.fetchAdvancePayments(emp.id.toString());
|
child: RefreshIndicator(
|
||||||
}
|
onRefresh: () async {
|
||||||
},
|
final emp = controller.selectedEmployee.value;
|
||||||
color: Colors.white,
|
if (emp != null) {
|
||||||
backgroundColor: contentTheme.primary,
|
await controller.fetchAdvancePayments(emp.id.toString());
|
||||||
strokeWidth: 2.5,
|
}
|
||||||
displacement: 60,
|
},
|
||||||
child: SingleChildScrollView(
|
color: Colors.white,
|
||||||
physics: const AlwaysScrollableScrollPhysics(),
|
backgroundColor: contentTheme.primary,
|
||||||
child: Container(
|
strokeWidth: 2.5,
|
||||||
color:
|
displacement: 60,
|
||||||
const Color(0xFFF5F5F5),
|
child: SingleChildScrollView(
|
||||||
child: Column(
|
physics: const AlwaysScrollableScrollPhysics(),
|
||||||
children: [
|
child: Padding(
|
||||||
_buildSearchBar(),
|
// ✅ Extra bottom padding so content does NOT go under 3-button navbar
|
||||||
_buildEmployeeDropdown(context),
|
padding: EdgeInsets.only(
|
||||||
_buildTopBalance(),
|
bottom: MediaQuery.of(context).padding.bottom + 20,
|
||||||
_buildPaymentList(),
|
),
|
||||||
],
|
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
_buildSearchBar(),
|
||||||
|
_buildEmployeeDropdown(context),
|
||||||
|
_buildTopBalance(),
|
||||||
|
_buildPaymentList(),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -322,7 +328,6 @@ class _AdvancePaymentScreenState extends State<AdvancePaymentScreen>
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ✅ No employee selected yet
|
|
||||||
if (controller.selectedEmployee.value == null) {
|
if (controller.selectedEmployee.value == null) {
|
||||||
return const Padding(
|
return const Padding(
|
||||||
padding: EdgeInsets.only(top: 100),
|
padding: EdgeInsets.only(top: 100),
|
||||||
@ -330,7 +335,6 @@ class _AdvancePaymentScreenState extends State<AdvancePaymentScreen>
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ✅ Employee selected but no payments found
|
|
||||||
if (controller.payments.isEmpty) {
|
if (controller.payments.isEmpty) {
|
||||||
return const Padding(
|
return const Padding(
|
||||||
padding: EdgeInsets.only(top: 100),
|
padding: EdgeInsets.only(top: 100),
|
||||||
@ -340,7 +344,6 @@ class _AdvancePaymentScreenState extends State<AdvancePaymentScreen>
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ✅ Payments available
|
|
||||||
return ListView.builder(
|
return ListView.builder(
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
@ -378,7 +381,7 @@ class _AdvancePaymentScreenState extends State<AdvancePaymentScreen>
|
|||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.grey[100],
|
color: Colors.grey[100],
|
||||||
border: Border(
|
border: Border(
|
||||||
bottom: BorderSide(color: Color(0xFFE0E0E0), width: 0.9),
|
bottom: BorderSide(color: const Color(0xFFE0E0E0), width: 0.9),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
|
|||||||
@ -113,171 +113,190 @@ class _FinanceScreenState extends State<FinanceScreen>
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
body: FadeTransition(
|
body: SafeArea(
|
||||||
opacity: _fadeAnimation,
|
top: false, // keep appbar area same
|
||||||
child: Obx(() {
|
bottom: true, // avoid system bottom buttons
|
||||||
if (menuController.isLoading.value) {
|
child: FadeTransition(
|
||||||
return const Center(child: CircularProgressIndicator());
|
opacity: _fadeAnimation,
|
||||||
}
|
child: Obx(() {
|
||||||
|
if (menuController.isLoading.value) {
|
||||||
|
return const Center(child: CircularProgressIndicator());
|
||||||
|
}
|
||||||
|
|
||||||
if (menuController.hasError.value || menuController.menuItems.isEmpty) {
|
if (menuController.hasError.value ||
|
||||||
return const Center(
|
menuController.menuItems.isEmpty) {
|
||||||
child: Text(
|
return const Center(
|
||||||
"Failed to load menus. Please try again later.",
|
child: Text(
|
||||||
style: TextStyle(color: Colors.red),
|
"Failed to load menus. Please try again later.",
|
||||||
|
style: TextStyle(color: Colors.red),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
final financeMenuIds = [
|
||||||
|
MenuItems.expenseReimbursement,
|
||||||
|
MenuItems.paymentRequests,
|
||||||
|
MenuItems.advancePaymentStatements,
|
||||||
|
];
|
||||||
|
|
||||||
|
final financeMenus = menuController.menuItems
|
||||||
|
.where((m) => financeMenuIds.contains(m.id) && m.available)
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
if (financeMenus.isEmpty) {
|
||||||
|
return const Center(
|
||||||
|
child: Text(
|
||||||
|
"You don’t have access to the Finance section.",
|
||||||
|
style: TextStyle(color: Colors.grey),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- IMPORTANT FIX: Add bottom safe padding ----
|
||||||
|
final double bottomInset =
|
||||||
|
MediaQuery.of(context).viewPadding.bottom;
|
||||||
|
|
||||||
|
return SingleChildScrollView(
|
||||||
|
padding: EdgeInsets.fromLTRB(
|
||||||
|
16,
|
||||||
|
16,
|
||||||
|
16,
|
||||||
|
bottomInset +
|
||||||
|
24, // ensures charts never go under system buttons
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
_buildFinanceModulesCompact(financeMenus),
|
||||||
|
MySpacing.height(24),
|
||||||
|
ExpenseByStatusWidget(controller: dashboardController),
|
||||||
|
MySpacing.height(24),
|
||||||
|
ExpenseTypeReportChart(),
|
||||||
|
MySpacing.height(24),
|
||||||
|
MonthlyExpenseDashboardChart(),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}),
|
||||||
|
),
|
||||||
// Filter allowed Finance menus dynamically
|
|
||||||
final financeMenuIds = [
|
|
||||||
MenuItems.expenseReimbursement,
|
|
||||||
MenuItems.paymentRequests,
|
|
||||||
MenuItems.advancePaymentStatements,
|
|
||||||
];
|
|
||||||
|
|
||||||
final financeMenus = menuController.menuItems
|
|
||||||
.where((m) => financeMenuIds.contains(m.id) && m.available)
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
if (financeMenus.isEmpty) {
|
|
||||||
return const Center(
|
|
||||||
child: Text(
|
|
||||||
"You don’t have access to the Finance section.",
|
|
||||||
style: TextStyle(color: Colors.grey),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return SingleChildScrollView(
|
|
||||||
padding: const EdgeInsets.all(16),
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
_buildFinanceModulesCompact(financeMenus),
|
|
||||||
MySpacing.height(24),
|
|
||||||
ExpenseByStatusWidget(controller: dashboardController),
|
|
||||||
MySpacing.height(24),
|
|
||||||
ExpenseTypeReportChart(),
|
|
||||||
MySpacing.height(24),
|
|
||||||
MonthlyExpenseDashboardChart(),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Finance Modules (Compact Dashboard-style) ---
|
// --- Finance Modules (Compact Dashboard-style) ---
|
||||||
Widget _buildFinanceModulesCompact(List<MenuItem> financeMenus) {
|
Widget _buildFinanceModulesCompact(List<MenuItem> financeMenus) {
|
||||||
// Map menu IDs to icon + color
|
// Map menu IDs to icon + color
|
||||||
final Map<String, _FinanceCardMeta> financeCardMeta = {
|
final Map<String, _FinanceCardMeta> financeCardMeta = {
|
||||||
MenuItems.expenseReimbursement: _FinanceCardMeta(LucideIcons.badge_dollar_sign, contentTheme.info),
|
MenuItems.expenseReimbursement:
|
||||||
MenuItems.paymentRequests: _FinanceCardMeta(LucideIcons.receipt_text, contentTheme.primary),
|
_FinanceCardMeta(LucideIcons.badge_dollar_sign, contentTheme.info),
|
||||||
MenuItems.advancePaymentStatements: _FinanceCardMeta(LucideIcons.wallet, contentTheme.warning),
|
MenuItems.paymentRequests:
|
||||||
};
|
_FinanceCardMeta(LucideIcons.receipt_text, contentTheme.primary),
|
||||||
|
MenuItems.advancePaymentStatements:
|
||||||
|
_FinanceCardMeta(LucideIcons.wallet, contentTheme.warning),
|
||||||
|
};
|
||||||
|
|
||||||
// Build the stat items using API-provided mobileLink
|
// Build the stat items using API-provided mobileLink
|
||||||
final stats = financeMenus.map((menu) {
|
final stats = financeMenus.map((menu) {
|
||||||
final meta = financeCardMeta[menu.id]!;
|
final meta = financeCardMeta[menu.id]!;
|
||||||
|
|
||||||
// --- Log the routing info ---
|
// --- Log the routing info ---
|
||||||
debugPrint(
|
debugPrint(
|
||||||
"[Finance Card] ID: ${menu.id}, Title: ${menu.name}, Route: ${menu.mobileLink}");
|
"[Finance Card] ID: ${menu.id}, Title: ${menu.name}, Route: ${menu.mobileLink}");
|
||||||
|
|
||||||
return _FinanceStatItem(
|
return _FinanceStatItem(
|
||||||
meta.icon,
|
meta.icon,
|
||||||
menu.name,
|
menu.name,
|
||||||
meta.color,
|
meta.color,
|
||||||
menu.mobileLink, // Each card navigates to its own route
|
menu.mobileLink, // Each card navigates to its own route
|
||||||
);
|
);
|
||||||
}).toList();
|
}).toList();
|
||||||
|
|
||||||
final projectSelected = projectController.selectedProject != null;
|
final projectSelected = projectController.selectedProject != null;
|
||||||
|
|
||||||
return LayoutBuilder(builder: (context, constraints) {
|
return LayoutBuilder(builder: (context, constraints) {
|
||||||
// Determine number of columns dynamically
|
// Determine number of columns dynamically
|
||||||
int crossAxisCount = (constraints.maxWidth ~/ 80).clamp(2, 4);
|
int crossAxisCount = (constraints.maxWidth ~/ 80).clamp(2, 4);
|
||||||
double cardWidth = (constraints.maxWidth - (crossAxisCount - 1) * 6) / crossAxisCount;
|
double cardWidth =
|
||||||
|
(constraints.maxWidth - (crossAxisCount - 1) * 6) / crossAxisCount;
|
||||||
|
|
||||||
return Wrap(
|
return Wrap(
|
||||||
spacing: 6,
|
spacing: 6,
|
||||||
runSpacing: 6,
|
runSpacing: 6,
|
||||||
alignment: WrapAlignment.end,
|
alignment: WrapAlignment.end,
|
||||||
children: stats
|
children: stats
|
||||||
.map((stat) => _buildFinanceModuleCard(stat, projectSelected, cardWidth))
|
.map((stat) =>
|
||||||
.toList(),
|
_buildFinanceModuleCard(stat, projectSelected, cardWidth))
|
||||||
);
|
.toList(),
|
||||||
});
|
);
|
||||||
}
|
});
|
||||||
|
}
|
||||||
|
|
||||||
Widget _buildFinanceModuleCard(
|
Widget _buildFinanceModuleCard(
|
||||||
_FinanceStatItem stat, bool isProjectSelected, double width) {
|
_FinanceStatItem stat, bool isProjectSelected, double width) {
|
||||||
return Opacity(
|
return Opacity(
|
||||||
opacity: isProjectSelected ? 1.0 : 0.4, // Dim if no project selected
|
opacity: isProjectSelected ? 1.0 : 0.4, // Dim if no project selected
|
||||||
child: IgnorePointer(
|
child: IgnorePointer(
|
||||||
ignoring: !isProjectSelected,
|
ignoring: !isProjectSelected,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () => _onCardTap(stat, isProjectSelected),
|
onTap: () => _onCardTap(stat, isProjectSelected),
|
||||||
borderRadius: BorderRadius.circular(5),
|
borderRadius: BorderRadius.circular(5),
|
||||||
child: MyCard.bordered(
|
child: MyCard.bordered(
|
||||||
width: width,
|
width: width,
|
||||||
height: 60,
|
height: 60,
|
||||||
paddingAll: 4,
|
paddingAll: 4,
|
||||||
borderRadiusAll: 5,
|
borderRadiusAll: 5,
|
||||||
border: Border.all(color: Colors.grey.withOpacity(0.15)),
|
border: Border.all(color: Colors.grey.withOpacity(0.15)),
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.all(4),
|
padding: const EdgeInsets.all(4),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: stat.color.withOpacity(0.1),
|
color: stat.color.withOpacity(0.1),
|
||||||
borderRadius: BorderRadius.circular(4),
|
borderRadius: BorderRadius.circular(4),
|
||||||
),
|
),
|
||||||
child: Icon(
|
child: Icon(
|
||||||
stat.icon,
|
stat.icon,
|
||||||
size: 16,
|
size: 16,
|
||||||
color: stat.color,
|
color: stat.color,
|
||||||
),
|
|
||||||
),
|
|
||||||
MySpacing.height(4),
|
|
||||||
Flexible(
|
|
||||||
child: Text(
|
|
||||||
stat.title,
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 10,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
),
|
),
|
||||||
maxLines: 2,
|
|
||||||
softWrap: true,
|
|
||||||
),
|
),
|
||||||
),
|
MySpacing.height(4),
|
||||||
],
|
Flexible(
|
||||||
|
child: Text(
|
||||||
|
stat.title,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 10,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
maxLines: 2,
|
||||||
|
softWrap: true,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _onCardTap(_FinanceStatItem statItem, bool isEnabled) {
|
|
||||||
if (!isEnabled) {
|
|
||||||
Get.defaultDialog(
|
|
||||||
title: "No Project Selected",
|
|
||||||
middleText: "Please select a project before accessing this section.",
|
|
||||||
confirm: ElevatedButton(
|
|
||||||
onPressed: () => Get.back(),
|
|
||||||
child: const Text("OK"),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
} else {
|
}
|
||||||
// Navigate to the card's specific route
|
|
||||||
Get.toNamed(statItem.route);
|
void _onCardTap(_FinanceStatItem statItem, bool isEnabled) {
|
||||||
|
if (!isEnabled) {
|
||||||
|
Get.defaultDialog(
|
||||||
|
title: "No Project Selected",
|
||||||
|
middleText: "Please select a project before accessing this section.",
|
||||||
|
confirm: ElevatedButton(
|
||||||
|
onPressed: () => Get.back(),
|
||||||
|
child: const Text("OK"),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
// Navigate to the card's specific route
|
||||||
|
Get.toNamed(statItem.route);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
class _FinanceStatItem {
|
class _FinanceStatItem {
|
||||||
final IconData icon;
|
final IconData icon;
|
||||||
|
|||||||
@ -99,42 +99,50 @@ class _PaymentRequestMainScreenState extends State<PaymentRequestMainScreen>
|
|||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: Colors.white,
|
backgroundColor: Colors.white,
|
||||||
appBar: _buildAppBar(),
|
appBar: _buildAppBar(),
|
||||||
body: Column(
|
|
||||||
children: [
|
// ------------------------
|
||||||
Container(
|
// FIX: SafeArea prevents content from going under 3-button navbar
|
||||||
color: Colors.white,
|
// ------------------------
|
||||||
child: TabBar(
|
body: SafeArea(
|
||||||
controller: _tabController,
|
bottom: true,
|
||||||
labelColor: Colors.black,
|
child: Column(
|
||||||
unselectedLabelColor: Colors.grey,
|
children: [
|
||||||
indicatorColor: Colors.red,
|
Container(
|
||||||
tabs: const [
|
color: Colors.white,
|
||||||
Tab(text: "Current Month"),
|
child: TabBar(
|
||||||
Tab(text: "History"),
|
controller: _tabController,
|
||||||
],
|
labelColor: Colors.black,
|
||||||
),
|
unselectedLabelColor: Colors.grey,
|
||||||
),
|
indicatorColor: Colors.red,
|
||||||
Expanded(
|
tabs: const [
|
||||||
child: Container(
|
Tab(text: "Current Month"),
|
||||||
color: Colors.grey[100],
|
Tab(text: "History"),
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
_buildSearchBar(),
|
|
||||||
Expanded(
|
|
||||||
child: TabBarView(
|
|
||||||
controller: _tabController,
|
|
||||||
children: [
|
|
||||||
_buildPaymentRequestList(isHistory: false),
|
|
||||||
_buildPaymentRequestList(isHistory: true),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
Expanded(
|
||||||
],
|
child: Container(
|
||||||
|
color: Colors.grey[100],
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
_buildSearchBar(),
|
||||||
|
Expanded(
|
||||||
|
child: TabBarView(
|
||||||
|
controller: _tabController,
|
||||||
|
children: [
|
||||||
|
_buildPaymentRequestList(isHistory: false),
|
||||||
|
_buildPaymentRequestList(isHistory: true),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
floatingActionButton: Obx(() {
|
floatingActionButton: Obx(() {
|
||||||
if (permissionController.permissions.isEmpty) {
|
if (permissionController.permissions.isEmpty) {
|
||||||
return const SizedBox.shrink();
|
return const SizedBox.shrink();
|
||||||
@ -294,7 +302,6 @@ class _PaymentRequestMainScreenState extends State<PaymentRequestMainScreen>
|
|||||||
|
|
||||||
final list = filteredList(isHistory: isHistory);
|
final list = filteredList(isHistory: isHistory);
|
||||||
|
|
||||||
// ScrollController for infinite scroll
|
|
||||||
final scrollController = ScrollController();
|
final scrollController = ScrollController();
|
||||||
scrollController.addListener(() {
|
scrollController.addListener(() {
|
||||||
if (scrollController.position.pixels >=
|
if (scrollController.position.pixels >=
|
||||||
@ -309,6 +316,7 @@ class _PaymentRequestMainScreenState extends State<PaymentRequestMainScreen>
|
|||||||
child: list.isEmpty
|
child: list.isEmpty
|
||||||
? ListView(
|
? ListView(
|
||||||
physics: const AlwaysScrollableScrollPhysics(),
|
physics: const AlwaysScrollableScrollPhysics(),
|
||||||
|
padding: const EdgeInsets.only(bottom: 100),
|
||||||
children: [
|
children: [
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: MediaQuery.of(context).size.height * 0.5,
|
height: MediaQuery.of(context).size.height * 0.5,
|
||||||
@ -325,7 +333,12 @@ class _PaymentRequestMainScreenState extends State<PaymentRequestMainScreen>
|
|||||||
)
|
)
|
||||||
: ListView.separated(
|
: ListView.separated(
|
||||||
controller: scrollController,
|
controller: scrollController,
|
||||||
padding: const EdgeInsets.fromLTRB(12, 12, 12, 80),
|
|
||||||
|
// ------------------------
|
||||||
|
// FIX: ensure bottom list items stay visible above nav bar
|
||||||
|
// ------------------------
|
||||||
|
padding: const EdgeInsets.fromLTRB(12, 12, 12, 120),
|
||||||
|
|
||||||
itemCount: list.length + 1,
|
itemCount: list.length + 1,
|
||||||
separatorBuilder: (_, __) =>
|
separatorBuilder: (_, __) =>
|
||||||
Divider(color: Colors.grey.shade300, height: 20),
|
Divider(color: Colors.grey.shade300, height: 20),
|
||||||
@ -365,10 +378,6 @@ class _PaymentRequestMainScreenState extends State<PaymentRequestMainScreen>
|
|||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
MyText.bodyMedium(item.expenseCategory.name, fontWeight: 600),
|
MyText.bodyMedium(item.expenseCategory.name, fontWeight: 600),
|
||||||
|
|
||||||
// -------------------------------
|
|
||||||
// ADV CHIP (only if advance)
|
|
||||||
// -------------------------------
|
|
||||||
if (item.isAdvancePayment == true) ...[
|
if (item.isAdvancePayment == true) ...[
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
Container(
|
Container(
|
||||||
|
|||||||
@ -51,6 +51,7 @@ class _JobDetailsScreenState extends State<JobDetailsScreen> with UIMixin {
|
|||||||
controller.fetchJobDetail(widget.jobId).then((_) {
|
controller.fetchJobDetail(widget.jobId).then((_) {
|
||||||
final job = controller.jobDetail.value?.data;
|
final job = controller.jobDetail.value?.data;
|
||||||
if (job != null) {
|
if (job != null) {
|
||||||
|
_selectedTags.value = job.tags ?? [];
|
||||||
_titleController.text = job.title ?? '';
|
_titleController.text = job.title ?? '';
|
||||||
_descriptionController.text = job.description ?? '';
|
_descriptionController.text = job.description ?? '';
|
||||||
_startDateController.text = DateTimeUtils.convertUtcToLocal(
|
_startDateController.text = DateTimeUtils.convertUtcToLocal(
|
||||||
@ -169,6 +170,11 @@ class _JobDetailsScreenState extends State<JobDetailsScreen> with UIMixin {
|
|||||||
message: "Job updated successfully",
|
message: "Job updated successfully",
|
||||||
type: SnackbarType.success);
|
type: SnackbarType.success);
|
||||||
await controller.fetchJobDetail(widget.jobId);
|
await controller.fetchJobDetail(widget.jobId);
|
||||||
|
final updatedJob = controller.jobDetail.value?.data;
|
||||||
|
if (updatedJob != null) {
|
||||||
|
_selectedTags.value = updatedJob.tags ?? [];
|
||||||
|
}
|
||||||
|
|
||||||
isEditing.value = false;
|
isEditing.value = false;
|
||||||
} else {
|
} else {
|
||||||
showAppSnackbar(
|
showAppSnackbar(
|
||||||
|
|||||||
@ -22,11 +22,11 @@ class _ServiceProjectScreenState extends State<ServiceProjectScreen>
|
|||||||
final TextEditingController searchController = TextEditingController();
|
final TextEditingController searchController = TextEditingController();
|
||||||
final ServiceProjectController controller =
|
final ServiceProjectController controller =
|
||||||
Get.put(ServiceProjectController());
|
Get.put(ServiceProjectController());
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
|
||||||
// Fetch projects safely after first frame
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
controller.fetchProjects();
|
controller.fetchProjects();
|
||||||
});
|
});
|
||||||
@ -49,10 +49,9 @@ class _ServiceProjectScreenState extends State<ServiceProjectScreen>
|
|||||||
child: InkWell(
|
child: InkWell(
|
||||||
borderRadius: BorderRadius.circular(14),
|
borderRadius: BorderRadius.circular(14),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
// Navigate to ServiceProjectDetailsScreen
|
|
||||||
Get.to(() => ServiceProjectDetailsScreen(
|
Get.to(() => ServiceProjectDetailsScreen(
|
||||||
projectId: project.id,
|
projectId: project.id,
|
||||||
projectName: project.name,
|
projectName: project.name,
|
||||||
));
|
));
|
||||||
},
|
},
|
||||||
child: Padding(
|
child: Padding(
|
||||||
@ -60,7 +59,6 @@ class _ServiceProjectScreenState extends State<ServiceProjectScreen>
|
|||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
/// Project Header
|
|
||||||
Row(
|
Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
@ -92,20 +90,14 @@ class _ServiceProjectScreenState extends State<ServiceProjectScreen>
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
||||||
MySpacing.height(10),
|
MySpacing.height(10),
|
||||||
|
|
||||||
/// Assigned Date
|
|
||||||
_buildDetailRow(
|
_buildDetailRow(
|
||||||
Icons.date_range_outlined,
|
Icons.date_range_outlined,
|
||||||
Colors.teal,
|
Colors.teal,
|
||||||
"Assigned: ${DateTimeUtils.convertUtcToLocal(project.assignedDate.toIso8601String(), format: DateTimeUtils.defaultFormat)}",
|
"Assigned: ${DateTimeUtils.convertUtcToLocal(project.assignedDate.toIso8601String(), format: DateTimeUtils.defaultFormat)}",
|
||||||
fontSize: 13,
|
fontSize: 13,
|
||||||
),
|
),
|
||||||
|
|
||||||
MySpacing.height(8),
|
MySpacing.height(8),
|
||||||
|
|
||||||
/// Client Info
|
|
||||||
if (project.client != null)
|
if (project.client != null)
|
||||||
_buildDetailRow(
|
_buildDetailRow(
|
||||||
Icons.account_circle_outlined,
|
Icons.account_circle_outlined,
|
||||||
@ -113,20 +105,14 @@ class _ServiceProjectScreenState extends State<ServiceProjectScreen>
|
|||||||
"Client: ${project.client!.name} (${project.client!.contactPerson})",
|
"Client: ${project.client!.name} (${project.client!.contactPerson})",
|
||||||
fontSize: 13,
|
fontSize: 13,
|
||||||
),
|
),
|
||||||
|
|
||||||
MySpacing.height(8),
|
MySpacing.height(8),
|
||||||
|
|
||||||
/// Contact Info
|
|
||||||
_buildDetailRow(
|
_buildDetailRow(
|
||||||
Icons.phone,
|
Icons.phone,
|
||||||
Colors.green,
|
Colors.green,
|
||||||
"Contact: ${project.contactName} (${project.contactPhone})",
|
"Contact: ${project.contactName} (${project.contactPhone})",
|
||||||
fontSize: 13,
|
fontSize: 13,
|
||||||
),
|
),
|
||||||
|
|
||||||
MySpacing.height(12),
|
MySpacing.height(12),
|
||||||
|
|
||||||
/// Services List
|
|
||||||
if (project.services.isNotEmpty)
|
if (project.services.isNotEmpty)
|
||||||
Wrap(
|
Wrap(
|
||||||
spacing: 6,
|
spacing: 6,
|
||||||
@ -197,90 +183,97 @@ class _ServiceProjectScreenState extends State<ServiceProjectScreen>
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: const Color(0xFFF5F5F5),
|
backgroundColor: const Color(0xFFF5F5F5),
|
||||||
|
|
||||||
appBar: CustomAppBar(
|
appBar: CustomAppBar(
|
||||||
title: "Service Projects",
|
title: "Service Projects",
|
||||||
projectName: 'All Service Projects',
|
projectName: 'All Service Projects',
|
||||||
onBackPressed: () => Get.toNamed('/dashboard'),
|
onBackPressed: () => Get.toNamed('/dashboard'),
|
||||||
),
|
),
|
||||||
body: Column(
|
|
||||||
children: [
|
// FIX 1: Entire body wrapped in SafeArea
|
||||||
/// Search bar and actions
|
body: SafeArea(
|
||||||
Padding(
|
bottom: true,
|
||||||
padding: MySpacing.xy(8, 8),
|
child: Column(
|
||||||
child: Row(
|
children: [
|
||||||
children: [
|
Padding(
|
||||||
Expanded(
|
padding: MySpacing.xy(8, 8),
|
||||||
child: SizedBox(
|
child: Row(
|
||||||
height: 35,
|
children: [
|
||||||
child: TextField(
|
Expanded(
|
||||||
controller: searchController,
|
child: SizedBox(
|
||||||
decoration: InputDecoration(
|
height: 35,
|
||||||
contentPadding:
|
child: TextField(
|
||||||
const EdgeInsets.symmetric(horizontal: 12),
|
controller: searchController,
|
||||||
prefixIcon: const Icon(Icons.search,
|
decoration: InputDecoration(
|
||||||
size: 20, color: Colors.grey),
|
contentPadding:
|
||||||
suffixIcon: ValueListenableBuilder<TextEditingValue>(
|
const EdgeInsets.symmetric(horizontal: 12),
|
||||||
valueListenable: searchController,
|
prefixIcon: const Icon(Icons.search,
|
||||||
builder: (context, value, _) {
|
size: 20, color: Colors.grey),
|
||||||
if (value.text.isEmpty) {
|
suffixIcon: ValueListenableBuilder<TextEditingValue>(
|
||||||
return const SizedBox.shrink();
|
valueListenable: searchController,
|
||||||
}
|
builder: (context, value, _) {
|
||||||
return IconButton(
|
if (value.text.isEmpty) {
|
||||||
icon: const Icon(Icons.clear,
|
return const SizedBox.shrink();
|
||||||
size: 20, color: Colors.grey),
|
}
|
||||||
onPressed: () {
|
return IconButton(
|
||||||
searchController.clear();
|
icon: const Icon(Icons.clear,
|
||||||
controller.updateSearch('');
|
size: 20, color: Colors.grey),
|
||||||
},
|
onPressed: () {
|
||||||
);
|
searchController.clear();
|
||||||
},
|
controller.updateSearch('');
|
||||||
),
|
},
|
||||||
hintText: 'Search projects...',
|
);
|
||||||
filled: true,
|
},
|
||||||
fillColor: Colors.white,
|
),
|
||||||
border: OutlineInputBorder(
|
hintText: 'Search projects...',
|
||||||
borderRadius: BorderRadius.circular(5),
|
filled: true,
|
||||||
borderSide: BorderSide(color: Colors.grey.shade300),
|
fillColor: Colors.white,
|
||||||
),
|
border: OutlineInputBorder(
|
||||||
enabledBorder: OutlineInputBorder(
|
borderRadius: BorderRadius.circular(5),
|
||||||
borderRadius: BorderRadius.circular(5),
|
borderSide: BorderSide(color: Colors.grey.shade300),
|
||||||
borderSide: BorderSide(color: Colors.grey.shade300),
|
),
|
||||||
|
enabledBorder: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(5),
|
||||||
|
borderSide: BorderSide(color: Colors.grey.shade300),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
Expanded(
|
||||||
|
child: Obx(() {
|
||||||
|
if (controller.isLoading.value) {
|
||||||
|
return const Center(child: CircularProgressIndicator());
|
||||||
|
}
|
||||||
|
|
||||||
/// Project List
|
final projects = controller.filteredProjects;
|
||||||
Expanded(
|
|
||||||
child: Obx(() {
|
|
||||||
if (controller.isLoading.value) {
|
|
||||||
return const Center(child: CircularProgressIndicator());
|
|
||||||
}
|
|
||||||
|
|
||||||
final projects = controller.filteredProjects;
|
return MyRefreshIndicator(
|
||||||
return MyRefreshIndicator(
|
onRefresh: _refreshProjects,
|
||||||
onRefresh: _refreshProjects,
|
backgroundColor: Colors.indigo,
|
||||||
backgroundColor: Colors.indigo,
|
color: Colors.white,
|
||||||
color: Colors.white,
|
child: projects.isEmpty
|
||||||
child: projects.isEmpty
|
? _buildEmptyState()
|
||||||
? _buildEmptyState()
|
: ListView.separated(
|
||||||
: ListView.separated(
|
physics: const AlwaysScrollableScrollPhysics(),
|
||||||
physics: const AlwaysScrollableScrollPhysics(),
|
|
||||||
padding: MySpacing.only(
|
// FIX 2: Increased bottom padding for landscape
|
||||||
left: 8, right: 8, top: 4, bottom: 80),
|
padding: MySpacing.only(
|
||||||
itemCount: projects.length,
|
left: 8, right: 8, top: 4, bottom: 120),
|
||||||
separatorBuilder: (_, __) => MySpacing.height(12),
|
|
||||||
itemBuilder: (_, index) =>
|
itemCount: projects.length,
|
||||||
_buildProjectCard(projects[index]),
|
separatorBuilder: (_, __) => MySpacing.height(12),
|
||||||
),
|
itemBuilder: (_, index) =>
|
||||||
);
|
_buildProjectCard(projects[index]),
|
||||||
}),
|
),
|
||||||
),
|
);
|
||||||
],
|
}),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user