import 'package:dineindia/helpers/dineindiahelper.dart'; import…
- User
import 'package:dine_in_dia/helpers/dine_in_dia_helper.dart'; import 'package:dine_in_dia/helpers/keyboard_shortcut/widgets/keyboard_shortcut_manager.dart'; import 'package:dine_in_dia/helpers/keyboard_shortcut/widgets/short_cuts_popup.dart'; import 'package:dine_in_dia/helpers/keyboard_shortcut/widgets/shortcut_intents.dart'; import 'package:dine_in_dia/helpers/keyboard_shortcut/widgets/spotlight_search_popup.dart'; import 'package:dine_in_dia/routes/isselo_routes.dart'; import 'package:dine_in_dia/view/common_elements/bottom_footer/custom_drawer.dart'; import 'package:dine_in_dia/view/crm/customers/add_customer/add_customer_popup.dart'; import 'package:dine_in_dia/view/crm/customers/customer_profile_vm.dart'; import 'package:dine_in_dia/view/reports/items_report_vm.dart'; import 'package:dine_in_dia/view/reports/view_model/report_view_model.dart'; import 'package:dine_in_dia/view/sales/dia_cart/elements/delivery_address_helper.dart'; import 'package:dine_in_dia/view/sales/dia_cart/payment_elements/payment_tab_bar.dart'; import 'package:dine_in_dia/view/sales/dinein/vm/order_viewmodel.dart'; import 'package:dine_in_dia/view/sales/view_models/sales_new_sales.dart'; import 'package:dine_in_dia/view/sales/view_models/trading_vm.dart'; import 'package:dine_in_dia/view/stocks/item_list/item_add/item_add_main_screen.dart'; import 'package:dine_in_dia/view_model/riverpod.dart'; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:screl_core/enums/common_enums.dart'; import 'package:screl_core/enums/sales_enums.dart'; import 'package:screl_core/models/common_models.dart'; import 'package:screl_core/models/status_model.dart'; import 'package:screl_core/vm/riverpod.dart';
class KeyBoardShortcut extends HookConsumerWidget { final Widget childWidget; const KeyBoardShortcut({super.key, required this.childWidget});
@override Widget build(BuildContext context, WidgetRef ref) { final admin = DineInDiaHelper.powerModel.name == "Admin"; final currentRoute = GoRouterState.of(context).uri.toString(); print('eeeeeeeeeeeee currentRoute'); return Shortcuts( shortcuts: KeyboardShortcutManager.buildShortcuts(ref, context, currentRoute), child: Actions( actions: { ShowShortcutsIntent: CallbackAction<ShowShortcutsIntent>( onInvoke: (intent) { SideSheets.right( context: context, ref: ref, width: 600, body: const ShortcutsDrawerContent(), ); return null; }, ), AddCustomerIntent: CallbackAction<AddCustomerIntent>( onInvoke: (_) async { try { ref.read(accountsVM).clear(); ref.read(countryVM).clear(ref); await ref.read(customerProfileViewModelProvider.notifier).setEndUSerModel(null); showDialog(context: context, builder: (context) => const AddCustomerPopup()); debugPrint("AddCustomerIntent executed successfully"); return null; } catch (e, stackTrace) { debugPrint("Error in AddCustomerIntent: e\ne")), ); return null; } }, ), ShowItemAddDrawer: CallbackAction( onInvoke: (intent) async { ref.watch(itemsVM).onAddItem(ref: ref); await SideSheets.right(context: context, ref: ref, body: const ItemAddMainScreen(), barrierDismissible: false); return null; }, ), NavigateIntent: CallbackAction( onInvoke: (intent) async { await reInitDb(ref); intent.action?.call(); context.goNamed(intent.routeName); return null; }, ), SpotlightSearchIntent: CallbackAction( onInvoke: (_) { ref.read(spotlightVm).updateQuery(''); return showDialog(context: context, builder: (context) => const SpotlightSearchPopup()); }, ), PrintKotIntent: CallbackAction( onInvoke: (intent) async { if (intent.orderType == "Delivery") { if (intent.addressEmpty && intent.phoneEmpty) { if (intent.tradingData != null) { ref.read(tradingVmProvider.notifier).modifyTradingModel(intent.tradingData.copyWith(tradingModel: intent.tradingData.tradingModel.copyWith(mode: TradingMode.order))); } ref.read(salesVM).changeShippingAddressBool(ref); } else { if (!DeliveryAddressValidatorHelper().shouldProceedWithDelivery(context, ref, intent.salesType)) { return null; } await ref.read(tradingVmProvider.notifier).addUpdateSalesDb(salesType: intent.salesType, mode: TradingMode.order); } } else { if (!DeliveryAddressValidatorHelper().shouldProceedWithDelivery(context, ref, intent.salesType)) { return null; } await ref.read(tradingVmProvider.notifier).addUpdateSalesDb(salesType: intent.salesType, mode: ref.read(tradingVmProvider).value?.data?.tradingModel.mode ?? TradingMode.order); if (intent.orderType == "Dine-In") { await ref.read(dineInVM).routeOnTap(ref); } else {} } print("PrintKotIntent executed successfully"); return null; }, ), PayLaterIntent: CallbackAction( onInvoke: (intent) async { if (intent.orderType == "Delivery") { if (intent.addressEmpty && intent.phoneEmpty) { if (intent.tradingData != null) { ref.read(tradingVmProvider.notifier).modifyTradingModel(intent.tradingData.copyWith(tradingModel: intent.tradingData.tradingModel.copyWith(mode: TradingMode.unclosed_bill))); } ref.read(salesVM).changeShippingAddressBool(ref); } else { if (!DeliveryAddressValidatorHelper().shouldProceedWithDelivery(context, ref, intent.salesType)) { return null; } await ref.read(tradingVmProvider.notifier).addUpdateSalesDb(mode: TradingMode.unclosed_bill, salesType: intent.salesType); } } else { if (!DeliveryAddressValidatorHelper().shouldProceedWithDelivery(context, ref, intent.salesType)) { return null; } await ref.read(tradingVmProvider.notifier).addUpdateSalesDb(mode: TradingMode.unclosed_bill, salesType: intent.salesType); if (intent.orderType == "Dine-In") { await ref.read(dineInVM).routeOnTap(ref); } else {} } return null; }, ), PayNowIntent: CallbackAction( onInvoke: (intent) async { if (!admin) { ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text("Admin access required"))); return null; } try { if (intent.orderType == "Delivery") { if (intent.addressEmpty && intent.phoneEmpty) { if (intent.tradingData != null) { ref.read(tradingVmProvider.notifier).modifyTradingModel(intent.tradingData.copyWith(tradingModel: intent.tradingData.tradingModel.copyWith(mode: TradingMode.sales))); } ref.read(salesVM).changeShippingAddressBool(ref); } else { if (!DeliveryAddressValidatorHelper().shouldProceedWithDelivery(context, ref, intent.salesType)) { return null; } StatusModel status = ref.read(newSalesVmProvider.notifier).payNow(); if (status.operationStatus == OperationStatus.success) { ref.read(dineInVM).tabIndex = 1; } } } else { if (!DeliveryAddressValidatorHelper().shouldProceedWithDelivery(context, ref, intent.salesType)) { return null; } StatusModel status = ref.read(newSalesVmProvider.notifier).payNow(); if (status.operationStatus == OperationStatus.success) { ref.read(dineInVM).tabIndex = 1; } }
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.