- Changed AttendanceLogsTab from StatelessWidget to StatefulWidget to manage state for showing pending actions. - Added a status header in AttendanceLogsTab to indicate when only pending actions are displayed. - Updated filtering logic in AttendanceLogsTab to use filteredLogs based on the pending actions toggle. - Refactored AttendanceScreen to include a search bar for filtering attendance logs by name. - Introduced a new filter icon in AttendanceScreen for accessing the filter options. - Updated RegularizationRequestsTab to use filteredRegularizationLogs for displaying requests. - Modified TodaysAttendanceTab to utilize filteredEmployees for showing today's attendance. - Cleaned up code formatting and improved readability across various files.
159 lines
7.0 KiB
Dart
159 lines
7.0 KiB
Dart
// lib/view/attendance/tabs/regularization_requests_tab.dart
|
|
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:intl/intl.dart';
|
|
import 'package:marco/controller/attendance/attendance_screen_controller.dart';
|
|
import 'package:marco/helpers/widgets/avatar.dart';
|
|
import 'package:marco/helpers/widgets/my_card.dart';
|
|
import 'package:marco/helpers/widgets/my_container.dart';
|
|
import 'package:marco/helpers/widgets/my_spacing.dart';
|
|
import 'package:marco/helpers/widgets/my_text.dart';
|
|
import 'package:marco/helpers/widgets/my_custom_skeleton.dart';
|
|
import 'package:marco/model/attendance/log_details_view.dart';
|
|
import 'package:marco/model/attendance/regualrize_action_button.dart';
|
|
|
|
class RegularizationRequestsTab extends StatelessWidget {
|
|
final AttendanceController controller;
|
|
|
|
const RegularizationRequestsTab({super.key, required this.controller});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(vertical: 12.0, horizontal: 4.0),
|
|
child: MyText.titleMedium("Regularization Requests", fontWeight: 600),
|
|
),
|
|
Obx(() {
|
|
final employees = controller.filteredRegularizationLogs;
|
|
|
|
if (controller.isLoadingRegularizationLogs.value) {
|
|
return SkeletonLoaders.employeeListSkeletonLoader();
|
|
}
|
|
|
|
if (employees.isEmpty) {
|
|
return const SizedBox(
|
|
height: 120,
|
|
child: Center(
|
|
child:
|
|
Text("No Regularization Requests Found for this Project"),
|
|
),
|
|
);
|
|
}
|
|
|
|
return MyCard.bordered(
|
|
paddingAll: 8,
|
|
child: Column(
|
|
children: List.generate(employees.length, (index) {
|
|
final employee = employees[index];
|
|
return Column(
|
|
children: [
|
|
MyContainer(
|
|
paddingAll: 8,
|
|
child: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Avatar(
|
|
firstName: employee.firstName,
|
|
lastName: employee.lastName,
|
|
size: 31,
|
|
),
|
|
MySpacing.width(16),
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Row(
|
|
children: [
|
|
Flexible(
|
|
child: MyText.bodyMedium(
|
|
employee.name,
|
|
fontWeight: 600,
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
),
|
|
MySpacing.width(6),
|
|
Flexible(
|
|
child: MyText.bodySmall(
|
|
'(${employee.role})',
|
|
fontWeight: 600,
|
|
overflow: TextOverflow.ellipsis,
|
|
color: Colors.grey[700],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
MySpacing.height(8),
|
|
if (employee.checkIn != null ||
|
|
employee.checkOut != null)
|
|
Row(
|
|
children: [
|
|
if (employee.checkIn != null) ...[
|
|
const Icon(Icons.arrow_circle_right,
|
|
size: 16, color: Colors.green),
|
|
MySpacing.width(4),
|
|
MyText.bodySmall(
|
|
DateFormat('hh:mm a')
|
|
.format(employee.checkIn!),
|
|
fontWeight: 600,
|
|
),
|
|
MySpacing.width(16),
|
|
],
|
|
if (employee.checkOut != null) ...[
|
|
const Icon(Icons.arrow_circle_left,
|
|
size: 16, color: Colors.red),
|
|
MySpacing.width(4),
|
|
MyText.bodySmall(
|
|
DateFormat('hh:mm a')
|
|
.format(employee.checkOut!),
|
|
fontWeight: 600,
|
|
),
|
|
],
|
|
],
|
|
),
|
|
MySpacing.height(12),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
children: [
|
|
RegularizeActionButton(
|
|
attendanceController: controller,
|
|
log: employee,
|
|
uniqueLogKey: employee.employeeId,
|
|
action: ButtonActions.approve,
|
|
),
|
|
const SizedBox(width: 8),
|
|
RegularizeActionButton(
|
|
attendanceController: controller,
|
|
log: employee,
|
|
uniqueLogKey: employee.employeeId,
|
|
action: ButtonActions.reject,
|
|
),
|
|
const SizedBox(width: 8),
|
|
if (employee.checkIn != null)
|
|
AttendanceLogViewButton(
|
|
employee: employee,
|
|
attendanceController: controller,
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
if (index != employees.length - 1)
|
|
Divider(color: Colors.grey.withOpacity(0.3)),
|
|
],
|
|
);
|
|
}),
|
|
),
|
|
);
|
|
}),
|
|
],
|
|
);
|
|
}
|
|
}
|