refactor of usecases
This commit is contained in:
@@ -257,10 +257,83 @@ class _ClockInPageState extends State<ClockInPage> {
|
||||
],
|
||||
),
|
||||
)
|
||||
else
|
||||
else ...<Widget>[
|
||||
// Attire Photo Section
|
||||
if (!isCheckedIn) ...<Widget>[
|
||||
Container(
|
||||
padding: const EdgeInsets.all(UiConstants.space4),
|
||||
margin: const EdgeInsets.only(bottom: UiConstants.space4),
|
||||
decoration: BoxDecoration(
|
||||
color: UiColors.white,
|
||||
borderRadius: UiConstants.radiusLg,
|
||||
border: Border.all(color: UiColors.border),
|
||||
),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
width: 48,
|
||||
height: 48,
|
||||
decoration: BoxDecoration(
|
||||
color: UiColors.bgSecondary,
|
||||
borderRadius: UiConstants.radiusMd,
|
||||
),
|
||||
child: const Icon(UiIcons.camera, color: UiColors.primary),
|
||||
),
|
||||
const SizedBox(width: UiConstants.space3),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Text(i18n.attire_photo_label, style: UiTypography.body2b),
|
||||
Text(i18n.attire_photo_desc, style: UiTypography.body3r.textSecondary),
|
||||
],
|
||||
),
|
||||
),
|
||||
UiButton.secondary(
|
||||
text: i18n.take_attire_photo,
|
||||
onPressed: () {
|
||||
UiSnackbar.show(
|
||||
context,
|
||||
message: i18n.attire_captured,
|
||||
type: UiSnackbarType.success,
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
if (!isCheckedIn && (!state.isLocationVerified || state.currentLocation == null)) ...<Widget>[
|
||||
Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(UiConstants.space4),
|
||||
margin: const EdgeInsets.only(bottom: UiConstants.space4),
|
||||
decoration: BoxDecoration(
|
||||
color: UiColors.tagError,
|
||||
borderRadius: UiConstants.radiusLg,
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(UiIcons.error, color: UiColors.textError, size: 20),
|
||||
const SizedBox(width: UiConstants.space3),
|
||||
Expanded(
|
||||
child: Text(
|
||||
state.currentLocation == null
|
||||
? i18n.location_verifying
|
||||
: i18n.not_in_range(distance: '500'),
|
||||
style: UiTypography.body3m.textError,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
SwipeToCheckIn(
|
||||
isCheckedIn: isCheckedIn,
|
||||
mode: state.checkInMode,
|
||||
isDisabled: !isCheckedIn && !state.isLocationVerified,
|
||||
isLoading:
|
||||
state.status ==
|
||||
ClockInStatus.actionInProgress,
|
||||
@@ -293,6 +366,7 @@ class _ClockInPageState extends State<ClockInPage> {
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
] else if (selectedShift != null &&
|
||||
checkOutTime != null) ...<Widget>[
|
||||
// Shift Completed State
|
||||
|
||||
@@ -11,12 +11,14 @@ class SwipeToCheckIn extends StatefulWidget {
|
||||
this.isLoading = false,
|
||||
this.mode = 'swipe',
|
||||
this.isCheckedIn = false,
|
||||
this.isDisabled = false,
|
||||
});
|
||||
final VoidCallback? onCheckIn;
|
||||
final VoidCallback? onCheckOut;
|
||||
final bool isLoading;
|
||||
final String mode; // 'swipe' or 'nfc'
|
||||
final bool isCheckedIn;
|
||||
final bool isDisabled;
|
||||
|
||||
@override
|
||||
State<SwipeToCheckIn> createState() => _SwipeToCheckInState();
|
||||
@@ -40,7 +42,7 @@ class _SwipeToCheckInState extends State<SwipeToCheckIn>
|
||||
}
|
||||
|
||||
void _onDragUpdate(DragUpdateDetails details, double maxWidth) {
|
||||
if (_isComplete || widget.isLoading) return;
|
||||
if (_isComplete || widget.isLoading || widget.isDisabled) return;
|
||||
setState(() {
|
||||
_dragValue = (_dragValue + details.delta.dx).clamp(
|
||||
0.0,
|
||||
@@ -50,7 +52,7 @@ class _SwipeToCheckInState extends State<SwipeToCheckIn>
|
||||
}
|
||||
|
||||
void _onDragEnd(DragEndDetails details, double maxWidth) {
|
||||
if (_isComplete || widget.isLoading) return;
|
||||
if (_isComplete || widget.isLoading || widget.isDisabled) return;
|
||||
final double threshold = (maxWidth - _handleSize - 8) * 0.8;
|
||||
if (_dragValue > threshold) {
|
||||
setState(() {
|
||||
@@ -81,7 +83,7 @@ class _SwipeToCheckInState extends State<SwipeToCheckIn>
|
||||
if (widget.mode == 'nfc') {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
if (widget.isLoading) return;
|
||||
if (widget.isLoading || widget.isDisabled) return;
|
||||
// Simulate completion for NFC tap
|
||||
Future.delayed(const Duration(milliseconds: 300), () {
|
||||
if (widget.isCheckedIn) {
|
||||
@@ -94,9 +96,9 @@ class _SwipeToCheckInState extends State<SwipeToCheckIn>
|
||||
child: Container(
|
||||
height: 56,
|
||||
decoration: BoxDecoration(
|
||||
color: baseColor,
|
||||
color: widget.isDisabled ? UiColors.bgSecondary : baseColor,
|
||||
borderRadius: UiConstants.radiusLg,
|
||||
boxShadow: <BoxShadow>[
|
||||
boxShadow: widget.isDisabled ? [] : <BoxShadow>[
|
||||
BoxShadow(
|
||||
color: baseColor.withValues(alpha: 0.4),
|
||||
blurRadius: 25,
|
||||
@@ -116,7 +118,9 @@ class _SwipeToCheckInState extends State<SwipeToCheckIn>
|
||||
? i18n.checking_out
|
||||
: i18n.checking_in)
|
||||
: (widget.isCheckedIn ? i18n.nfc_checkout : i18n.nfc_checkin),
|
||||
style: UiTypography.body1b.white,
|
||||
style: UiTypography.body1b.copyWith(
|
||||
color: widget.isDisabled ? UiColors.textDisabled : UiColors.white,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -137,8 +141,10 @@ class _SwipeToCheckInState extends State<SwipeToCheckIn>
|
||||
final Color endColor = widget.isCheckedIn
|
||||
? UiColors.primary
|
||||
: UiColors.success;
|
||||
final Color currentColor =
|
||||
Color.lerp(startColor, endColor, progress) ?? startColor;
|
||||
|
||||
final Color currentColor = widget.isDisabled
|
||||
? UiColors.bgSecondary
|
||||
: (Color.lerp(startColor, endColor, progress) ?? startColor);
|
||||
|
||||
return Container(
|
||||
height: 56,
|
||||
@@ -162,7 +168,9 @@ class _SwipeToCheckInState extends State<SwipeToCheckIn>
|
||||
widget.isCheckedIn
|
||||
? i18n.swipe_checkout
|
||||
: i18n.swipe_checkin,
|
||||
style: UiTypography.body1b,
|
||||
style: UiTypography.body1b.copyWith(
|
||||
color: widget.isDisabled ? UiColors.textDisabled : UiColors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -170,7 +178,9 @@ class _SwipeToCheckInState extends State<SwipeToCheckIn>
|
||||
Center(
|
||||
child: Text(
|
||||
widget.isCheckedIn ? i18n.checkout_complete : i18n.checkin_complete,
|
||||
style: UiTypography.body1b,
|
||||
style: UiTypography.body1b.copyWith(
|
||||
color: widget.isDisabled ? UiColors.textDisabled : UiColors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
@@ -198,7 +208,7 @@ class _SwipeToCheckInState extends State<SwipeToCheckIn>
|
||||
child: Center(
|
||||
child: Icon(
|
||||
_isComplete ? UiIcons.check : UiIcons.arrowRight,
|
||||
color: startColor,
|
||||
color: widget.isDisabled ? UiColors.iconDisabled : startColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -211,4 +221,3 @@ class _SwipeToCheckInState extends State<SwipeToCheckIn>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user