Refactor attendance management screens for improved readability and g
This commit is contained in:
parent
3ad48016f3
commit
ed2eb014d8
@ -2,10 +2,8 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:on_field_work/controller/permission_controller.dart';
|
import 'package:on_field_work/controller/permission_controller.dart';
|
||||||
import 'package:on_field_work/controller/attendance/attendance_screen_controller.dart';
|
import 'package:on_field_work/controller/attendance/attendance_screen_controller.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/utils/permission_constants.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:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:on_field_work/helpers/utils/date_time_utils.dart';
|
|
||||||
import 'package:on_field_work/helpers/widgets/date_range_picker.dart';
|
import 'package:on_field_work/helpers/widgets/date_range_picker.dart';
|
||||||
|
|
||||||
class AttendanceFilterBottomSheet extends StatefulWidget {
|
class AttendanceFilterBottomSheet extends StatefulWidget {
|
||||||
@ -27,21 +25,6 @@ class AttendanceFilterBottomSheet extends StatefulWidget {
|
|||||||
|
|
||||||
class _AttendanceFilterBottomSheetState
|
class _AttendanceFilterBottomSheetState
|
||||||
extends State<AttendanceFilterBottomSheet> {
|
extends State<AttendanceFilterBottomSheet> {
|
||||||
late String tempSelectedTab;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
tempSelectedTab = widget.selectedTab;
|
|
||||||
}
|
|
||||||
|
|
||||||
String getLabelText() {
|
|
||||||
final start = DateTimeUtils.formatDate(
|
|
||||||
widget.controller.startDateAttendance.value, 'dd MMM yyyy');
|
|
||||||
final end = DateTimeUtils.formatDate(
|
|
||||||
widget.controller.endDateAttendance.value, 'dd MMM yyyy');
|
|
||||||
return "$start - $end";
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _popupSelector({
|
Widget _popupSelector({
|
||||||
required String currentValue,
|
required String currentValue,
|
||||||
@ -51,12 +34,8 @@ class _AttendanceFilterBottomSheetState
|
|||||||
return PopupMenuButton<String>(
|
return PopupMenuButton<String>(
|
||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||||
onSelected: onSelected,
|
onSelected: onSelected,
|
||||||
itemBuilder: (context) => items
|
itemBuilder: (context) =>
|
||||||
.map((e) => PopupMenuItem<String>(
|
items.map((e) => PopupMenuItem<String>(value: e, child: MyText(e))).toList(),
|
||||||
value: e,
|
|
||||||
child: MyText(e),
|
|
||||||
))
|
|
||||||
.toList(),
|
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
@ -107,46 +86,11 @@ class _AttendanceFilterBottomSheetState
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Widget> buildMainFilters() {
|
List<Widget> _buildFilters() {
|
||||||
final hasRegularizationPermission = widget.permissionController
|
final List<Widget> widgets = [];
|
||||||
.hasPermission(Permissions.regularizeAttendance);
|
|
||||||
|
|
||||||
final viewOptions = [
|
|
||||||
{'label': 'Today\'s Attendance', 'value': 'todaysAttendance'},
|
|
||||||
{'label': 'Attendance Logs', 'value': 'attendanceLogs'},
|
|
||||||
{'label': 'Regularization Requests', 'value': 'regularizationRequests'},
|
|
||||||
];
|
|
||||||
|
|
||||||
final filteredOptions = viewOptions.where((item) {
|
|
||||||
return item['value'] != 'regularizationRequests' ||
|
|
||||||
hasRegularizationPermission;
|
|
||||||
}).toList();
|
|
||||||
|
|
||||||
final List<Widget> widgets = [
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(bottom: 4),
|
|
||||||
child: Align(
|
|
||||||
alignment: Alignment.centerLeft,
|
|
||||||
child: MyText.titleSmall("View", fontWeight: 600),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
...filteredOptions.map((item) {
|
|
||||||
return RadioListTile<String>(
|
|
||||||
dense: true,
|
|
||||||
contentPadding: EdgeInsets.zero,
|
|
||||||
title: MyText.bodyMedium(
|
|
||||||
item['label']!,
|
|
||||||
fontWeight: 500,
|
|
||||||
),
|
|
||||||
value: item['value']!,
|
|
||||||
groupValue: tempSelectedTab,
|
|
||||||
onChanged: (value) => setState(() => tempSelectedTab = value!),
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
];
|
|
||||||
|
|
||||||
|
// Organization selector
|
||||||
widgets.addAll([
|
widgets.addAll([
|
||||||
const Divider(),
|
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(top: 12, bottom: 12),
|
padding: const EdgeInsets.only(top: 12, bottom: 12),
|
||||||
child: Align(
|
child: Align(
|
||||||
@ -180,7 +124,8 @@ class _AttendanceFilterBottomSheetState
|
|||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (tempSelectedTab == 'attendanceLogs') {
|
// Date range (only for Attendance Logs)
|
||||||
|
if (widget.selectedTab == 'attendanceLogs') {
|
||||||
widgets.addAll([
|
widgets.addAll([
|
||||||
const Divider(),
|
const Divider(),
|
||||||
Padding(
|
Padding(
|
||||||
@ -208,24 +153,20 @@ class _AttendanceFilterBottomSheetState
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return SafeArea(
|
return SafeArea(
|
||||||
// ← FIX: avoids hiding under navigation buttons
|
|
||||||
child: BaseBottomSheet(
|
child: BaseBottomSheet(
|
||||||
title: "Attendance Filter",
|
title: "Attendance Filter",
|
||||||
submitText: "Apply",
|
submitText: "Apply",
|
||||||
onCancel: () => Navigator.pop(context),
|
onCancel: () => Navigator.pop(context),
|
||||||
onSubmit: () => Navigator.pop(context, {
|
onSubmit: () => Navigator.pop(context, {
|
||||||
'selectedTab': tempSelectedTab,
|
|
||||||
'selectedOrganization': widget.controller.selectedOrganization?.id,
|
'selectedOrganization': widget.controller.selectedOrganization?.id,
|
||||||
}),
|
}),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding:
|
padding: const EdgeInsets.only(bottom: 24),
|
||||||
const EdgeInsets.only(bottom: 24), // ← FIX: extra safe padding
|
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
// ← FIX: full scrollable in landscape
|
|
||||||
physics: const BouncingScrollPhysics(),
|
physics: const BouncingScrollPhysics(),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: buildMainFilters(),
|
children: _buildFilters(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -3,7 +3,6 @@ import 'package:get/get.dart';
|
|||||||
import 'package:on_field_work/controller/attendance/attendance_screen_controller.dart';
|
import 'package:on_field_work/controller/attendance/attendance_screen_controller.dart';
|
||||||
import 'package:on_field_work/helpers/utils/date_time_utils.dart';
|
import 'package:on_field_work/helpers/utils/date_time_utils.dart';
|
||||||
import 'package:on_field_work/helpers/widgets/avatar.dart';
|
import 'package:on_field_work/helpers/widgets/avatar.dart';
|
||||||
import 'package:on_field_work/helpers/widgets/my_card.dart';
|
|
||||||
import 'package:on_field_work/helpers/widgets/my_container.dart';
|
import 'package:on_field_work/helpers/widgets/my_container.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_text.dart';
|
import 'package:on_field_work/helpers/widgets/my_text.dart';
|
||||||
@ -12,21 +11,14 @@ import 'package:on_field_work/model/attendance/log_details_view.dart';
|
|||||||
import 'package:on_field_work/model/attendance/attendence_action_button.dart';
|
import 'package:on_field_work/model/attendance/attendence_action_button.dart';
|
||||||
import 'package:on_field_work/helpers/utils/attendance_actions.dart';
|
import 'package:on_field_work/helpers/utils/attendance_actions.dart';
|
||||||
|
|
||||||
class AttendanceLogsTab extends StatefulWidget {
|
class AttendanceLogsTab extends StatelessWidget {
|
||||||
final AttendanceController controller;
|
final AttendanceController controller;
|
||||||
|
|
||||||
const AttendanceLogsTab({super.key, required this.controller});
|
const AttendanceLogsTab({super.key, required this.controller});
|
||||||
|
|
||||||
@override
|
|
||||||
State<AttendanceLogsTab> createState() => _AttendanceLogsTabState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _AttendanceLogsTabState extends State<AttendanceLogsTab> {
|
|
||||||
Widget _buildStatusHeader() {
|
Widget _buildStatusHeader() {
|
||||||
return Obx(() {
|
return Obx(() {
|
||||||
if (!widget.controller.showPendingOnly.value) {
|
if (!controller.showPendingOnly.value) return const SizedBox.shrink();
|
||||||
return const SizedBox.shrink();
|
|
||||||
}
|
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
@ -46,7 +38,7 @@ class _AttendanceLogsTabState extends State<AttendanceLogsTab> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
InkWell(
|
InkWell(
|
||||||
onTap: () => widget.controller.showPendingOnly.value = false,
|
onTap: () => controller.showPendingOnly.value = false,
|
||||||
child: const Icon(Icons.close, size: 18, color: Colors.orange),
|
child: const Icon(Icons.close, size: 18, color: Colors.orange),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -55,7 +47,6 @@ class _AttendanceLogsTabState extends State<AttendanceLogsTab> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return button text priority for sorting inside same date
|
|
||||||
int _getActionPriority(employee) {
|
int _getActionPriority(employee) {
|
||||||
final text = AttendanceButtonHelper.getButtonText(
|
final text = AttendanceButtonHelper.getButtonText(
|
||||||
activity: employee.activity,
|
activity: employee.activity,
|
||||||
@ -77,32 +68,20 @@ class _AttendanceLogsTabState extends State<AttendanceLogsTab> {
|
|||||||
final isCheckoutAction =
|
final isCheckoutAction =
|
||||||
text.contains("checkout") || text.contains("check out");
|
text.contains("checkout") || text.contains("check out");
|
||||||
|
|
||||||
int priority;
|
if (isYesterdayCheckIn && isMissingCheckout && isCheckoutAction) return 0;
|
||||||
if (isYesterdayCheckIn && isMissingCheckout && isCheckoutAction) {
|
if (isCheckoutAction) return 0;
|
||||||
priority = 0;
|
if (text.contains("regular")) return 1;
|
||||||
} else if (isCheckoutAction) {
|
if (text == "requested") return 2;
|
||||||
priority = 0;
|
if (text == "approved") return 3;
|
||||||
} else if (text.contains("regular")) {
|
if (text == "rejected") return 4;
|
||||||
priority = 1;
|
return 5;
|
||||||
} else if (text == "requested") {
|
|
||||||
priority = 2;
|
|
||||||
} else if (text == "approved") {
|
|
||||||
priority = 3;
|
|
||||||
} else if (text == "rejected") {
|
|
||||||
priority = 4;
|
|
||||||
} else {
|
|
||||||
priority = 5;
|
|
||||||
}
|
|
||||||
return priority;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Obx(() {
|
return Obx(() {
|
||||||
final allLogs = List.of(widget.controller.filteredLogs);
|
final allLogs = List.of(controller.filteredLogs);
|
||||||
|
final showPendingOnly = controller.showPendingOnly.value;
|
||||||
// Filter logs if "pending only"
|
|
||||||
final showPendingOnly = widget.controller.showPendingOnly.value;
|
|
||||||
final filteredLogs = showPendingOnly
|
final filteredLogs = showPendingOnly
|
||||||
? allLogs.where((emp) => emp.activity == 1).toList()
|
? allLogs.where((emp) => emp.activity == 1).toList()
|
||||||
: allLogs;
|
: allLogs;
|
||||||
@ -116,7 +95,6 @@ class _AttendanceLogsTabState extends State<AttendanceLogsTab> {
|
|||||||
groupedLogs.putIfAbsent(dateKey, () => []).add(log);
|
groupedLogs.putIfAbsent(dateKey, () => []).add(log);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort dates (latest first)
|
|
||||||
final sortedDates = groupedLogs.keys.toList()
|
final sortedDates = groupedLogs.keys.toList()
|
||||||
..sort((a, b) {
|
..sort((a, b) {
|
||||||
final da = DateTimeUtils.parseDate(a, 'dd MMM yyyy') ?? DateTime(0);
|
final da = DateTimeUtils.parseDate(a, 'dd MMM yyyy') ?? DateTime(0);
|
||||||
@ -125,22 +103,19 @@ class _AttendanceLogsTabState extends State<AttendanceLogsTab> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
final dateRangeText =
|
final dateRangeText =
|
||||||
'${DateTimeUtils.formatDate(widget.controller.startDateAttendance.value, 'dd MMM yyyy')} - '
|
'${DateTimeUtils.formatDate(controller.startDateAttendance.value, 'dd MMM yyyy')} - '
|
||||||
'${DateTimeUtils.formatDate(widget.controller.endDateAttendance.value, 'dd MMM yyyy')}';
|
'${DateTimeUtils.formatDate(controller.endDateAttendance.value, 'dd MMM yyyy')}';
|
||||||
|
|
||||||
return SingleChildScrollView(
|
// Sticky header + scrollable list
|
||||||
padding: MySpacing.only(bottom: 80), // Added bottom spacing for scroll view
|
return Column(
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
children: [
|
||||||
// Header row
|
// Header Row
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 8),
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 8),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
MyText.titleMedium("Attendance Logs", fontWeight: 600),
|
controller.isLoadingAttendanceLogs.value
|
||||||
widget.controller.isLoading.value
|
|
||||||
? SkeletonLoaders.dateSkeletonLoader()
|
? SkeletonLoaders.dateSkeletonLoader()
|
||||||
: MyText.bodySmall(
|
: MyText.bodySmall(
|
||||||
dateRangeText,
|
dateRangeText,
|
||||||
@ -154,50 +129,53 @@ class _AttendanceLogsTabState extends State<AttendanceLogsTab> {
|
|||||||
|
|
||||||
// Pending-only header
|
// Pending-only header
|
||||||
_buildStatusHeader(),
|
_buildStatusHeader(),
|
||||||
MySpacing.height(8),
|
|
||||||
|
|
||||||
// Content: loader, empty, or logs
|
// Divider between header and list
|
||||||
if (widget.controller.isLoadingAttendanceLogs.value)
|
const Divider(height: 1),
|
||||||
SkeletonLoaders.employeeListSkeletonLoader()
|
|
||||||
else if (filteredLogs.isEmpty)
|
// Scrollable attendance logs
|
||||||
SizedBox(
|
Expanded(
|
||||||
height: 120,
|
child: controller.isLoadingAttendanceLogs.value
|
||||||
child: Center(
|
? SkeletonLoaders.employeeListSkeletonLoader()
|
||||||
|
: filteredLogs.isEmpty
|
||||||
|
? Center(
|
||||||
child: Text(showPendingOnly
|
child: Text(showPendingOnly
|
||||||
? "No Pending Actions Found"
|
? "No Pending Actions Found"
|
||||||
: "No Attendance Logs Found for this Project"),
|
: "No Attendance Logs Found for this Project"),
|
||||||
),
|
|
||||||
)
|
)
|
||||||
else
|
: ListView.builder(
|
||||||
MyCard.bordered(
|
padding: MySpacing.all(8),
|
||||||
paddingAll: 8,
|
itemCount: sortedDates.length,
|
||||||
child: Column(
|
itemBuilder: (context, dateIndex) {
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
final date = sortedDates[dateIndex];
|
||||||
children: [
|
final employees = groupedLogs[date]!
|
||||||
for (final date in sortedDates) ...[
|
..sort((a, b) {
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
|
||||||
child: MyText.bodyMedium(date, fontWeight: 700),
|
|
||||||
),
|
|
||||||
|
|
||||||
// Sort employees inside this date by action priority first, then latest entry
|
|
||||||
for (final emp in (groupedLogs[date]!
|
|
||||||
..sort(
|
|
||||||
(a, b) {
|
|
||||||
final priorityCompare = _getActionPriority(a)
|
final priorityCompare = _getActionPriority(a)
|
||||||
.compareTo(_getActionPriority(b));
|
.compareTo(_getActionPriority(b));
|
||||||
if (priorityCompare != 0) return priorityCompare;
|
if (priorityCompare != 0) return priorityCompare;
|
||||||
|
final aTime =
|
||||||
|
a.checkOut ?? a.checkIn ?? DateTime(0);
|
||||||
|
final bTime =
|
||||||
|
b.checkOut ?? b.checkIn ?? DateTime(0);
|
||||||
|
return bTime.compareTo(aTime);
|
||||||
|
});
|
||||||
|
|
||||||
final aTime = a.checkOut ?? a.checkIn ?? DateTime(0);
|
return Column(
|
||||||
final bTime = b.checkOut ?? b.checkIn ?? DateTime(0);
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
return bTime.compareTo(
|
children: [
|
||||||
aTime);
|
Padding(
|
||||||
},
|
padding:
|
||||||
))) ...[
|
const EdgeInsets.symmetric(vertical: 8),
|
||||||
|
child: MyText.bodyMedium(date, fontWeight: 700),
|
||||||
|
),
|
||||||
|
...employees.map(
|
||||||
|
(emp) => Column(
|
||||||
|
children: [
|
||||||
MyContainer(
|
MyContainer(
|
||||||
paddingAll: 8,
|
paddingAll: 8,
|
||||||
child: Row(
|
child: Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment:
|
||||||
|
CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Avatar(
|
Avatar(
|
||||||
firstName: emp.firstName,
|
firstName: emp.firstName,
|
||||||
@ -207,7 +185,8 @@ class _AttendanceLogsTabState extends State<AttendanceLogsTab> {
|
|||||||
MySpacing.width(16),
|
MySpacing.width(16),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment:
|
||||||
|
CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
@ -215,7 +194,8 @@ class _AttendanceLogsTabState extends State<AttendanceLogsTab> {
|
|||||||
child: MyText.bodyMedium(
|
child: MyText.bodyMedium(
|
||||||
emp.name,
|
emp.name,
|
||||||
fontWeight: 600,
|
fontWeight: 600,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow
|
||||||
|
.ellipsis,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
MySpacing.width(6),
|
MySpacing.width(6),
|
||||||
@ -224,7 +204,8 @@ class _AttendanceLogsTabState extends State<AttendanceLogsTab> {
|
|||||||
'(${emp.designation})',
|
'(${emp.designation})',
|
||||||
fontWeight: 600,
|
fontWeight: 600,
|
||||||
color: Colors.grey[700],
|
color: Colors.grey[700],
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow
|
||||||
|
.ellipsis,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -234,24 +215,37 @@ class _AttendanceLogsTabState extends State<AttendanceLogsTab> {
|
|||||||
emp.checkOut != null)
|
emp.checkOut != null)
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
if (emp.checkIn != null) ...[
|
if (emp.checkIn !=
|
||||||
const Icon(Icons.arrow_circle_right,
|
null) ...[
|
||||||
size: 16, color: Colors.green),
|
const Icon(
|
||||||
|
Icons
|
||||||
|
.arrow_circle_right,
|
||||||
|
size: 16,
|
||||||
|
color:
|
||||||
|
Colors.green),
|
||||||
MySpacing.width(4),
|
MySpacing.width(4),
|
||||||
MyText.bodySmall(
|
MyText.bodySmall(
|
||||||
DateTimeUtils.formatDate(
|
DateTimeUtils
|
||||||
emp.checkIn!, 'hh:mm a'),
|
.formatDate(
|
||||||
|
emp.checkIn!,
|
||||||
|
'hh:mm a'),
|
||||||
fontWeight: 600,
|
fontWeight: 600,
|
||||||
),
|
),
|
||||||
MySpacing.width(16),
|
MySpacing.width(16),
|
||||||
],
|
],
|
||||||
if (emp.checkOut != null) ...[
|
if (emp.checkOut !=
|
||||||
const Icon(Icons.arrow_circle_left,
|
null) ...[
|
||||||
size: 16, color: Colors.red),
|
const Icon(
|
||||||
|
Icons
|
||||||
|
.arrow_circle_left,
|
||||||
|
size: 16,
|
||||||
|
color: Colors.red),
|
||||||
MySpacing.width(4),
|
MySpacing.width(4),
|
||||||
MyText.bodySmall(
|
MyText.bodySmall(
|
||||||
DateTimeUtils.formatDate(
|
DateTimeUtils
|
||||||
emp.checkOut!, 'hh:mm a'),
|
.formatDate(
|
||||||
|
emp.checkOut!,
|
||||||
|
'hh:mm a'),
|
||||||
fontWeight: 600,
|
fontWeight: 600,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -259,16 +253,19 @@ class _AttendanceLogsTabState extends State<AttendanceLogsTab> {
|
|||||||
),
|
),
|
||||||
MySpacing.height(12),
|
MySpacing.height(12),
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment:
|
||||||
|
MainAxisAlignment.end,
|
||||||
children: [
|
children: [
|
||||||
AttendanceActionButton(
|
AttendanceActionButton(
|
||||||
employee: emp,
|
employee: emp,
|
||||||
attendanceController: widget.controller,
|
attendanceController:
|
||||||
|
controller,
|
||||||
),
|
),
|
||||||
MySpacing.width(8),
|
MySpacing.width(8),
|
||||||
AttendanceLogViewButton(
|
AttendanceLogViewButton(
|
||||||
employee: emp,
|
employee: emp,
|
||||||
attendanceController: widget.controller,
|
attendanceController:
|
||||||
|
controller,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@ -278,21 +275,15 @@ class _AttendanceLogsTabState extends State<AttendanceLogsTab> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Divider(color: Colors.grey.withOpacity(0.3)),
|
|
||||||
],
|
|
||||||
],
|
|
||||||
// Remove the trailing Divider if we are at the end of the logs
|
|
||||||
if (sortedDates.isNotEmpty)
|
|
||||||
// We can use MySpacing.height(8) here if we need to ensure the last divider doesn't show
|
|
||||||
// But keeping the original structure, the divider is inside the inner loop.
|
|
||||||
// A clean up would be needed to manage that last divider, but for now,
|
|
||||||
// the bottom padding handles the visible spacing.
|
|
||||||
const SizedBox.shrink(),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -61,9 +61,9 @@ class _AttendanceScreenState extends State<AttendanceScreen>
|
|||||||
|
|
||||||
void _initializeTabs() async {
|
void _initializeTabs() async {
|
||||||
final allTabs = [
|
final allTabs = [
|
||||||
{'label': "Today's Attendance", 'value': 'todaysAttendance'},
|
{'label': "Today's", 'value': 'todaysAttendance'},
|
||||||
{'label': "Attendance Logs", 'value': 'attendanceLogs'},
|
{'label': "Logs", 'value': 'attendanceLogs'},
|
||||||
{'label': "Regularization Requests", 'value': 'regularizationRequests'},
|
{'label': "Regularization", 'value': 'regularizationRequests'},
|
||||||
];
|
];
|
||||||
|
|
||||||
final hasRegularizationPermission =
|
final hasRegularizationPermission =
|
||||||
@ -133,8 +133,7 @@ class _AttendanceScreenState extends State<AttendanceScreen>
|
|||||||
final query = attendanceController.searchQuery.value;
|
final query = attendanceController.searchQuery.value;
|
||||||
return TextField(
|
return TextField(
|
||||||
controller: TextEditingController(text: query)
|
controller: TextEditingController(text: query)
|
||||||
..selection =
|
..selection = TextSelection.collapsed(offset: query.length),
|
||||||
TextSelection.collapsed(offset: query.length),
|
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
attendanceController.searchQuery.value = value;
|
attendanceController.searchQuery.value = value;
|
||||||
},
|
},
|
||||||
@ -325,7 +324,8 @@ class _AttendanceScreenState extends State<AttendanceScreen>
|
|||||||
child: noProjectSelected
|
child: noProjectSelected
|
||||||
? _buildNoProjectWidget()
|
? _buildNoProjectWidget()
|
||||||
: SizedBox(
|
: SizedBox(
|
||||||
height: MediaQuery.of(context).size.height -
|
height:
|
||||||
|
MediaQuery.of(context).size.height -
|
||||||
200,
|
200,
|
||||||
child: _buildTabBarView(),
|
child: _buildTabBarView(),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
// lib/view/attendance/tabs/regularization_requests_tab.dart
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
@ -19,17 +18,11 @@ class RegularizationRequestsTab extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Column(
|
return Obx(() {
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
final isLoading = controller.isLoadingRegularizationLogs.value;
|
||||||
children: [
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(vertical: 12.0, horizontal: 4.0),
|
|
||||||
child: MyText.titleMedium("Regularization Requests", fontWeight: 600),
|
|
||||||
),
|
|
||||||
Obx(() {
|
|
||||||
final employees = controller.filteredRegularizationLogs;
|
final employees = controller.filteredRegularizationLogs;
|
||||||
|
|
||||||
if (controller.isLoadingRegularizationLogs.value) {
|
if (isLoading) {
|
||||||
return SkeletonLoaders.employeeListSkeletonLoader();
|
return SkeletonLoaders.employeeListSkeletonLoader();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,18 +30,22 @@ class RegularizationRequestsTab extends StatelessWidget {
|
|||||||
return const SizedBox(
|
return const SizedBox(
|
||||||
height: 120,
|
height: 120,
|
||||||
child: Center(
|
child: Center(
|
||||||
child:
|
child: Text("No Regularization Requests Found for this Project"),
|
||||||
Text("No Regularization Requests Found for this Project"),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return MyCard.bordered(
|
return ListView.builder(
|
||||||
|
itemCount: employees.length,
|
||||||
|
padding: MySpacing.only(bottom: 80),
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
final employee = employees[index]; // Corrected index
|
||||||
|
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.only(bottom: 12),
|
||||||
|
child: MyCard.bordered(
|
||||||
paddingAll: 8,
|
paddingAll: 8,
|
||||||
child: Column(
|
child: Column(
|
||||||
children: List.generate(employees.length, (index) {
|
|
||||||
final employee = employees[index];
|
|
||||||
return Column(
|
|
||||||
children: [
|
children: [
|
||||||
MyContainer(
|
MyContainer(
|
||||||
paddingAll: 8,
|
paddingAll: 8,
|
||||||
@ -58,7 +55,7 @@ class RegularizationRequestsTab extends StatelessWidget {
|
|||||||
Avatar(
|
Avatar(
|
||||||
firstName: employee.firstName,
|
firstName: employee.firstName,
|
||||||
lastName: employee.lastName,
|
lastName: employee.lastName,
|
||||||
size: 31,
|
size: 35,
|
||||||
),
|
),
|
||||||
MySpacing.width(16),
|
MySpacing.width(16),
|
||||||
Expanded(
|
Expanded(
|
||||||
@ -144,15 +141,13 @@ class RegularizationRequestsTab extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (index != employees.length - 1)
|
|
||||||
Divider(color: Colors.grey.withOpacity(0.3)),
|
|
||||||
],
|
],
|
||||||
);
|
),
|
||||||
}),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}),
|
},
|
||||||
],
|
|
||||||
);
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,6 @@ import 'package:on_field_work/controller/attendance/attendance_screen_controller
|
|||||||
import 'package:on_field_work/helpers/utils/date_time_utils.dart';
|
import 'package:on_field_work/helpers/utils/date_time_utils.dart';
|
||||||
import 'package:on_field_work/helpers/widgets/avatar.dart';
|
import 'package:on_field_work/helpers/widgets/avatar.dart';
|
||||||
import 'package:on_field_work/helpers/widgets/my_card.dart';
|
import 'package:on_field_work/helpers/widgets/my_card.dart';
|
||||||
import 'package:on_field_work/helpers/widgets/my_container.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_text.dart';
|
import 'package:on_field_work/helpers/widgets/my_text.dart';
|
||||||
import 'package:on_field_work/helpers/widgets/my_custom_skeleton.dart';
|
import 'package:on_field_work/helpers/widgets/my_custom_skeleton.dart';
|
||||||
@ -36,11 +35,9 @@ class TodaysAttendanceTab extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return ListView.builder(
|
return ListView.builder(
|
||||||
itemCount: employees.length + 1, // +1 for header
|
itemCount: employees.length + 1,
|
||||||
padding: MySpacing.only(
|
padding: MySpacing.only(bottom: 80),
|
||||||
bottom: 80), // Adjusted padding to add spacing at the bottom
|
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
// --- Header Row ---
|
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.only(bottom: 12, top: 4),
|
padding: const EdgeInsets.only(bottom: 12, top: 4),
|
||||||
@ -59,68 +56,62 @@ class TodaysAttendanceTab extends StatelessWidget {
|
|||||||
final employee = employees[index - 1];
|
final employee = employees[index - 1];
|
||||||
|
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.only(bottom: 12),
|
padding: const EdgeInsets.only(bottom: 8),
|
||||||
child: MyCard.bordered(
|
child: MyCard.bordered(
|
||||||
paddingAll: 12,
|
paddingAll: 10,
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
// 1. Employee Info Row
|
// --- 1. Employee Info Row (Avatar, Name, Designation ONLY) ---
|
||||||
Row(
|
Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
|
// Avatar
|
||||||
Avatar(
|
Avatar(
|
||||||
firstName: employee.firstName,
|
firstName: employee.firstName,
|
||||||
lastName: employee.lastName,
|
lastName: employee.lastName,
|
||||||
size: 35,
|
size: 30,
|
||||||
),
|
),
|
||||||
MySpacing.width(16),
|
MySpacing.width(10),
|
||||||
|
|
||||||
|
// Employee Details (Expanded to use remaining space)
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
MyText.titleMedium(employee.name, fontWeight: 600),
|
MyText.titleSmall(employee.name,
|
||||||
MySpacing.height(2),
|
fontWeight: 600, overflow: TextOverflow.ellipsis),
|
||||||
MyText.bodySmall(
|
MyText.labelSmall(
|
||||||
employee.designation,
|
employee.designation,
|
||||||
fontWeight: 500,
|
fontWeight: 500,
|
||||||
color: Colors.grey[600],
|
color: Colors.grey[600],
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
|
||||||
),
|
|
||||||
|
|
||||||
// Separator
|
// Status Text (Added back for context)
|
||||||
if (employee.checkIn != null || employee.checkOut != null)
|
if (employee.checkIn == null)
|
||||||
const Divider(height: 24),
|
MyText.bodySmall(
|
||||||
|
'Check In Pending',
|
||||||
// 2. Attendance Time Details Row
|
fontWeight: 600,
|
||||||
if (employee.checkIn != null || employee.checkOut != null)
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
// Check-in Time
|
|
||||||
_buildLogTime(
|
|
||||||
icon: Icons.login,
|
|
||||||
color: Colors.green,
|
|
||||||
label: 'Check-in',
|
|
||||||
time: employee.checkIn,
|
|
||||||
),
|
|
||||||
|
|
||||||
// Check-out Time
|
|
||||||
_buildLogTime(
|
|
||||||
icon: Icons.logout,
|
|
||||||
color: Colors.red,
|
color: Colors.red,
|
||||||
label: 'Check-out',
|
)
|
||||||
time: employee.checkOut,
|
else if (employee.checkOut == null)
|
||||||
|
MyText.bodySmall(
|
||||||
|
'Checked In',
|
||||||
|
fontWeight: 600,
|
||||||
|
color: Colors.green,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
||||||
// 3. Action Buttons Row
|
// --- Separator before buttons ---
|
||||||
MySpacing.height(16),
|
MySpacing.height(12),
|
||||||
|
|
||||||
|
// --- 2. Action Buttons Row (Below main info) ---
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
children: [
|
children: [
|
||||||
@ -145,50 +136,4 @@ class TodaysAttendanceTab extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper function to build a cleaner log time widget
|
|
||||||
Widget _buildLogTime({
|
|
||||||
required IconData icon,
|
|
||||||
required Color color,
|
|
||||||
required String label,
|
|
||||||
required DateTime? time,
|
|
||||||
}) {
|
|
||||||
if (time == null) {
|
|
||||||
return MyContainer(
|
|
||||||
padding: MySpacing.xy(12, 6),
|
|
||||||
borderRadiusAll: 5,
|
|
||||||
color: Colors.grey[100],
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Icon(icon, size: 16, color: Colors.grey),
|
|
||||||
MySpacing.width(6),
|
|
||||||
MyText.bodySmall('$label: **N/A**',
|
|
||||||
fontWeight: 600, color: Colors.grey),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return MyContainer(
|
|
||||||
padding: MySpacing.xy(12, 6),
|
|
||||||
borderRadiusAll: 6,
|
|
||||||
color: color.withOpacity(0.1),
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Icon(icon, size: 16, color: color),
|
|
||||||
MySpacing.width(6),
|
|
||||||
Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
MyText.labelSmall(label, color: color, fontWeight: 600),
|
|
||||||
MyText.bodyMedium(
|
|
||||||
DateTimeUtils.formatDate(time, 'hh:mm a'),
|
|
||||||
fontWeight: 600,
|
|
||||||
color: Colors.black87,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user