diff --git a/apps/mobile/packages/features/client/home/lib/src/presentation/widgets/actions_widget.dart b/apps/mobile/packages/features/client/home/lib/src/presentation/widgets/actions_widget.dart index 3af93fc3..0b7eb44b 100644 --- a/apps/mobile/packages/features/client/home/lib/src/presentation/widgets/actions_widget.dart +++ b/apps/mobile/packages/features/client/home/lib/src/presentation/widgets/actions_widget.dart @@ -1,22 +1,13 @@ 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_core/core.dart'; /// A widget that displays quick actions for the client. class ActionsWidget extends StatelessWidget { /// Creates an [ActionsWidget]. - const ActionsWidget({ - super.key, - required this.onRapidPressed, - required this.onCreateOrderPressed, - this.subtitle, - }); - - /// Callback when RAPID is pressed. - final VoidCallback onRapidPressed; - - /// Callback when Create Order is pressed. - final VoidCallback onCreateOrderPressed; + const ActionsWidget({super.key, this.subtitle}); /// Optional subtitle for the section. final String? subtitle; @@ -40,7 +31,7 @@ class ActionsWidget extends StatelessWidget { iconColor: UiColors.textError, textColor: UiColors.textError, subtitleColor: UiColors.textError.withValues(alpha: 0.8), - onTap: onRapidPressed, + onTap: () => Modular.to.toCreateOrderRapid(), ), ), Expanded( @@ -54,7 +45,7 @@ class ActionsWidget extends StatelessWidget { iconColor: UiColors.primary, textColor: UiColors.textPrimary, subtitleColor: UiColors.textSecondary, - onTap: onCreateOrderPressed, + onTap: () => Modular.to.toCreateOrder(), ), ), ], diff --git a/apps/mobile/packages/features/client/home/lib/src/presentation/widgets/dashboard_widget_builder.dart b/apps/mobile/packages/features/client/home/lib/src/presentation/widgets/dashboard_widget_builder.dart index d3f3f11a..296b04d8 100644 --- a/apps/mobile/packages/features/client/home/lib/src/presentation/widgets/dashboard_widget_builder.dart +++ b/apps/mobile/packages/features/client/home/lib/src/presentation/widgets/dashboard_widget_builder.dart @@ -1,7 +1,6 @@ import 'package:core_localization/core_localization.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 '../blocs/client_home_state.dart'; import '../widgets/actions_widget.dart'; @@ -10,7 +9,6 @@ import '../widgets/draggable_widget_wrapper.dart'; import '../widgets/live_activity_widget.dart'; import '../widgets/reorder_widget.dart'; import '../widgets/spending_widget.dart'; -import 'client_home_sheets.dart'; /// A widget that builds dashboard content based on widget ID. /// @@ -63,41 +61,9 @@ class DashboardWidgetBuilder extends StatelessWidget { switch (id) { case 'actions': - return ActionsWidget( - onRapidPressed: () => Modular.to.toCreateOrderRapid(), - onCreateOrderPressed: () => Modular.to.toCreateOrder(), - subtitle: subtitle, - ); + return ActionsWidget(subtitle: subtitle); case 'reorder': - return ReorderWidget( - orders: state.reorderItems, - onReorderPressed: (Map data) { - ClientHomeSheets.showOrderFormSheet( - context, - data, - onSubmit: (Map submittedData) { - final String? typeStr = submittedData['type']?.toString(); - if (typeStr == null || typeStr.isEmpty) { - return; - } - final OrderType orderType = OrderType.fromString(typeStr); - switch (orderType) { - case OrderType.recurring: - Modular.to.toCreateOrderRecurring(); - break; - case OrderType.permanent: - Modular.to.toCreateOrderPermanent(); - break; - case OrderType.oneTime: - default: - Modular.to.toCreateOrderOneTime(); - break; - } - }, - ); - }, - subtitle: subtitle, - ); + return ReorderWidget(orders: state.reorderItems, subtitle: subtitle); case 'spending': return SpendingWidget( weeklySpending: state.dashboardData.weeklySpending, diff --git a/apps/mobile/packages/features/client/home/lib/src/presentation/widgets/reorder_widget.dart b/apps/mobile/packages/features/client/home/lib/src/presentation/widgets/reorder_widget.dart index 9f67d4f1..c9d91f2a 100644 --- a/apps/mobile/packages/features/client/home/lib/src/presentation/widgets/reorder_widget.dart +++ b/apps/mobile/packages/features/client/home/lib/src/presentation/widgets/reorder_widget.dart @@ -1,24 +1,20 @@ 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_core/core.dart'; import 'package:krow_domain/krow_domain.dart'; +import 'client_home_sheets.dart'; + /// A widget that allows clients to reorder recent shifts. class ReorderWidget extends StatelessWidget { /// Creates a [ReorderWidget]. - const ReorderWidget({ - super.key, - required this.orders, - required this.onReorderPressed, - this.subtitle, - }); + const ReorderWidget({super.key, required this.orders, this.subtitle}); /// Recent completed orders for reorder. final List orders; - /// Callback when a reorder button is pressed. - final Function(Map shiftData) onReorderPressed; - /// Optional subtitle for the section. final String? subtitle; @@ -154,16 +150,17 @@ class ReorderWidget extends StatelessWidget { leadingIcon: UiIcons.zap, iconSize: 12, fullWidth: true, - onPressed: () => onReorderPressed({ - 'orderId': order.orderId, - 'title': order.title, - 'location': order.location, - 'hourlyRate': order.hourlyRate, - 'hours': order.hours, - 'workers': order.workers, - 'type': order.type, - 'totalCost': order.totalCost, - }), + onPressed: () => + _handleReorderPressed(context, { + 'orderId': order.orderId, + 'title': order.title, + 'location': order.location, + 'hourlyRate': order.hourlyRate, + 'hours': order.hours, + 'workers': order.workers, + 'type': order.type, + 'totalCost': order.totalCost, + }), ), ], ), @@ -174,6 +171,32 @@ class ReorderWidget extends StatelessWidget { ], ); } + + void _handleReorderPressed(BuildContext context, Map data) { + ClientHomeSheets.showOrderFormSheet( + context, + data, + onSubmit: (Map submittedData) { + final String? typeStr = submittedData['type']?.toString(); + if (typeStr == null || typeStr.isEmpty) { + return; + } + final OrderType orderType = OrderType.fromString(typeStr); + switch (orderType) { + case OrderType.recurring: + Modular.to.toCreateOrderRecurring(); + break; + case OrderType.permanent: + Modular.to.toCreateOrderPermanent(); + break; + case OrderType.oneTime: + default: + Modular.to.toCreateOrderOneTime(); + break; + } + }, + ); + } } class _Badge extends StatelessWidget {