refactor: remove redundant pushShiftDetails navigation method and update its usages to toShiftDetails.

This commit is contained in:
Achintha Isuru
2026-02-22 21:16:46 -05:00
parent fa00a0bf75
commit 7f3a66ba11
4 changed files with 33 additions and 49 deletions

View File

@@ -159,15 +159,6 @@ extension StaffNavigator on IModularNavigator {
navigate(StaffPaths.shiftDetails(shift.id), arguments: shift); 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 // ONBOARDING & PROFILE SECTIONS
// ========================================================================== // ==========================================================================

View File

@@ -2,9 +2,8 @@ import 'package:core_localization/core_localization.dart';
import 'package:design_system/design_system.dart'; import 'package:design_system/design_system.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_modular/flutter_modular.dart'; import 'package:flutter_modular/flutter_modular.dart';
import 'package:krow_domain/krow_domain.dart';
import 'package:krow_core/core.dart'; import 'package:krow_core/core.dart';
import 'package:krow_domain/krow_domain.dart';
class RecommendedShiftCard extends StatelessWidget { class RecommendedShiftCard extends StatelessWidget {
final Shift shift; final Shift shift;
@@ -17,7 +16,7 @@ class RecommendedShiftCard extends StatelessWidget {
return GestureDetector( return GestureDetector(
onTap: () { onTap: () {
Modular.to.pushShiftDetails(shift); Modular.to.toShiftDetails(shift);
}, },
child: Container( child: Container(
width: 300, width: 300,
@@ -43,7 +42,9 @@ class RecommendedShiftCard extends StatelessWidget {
children: [ children: [
Text( Text(
recI18n.act_now, recI18n.act_now,
style: UiTypography.body3m.copyWith(color: UiColors.textError), style: UiTypography.body3m.copyWith(
color: UiColors.textError,
),
), ),
const SizedBox(width: UiConstants.space2), const SizedBox(width: UiConstants.space2),
Container( Container(
@@ -71,7 +72,9 @@ class RecommendedShiftCard extends StatelessWidget {
height: UiConstants.space10, height: UiConstants.space10,
decoration: BoxDecoration( decoration: BoxDecoration(
color: UiColors.tagInProgress, color: UiColors.tagInProgress,
borderRadius: BorderRadius.circular(UiConstants.radiusBase), borderRadius: BorderRadius.circular(
UiConstants.radiusBase,
),
), ),
child: const Icon( child: const Icon(
UiIcons.calendar, UiIcons.calendar,
@@ -128,10 +131,7 @@ class RecommendedShiftCard extends StatelessWidget {
color: UiColors.mutedForeground, color: UiColors.mutedForeground,
), ),
const SizedBox(width: UiConstants.space1), const SizedBox(width: UiConstants.space1),
Text( Text(recI18n.today, style: UiTypography.body3r.textSecondary),
recI18n.today,
style: UiTypography.body3r.textSecondary,
),
const SizedBox(width: UiConstants.space3), const SizedBox(width: UiConstants.space3),
const Icon( const Icon(
UiIcons.clock, UiIcons.clock,

View File

@@ -60,7 +60,8 @@ class _ShiftCardState extends State<ShiftCard> {
final date = DateTime.parse(dateStr); final date = DateTime.parse(dateStr);
final diff = DateTime.now().difference(date); final diff = DateTime.now().difference(date);
if (diff.inHours < 1) return t.staff_shifts.card.just_now; 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'); return t.staff_shifts.details.pending_time(time: '${diff.inDays}d');
} catch (e) { } catch (e) {
return ''; return '';
@@ -75,7 +76,7 @@ class _ShiftCardState extends State<ShiftCard> {
? null ? null
: () { : () {
setState(() => isExpanded = !isExpanded); setState(() => isExpanded = !isExpanded);
Modular.to.pushShiftDetails(widget.shift); Modular.to.toShiftDetails(widget.shift);
}, },
child: Container( child: Container(
margin: const EdgeInsets.only(bottom: UiConstants.space3), margin: const EdgeInsets.only(bottom: UiConstants.space3),
@@ -97,17 +98,15 @@ class _ShiftCardState extends State<ShiftCard> {
), ),
child: widget.shift.logoUrl != null child: widget.shift.logoUrl != null
? ClipRRect( ? ClipRRect(
borderRadius: borderRadius: BorderRadius.circular(
BorderRadius.circular(UiConstants.radiusBase), UiConstants.radiusBase,
),
child: Image.network( child: Image.network(
widget.shift.logoUrl!, widget.shift.logoUrl!,
fit: BoxFit.contain, fit: BoxFit.contain,
), ),
) )
: Icon( : Icon(UiIcons.building, color: UiColors.mutedForeground),
UiIcons.building,
color: UiColors.mutedForeground,
),
), ),
const SizedBox(width: UiConstants.space3), const SizedBox(width: UiConstants.space3),
Expanded( Expanded(
@@ -129,10 +128,7 @@ class _ShiftCardState extends State<ShiftCard> {
text: '\$${widget.shift.hourlyRate}', text: '\$${widget.shift.hourlyRate}',
style: UiTypography.body1b.textPrimary, style: UiTypography.body1b.textPrimary,
children: [ children: [
TextSpan( TextSpan(text: '/h', style: UiTypography.body3r),
text: '/h',
style: UiTypography.body3r,
),
], ],
), ),
), ),
@@ -186,13 +182,16 @@ class _ShiftCardState extends State<ShiftCard> {
height: UiConstants.space14, height: UiConstants.space14,
decoration: BoxDecoration( decoration: BoxDecoration(
color: UiColors.white, color: UiColors.white,
borderRadius: BorderRadius.circular(UiConstants.radiusBase), borderRadius: BorderRadius.circular(
UiConstants.radiusBase,
),
border: Border.all(color: UiColors.border), border: Border.all(color: UiColors.border),
), ),
child: widget.shift.logoUrl != null child: widget.shift.logoUrl != null
? ClipRRect( ? ClipRRect(
borderRadius: borderRadius: BorderRadius.circular(
BorderRadius.circular(UiConstants.radiusBase), UiConstants.radiusBase,
),
child: Image.network( child: Image.network(
widget.shift.logoUrl!, widget.shift.logoUrl!,
fit: BoxFit.contain, fit: BoxFit.contain,
@@ -251,10 +250,7 @@ class _ShiftCardState extends State<ShiftCard> {
text: '\$${widget.shift.hourlyRate}', text: '\$${widget.shift.hourlyRate}',
style: UiTypography.headline3m.textPrimary, style: UiTypography.headline3m.textPrimary,
children: [ children: [
TextSpan( TextSpan(text: '/h', style: UiTypography.body1r),
text: '/h',
style: UiTypography.body1r,
),
], ],
), ),
), ),
@@ -336,8 +332,9 @@ class _ShiftCardState extends State<ShiftCard> {
foregroundColor: UiColors.white, foregroundColor: UiColors.white,
elevation: 0, elevation: 0,
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: borderRadius: BorderRadius.circular(
BorderRadius.circular(UiConstants.radiusBase), UiConstants.radiusBase,
),
), ),
), ),
child: Text(t.staff_shifts.card.accept_shift), child: Text(t.staff_shifts.card.accept_shift),
@@ -355,8 +352,9 @@ class _ShiftCardState extends State<ShiftCard> {
color: UiColors.destructive.withValues(alpha: 0.3), color: UiColors.destructive.withValues(alpha: 0.3),
), ),
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: borderRadius: BorderRadius.circular(
BorderRadius.circular(UiConstants.radiusBase), UiConstants.radiusBase,
),
), ),
), ),
child: Text(t.staff_shifts.card.decline_shift), child: Text(t.staff_shifts.card.decline_shift),

View File

@@ -9,10 +9,7 @@ import '../shared/empty_state_view.dart';
class HistoryShiftsTab extends StatelessWidget { class HistoryShiftsTab extends StatelessWidget {
final List<Shift> historyShifts; final List<Shift> historyShifts;
const HistoryShiftsTab({ const HistoryShiftsTab({super.key, required this.historyShifts});
super.key,
required this.historyShifts,
});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@@ -33,10 +30,8 @@ class HistoryShiftsTab extends StatelessWidget {
(shift) => Padding( (shift) => Padding(
padding: const EdgeInsets.only(bottom: UiConstants.space3), padding: const EdgeInsets.only(bottom: UiConstants.space3),
child: GestureDetector( child: GestureDetector(
onTap: () => Modular.to.pushShiftDetails(shift), onTap: () => Modular.to.toShiftDetails(shift),
child: MyShiftCard( child: MyShiftCard(shift: shift),
shift: shift,
),
), ),
), ),
), ),