diff --git a/lib/helpers/utils/attendance_actions.dart b/lib/helpers/utils/attendance_actions.dart index cc67376..0a7a315 100644 --- a/lib/helpers/utils/attendance_actions.dart +++ b/lib/helpers/utils/attendance_actions.dart @@ -95,7 +95,7 @@ class AttendanceButtonHelper { } } - static Color getButtonColor({ + static Color getprimary({ required bool isYesterday, required bool isTodayApproved, required int activity, diff --git a/lib/model/attendance/attendence_action_button.dart b/lib/model/attendance/attendence_action_button.dart index 6959268..9b1d35c 100644 --- a/lib/model/attendance/attendence_action_button.dart +++ b/lib/model/attendance/attendence_action_button.dart @@ -7,7 +7,6 @@ import 'package:marco/controller/attendance/attendance_screen_controller.dart'; import 'package:marco/helpers/utils/attendance_actions.dart'; import 'package:marco/controller/project_controller.dart'; import 'package:marco/helpers/utils/base_bottom_sheet.dart'; -import 'package:marco/helpers/widgets/my_text.dart'; class AttendanceActionButton extends StatefulWidget { final dynamic employee; @@ -42,33 +41,26 @@ class _AttendanceActionButtonState extends State { }); } - Future _pickRegularizationTime(DateTime checkInTime) async { + Future _pickRegularizationTime(DateTime referenceTime) async { final pickedTime = await showTimePicker( context: context, - initialTime: TimeOfDay.fromDateTime(DateTime.now()), + initialTime: + TimeOfDay.fromDateTime(referenceTime), // start from actual log time ); if (pickedTime == null) return null; final selected = DateTime( - checkInTime.year, - checkInTime.month, - checkInTime.day, + referenceTime.year, + referenceTime.month, + referenceTime.day, pickedTime.hour, pickedTime.minute, ); final now = DateTime.now(); - if (selected.isBefore(checkInTime)) { - showAppSnackbar( - title: "Invalid Time", - message: "Time must be after check-in.", - type: SnackbarType.warning, - ); - return null; - } - + // Allow times before check-in for regularization, but never future if (selected.isAfter(now)) { showAppSnackbar( title: "Invalid Time", @@ -85,8 +77,6 @@ class _AttendanceActionButtonState extends State { final controller = widget.attendanceController; final projectController = Get.find(); final selectedProjectId = projectController.selectedProject?.id; - final projectName = - projectController.selectedProject?.name ?? 'Unknown Project'; if (selectedProjectId == null) { showAppSnackbar( @@ -163,9 +153,7 @@ class _AttendanceActionButtonState extends State { actionText, selectedTime: selectedTime, checkInDate: widget.employee.checkIn, - projectName: projectName, ); - if (comment == null || comment.isEmpty) { controller.uploadingStates[uniqueLogKey]?.value = false; return; @@ -240,7 +228,7 @@ class _AttendanceActionButtonState extends State { isTodayApproved: isTodayApproved, ); - final buttonColor = AttendanceButtonHelper.getButtonColor( + final primary = AttendanceButtonHelper.getprimary( isYesterday: isYesterday, isTodayApproved: isTodayApproved, activity: emp.activity, @@ -250,7 +238,7 @@ class _AttendanceActionButtonState extends State { isUploading: isUploading, isButtonDisabled: isButtonDisabled, buttonText: buttonText, - buttonColor: buttonColor, + primary: primary, onPressed: isButtonDisabled ? null : _handleButtonPressed, ); }); @@ -261,7 +249,7 @@ class AttendanceActionButtonUI extends StatelessWidget { final bool isUploading; final bool isButtonDisabled; final String buttonText; - final Color buttonColor; + final Color primary; final VoidCallback? onPressed; const AttendanceActionButtonUI({ @@ -269,7 +257,7 @@ class AttendanceActionButtonUI extends StatelessWidget { required this.isUploading, required this.isButtonDisabled, required this.buttonText, - required this.buttonColor, + required this.primary, required this.onPressed, }); @@ -280,17 +268,17 @@ class AttendanceActionButtonUI extends StatelessWidget { child: ElevatedButton( onPressed: onPressed, style: ElevatedButton.styleFrom( - backgroundColor: buttonColor, + backgroundColor: primary, padding: const EdgeInsets.symmetric(vertical: 4, horizontal: 12), textStyle: const TextStyle(fontSize: 12), ), child: isUploading - ? const SizedBox( - width: 16, - height: 16, - child: CircularProgressIndicator( - strokeWidth: 2, - valueColor: AlwaysStoppedAnimation(Colors.white), + ? Container( + width: 60, + height: 14, + decoration: BoxDecoration( + color: Colors.white.withOpacity(0.5), + borderRadius: BorderRadius.circular(4), ), ) : Row( @@ -307,11 +295,10 @@ class AttendanceActionButtonUI extends StatelessWidget { .contains(buttonText.toLowerCase())) const SizedBox(width: 4), Flexible( - child: MyText.bodySmall( + child: Text( buttonText, overflow: TextOverflow.ellipsis, - fontWeight: 500, - color: Colors.white, + style: const TextStyle(fontSize: 12), ), ), ], @@ -326,18 +313,15 @@ Future _showCommentBottomSheet( String actionText, { DateTime? selectedTime, DateTime? checkInDate, - String? projectName, }) async { final commentController = TextEditingController(); String? errorText; - String sheetTitle = - "Adding Comment for ${capitalizeFirstLetter(actionText)}"; + // Prepare title + String sheetTitle = "Add Comment for ${capitalizeFirstLetter(actionText)}"; if (selectedTime != null && checkInDate != null) { sheetTitle = - "${capitalizeFirstLetter(actionText)} • ${DateFormat('dd MMM yyyy').format(checkInDate)} " - "at ${DateFormat('hh:mm a').format(selectedTime)}\n" - "${projectName ?? 'Project'}"; + "${capitalizeFirstLetter(actionText)} for ${DateFormat('dd MMM yyyy').format(checkInDate)} at ${DateFormat('hh:mm a').format(selectedTime)}"; } return showModalBottomSheet( @@ -363,39 +347,28 @@ Future _showCommentBottomSheet( padding: EdgeInsets.only( bottom: MediaQuery.of(context).viewInsets.bottom), child: BaseBottomSheet( - title: sheetTitle, - subtitle: projectName, + title: sheetTitle, // 👈 now showing full sentence as title onCancel: () => Navigator.of(context).pop(), onSubmit: submit, isSubmitting: false, submitText: 'Submit', - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - MyText.bodyMedium( - 'Add a comment to proceed', - fontWeight: 500, + child: TextField( + controller: commentController, + maxLines: 4, + decoration: InputDecoration( + hintText: 'Type your comment here...', + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(8), ), - const SizedBox(height: 8), - TextField( - controller: commentController, - maxLines: 4, - decoration: InputDecoration( - hintText: 'Type your comment here...', - border: OutlineInputBorder( - borderRadius: BorderRadius.circular(8), - ), - filled: true, - fillColor: Colors.grey.shade100, - errorText: errorText, - ), - onChanged: (_) { - if (errorText != null) { - setModalState(() => errorText = null); - } - }, - ), - ], + filled: true, + fillColor: Colors.grey.shade100, + errorText: errorText, + ), + onChanged: (_) { + if (errorText != null) { + setModalState(() => errorText = null); + } + }, ), ), );