- Updated import paths for employee model files to reflect new directory structure. - Deleted obsolete models: JobRecentApplicationModel, LeadReportModel, Product, ProductOrderModal, ProjectSummaryModel, RecentOrderModel, TaskListModel, TimeLineModel, User, VisitorByChannelsModel. - Introduced new AttendanceLogModel, AttendanceLogViewModel, AttendanceModel, TaskModel, TaskListModel, EmployeeInfo, and EmployeeModel with comprehensive fields and JSON serialization methods. - Enhanced data handling in attendance and task management features.
85 lines
2.9 KiB
Dart
85 lines
2.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:marco/helpers/widgets/my_spacing.dart';
|
|
import 'package:marco/helpers/widgets/my_text.dart';
|
|
import 'package:marco/helpers/utils/base_bottom_sheet.dart';
|
|
import 'package:marco/model/employees/employee_model.dart';
|
|
|
|
class ReusableEmployeeSelectorBottomSheet extends StatelessWidget {
|
|
final TextEditingController searchController;
|
|
final RxList<EmployeeModel> searchResults;
|
|
final RxBool isSearching;
|
|
final void Function(String) onSearch;
|
|
final void Function(EmployeeModel) onSelect;
|
|
|
|
const ReusableEmployeeSelectorBottomSheet({
|
|
super.key,
|
|
required this.searchController,
|
|
required this.searchResults,
|
|
required this.isSearching,
|
|
required this.onSearch,
|
|
required this.onSelect,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return BaseBottomSheet(
|
|
title: "Search Employee",
|
|
onCancel: () => Get.back(),
|
|
onSubmit: () {},
|
|
showButtons: false,
|
|
child: Obx(() {
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
TextField(
|
|
controller: searchController,
|
|
decoration: InputDecoration(
|
|
hintText: "Search by name, email...",
|
|
prefixIcon: const Icon(Icons.search),
|
|
border: OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(8),
|
|
),
|
|
contentPadding:
|
|
const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
|
|
),
|
|
onChanged: onSearch,
|
|
),
|
|
MySpacing.height(12),
|
|
SizedBox(
|
|
height: 400,
|
|
child: isSearching.value
|
|
? const Center(child: CircularProgressIndicator())
|
|
: searchResults.isEmpty
|
|
? Center(
|
|
child: MyText.bodyMedium(
|
|
"No employees found.",
|
|
fontWeight: 500,
|
|
),
|
|
)
|
|
: ListView.builder(
|
|
itemCount: searchResults.length,
|
|
itemBuilder: (_, index) {
|
|
final emp = searchResults[index];
|
|
final fullName =
|
|
'${emp.firstName} ${emp.lastName}'.trim();
|
|
return ListTile(
|
|
title: MyText.bodyLarge(
|
|
fullName.isNotEmpty ? fullName : "Unnamed",
|
|
fontWeight: 600,
|
|
),
|
|
onTap: () {
|
|
onSelect(emp);
|
|
Get.back();
|
|
},
|
|
);
|
|
},
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}),
|
|
);
|
|
}
|
|
}
|