From f6de07fc258a1752b41a948880a108b0d7bda173 Mon Sep 17 00:00:00 2001 From: Achintha Isuru Date: Sat, 14 Mar 2026 20:28:28 -0400 Subject: [PATCH] refactor(clock_in): rename error handling variable for clarity in check-in interactions --- .claude/agents/mobile-builder.md | 1 + .../strategies/check_in_interaction.dart | 2 +- .../strategies/nfc_check_in_interaction.dart | 2 +- .../swipe_check_in_interaction.dart | 4 +- .../widgets/clock_in_action_section.dart | 37 ++++++++++--------- .../presentation/widgets/clock_in_body.dart | 2 +- .../widgets/swipe_to_check_in.dart | 6 +-- 7 files changed, 28 insertions(+), 26 deletions(-) diff --git a/.claude/agents/mobile-builder.md b/.claude/agents/mobile-builder.md index cd55655b..3d9009e0 100644 --- a/.claude/agents/mobile-builder.md +++ b/.claude/agents/mobile-builder.md @@ -47,6 +47,7 @@ If any of these files are missing or unreadable, notify the user before proceedi - Skip tests for business logic ### ALWAYS: +- **Use `package:` imports everywhere inside `lib/`** for consistency and robustness. Use relative imports only in `test/` and `bin/` directories. Example: `import 'package:staff_clock_in/src/presentation/bloc/clock_in/clock_in_bloc.dart';` not `import '../bloc/clock_in/clock_in_bloc.dart';` - Place reusable utility functions (math, geo, formatting, etc.) in `apps/mobile/packages/core/lib/src/utils/` and export from `core.dart` — never keep them as private methods in feature packages - Use feature-first packaging: `domain/`, `data/`, `presentation/` - Export public API via barrel files diff --git a/apps/mobile/packages/features/staff/clock_in/lib/src/presentation/strategies/check_in_interaction.dart b/apps/mobile/packages/features/staff/clock_in/lib/src/presentation/strategies/check_in_interaction.dart index 6f218f90..dd0f5bdc 100644 --- a/apps/mobile/packages/features/staff/clock_in/lib/src/presentation/strategies/check_in_interaction.dart +++ b/apps/mobile/packages/features/staff/clock_in/lib/src/presentation/strategies/check_in_interaction.dart @@ -16,7 +16,7 @@ abstract class CheckInInteraction { required bool isCheckedIn, required bool isDisabled, required bool isLoading, - required bool hasError, + required bool hasClockinError, required VoidCallback onCheckIn, required VoidCallback onCheckOut, }); diff --git a/apps/mobile/packages/features/staff/clock_in/lib/src/presentation/strategies/nfc_check_in_interaction.dart b/apps/mobile/packages/features/staff/clock_in/lib/src/presentation/strategies/nfc_check_in_interaction.dart index efa2e0e3..8dc3297d 100644 --- a/apps/mobile/packages/features/staff/clock_in/lib/src/presentation/strategies/nfc_check_in_interaction.dart +++ b/apps/mobile/packages/features/staff/clock_in/lib/src/presentation/strategies/nfc_check_in_interaction.dart @@ -21,7 +21,7 @@ class NfcCheckInInteraction implements CheckInInteraction { required bool isCheckedIn, required bool isDisabled, required bool isLoading, - required bool hasError, + required bool hasClockinError, required VoidCallback onCheckIn, required VoidCallback onCheckOut, }) { diff --git a/apps/mobile/packages/features/staff/clock_in/lib/src/presentation/strategies/swipe_check_in_interaction.dart b/apps/mobile/packages/features/staff/clock_in/lib/src/presentation/strategies/swipe_check_in_interaction.dart index 4e27e0e6..56a6a1ee 100644 --- a/apps/mobile/packages/features/staff/clock_in/lib/src/presentation/strategies/swipe_check_in_interaction.dart +++ b/apps/mobile/packages/features/staff/clock_in/lib/src/presentation/strategies/swipe_check_in_interaction.dart @@ -16,7 +16,7 @@ class SwipeCheckInInteraction implements CheckInInteraction { required bool isCheckedIn, required bool isDisabled, required bool isLoading, - required bool hasError, + required bool hasClockinError, required VoidCallback onCheckIn, required VoidCallback onCheckOut, }) { @@ -24,7 +24,7 @@ class SwipeCheckInInteraction implements CheckInInteraction { isCheckedIn: isCheckedIn, isDisabled: isDisabled, isLoading: isLoading, - hasError: hasError, + hasClockinError: hasClockinError, onCheckIn: onCheckIn, onCheckOut: onCheckOut, ); diff --git a/apps/mobile/packages/features/staff/clock_in/lib/src/presentation/widgets/clock_in_action_section.dart b/apps/mobile/packages/features/staff/clock_in/lib/src/presentation/widgets/clock_in_action_section.dart index c1791c0b..bbc2234b 100644 --- a/apps/mobile/packages/features/staff/clock_in/lib/src/presentation/widgets/clock_in_action_section.dart +++ b/apps/mobile/packages/features/staff/clock_in/lib/src/presentation/widgets/clock_in_action_section.dart @@ -5,6 +5,7 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_modular/flutter_modular.dart'; import 'package:krow_core/core.dart'; import 'package:krow_domain/krow_domain.dart'; +import 'package:staff_clock_in/src/presentation/widgets/early_check_in_banner.dart'; import '../../domain/validators/clock_in_validation_context.dart'; import '../../domain/validators/validators/time_window_validator.dart'; @@ -34,7 +35,7 @@ class ClockInActionSection extends StatelessWidget { required this.checkOutTime, required this.checkInMode, required this.isActionInProgress, - this.hasError = false, + this.hasClockinError = false, super.key, }); @@ -61,7 +62,7 @@ class ClockInActionSection extends StatelessWidget { final bool isActionInProgress; /// Whether the last action attempt resulted in an error. - final bool hasError; + final bool hasClockinError; /// Resolves the [CheckInInteraction] for the current mode. /// @@ -84,21 +85,21 @@ class ClockInActionSection extends StatelessWidget { /// Builds the action widget for an active (not completed) shift. Widget _buildActiveShiftAction(BuildContext context) { - // if (!isCheckedIn && !_isCheckInAllowed(selectedShift!)) { - // return Column( - // mainAxisSize: MainAxisSize.min, - // children: [ - // const GeofenceStatusBanner(), - // const SizedBox(height: UiConstants.space3), - // EarlyCheckInBanner( - // availabilityTime: _getAvailabilityTimeText( - // selectedShift!, - // context, - // ), - // ), - // ], - // ); - // } + if (!isCheckedIn && !_isCheckInAllowed(selectedShift!)) { + return Column( + mainAxisSize: MainAxisSize.min, + children: [ + const GeofenceStatusBanner(), + const SizedBox(height: UiConstants.space3), + EarlyCheckInBanner( + availabilityTime: _getAvailabilityTimeText( + selectedShift!, + context, + ), + ), + ], + ); + } return BlocBuilder( builder: (BuildContext context, GeofenceState geofenceState) { @@ -122,7 +123,7 @@ class ClockInActionSection extends StatelessWidget { isCheckedIn: isCheckedIn, isDisabled: isGeofenceBlocking, isLoading: isActionInProgress, - hasError: hasError, + hasClockinError: hasClockinError, onCheckIn: () => _handleCheckIn(context), onCheckOut: () => _handleCheckOut(context), ), diff --git a/apps/mobile/packages/features/staff/clock_in/lib/src/presentation/widgets/clock_in_body.dart b/apps/mobile/packages/features/staff/clock_in/lib/src/presentation/widgets/clock_in_body.dart index 05f1f7cc..c9f6ea50 100644 --- a/apps/mobile/packages/features/staff/clock_in/lib/src/presentation/widgets/clock_in_body.dart +++ b/apps/mobile/packages/features/staff/clock_in/lib/src/presentation/widgets/clock_in_body.dart @@ -111,7 +111,7 @@ class _ClockInBodyState extends State { checkInMode: state.checkInMode, isActionInProgress: state.status == ClockInStatus.actionInProgress, - hasError: state.status == ClockInStatus.failure, + hasClockinError: state.status == ClockInStatus.failure, ), // checked-in banner (only when checked in to the selected shift) diff --git a/apps/mobile/packages/features/staff/clock_in/lib/src/presentation/widgets/swipe_to_check_in.dart b/apps/mobile/packages/features/staff/clock_in/lib/src/presentation/widgets/swipe_to_check_in.dart index 2ed7cc7b..4f0b2fd5 100644 --- a/apps/mobile/packages/features/staff/clock_in/lib/src/presentation/widgets/swipe_to_check_in.dart +++ b/apps/mobile/packages/features/staff/clock_in/lib/src/presentation/widgets/swipe_to_check_in.dart @@ -17,7 +17,7 @@ class SwipeToCheckIn extends StatefulWidget { this.isLoading = false, this.isCheckedIn = false, this.isDisabled = false, - this.hasError = false, + this.hasClockinError = false, }); /// Called when the user completes the swipe to check in. @@ -36,7 +36,7 @@ class SwipeToCheckIn extends StatefulWidget { final bool isDisabled; /// Whether an error occurred during the last action attempt. - final bool hasError; + final bool hasClockinError; @override State createState() => _SwipeToCheckInState(); @@ -62,7 +62,7 @@ class _SwipeToCheckInState extends State if (_isComplete && widget.isCheckedIn == oldWidget.isCheckedIn && ((oldWidget.isLoading && !widget.isLoading) || - (!oldWidget.hasError && widget.hasError))) { + (!oldWidget.hasClockinError && widget.hasClockinError))) { setState(() { _isComplete = false; _dragValue = 0.0;