From 7f3a66ba110e1ff47dac3b2120d3c225c077f19d Mon Sep 17 00:00:00 2001 From: Achintha Isuru Date: Sun, 22 Feb 2026 21:16:46 -0500 Subject: [PATCH] refactor: remove redundant `pushShiftDetails` navigation method and update its usages to `toShiftDetails`. --- .../core/lib/src/routing/staff/navigator.dart | 9 ---- .../home_page/recommended_shift_card.dart | 18 ++++---- .../src/presentation/widgets/shift_card.dart | 44 +++++++++---------- .../widgets/tabs/history_shifts_tab.dart | 11 ++--- 4 files changed, 33 insertions(+), 49 deletions(-) diff --git a/apps/mobile/packages/core/lib/src/routing/staff/navigator.dart b/apps/mobile/packages/core/lib/src/routing/staff/navigator.dart index aa6288fe..e83a85d2 100644 --- a/apps/mobile/packages/core/lib/src/routing/staff/navigator.dart +++ b/apps/mobile/packages/core/lib/src/routing/staff/navigator.dart @@ -159,15 +159,6 @@ extension StaffNavigator on IModularNavigator { navigate(StaffPaths.shiftDetails(shift.id), arguments: shift); } - /// Pushes the shift details page (alternative method). - /// - /// Same as [toShiftDetails] but using pushNamed instead of navigate. - /// Use this when you want to add the details page to the stack rather - /// than replacing the current route. - void pushShiftDetails(Shift shift) { - pushNamed(StaffPaths.shiftDetails(shift.id), arguments: shift); - } - // ========================================================================== // ONBOARDING & PROFILE SECTIONS // ========================================================================== diff --git a/apps/mobile/packages/features/staff/home/lib/src/presentation/widgets/home_page/recommended_shift_card.dart b/apps/mobile/packages/features/staff/home/lib/src/presentation/widgets/home_page/recommended_shift_card.dart index e5ead2d2..1dd260f2 100644 --- a/apps/mobile/packages/features/staff/home/lib/src/presentation/widgets/home_page/recommended_shift_card.dart +++ b/apps/mobile/packages/features/staff/home/lib/src/presentation/widgets/home_page/recommended_shift_card.dart @@ -2,9 +2,8 @@ import 'package:core_localization/core_localization.dart'; import 'package:design_system/design_system.dart'; import 'package:flutter/material.dart'; import 'package:flutter_modular/flutter_modular.dart'; -import 'package:krow_domain/krow_domain.dart'; - import 'package:krow_core/core.dart'; +import 'package:krow_domain/krow_domain.dart'; class RecommendedShiftCard extends StatelessWidget { final Shift shift; @@ -17,7 +16,7 @@ class RecommendedShiftCard extends StatelessWidget { return GestureDetector( onTap: () { - Modular.to.pushShiftDetails(shift); + Modular.to.toShiftDetails(shift); }, child: Container( width: 300, @@ -43,7 +42,9 @@ class RecommendedShiftCard extends StatelessWidget { children: [ Text( recI18n.act_now, - style: UiTypography.body3m.copyWith(color: UiColors.textError), + style: UiTypography.body3m.copyWith( + color: UiColors.textError, + ), ), const SizedBox(width: UiConstants.space2), Container( @@ -71,7 +72,9 @@ class RecommendedShiftCard extends StatelessWidget { height: UiConstants.space10, decoration: BoxDecoration( color: UiColors.tagInProgress, - borderRadius: BorderRadius.circular(UiConstants.radiusBase), + borderRadius: BorderRadius.circular( + UiConstants.radiusBase, + ), ), child: const Icon( UiIcons.calendar, @@ -128,10 +131,7 @@ class RecommendedShiftCard extends StatelessWidget { color: UiColors.mutedForeground, ), const SizedBox(width: UiConstants.space1), - Text( - recI18n.today, - style: UiTypography.body3r.textSecondary, - ), + Text(recI18n.today, style: UiTypography.body3r.textSecondary), const SizedBox(width: UiConstants.space3), const Icon( UiIcons.clock, diff --git a/apps/mobile/packages/features/staff/home/lib/src/presentation/widgets/shift_card.dart b/apps/mobile/packages/features/staff/home/lib/src/presentation/widgets/shift_card.dart index f35d97ae..f851225c 100644 --- a/apps/mobile/packages/features/staff/home/lib/src/presentation/widgets/shift_card.dart +++ b/apps/mobile/packages/features/staff/home/lib/src/presentation/widgets/shift_card.dart @@ -60,7 +60,8 @@ class _ShiftCardState extends State { final date = DateTime.parse(dateStr); final diff = DateTime.now().difference(date); if (diff.inHours < 1) return t.staff_shifts.card.just_now; - if (diff.inHours < 24) return t.staff_shifts.details.pending_time(time: '${diff.inHours}h'); + if (diff.inHours < 24) + return t.staff_shifts.details.pending_time(time: '${diff.inHours}h'); return t.staff_shifts.details.pending_time(time: '${diff.inDays}d'); } catch (e) { return ''; @@ -75,7 +76,7 @@ class _ShiftCardState extends State { ? null : () { setState(() => isExpanded = !isExpanded); - Modular.to.pushShiftDetails(widget.shift); + Modular.to.toShiftDetails(widget.shift); }, child: Container( margin: const EdgeInsets.only(bottom: UiConstants.space3), @@ -97,17 +98,15 @@ class _ShiftCardState extends State { ), child: widget.shift.logoUrl != null ? ClipRRect( - borderRadius: - BorderRadius.circular(UiConstants.radiusBase), + borderRadius: BorderRadius.circular( + UiConstants.radiusBase, + ), child: Image.network( widget.shift.logoUrl!, fit: BoxFit.contain, ), ) - : Icon( - UiIcons.building, - color: UiColors.mutedForeground, - ), + : Icon(UiIcons.building, color: UiColors.mutedForeground), ), const SizedBox(width: UiConstants.space3), Expanded( @@ -129,10 +128,7 @@ class _ShiftCardState extends State { text: '\$${widget.shift.hourlyRate}', style: UiTypography.body1b.textPrimary, children: [ - TextSpan( - text: '/h', - style: UiTypography.body3r, - ), + TextSpan(text: '/h', style: UiTypography.body3r), ], ), ), @@ -186,13 +182,16 @@ class _ShiftCardState extends State { height: UiConstants.space14, decoration: BoxDecoration( color: UiColors.white, - borderRadius: BorderRadius.circular(UiConstants.radiusBase), + borderRadius: BorderRadius.circular( + UiConstants.radiusBase, + ), border: Border.all(color: UiColors.border), ), child: widget.shift.logoUrl != null ? ClipRRect( - borderRadius: - BorderRadius.circular(UiConstants.radiusBase), + borderRadius: BorderRadius.circular( + UiConstants.radiusBase, + ), child: Image.network( widget.shift.logoUrl!, fit: BoxFit.contain, @@ -251,10 +250,7 @@ class _ShiftCardState extends State { text: '\$${widget.shift.hourlyRate}', style: UiTypography.headline3m.textPrimary, children: [ - TextSpan( - text: '/h', - style: UiTypography.body1r, - ), + TextSpan(text: '/h', style: UiTypography.body1r), ], ), ), @@ -336,8 +332,9 @@ class _ShiftCardState extends State { foregroundColor: UiColors.white, elevation: 0, shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(UiConstants.radiusBase), + borderRadius: BorderRadius.circular( + UiConstants.radiusBase, + ), ), ), child: Text(t.staff_shifts.card.accept_shift), @@ -355,8 +352,9 @@ class _ShiftCardState extends State { color: UiColors.destructive.withValues(alpha: 0.3), ), shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(UiConstants.radiusBase), + borderRadius: BorderRadius.circular( + UiConstants.radiusBase, + ), ), ), child: Text(t.staff_shifts.card.decline_shift), diff --git a/apps/mobile/packages/features/staff/shifts/lib/src/presentation/widgets/tabs/history_shifts_tab.dart b/apps/mobile/packages/features/staff/shifts/lib/src/presentation/widgets/tabs/history_shifts_tab.dart index 6b325194..bc24669a 100644 --- a/apps/mobile/packages/features/staff/shifts/lib/src/presentation/widgets/tabs/history_shifts_tab.dart +++ b/apps/mobile/packages/features/staff/shifts/lib/src/presentation/widgets/tabs/history_shifts_tab.dart @@ -9,10 +9,7 @@ import '../shared/empty_state_view.dart'; class HistoryShiftsTab extends StatelessWidget { final List historyShifts; - const HistoryShiftsTab({ - super.key, - required this.historyShifts, - }); + const HistoryShiftsTab({super.key, required this.historyShifts}); @override Widget build(BuildContext context) { @@ -33,10 +30,8 @@ class HistoryShiftsTab extends StatelessWidget { (shift) => Padding( padding: const EdgeInsets.only(bottom: UiConstants.space3), child: GestureDetector( - onTap: () => Modular.to.pushShiftDetails(shift), - child: MyShiftCard( - shift: shift, - ), + onTap: () => Modular.to.toShiftDetails(shift), + child: MyShiftCard(shift: shift), ), ), ),